Skip to main content
GameDev.net gamedev.net
🔒 Locked

glTexImage2d 2 pixel width

Started by movTheImposter May 12, 2004 at 1:13 AM 0 replies 300+ views
Original Post
movTheImposter
movTheImposter
I can''t figure out why glTexImage2D is skipping two bytes in this 16 byte array. I can see there is no problem initializing the array in the debugger. Any Ideas? glGenTextures(1, &arid[10]); glBindTexture(GL_TEXTURE_2D, arid[10]); unsigned char b2[2][2][3]; //pixel 1 b2[0][0][0] = 255; b2[0][0][1] = 255; b2[0][0][2] = 255; //pixel 2 b2[0][1][0] = 255; b2[0][1][1] = 255; b2[0][1][2] = 255; //pixel 3 b2[1][0][0] = 255; //it skips these two bytes b2[1][0][1] = 255; //it skips these two bytes b2[1][0][2] = 255; //now pixel 3 starts here and takes from pixel 4 //pixel 4 b2[1][1][0] = 255; b2[1][1][1] = 255; b2[1][1][2] = 255; glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, b2); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
movTheImposter
movTheImposter
Problem solved. Someone suggested checking out pixel store, I needed to call glPixelStorei(GL_UNPACK_ALIGNMENT, 1) before glTexImage. My textures over 4 pxls squared don''t have any problems without the pixel store call though.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.