summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 87c3a28)
raw | patch | inline | side by side (parent: 87c3a28)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 13 Oct 2019 00:31:05 +0000 (03:31 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 13 Oct 2019 14:19:20 +0000 (17:19 +0300) |
src/engine/e_graphics.pas | patch | blob | history | |
src/game/g_gfx.pas | patch | blob | history | |
src/game/g_window.pas | patch | blob | history | |
src/game/sdl/g_system.pas | patch | blob | history | |
src/game/sdl2/g_system.pas | patch | blob | history | |
src/nogl/noGL.pas | patch | blob | history | |
src/nogl/noGLSTUB.inc | [new file with mode: 0644] | patch | blob |
src/nogl/noGLuses.inc | patch | blob | history | |
src/shared/a_modes.inc | patch | blob | history |
index ca6dcf17bcbbb5565476c63f14b30e8fe3c8f2a2..6e8966eaf5628467df56d3dc145d29f22f05193b 100644 (file)
procedure e_DrawQuad(X1, Y1, X2, Y2: Integer; Red, Green, Blue: Byte; Alpha: Byte = 0);
var
nX1, nY1, nX2, nY2: Integer;
-{$IFDEF USE_NANOGL}
- v: array [0..15] of GLfloat;
-{$ENDIF}
begin
if e_NoGraphics then Exit;
// Only top-left/bottom-right quad
begin
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- end else
+ end
+ else
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
glColor4ub(Red, Green, Blue, 255-Alpha);
glLineWidth(1);
-{$IFDEF USE_NANOGL}
- nX1 := X1; nY1 := Y1;
- nX2 := X2; nY2 := Y1;
- e_LineCorrection(nX1, nY1, nX2, nY2);
- v[0] := nX1; v[1] := nY1; v[2] := nX2; v[3] := nY2;
-
- nX1 := X2; nY1 := Y1;
- nX2 := X2; nY2 := Y2;
- e_LineCorrection(nX1, nY1, nX2, nY2);
- v[4] := nX1; v[5] := nY1; v[6] := nX2; v[7] := nY2;
-
- nX1 := X2; nY1 := Y2;
- nX2 := X1; nY2 := Y2;
- e_LineCorrection(nX1, nY1, nX2, nY2);
- v[8] := nX1; v[9] := nY1; v[10] := nX2; v[11] := nY2;
-
- nX1 := X1; nY1 := Y2;
- nX2 := X1; nY2 := Y1;
- e_LineCorrection(nX1, nY1, nX2, nY2);
- v[12] := nX1; v[13] := nY1; v[14] := nX2; v[15] := nY2;
-
- glVertexPointer(2, GL_FLOAT, 0, @v[0]);
- glEnableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDrawArrays(GL_LINES, 0, 16);
-{$ELSE}
glBegin(GL_LINES);
nX1 := X1; nY1 := Y1;
nX2 := X2; nY2 := Y1;
glVertex2i(nX1, nY1);
glVertex2i(nX2, nY2);
glEnd();
-{$ENDIF}
-
glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
-
glDisable(GL_BLEND);
end;
procedure e_DrawLine(Width: Byte; X1, Y1, X2, Y2: Integer; Red, Green, Blue: Byte; Alpha: Byte = 0);
-{$IFDEF USE_NANOGL}
- var
- v: array [0..3] of GLfloat;
-{$ENDIF}
begin
if e_NoGraphics then Exit;
// Pixel-perfect lines
glDisable(GL_TEXTURE_2D);
glColor4ub(Red, Green, Blue, 255-Alpha);
glLineWidth(Width);
-
-{$IFDEF USE_NANOGL}
- v[0] := X1; v[1] := Y1; v[2] := X2; v[3] := Y2;
- glVertexPointer(2, GL_FLOAT, 0, @v[0]);
- glEnableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDrawArrays(GL_LINES, 0, 4);
-{$ELSE}
glBegin(GL_LINES);
glVertex2i(X1, Y1);
glVertex2i(X2, Y2);
glEnd();
-{$ENDIF}
-
glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
glDisable(GL_BLEND);
procedure e_TextureFontBuild(Tex: DWORD; var FontID: DWORD; XCount, YCount: Word;
Space: ShortInt=0);
var
-{$IF not DEFINED(USE_NANOGL) and not DEFINED(USE_NOGL)}
+{$IFDEF NOGL_LISTS}
loop1 : GLuint;
cx, cy : real;
{$ENDIF}
with e_TextureFonts[id] do
begin
-{$IF not DEFINED(USE_NANOGL) and not DEFINED(USE_NOGL)}
+{$IFDEF NOGL_LISTS}
Base := glGenLists(XCount*YCount);
{$ENDIF}
TextureID := e_Textures[Tex].tx.id;
SPC := Space;
end;
-{$IF not DEFINED(USE_NANOGL) and not DEFINED(USE_NOGL)}
+{$IFDEF NOGL_LISTS}
glBindTexture(GL_TEXTURE_2D, e_Textures[Tex].tx.id);
for loop1 := 0 to XCount*YCount-1 do
begin
procedure e_TextureFontKill(FontID: DWORD);
begin
if e_NoGraphics then Exit;
-{$IF not DEFINED(USE_NANOGL) and not DEFINED(USE_NOGL)}
+{$IFDEF NOGL_LISTS}
glDeleteLists(e_TextureFonts[FontID].Base, 256);
{$ENDIF}
e_TextureFonts[FontID].Base := 0;
end;
-{$IF DEFINED(USE_NANOGL) or DEFINED(USE_NOGL)}
+{$IFNDEF NOGL_LISTS}
procedure e_TextureFontDrawChar(ch: Char; FontID: DWORD);
var
index: Integer;
glBindTexture(GL_TEXTURE_2D, e_TextureFonts[FontID].TextureID);
glEnable(GL_TEXTURE_2D);
glTranslatef(x, y, 0);
-{$IF DEFINED(USE_NANOGL) or DEFINED(USE_NOGL)}
- e_TextureFontDrawString(Text, FontID);
-{$ELSE}
+{$IFDEF NOGL_LISTS}
glListBase(DWORD(Integer(e_TextureFonts[FontID].Base)-32));
glCallLists(Length(Text), GL_UNSIGNED_BYTE, PChar(Text));
+{$ELSE}
+ e_TextureFontDrawString(Text, FontID);
{$ENDIF}
glDisable(GL_TEXTURE_2D);
glPopMatrix;
begin
glColor4ub(0, 0, 0, 128);
glTranslatef(X+1, Y+1, 0);
-{$IF DEFINED(USE_NANOGL) or DEFINED(USE_NOGL)}
- e_TextureFontDrawChar(Ch, FontID);
-{$ELSE}
+{$IFDEF NOGL_LISTS}
glCallLists(1, GL_UNSIGNED_BYTE, @Ch);
+{$ELSE}
+ e_TextureFontDrawChar(Ch, FontID);
{$ENDIF}
glPopMatrix;
glPushMatrix;
glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
glTranslatef(X, Y, 0);
-{$IF DEFINED(USE_NANOGL) or DEFINED(USE_NOGL)}
- e_TextureFontDrawChar(Ch, FontID);
-{$ELSE}
+{$IFDEF NOGL_LISTS}
glCallLists(1, GL_UNSIGNED_BYTE, @Ch);
+{$ELSE}
+ e_TextureFontDrawChar(Ch, FontID);
{$ENDIF}
glPopMatrix;
glBindTexture(GL_TEXTURE_2D, e_TextureFonts[FontID].TextureID);
glEnable(GL_TEXTURE_2D);
-{$IF not DEFINED(USE_NANOGL) and not DEFINED(USE_NOGL)}
+{$IFDEF NOGL_LISTS}
glListBase(DWORD(Integer(e_TextureFonts[FontID].Base)-32));
{$ENDIF}
glBindTexture(GL_TEXTURE_2D, e_TextureFonts[FontID].TextureID);
glEnable(GL_TEXTURE_2D);
-{$IF not DEFINED(USE_NANOGL) and not DEFINED(USE_NOGL)}
+{$IFDEF NOGL_LISTS}
glListBase(DWORD(Integer(e_TextureFonts[FontID].Base)-32));
{$ENDIF}
glColor4ub(0, 0, 0, 128);
glTranslatef(x+1, y+1, 0);
glScalef(Scale, Scale, 0);
-{$IF DEFINED(USE_NANOGL) or DEFINED(USE_NOGL)}
- e_TextureFontDrawString(Text, FontID);
-{$ELSE}
+{$IFDEF NOGL_LISTS}
glCallLists(Length(Text), GL_UNSIGNED_BYTE, PChar(Text));
+{$ELSE}
+ e_TextureFontDrawString(Text, FontID);
{$ENDIF}
glPopMatrix;
glPushMatrix;
glColor4ub(Red, Green, Blue, 255);
glTranslatef(x, y, 0);
glScalef(Scale, Scale, 0);
-{$IF DEFINED(USE_NANOGL) or DEFINED(USE_NOGL)}
- e_TextureFontDrawString(Text, FontID);
-{$ELSE}
+{$IFDEF NOGL_LISTS}
glCallLists(Length(Text), GL_UNSIGNED_BYTE, PChar(Text));
+{$ELSE}
+ e_TextureFontDrawString(Text, FontID);
{$ENDIF}
glDisable(GL_TEXTURE_2D);
for i := 0 to High(e_TextureFonts) do
if e_TextureFonts[i].Base <> 0 then
begin
-{$IF not DEFINED(USE_NANOGL) and not DEFINED(USE_NOGL)}
+{$IFDEF NOGL_LISTS}
glDeleteLists(e_TextureFonts[i].Base, 256);
{$ENDIF}
e_TextureFonts[i].Base := 0;
diff --git a/src/game/g_gfx.pas b/src/game/g_gfx.pas
index e9118a313c4c3ad2fecd7f161dc154c1e4d7d129..8094c4e4e1af00e578f2f6d82d70340e75c565f0 100644 (file)
--- a/src/game/g_gfx.pas
+++ b/src/game/g_gfx.pas
procedure g_GFX_Draw ();
var
a, len: Integer;
-{$IFDEF USE_NANOGL}
- type
- Vertex = record
- x, y: GLfloat;
- r, g, b, a: GLfloat;
- end;
- var
- count: Integer;
- v: array of Vertex;
-{$ENDIF}
begin
if not gpart_dbg_enabled then exit;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-{$IFDEF USE_NANOGL}
- count := 0;
- SetLength(v, Length(Particles));
- for a := 0 to High(Particles) do
- begin
- with Particles[a] do
- begin
- if alive and (x >= sX) and (y >= sY) and (x <= sX + sWidth) and (sY <= sY + sHeight) then
- begin
- v[count].x := x + 0.37;
- v[count].y := y + 0.37;
- v[count].r := red / 255;
- v[count].g := green / 255;
- v[count].b := blue / 255;
- v[count].a := alpha / 255;
- Inc(count);
- end;
- end;
- end;
-
- glVertexPointer(2, GL_FLOAT, SizeOf(Vertex), @v[0].x);
- glColorPointer(4, GL_FLOAT, SizeOf(Vertex), @v[0].r);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDrawArrays(GL_POINTS, 0, count);
-{$ELSE}
glBegin(GL_POINTS);
len := High(Particles);
end;
glEnd();
-{$ENDIF}
glDisable(GL_BLEND);
end;
diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index 3ea192bd998ede79b04215dec5bb09251afb2ab4..6cce5613bb0afa67e1014baf3915e9ed0b806e3a 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
end;
end;
-{$IFDEF USE_SYSSTUB}
+{$IFNDEF USE_SYSSTUB}
PrintGLSupportedExtensions;
glLegacyNPOT := GLExtensionSupported('GL_ARB_texture_non_power_of_two') or GLExtensionSupported('GL_OES_texture_npot');
{$ELSE}
index 3e78fadcfdc997d324162bb67f1e47560c8f4ad4..b86a70b0941e5b187b454d872abeb29b6eff3bfe 100644 (file)
screen := SDL_SetVideoMode(w, h, bpp, flags);
if screen <> nil then
begin
- {$IFDEF USE_NOGL}
+ {$IFDEF NOGL_INIT}
nogl_Init;
{$ENDIF}
SDL_WM_SetCaption(GameTitle, nil);
RemoveJoystick(i);
if screen <> nil then
begin
- {$IFDEF USE_NOGL}
+ {$IFDEF NOGL_INIT}
nogl_Quit;
{$ENDIF}
SDL_FreeSurface(screen)
index 9485fd9b6e9a0897a5eb328b7232ae8f7ac8a3d9..85e5d947e2dd9af743c1c4b5d48752ba40fbefd8 100644 (file)
context := SDL_GL_CreateContext(window);
if context <> nil then
begin
- {$IFDEF USE_NOGL}
+ {$IFDEF NOGL_INIT}
nogl_Init;
{$ENDIF}
UpdateSize(w, h);
e_WriteLog('Releasing SDL2', TMsgType.Notify);
if context <> nil then
begin
- {$IFDEF USE_NOGL}
+ {$IFDEF NOGL_INIT}
nogl_Quit;
{$ENDIF}
SDL_GL_DeleteContext(context);
diff --git a/src/nogl/noGL.pas b/src/nogl/noGL.pas
index 941c8d2dab660957757dd89af164294463b2b0b5..7f7ab2eefa068842399b8e1903e2db504776b7ad 100644 (file)
--- a/src/nogl/noGL.pas
+++ b/src/nogl/noGL.pas
procedure nogl_Init;
procedure nogl_Quit;
-{$I noGLES1.inc}
+{$IFDEF USE_GLES1}
+ {$I noGLES1.inc}
+{$ENDIF}
+{$IFDEF USE_GLSTUB}
+ {$I noGLSTUB.inc}
+{$ENDIF}
end.
diff --git a/src/nogl/noGLSTUB.inc b/src/nogl/noGLSTUB.inc
--- /dev/null
+++ b/src/nogl/noGLSTUB.inc
@@ -0,0 +1,193 @@
+implementation
+
+ procedure glEnable(cap: GLenum);
+ begin
+ end;
+
+ procedure glDisable(cap: GLenum);
+ begin
+ end;
+
+ function glIsEnabled(cap: GLenum): GLboolean;
+ begin
+ result := 0
+ end;
+
+ function glGetString(name: GLenum): PChar;
+ begin
+ result := ''
+ end;
+
+ procedure glClearColor(red, green, blue, alpha: GLclampf);
+ begin
+ end;
+
+ procedure glClear(mask: GLbitfield);
+ begin
+ end;
+
+ procedure glAlphaFunc(func: GLenum; ref: GLclampf);
+ begin
+ end;
+
+ procedure glBlendFunc(sfactor, dfactor: GLenum);
+ begin
+ end;
+
+ procedure glPointSize(size: GLfloat);
+ begin
+ end;
+
+ procedure glLineWidth(width: GLfloat);
+ begin
+ end;
+
+ procedure glGetIntegerv(pname: GLenum; params: PGLint);
+ begin
+ end;
+
+ procedure glFlush;
+ begin
+ end;
+
+ procedure glFinish;
+ begin
+ end;
+
+ procedure glBegin(mode: GLenum);
+ begin
+ end;
+
+ procedure glEnd;
+ begin
+ end;
+
+ procedure glVertex2f(x, y: GLfloat);
+ begin
+ end;
+
+ procedure glVertex2i(x, y: GLint);
+ begin
+ end;
+
+ procedure glColor4f(red, green, blue, alpha: GLfloat);
+ begin
+ end;
+
+ procedure glColor4ub(red, green, blue, alpha: GLubyte);
+ begin
+ end;
+
+ procedure glColor3ub(red, green, blue: GLubyte);
+ begin
+ end;
+
+ procedure glTexCoord2f(s, t: GLfloat);
+ begin
+ end;
+
+ procedure glTexCoord2i(s, t: GLint);
+ begin
+ end;
+
+ procedure glReadPixels(x, y: GLint; width, height: GLsizei; format, atype: GLenum; pixels: Pointer);
+ begin
+ end;
+
+ procedure glLoadIdentity;
+ begin
+ end;
+
+ procedure glMatrixMode(mode: GLenum);
+ begin
+ end;
+
+ procedure glLoadMatrixd(const m: PGLdouble);
+ begin
+ end;
+
+ procedure glPushMatrix;
+ begin
+ end;
+
+ procedure glPopMatrix;
+ begin
+ end;
+
+ procedure glTranslatef(x, y, z: GLfloat);
+ begin
+ end;
+
+ procedure glRotatef(angle, x, y, z: GLfloat);
+ begin
+ end;
+
+ procedure glScalef(x, y, z: GLfloat);
+ begin
+ end;
+
+ procedure glViewport(x, y: GLint; width, height: GLsizei);
+ begin
+ end;
+
+ procedure glScissor(x, y: GLint; width, height: GLsizei);
+ begin
+ end;
+
+ procedure glStencilMask(mask: GLuint);
+ begin
+ end;
+
+ procedure glStencilFunc(func: GLenum; ref: GLint; mask: GLuint);
+ begin
+ end;
+
+ procedure glStencilOp(fail, zfail, zpass: GLenum);
+ begin
+ end;
+
+ procedure glColorMask(red, green, blue, alpha: GLboolean);
+ begin
+ end;
+
+ procedure glBindTexture(target: GLenum; texture: GLuint);
+ begin
+ end;
+
+ procedure glGenTextures(n: GLsizei; textures: PGLuint);
+ begin
+ end;
+
+ procedure glTexEnvi(target: GLenum; pname: GLenum; param: GLint);
+ begin
+ end;
+
+ procedure glTexParameterf(target: GLenum; pname: GLenum; param: GLfloat);
+ begin
+ end;
+
+ procedure glTexParameteri(target: GLenum; pname: GLenum; param: GLint);
+ begin
+ end;
+
+ procedure glTexImage2D(target: GLenum; level, internalformat: GLint; width, height: GLsizei; border: GLint; format, atype: GLenum; const pixels: Pointer);
+ begin
+ end;
+
+ procedure glTexSubImage2D(target: GLenum; level, xoffset, yoffset: GLint; width, height: GLsizei; format, atype: GLenum; const pixels: Pointer);
+ begin
+ end;
+
+ procedure glDeleteTextures(n: GLsizei; const textures: PGLuint);
+ begin
+ end;
+
+ procedure nogl_Init;
+ begin
+ end;
+
+ procedure nogl_Quit;
+ begin
+ end;
+
+initialization
diff --git a/src/nogl/noGLuses.inc b/src/nogl/noGLuses.inc
index 458f546ad9932ddafb94b061af7db8d18d20a59f..acfe89e52ac0982c93d55b577f9a3206d1bfa596 100644 (file)
--- a/src/nogl/noGLuses.inc
+++ b/src/nogl/noGLuses.inc
-{$IFDEF USE_NANOGL}
- {$DEFINE USE_GLES1}
-{$ELSE}
- {$IFDEF USE_NOGL}
- {$DEFINE USE_GLES1}
- {$ENDIF}
-{$ENDIF}
-
-{$IFDEF USE_GLES1}
- {$IFNDEF USE_NANOGL}
- {$DEFINE USE_NOGL}
- {$ENDIF}
-{$ENDIF}
-
-{$IF DEFINED(USE_NANOGL) and DEFINED(USE_NOGL)}
- {$WARNING you can use only one OpenGL ES wrapper}
-{$ENDIF}
-
-{$IFDEF USE_NANOGL}
- nanoGL in '../lib/nanogl/nanoGL.pas',
-{$ELSE}
- {$IFDEF USE_NOGL}
- noGL in '../nogl/noGL.pas',
- {$ELSE}
- GL, GLExt,
- {$ENDIF}
+{$IF DEFINED(USE_GLES1) OR DEFINED(USE_GLSTUB)}
+ {$UNDEF NOGL_LISTS}
+ {$DEFINE NOGL_INIT}
+ noGL in '../nogl/noGL.pas',
+{$ENDIF}
+{$IFDEF USE_OPENGL}
+ {$DEFINE NOGL_LISTS}
+ GL, GLExt,
{$ENDIF}
diff --git a/src/shared/a_modes.inc b/src/shared/a_modes.inc
index 733abb82e82d58ff9d11777541efe0924870758b..c9fd4571b336f7d94b085d046a4ee698fd7d49e6 100644 (file)
--- a/src/shared/a_modes.inc
+++ b/src/shared/a_modes.inc
{$UNDEF USE_SDL}
{$UNDEF USE_SDL2}
{$ENDIF}
+ {$DEFINE USE_GLSTUB}
+ {$IF DEFINED(USE_GLES1) OR DEFINED(USE_OPENGL)}
+ {$WARNING Render drivers not needed in headless mode. Force stub driver...}
+ {$UNDEF USE_GLES1}
+ {$UNDEF USE_OPENGL}
+ {$ENDIF}
+ {$IFDEF ENABLE_HOLMES}
+ {$WARNING Holmes in headless mode has no sense. Disabled.}
+ {$UNDEF ENABLE_HOLMES}
+ {$ENDIF}
{$ENDIF}
{$IF DEFINED(USE_SYSSTUB)}
{$ERROR Sound driver not selected. Use -dUSE_SOUNDSTUB or -dUSE_SDLMIXER or -dUSE_FMOD or -dUSE_OPENAL}
{$ENDIF}
-{$IFDEF ENABLE_HOLMES}
- {$IFDEF HEADLESS}
- {$ERROR Holmes in HEADLESS mode has no sense}
+{$IF DEFINED(USE_GLSTUB)}
+ {$IF DEFINED(USE_GLES1) OR DEFINED(USE_OPENGL)}
+ {$ERROR Only one render driver must be selected!}
+ {$ENDIF}
+{$ELSEIF DEFINED(USE_GLES1)}
+ {$IF DEFINED(USE_GLSTUB) OR DEFINED(USE_OPENGL)}
+ {$ERROR Only one render driver must be selected!}
+ {$ENDIF}
+{$ELSEIF DEFINED(USE_OPENGL)}
+ {$IF DEFINED(USE_GLSTUB) OR DEFINED(USE_GLES1)}
+ {$ERROR Only one render driver must be selected!}
{$ENDIF}
+{$ELSE}
+ {$DEFINE USE_OPENGL}
+ {.$ERROR Render driver not selected. Use -dUSE_GLSTUB or -dUSE_GLES1 or -dUSE_OPENGL}
+{$ENDIF}
+
+{$IFDEF ENABLE_HOLMES}
{$IFNDEF USE_SDL2}
{$ERROR Holmes supported only with SDL2}
{$ENDIF}
- {$IFDEF USE_GLES1}
- {$ERROR Holmes not supported with GLES}
+ {$IFNDEF USE_OPENGL}
+ {$ERROR Holmes supported only with desktop OpenGL}
{$ENDIF}
{$ENDIF}