MACCERS
1
Can someone tell me way there is an access violation here:
HBITMAP i = DibSectionPieceWise(3);
BITMAP texture1;
// if (!texture1) exit(1);
// Create Texture
::GetObject( i, sizeof( texture1 ), &texture1 );
glGenTextures(1, &texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glTexImage2D(GL_TEXTURE_2D, 0, 3, texture1.bmWidth, texture1.bmHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, texture1.bmBits);
MACCERS
2
sorry I should have said it was to do with the texture1.bmBits?
Originally posted by MACCERS:
[b]Can someone tell me way there is an access violation here:
HBITMAP i = DibSectionPieceWise(3);
BITMAP texture1;
// if (!texture1) exit(1);
// Create Texture
::GetObject( i, sizeof( texture1 ), &texture1 );
glGenTextures(1, &texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glTexImage2D(GL_TEXTURE_2D, 0, 3, texture1.bmWidth, texture1.bmHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, texture1.bmBits);
[/b]
Relic
3
Read the BITMAPINFOHEADER manual on MSDN.
Multiple things can go wrong here.
- You’re sure you need unpack alignment of 4, not 1?
- Texture size needs to be power of two.
- texture1.biBitcount needs to be 24.
- texture1.biCompression must be BI_RGB (uncompressed).
- bmHeight can be negative!