Login  Register

Re: JOGL GL2.GL_REPEAT

Posted by Pixelapp on Nov 07, 2011; 4:01am
URL: https://forum.jogamp.org/JOGL-GL2-GL-REPEAT-tp3483478p3486012.html

Ok. The idea to solve the problem is to convert an image (.png) into a Buffer object (java.nio.Buffer;).

then bind a gl object. I.e. gl.glBind(GL_TEXTURE_2D, blah),

set parameters: linear, linear, glrepeat, glrepeat. Respectively.

and the final step to load the texture is gl.glTexImage2D(). Which is here where you put the Buffer image as an argument of the glTexImage2D() method from javax.media.opengl.GL2 package.

Note: this is some serious but very short (8 to 10 lines) coding.

It should be almost identical to this:

            //Create Texture
            gl.glGenTextures(1, texture);
            gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
         
            gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
            gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
       
            // GL_REPEAT HERE
            // GL_REPEAT HERE
         
            gl.glTexImage2D(GL_TEXTURE_2D,
                           0,
                           3,
                           texLoader.getImageWidth(),
                           texLoader.getImageHeight(),
                           0,
                           GL_RGB,
                           GL_UNSIGNED_BYTE,
                           /** Buffer object goes here*/);

NOTICE; pay close attention, I never used the Texture Class (com.jogamp.opengl.util.texture) to create textures in this.