View Full Version : cube mapping in LWJGL

02-01-2011, 12:41 PM
I try to add cube mapping to my project but i get one error that i dont know how to fix it
when i comment these few line every thing work fine but when they are in ...this error occur
"Exception in thread "main" org.lwjgl.opengl.OpenGLException: Cannot use offsets when Pixel Unpack Buffer Object is disabled"

GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);

GL11.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_POSITIV E_X,0,GL11.GL_RGBA,20,20,0,GL11.GL_RGBA,GL11.GL_UN SIGNED_BYTE,temp.getTextureID());
GL11.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_NEGATIV E_X,0,GL11.GL_RGBA,20,20,0,GL11.GL_RGBA,GL11.GL_UN SIGNED_BYTE,temp.getTextureID());
GL11.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_POSITIV E_Y,0,GL11.GL_RGBA,20,20,0,GL11.GL_RGBA,GL11.GL_UN SIGNED_BYTE,temp.getTextureID());
GL11.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_NEGATIV E_Y,0,GL11.GL_RGBA,20,20,0,GL11.GL_RGBA,GL11.GL_UN SIGNED_BYTE,temp.getTextureID());
GL11.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_POSITIV E_Z,0,GL11.GL_RGBA,20,20,0,GL11.GL_RGBA,GL11.GL_UN SIGNED_BYTE,temp.getTextureID());
GL11.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_NEGATIV E_Z,0,GL11.GL_RGBA,20,20,0,GL11.GL_RGBA,GL11.GL_UN SIGNED_BYTE,temp.getTextureID());

is there any thing wrong?
how can i fix this error?

thank you for your time

02-02-2011, 09:42 AM
What does temp.getTextureID() do?
Also, show your glBindTexture and the glTexParameter calls.

02-02-2011, 12:19 PM
I change my code to this ...
but i still dont know what exactly should pass to glteximage2d as last parameter...

GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D,0,GL11.GL _RGBA,0,0,Display.getDisplayMode().getWidth(),Disp lay.getDisplayMode().getHeight(),0);

GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
ByteBuffer tocube=ByteBuffer.wrap(temp.getTextureData());
for(int i=0;i<6;i++){
GL11.glTexImage2D(target[i],0,GL11.GL_RGB,temp.getImageWidth(),temp.getTextur eHeight(),0,GL11.GL_RGB,GL11.GL_UNSIGNED_BYTE,tocu be);

GL11.glTranslatef(0.0f,0.0f,-5.0f); // Move Into The Screen 5 Units
GL11.glRotatef(xrot,1.0f,0.0f,0.0f); // Rotate On The X Axis
GL11.glRotatef(yrot,0.0f,1.0f,0.0f); // Rotate On The Y Axis
GL11.glRotatef(zrot,0.0f,0.0f,1.0f); // Rotate On The Z Axis

in this code i try to take a screenshot with glcopyteximage and map it on cube and then use cube mapping the rest of code work fine without cube mapping part

and also i dont know what shuold i exactly set with gltexparameter in this case so i leave them default

now i get this error
"# A fatal error has been detected by the Java Runtime Environment:
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x698366a7, pid=5708, tid=5304"

i dont know what to do...
thank you for your reply...