help using TextureIO.newTexture() ???

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

help using TextureIO.newTexture() ???

cylob
I'm coming from doing opengl with java on android. The way I have it there is when I go to load a texture, I specify an ID for the texture ahead of time, then i call the following before teximage2d uploads the image:

    glActiveTexture(GL_TEXTURE0+ID);

and after teximage2d i call:

    glUniform1i(glGetUniformLocation(shaderID,"tex_unit"+String.valueOf(ID)),ID);

and in this way, i can just associate a tex id in my vertex buffers to a tex_unitN in my frag shader....thats just how i do things so i dont have to mess with binding textures and stuff in my draw loop....but i cant seem to figure out how to do this with jogl because newTexture() doesnt let you specify an id, does anyone know if i can do this? thanks for your help plz

Reply | Threaded
Open this post in threaded view
|

Re: help using TextureIO.newTexture() ???

gouessej
Administrator
Hello

By the way, JOGL works under Android too even though there is a lack of documentation about that.

Nothing forces you to use JOGL high level helpers. You can use TextureIO.newTextureData() and create your texture with low level calls but in my humble opinion, you seem to confuse the identifier of the texture and the identifier of the texture unit, which are two distinct notions. this confusion has nothing to do with Android, OpenGL and OpenGL-ES are cross-platform.

Do you use bindless textures?
https://www.khronos.org/opengl/wiki/Bindless_Texture
If it's the case, my suggestion will work.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: help using TextureIO.newTexture() ???

cylob
ok thanks for your reply. i managed to fix it. all i had to do was put the glactivetexture() call before the newTexture() call, doh...thanks for your time and help still
Reply | Threaded
Open this post in threaded view
|

Re: help using TextureIO.newTexture() ???

cylob
In reply to this post by gouessej
p.s. while we're here, do you know if, with newTexture(), when i can specify my own mag, min filters, and clamping calls?
Reply | Threaded
Open this post in threaded view
|

Re: help using TextureIO.newTexture() ???

gouessej
Administrator
There are setTexParameter methods for that but I fear that we don't cover all cases. If you do most OpenGL setup by yourself, rather use only a TextureData object, don't create a Texture object.
Julien Gouesse | Personal blog | Website