   Uploading texture data with stride
  Hello!Up to recently, I thought that OpenGL didn't provide any means of specifying the stride (distance in bytes between the first pixel of two adjacent rows) of texture data because there was no such parameter in glTexImage2D. However, I recently found a thread talking about glPixelStore, which could maybe allow this. I've looked at the documentation but because of crappy inlined ASCII art for algebraic formulas, I couldn't figure out if it was what I needed.Does glPixelStore allow this?If so, could someone post a sample chunk of code calling that function?Also, should I care about GL_UNPACK_ALIGNMENT if I'm not doing anything fancy?Thanks!   
  To set the stride, callglPixelStorei(GL_UNPACK_ROW_LENGTH,stride);before calling glTexImage2D (or similar functions), stride is the length of a row in bytes although the default value of 0 means the data is tightly packed. When done, it's a good idea to set the value back to zero to avoid any problems.Regarding GL_UNPACK_ALIGNMENT, read the documentation here (no ASCII art). I don't think you need to touch the value.An example of calling the function:void update_texture(GLuint tex, unsigned char* buf,int w,int h, int stride) {glPixelStorei(GL_UNPACK_ROW_LENGTH,stride);glBindTexture(GL_TEXTURE_2D,tex);glTexSubImage2D(GL_TEXTURE_2D,0,0,0,w,h,GL_LUMINANCE,GL_UNSIGNED_BYTE,buf);// set GL_UNPACK_ROW_LENGTH back to 0 to avoid bugs glPixelStorei(GL_UNPACK_ROW_LENGTH,0);}(To see the entire source code download liboggplayer (my project) and open examples/ogl_glsl.cpp)   ;  Cool, thanks Kambiz!I was pretty sure that GL_UNPACK_ROW_LENGTH was what I needed to look at because of its name but I found the documentation somewhat misleading:Quote:If greater than 0, GL_UNPACK_ROW_LENGTH defines the number of pixels in a row.Anyways, I'm trying it now!   