-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Currently, the idea is to call allocateImageX to allocate the texture:
https://github.com/storm-enroute/macrogl/blob/master/src/main/scala/org/macrogl/Texture.scala#L70
The original idea was to set the texture parameters before allocating the image. The Texture ctor was meant to be used like this to allocate space for the image:
Texture(GL_TEXTURE_2d) { tex =>
tex.magFilter = GL_NEAREST
allocateImage2D(0, GL_RGB, 64, 64, 0, GL_UNSIGNED_BYTE)
}
To actually transfer the bytes, there is no support yet!
Here's one way we can go around this:
-
We need to add a default argument to
allocateImageX-- the buffer which is by defaultnullorNone. A non-null value would mean that there is data to be transfered. -
The
allocateImageXcalled outside the ctor or whenever the texture is not bound should throw an exception. -
Another thing I see that we should fix: once bound in the
updatedmethod, theTextureis not unbound (returned to previous setting). We should surround theinitcall in theacquirewith theglBindTexturecalls to set and reset the bound texture properly:
https://github.com/storm-enroute/macrogl/blob/master/src/main/scala/org/macrogl/Texture.scala#L29
There should be no glBindTexture calls in update.
- Setting the texture parameters or calling
allocateImageXoutside the ctor should throw an exception, unless the texture is bound.