Posted by
Pixelapp on
Nov 04, 2011; 4:37am
URL: https://forum.jogamp.org/JOGL-2-Texture-GL-REPEAT-Question-tp3479242.html

I have a question. When I use GL_REPEAT in my code I get the above picture (my snippet of code is below). I'm expecting not to get spaces between the tiles which are white. You can identify the space which are blue in between the tiles. Why aren't the tiles close to each other "back to back"? Why can I see the blue background?
Moreover, when I need to use GL_CLAMP_TO_EDGE OR GL_CLAMP everything works fine, meaning I get the desired results which is a clamped texture. However; not with GL_REPEAT, I don't get a repeated texture.
Please don't rush into finding a solution; I just want to know, is this a bug or not?
// Obviously my texture loader method
private void loadTexture(String[] fnm, GL2 gl) {
for (count = ZERO; count < NUMTEXTURES; count++) {
fileName[count] = folder + fnm[count];
try {
tex[count] = TextureIO.newTexture(
cl.getResource(fileName[count]), false, null);
tex[count].setTexParameterf(gl, GL2.GL_TEXTURE_MIN_FILTER,
GL2.GL_NEAREST);
tex[count].setTexParameterf(gl, GL2.GL_TEXTURE_MAG_FILTER,
GL2.GL_NEAREST);
tex[count].setTexParameterf(gl, GL2.GL_TEXTURE_WRAP_S,
GL2.GL_REPEAT);
tex[count].setTexParameterf(gl, GL2.GL_TEXTURE_WRAP_T,
GL2.GL_REPEAT);
} catch (Exception e) {
System.out.println("Error loading texture " + fileName[count]);
}
}
}
// Here I set the texture coordinates
mTexBufferDisplay[0].put(tc[32].left()); // x or s
mTexBufferDisplay[0].put(3); // y or t
mTexBufferDisplay[0].put(3); // x or s
mTexBufferDisplay[0].put(3); // y or t
mTexBufferDisplay[0].put(3); // x or s
mTexBufferDisplay[0].put(tc[32].top()); // y or t
mTexBufferDisplay[0].put(tc[32].left()); // x or s
mTexBufferDisplay[0].put(tc[32].top()); // y or t
mTexBufferDisplay[0].position(0);
Thanks in advance.