Forewarning: I’m pretty new to OpenGL and JOGL
I’m trying to institute Texture Borders using JOGL to allow me to display large images as a set of subtiles without artifacts at the seams of the textures. Before trying to do Texture Borders, I tried to use GL_CLAMP_TO_EDGE, which certainly improved the appearance of the borders, but they are still quite noticable when zoomed enough.
I do not want to use mipmapping because we have our own set of progressively smaller tiles.
I tried to implement texture borders as follows:
I increased each individual tiled image from 256x256 to 258x258 by including a 1 pixel border from the adjacent tile. The tiled image was loaded using TextureIO as follows:
First the images were prepared as a buffered image, then loaded into texturedata:
theData = TextureIO.newTextureData(bufImg, false);
theData.setBorder(1); // 1 pixel border
Then later loaded in as a texture when needed:
Texture tex = TextureIO.newTexture(theData);
However, as long as setBorder(1) is called, the textures show up blank. No error is thrown, the texture is not displayed. Thinking that it might be because the texture is no longer a power of two (even though my card supports this)… I tried a 256x256 image with the same result–nothing drawn.
I then tried to bypass TextureIO’s last step and try to load the texture myself:
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, theData.getInternalFormat(),
258, 258, 0,
theData.getPixelFormat(), theData.getPixelType(), theData.getBuffer());
In this case, I get a much different problem: It throws this error:
Caused by: java.lang.IndexOutOfBoundsException: Required 266256 remaining bytes in buffer, only had 265224
at com.sun.gluegen.runtime.BufferFactory.rangeCheckBytes(BufferFactory.java:274)
at com.sun.opengl.impl.GLImpl.glTexImage2D(GLImpl.java:19579)
However, when I again remove the setBorder(1), it displays again–without a border.
Do I not understand how texture borders are supposed to work?
(FYI I am using an Nvidia 6800 under Windows using the latest JOGL release)