diff --git a/sc2/ChangeLog b/sc2/ChangeLog index bfe6c8c80..e57408bd3 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,7 @@ Changes towards version 0.7: +- OpenGL texture loading uses surface pitch instead of screen width. + This should head off future bugs similar to Bug #740 (this issue was + reported as Bug #956) - Michael 0.6.2 (maintenance release): - A bit more debug info for failed connects. - SvdB diff --git a/sc2/src/sc2code/libs/graphics/sdl/opengl.c b/sc2/src/sc2code/libs/graphics/sdl/opengl.c index bea2d80f4..c15bc33c7 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/opengl.c +++ b/sc2/src/sc2code/libs/graphics/sdl/opengl.c @@ -388,7 +388,8 @@ TFB_GL_Unscaled_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect) if (GL_Screens[screen].dirty) { - glPixelStorei (GL_UNPACK_ROW_LENGTH, ScreenWidth); + int PitchWords = SDL_Screens[screen]->pitch / 4; + glPixelStorei (GL_UNPACK_ROW_LENGTH, PitchWords); /* Matrox OpenGL drivers do not handle GL_UNPACK_SKIP_* correctly */ glPixelStorei (GL_UNPACK_SKIP_ROWS, 0); @@ -400,7 +401,7 @@ TFB_GL_Unscaled_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect) GL_Screens[screen].updated.h, GL_RGBA, GL_UNSIGNED_BYTE, (Uint32 *)SDL_Screens[screen]->pixels + - (GL_Screens[screen].updated.y * ScreenWidth + + (GL_Screens[screen].updated.y * PitchWords + GL_Screens[screen].updated.x)); SDL_UnlockSurface (SDL_Screens[screen]); GL_Screens[screen].dirty = FALSE; @@ -434,8 +435,9 @@ TFB_GL_Scaled_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect) if (GL_Screens[screen].dirty) { + int PitchWords = GL_Screens[screen].scaled->pitch / 4; scaler (SDL_Screens[screen], GL_Screens[screen].scaled, &GL_Screens[screen].updated); - glPixelStorei (GL_UNPACK_ROW_LENGTH, ScreenWidth * 2); + glPixelStorei (GL_UNPACK_ROW_LENGTH, PitchWords); /* Matrox OpenGL drivers do not handle GL_UNPACK_SKIP_* correctly */ @@ -448,7 +450,7 @@ TFB_GL_Scaled_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect) GL_Screens[screen].updated.h * 2, GL_RGBA, GL_UNSIGNED_BYTE, (Uint32 *)GL_Screens[screen].scaled->pixels + - (GL_Screens[screen].updated.y * 4 * ScreenWidth + + (GL_Screens[screen].updated.y * 2 * PitchWords + GL_Screens[screen].updated.x * 2)); SDL_UnlockSurface (GL_Screens[screen].scaled); GL_Screens[screen].dirty = FALSE;