Bug with glTexSubImage2D with Texture NPOT

Hi,

I have a problem to upload a texture NPOT with glTexSubImage2D.

So I’ve a texture ( RGB 34x34 ) and I upload this texture by block of 4 lines. The pitch of the buffer is alignment on 4 bytes so the size of a line is equal to 104 bytes

here my GL code :

FIBITMAP* pTexData2 = FreeImage_Load(FreeImage_GetFIFFromFilename(“avion_roll2.png”), “avion_roll2.png”);
vBpp = FreeImage_GetBPP(pTexData2);
vW = FreeImage_GetWidth(pTexData2);
vH = FreeImage_GetHeight(pTexData2);

if( pTexData2 != NULL )
{
	glGenTextures( 1, &IDTexture );
	glBindTexture( GL_TEXTURE_2D, IDTexture );

	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
	glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

	glPixelStorei( GL_UNPACK_ALIGNMENT, 4 ) ;
			
	int pitch = FreeImage_GetPitch(pTexData2);
	glTexImage2D( GL_TEXTURE_2D, 0, 3, vW, vH, 0,
		GL_BGR_EXT, GL_UNSIGNED_BYTE, NULL);
	for(int i = 0; i < 32; i+=4 )
		glTexSubImage2D( GL_TEXTURE_2D, 0, 0, i, 34,10, GL_BGR_EXT, GL_UNSIGNED_BYTE, FreeImage_GetBits(pTexData2) + pitch * i);

The problem is that for each block of 4 lines, the fourth line has its last 2 pixels that are black.

Here the original texture :

Here a capture of the OpenGL Rendering :

So if I increase the number of line per block, it’s always the last of each block where there are black pixels

I work on Windows XP with a Geforce 7900 GTS. My driver is OK.

Is it a bug in OpenGL driver ??

Thanks a lot for your help

something is wrong with GL_PACK_ALIGNMENT/GL_UNPACK_ALIGNMENT options. you specify BGR texture format and use 4 in glPixelStorei which is UNSIGNED_INT i guess. try experimenting with glPixelStorei.

I’ve test my program on a mobile computer with Windows XP and an ATI Mobility FireGL T2, and the rendering was correct !

So, on a computer with Windows XP and a GeForce 8600 GTS, the bug appears but the rendering is different.
See the next capture :

It seems that this bug is only on the NVidia Graphic Cards…

So, _NK47 thanks for your answer, I will try to experiment with glPixelStorei.

thanks