From: DeaDDooMER Date: Mon, 19 Feb 2018 21:41:58 +0000 (+0300) Subject: Fix textures with nanoGL, disable particles with nanoGL and comment regressions with... X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=281b90361877a19420b086d8729eb4b6aaf882fa;p=d2df-sdl.git Fix textures with nanoGL, disable particles with nanoGL and comment regressions with nanoGL --- diff --git a/src/engine/e_graphics.pas b/src/engine/e_graphics.pas index 99d63e3..b78a175 100644 --- a/src/engine/e_graphics.pas +++ b/src/engine/e_graphics.pas @@ -385,7 +385,7 @@ begin Result.Width := w; Result.Height := h; -{$IFNDEF USE_NANOGL} +{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support glGetTexImage if e_NoGraphics then Exit; data := GetMemory(w*h*4); @@ -466,7 +466,7 @@ begin end; FreeMemory(data); -{$ENDIF USE_NANOGL} +{$ENDIF} end; procedure e_ResizeWindow(Width, Height: Integer); @@ -958,6 +958,7 @@ procedure e_DrawQuad(X1, Y1, X2, Y2: Integer; Red, Green, Blue: Byte; Alpha: Byt var nX1, nY1, nX2, nY2: Integer; begin +{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support glBegin(GL_LINES) if e_NoGraphics then Exit; // Only top-left/bottom-right quad if X1 > X2 then @@ -1013,6 +1014,7 @@ begin glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255); glDisable(GL_BLEND); +{$ENDIF} end; procedure e_DrawFillQuad(X1, Y1, X2, Y2: Integer; Red, Green, Blue, Alpha: Byte; @@ -1084,6 +1086,7 @@ end; procedure e_DrawLine(Width: Byte; X1, Y1, X2, Y2: Integer; Red, Green, Blue: Byte; Alpha: Byte = 0); begin +{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support glBegin(GL_LINES) if e_NoGraphics then Exit; // Pixel-perfect lines if Width = 1 then @@ -1108,6 +1111,7 @@ begin glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255); glDisable(GL_BLEND); +{$ENDIF} end; //------------------------------------------------------------------ @@ -1578,7 +1582,7 @@ begin id := High(e_TextureFonts); end; -{$IFNDEF USE_NANOGL} +{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support gl-lists with e_TextureFonts[id] do begin Base := glGenLists(XCount*YCount); @@ -1622,7 +1626,7 @@ end; procedure e_TextureFontKill(FontID: DWORD); begin if e_NoGraphics then Exit; -{$IFNDEF USE_NANOGL} +{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support gl-lists glDeleteLists(e_TextureFonts[FontID].Base, 256); {$ENDIF} e_TextureFonts[FontID].Base := 0; @@ -1630,6 +1634,7 @@ end; procedure e_TextureFontPrint(X, Y: GLint; Text: string; FontID: DWORD); begin +{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support gl-lists if e_NoGraphics then Exit; if Integer(FontID) > High(e_TextureFonts) then Exit; if Text = '' then Exit; @@ -1639,7 +1644,6 @@ begin glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255); -{$IFNDEF USE_NANOGL} glPushMatrix; glBindTexture(GL_TEXTURE_2D, e_TextureFonts[FontID].TextureID); glEnable(GL_TEXTURE_2D); @@ -1648,18 +1652,18 @@ begin glCallLists(Length(Text), GL_UNSIGNED_BYTE, PChar(Text)); glDisable(GL_TEXTURE_2D); glPopMatrix; -{$ENDIF} glDisable(GL_BLEND); +{$ENDIF} end; // god forgive me for this, but i cannot figure out how to do it without lists procedure e_TextureFontPrintChar(X, Y: Integer; Ch: Char; FontID: DWORD; Shadow: Boolean = False); begin +{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support gl-lists if e_NoGraphics then Exit; glPushMatrix; -{$IFNDEF USE_NANOGL} if Shadow then begin glColor4ub(0, 0, 0, 128); @@ -1672,9 +1676,9 @@ begin glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255); glTranslated(X, Y, 0); glCallLists(1, GL_UNSIGNED_BYTE, @Ch); -{$ENDIF} glPopMatrix; +{$ENDIF} end; procedure e_TextureFontPrintCharEx (X, Y: Integer; Ch: Char; FontID: DWORD; Shadow: Boolean = False); @@ -1701,6 +1705,7 @@ var tc, c: TRGB; w: Word; begin +{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support gl-lists if e_NoGraphics then Exit; if Text = '' then Exit; if e_TextureFonts = nil then Exit; @@ -1716,7 +1721,6 @@ begin w := e_TextureFonts[FontID].CharWidth; -{$IFNDEF USE_NANOGL} with e_TextureFonts[FontID] do begin glBindTexture(GL_TEXTURE_2D, e_TextureFonts[FontID].TextureID); @@ -1793,10 +1797,10 @@ end; procedure e_TextureFontPrintEx(X, Y: GLint; Text: string; FontID: DWORD; Red, Green, Blue: Byte; Scale: Single; Shadow: Boolean = False); begin +{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support gl-lists if e_NoGraphics then Exit; if Text = '' then Exit; -{$IFNDEF USE_NANOGL} glPushMatrix; glBindTexture(GL_TEXTURE_2D, e_TextureFonts[FontID].TextureID); glEnable(GL_TEXTURE_2D); @@ -1848,7 +1852,7 @@ begin for i := 0 to High(e_TextureFonts) do if e_TextureFonts[i].Base <> 0 then begin -{$IFNDEF USE_NANOGL} +{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support gl-lists glDeleteLists(e_TextureFonts[i].Base, 256); {$ENDIF} e_TextureFonts[i].Base := 0; diff --git a/src/engine/e_log.pas b/src/engine/e_log.pas index 8ffb75d..e2a88e0 100644 --- a/src/engine/e_log.pas +++ b/src/engine/e_log.pas @@ -89,7 +89,9 @@ var ss: ShortString; slen: Integer; b: PByte; +{$IFDEF ANDROID} cstr: PChar; +{$ENDIF} begin if (len < 1) then exit; b := PByte(@buf); @@ -101,7 +103,7 @@ begin cstr[slen + 1] := #0; SDL_Log(cstr, []); Dispose(cstr); -{$ENDIF ANDROID} +{$ENDIF} while (len > 0) do begin diff --git a/src/flexui/fui_gfx_gl.pas b/src/flexui/fui_gfx_gl.pas index 67ad97c..93992fa 100644 --- a/src/flexui/fui_gfx_gl.pas +++ b/src/flexui/fui_gfx_gl.pas @@ -191,11 +191,9 @@ end; function isScaled (): Boolean; var - mt: packed array [0..15] of Double; + mt: packed array [0..15] of GLfloat; begin -{$IFNDEF USE_NANOGL} - glGetDoublev(GL_MODELVIEW_MATRIX, @mt[0]); -{$ENDIF} + glGetFloatv(GL_MODELVIEW_MATRIX, @mt[0]); result := (mt[0] <> 1.0) or (mt[1*4+1] <> 1.0); end; @@ -237,7 +235,7 @@ begin glMatrixMode(GL_MODELVIEW); glPushMatrix(); glMatrixMode(GL_TEXTURE); glPushMatrix(); glMatrixMode(GL_COLOR); glPushMatrix(); -{$IFNDEF USE_NANOGL} +{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support glPushAttrib glPushAttrib({GL_ENABLE_BIT|GL_COLOR_BUFFER_BIT|GL_CURRENT_BIT}GL_ALL_ATTRIB_BITS); // let's play safe {$ENDIF} saved := true; @@ -246,7 +244,7 @@ end; procedure TSavedGLState.restore (); begin if (not saved) then raise Exception.Create('cannot restore unsaved OpenGL state'); -{$IFNDEF USE_NANOGL} +{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support glPopAttrib glPopAttrib({GL_ENABLE_BIT}); {$ENDIF} glMatrixMode(GL_PROJECTION); glPopMatrix(); @@ -272,7 +270,7 @@ var // set active context; `ctx` can be `nil` procedure gxSetContextInternal (ctx: TGxContext; ascale: Single; domatrix: Boolean); var - mt: packed array [0..15] of Double; + mt: packed array [0..15] of GLfloat; begin if (savedGLState.saved) then savedGLState.restore(); @@ -297,9 +295,7 @@ begin else begin // assume uniform scale -{$IFNDEF USE_NANOGL} - glGetDoublev(GL_MODELVIEW_MATRIX, @mt[0]); -{$ENDIF} + glGetFloatv(GL_MODELVIEW_MATRIX, @mt[0]); ctx.mScaled := (mt[0] <> 1.0) or (mt[1*4+1] <> 1.0); ctx.mScale := mt[0]; oglSetup2DState(); @@ -333,8 +329,8 @@ type procedure TScissorSave.save (enableScissoring: Boolean); begin -{$IFDEF USE_NANOGL} - wassc := false; // FIXIT +{$IFDEF USE_NANOGL} // FIXIT: nanoGL doesn't support glIsEnabled + wassc := false; {$ELSE} wassc := (glIsEnabled(GL_SCISSOR_TEST) <> 0); {$ENDIF} diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 726d370..3e4e022 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -3007,8 +3007,8 @@ begin * glBlendFunc(GL_DST_ALPHA, GL_ONE); * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting *) -{$IFDEF USE_NANOGL} - wassc := false; // FIXIT +{$IFDEF USE_NANOGL} // FIXIT: nanoGL doesn't support glIsEnabled + wassc := false; {$ELSE} wassc := (glIsEnabled(GL_SCISSOR_TEST) <> 0); {$ENDIF} diff --git a/src/game/g_gfx.pas b/src/game/g_gfx.pas index 878c45a..0f26212 100644 --- a/src/game/g_gfx.pas +++ b/src/game/g_gfx.pas @@ -1469,6 +1469,9 @@ procedure g_GFX_SetMax (count: Integer); var a: Integer; begin +{$IFDEF USE_NANOGL} // FIXIT: nanoGL doesn't support glBegin(GL_POINTS) + count := 0; +{$ENDIF} if count > 50000 then count := 50000; if (count < 1) then count := 1; SetLength(Particles, count); diff --git a/src/game/g_window.pas b/src/game/g_window.pas index 90c5950..395f44e 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -93,9 +93,9 @@ begin if (h_Wnd <> nil) then SDL_DestroyWindow(h_Wnd); if (h_GL <> nil) and (not preserveGL) then begin - {$IFDEF USE_NANOGL} - nanoGL_Destroy; - {$ENDIF USE_NANOGL} +{$IFDEF USE_NANOGL} + nanoGL_Destroy; +{$ENDIF USE_NANOGL} SDL_GL_DeleteContext(h_GL); end; h_Wnd := nil; @@ -542,7 +542,7 @@ begin e_WriteLog('nanoGL initialization error', TMsgType.Fatal); exit; end; -{$ENDIF USE_NANOGL} +{$ENDIF} if (assigned(oglInitCB)) then oglInitCB(); if (h_GL <> nil) then g_SetVSync(gVSync); {$ENDIF} diff --git a/src/lib/nanogl/nanoGL.pas b/src/lib/nanogl/nanoGL.pas index f63e9ce..f16d060 100644 --- a/src/lib/nanogl/nanoGL.pas +++ b/src/lib/nanogl/nanoGL.pas @@ -790,7 +790,7 @@ end; procedure glTexCoord2i(s, t: GLint); begin - glTexCoord2f(1 / s, 1 / t); + glTexCoord2f(s, t); end; end.