Skip to content

Texture fixes #12

@axel22

Description

@axel22

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:

  1. We need to add a default argument to allocateImageX -- the buffer which is by default null or None. A non-null value would mean that there is data to be transfered.

  2. The allocateImageX called outside the ctor or whenever the texture is not bound should throw an exception.

  3. Another thing I see that we should fix: once bound in the updated method, the Texture is not unbound (returned to previous setting). We should surround the init call in the acquire with the glBindTexture calls 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.

  1. Setting the texture parameters or calling allocateImageX outside the ctor should throw an exception, unless the texture is bound.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions