Opengl fix: bitmaps having a width not multiple of 4 were incorrectly drawn.
This fix draws a "sub bitmap" having a width multiple of 4. (The loss of 1 to 3 pixels in horizontal size should be not really noticeable)
This commit is contained in:
parent
6e9990449f
commit
3a02e54411
|
@ -121,21 +121,28 @@ GLuint GL_BITMAP_CACHE::cacheBitmap( const BITMAP_BASE* aBitmap )
|
||||||
bmp.w = aBitmap->GetSizePixels().x;
|
bmp.w = aBitmap->GetSizePixels().x;
|
||||||
bmp.h = aBitmap->GetSizePixels().y;
|
bmp.h = aBitmap->GetSizePixels().y;
|
||||||
|
|
||||||
|
// There are draw issues (incorrect rendering) with some w values.
|
||||||
|
// It happens when the w value is not a multiple of 4
|
||||||
|
// so we use only a sub image with a modified width
|
||||||
|
bmp.w -= bmp.w % 4;
|
||||||
|
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
glGenTextures(1, &textureID);
|
glGenTextures(1, &textureID);
|
||||||
|
|
||||||
uint8_t *buf = new uint8_t [ bmp.w * bmp.h * 3];
|
uint8_t *buf = new uint8_t [ bmp.w * bmp.h * 3];
|
||||||
auto imgData = const_cast<BITMAP_BASE*>( aBitmap )->GetImageData();
|
auto imgData = const_cast<BITMAP_BASE*>( aBitmap )->GetImageData();
|
||||||
|
|
||||||
for( int y=0; y < bmp.h; y++ )
|
for( int y = 0; y < bmp.h; y++ )
|
||||||
for( int x = 0; x < bmp.w;x++)
|
|
||||||
{
|
{
|
||||||
auto *p = buf + ( bmp.w * y + x ) * 3;
|
for( int x = 0; x < bmp.w; x++ )
|
||||||
|
{
|
||||||
|
uint8_t *p = buf + ( bmp.w * y + x ) * 3;
|
||||||
|
|
||||||
p[0] = imgData->GetRed( x, y );
|
p[0] = imgData->GetRed( x, y );
|
||||||
p[1] = imgData->GetGreen( x, y );
|
p[1] = imgData->GetGreen( x, y );
|
||||||
p[2] = imgData->GetBlue( x, y );
|
p[2] = imgData->GetBlue( x, y );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glBindTexture( GL_TEXTURE_2D, textureID );
|
glBindTexture( GL_TEXTURE_2D, textureID );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue