--- a/hedgewars/SDLh.pas Fri Jan 25 20:47:50 2008 +0000
+++ b/hedgewars/SDLh.pas Fri Jan 25 21:55:48 2008 +0000
@@ -65,7 +65,12 @@
SDL_GL_DOUBLEBUFFER = 5;
SDL_OPENGL = 2;
-
+
+ RMask = $FF;
+ GMask = $FF00;
+ BMask = $FF0000;
+ AMask = $FF000000;
+
type PSDL_Rect = ^TSDL_Rect;
TSDL_Rect = record
x, y: SmallInt;
--- a/hedgewars/uLand.pas Fri Jan 25 20:47:50 2008 +0000
+++ b/hedgewars/uLand.pas Fri Jan 25 21:55:48 2008 +0000
@@ -514,14 +514,16 @@
GenBlank(EdgeTemplates[SelectTemplate]);
AddProgress;
-with PixelFormat^ do
- tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2048, 1024, 32, $FF, $FF00, $FF0000, 0);
+
+tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2048, 1024, 32, RMask, GMask, BMask, AMask);
+
TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true);
ColorizeLand(tmpsurf);
AddProgress;
AddBorder(tmpsurf);
-with PixelFormat^ do
- LandSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2048, 1024, 32, $FF, $FF00, $FF0000, 0);
+
+LandSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2048, 1024, 32, RMask, GMask, BMask, AMask);
+
TryDo(LandSurface <> nil, 'Error creating land surface', true);
SDL_FillRect(LandSurface, nil, 0);
AddProgress;
@@ -540,8 +542,8 @@
WriteLnToConsole('Generating forts land...');
TryDo(TeamsCount = 2, 'More or less than 2 teams on map in forts mode!', true);
-with PixelFormat^ do
- LandSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 2048, 1024, 32, RMask, GMask, BMask, AMask);
+LandSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 2048, 1024, 32, RMask, GMask, BMask, AMask);
+
SDL_FillRect(LandSurface, nil, 0);
tmpsurf:= LoadImage(Pathz[ptForts] + '/' + TeamsArray[0]^.FortName + 'L', false, true, true);
@@ -551,6 +553,8 @@
tmpsurf:= LoadImage(Pathz[ptForts] + '/' + TeamsArray[1]^.FortName + 'R', false, true, true);
BlitImageAndGenerateCollisionInfo(1024, 0, tmpsurf, LandSurface);
SDL_FreeSurface(tmpsurf);
+
+LandTexture:= Surface2Tex(LandSurface)
end;
procedure LoadMap;
@@ -568,12 +572,7 @@
p:= LandSurface^.pixels;
case LandSurface^.format^.BytesPerPixel of
1: OutError('We don''t work with 8 bit surfaces', true);
- 2: for y:= 0 to 1023 do
- begin
- for x:= 0 to 2047 do
- if PWord(@(p^[x * 2]))^ <> 0 then Land[y, x]:= COLOR_LAND;
- p:= @(p^[LandSurface^.pitch]);
- end;
+ 2: OutError('We don''t work with 16 bit surfaces', true);
3: for y:= 0 to 1023 do
begin
for x:= 0 to 2047 do
@@ -592,6 +591,8 @@
if SDL_MustLock(LandSurface) then
SDL_UnlockSurface(LandSurface);
+
+LandTexture:= Surface2Tex(LandSurface)
end;
procedure GenMap;
--- a/hedgewars/uMisc.pas Fri Jan 25 20:47:50 2008 +0000
+++ b/hedgewars/uMisc.pas Fri Jan 25 21:55:48 2008 +0000
@@ -258,6 +258,9 @@
var mode: LongInt;
texId: GLuint;
begin
+if SDL_MustLock(surf) then
+ SDLTry(SDL_LockSurface(surf) >= 0, true);
+
if (surf^.format^.BytesPerPixel = 3) then mode:= GL_RGB else
if (surf^.format^.BytesPerPixel = 4) then mode:= GL_RGBA else
begin
@@ -272,6 +275,9 @@
glTexImage2D(GL_TEXTURE_2D, 0, mode, surf^.w, surf^.h, 0, mode, GL_UNSIGNED_BYTE, surf^.pixels);
+if SDL_MustLock(surf) then
+ SDL_UnlockSurface(surf);
+
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
--- a/hedgewars/uStore.pas Fri Jan 25 20:47:50 2008 +0000
+++ b/hedgewars/uStore.pas Fri Jan 25 21:55:48 2008 +0000
@@ -369,20 +369,20 @@
glBegin(GL_QUADS);
// top left
- glTexCoord2f(0, 0);
- glVertex2f(0, 0);
+ glTexCoord2i(0, 0);
+ glVertex2i(X, Y);
// top right
- glTexCoord2f(1, 0);
- glVertex2f(1, 0);
+ glTexCoord2i(1, 0);
+ glVertex2i(2048 + X, Y);
// bottom right
- glTexCoord2f(1, 1);
- glVertex2f(1, 1);
+ glTexCoord2i(1, 1);
+ glVertex2i(2048 + X, 1024 + Y);
// bottom left
- glTexCoord2f(0, 1);
- glVertex2f(0, 1);
+ glTexCoord2i(0, 1);
+ glVertex2i(X, 1024 + Y);
glEnd();
//DrawFromRect(X, Y, @r, LandSurface, Surface)
@@ -475,7 +475,8 @@
aspect:= cScreenWidth / cScreenHeight;
glViewport(0, 0, cScreenWidth, cScreenHeight);
-
+glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0);
+glTranslatef(-cScreenWidth / 2, -cScreenHeight / 2, 0);
//glMatrixMode(GL_PROJECTION);
//glLoadIdentity();