[Scummvm-git-logs] scummvm master -> 69198d5d3004524a296c68dc6867087c695c36a1
aquadran
noreply at scummvm.org
Sat Jan 1 13:07:13 UTC 2022
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
04b13dc61a TINYGL: Split/move functions to API and internal implementation.
fef0e04cb7 TINYGL: No need to check for current_texture
69198d5d30 TINYGL: Corrected variable type
Commit: 04b13dc61a6b4bc0ba01ac31265a4df9b0c6e5fe
https://github.com/scummvm/scummvm/commit/04b13dc61a6b4bc0ba01ac31265a4df9b0c6e5fe
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2022-01-01T14:06:10+01:00
Commit Message:
TINYGL: Split/move functions to API and internal implementation.
Changed paths:
graphics/tinygl/api.cpp
graphics/tinygl/arrays.cpp
graphics/tinygl/get.cpp
graphics/tinygl/gl.h
graphics/tinygl/init.cpp
graphics/tinygl/light.cpp
graphics/tinygl/list.cpp
graphics/tinygl/matrix.cpp
graphics/tinygl/texture.cpp
graphics/tinygl/zdirtyrect.h
graphics/tinygl/zgl.h
diff --git a/graphics/tinygl/api.cpp b/graphics/tinygl/api.cpp
index d1eac0dd7ad..54334962321 100644
--- a/graphics/tinygl/api.cpp
+++ b/graphics/tinygl/api.cpp
@@ -632,6 +632,21 @@ void tglClearStencil(TGLint s) {
c->gl_add_op(p);
}
+void tglFlush() {
+ // nothing to do
+}
+
+void tglHint(TGLenum target, TGLenum mode) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+ TinyGL::GLParam p[3];
+
+ p[0].op = TinyGL::OP_Hint;
+ p[1].i = target;
+ p[2].i = mode;
+
+ c->gl_add_op(p);
+}
+
// textures
void tglTexImage2D(TGLenum target, TGLint level, TGLint internalformat, TGLsizei width,
@@ -696,6 +711,18 @@ void tglTexParameteri(TGLenum target, TGLenum pname, TGLint param) {
c->gl_add_op(p);
}
+void tglGenTextures(TGLsizei n, TGLuint *textures) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+
+ c->gl_GenTextures(n, textures);
+}
+
+void tglDeleteTextures(TGLsizei n, const TGLuint *textures) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+
+ c->gl_DeleteTextures(n, textures);
+}
+
void tglPixelStorei(TGLenum pname, TGLint param) {
TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[3];
@@ -758,7 +785,7 @@ void tglPolygonOffset(TGLfloat factor, TGLfloat units) {
c->gl_add_op(p);
}
-// Special Functions
+// lists
void tglCallList(TGLuint list) {
TinyGL::GLContext *c = TinyGL::gl_get_context();
@@ -770,24 +797,183 @@ void tglCallList(TGLuint list) {
c->gl_add_op(p);
}
-void tglFlush() {
- // nothing to do
+void tglNewList(TGLuint list, TGLenum mode) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+
+ c->gl_NewList(list, mode);
}
-void tglHint(TGLenum target, TGLenum mode) {
+void tglEndList() {
TinyGL::GLContext *c = TinyGL::gl_get_context();
- TinyGL::GLParam p[3];
- p[0].op = TinyGL::OP_Hint;
- p[1].i = target;
- p[2].i = mode;
+ c->gl_EndList();
+}
+
+TGLboolean tglIsList(TGLuint list) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+
+ TinyGL::GLList *l = c->find_list(list);
+ return (l != nullptr);
+}
+
+TGLuint tglGenLists(TGLsizei range) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+
+ return c->gl_GenLists(range);
+}
+
+// arrays
+
+void tglArrayElement(TGLint i) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+ TinyGL::GLParam p[2];
+
+ p[0].op = TinyGL::OP_ArrayElement;
+ p[1].i = i;
+
+ c->gl_add_op(p);
+}
+
+void tglDrawArrays(TGLenum mode, TGLint first, TGLsizei count) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+ TinyGL::GLParam p[4];
+
+ p[0].op = TinyGL::OP_DrawArrays;
+ p[1].i = mode;
+ p[2].i = first;
+ p[3].i = count;
+
+ c->gl_add_op(p);
+}
+
+void tglDrawElements(TGLenum mode, TGLsizei count, TGLenum type, const TGLvoid *indices) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+ TinyGL::GLParam p[5];
+
+ p[0].op = TinyGL::OP_DrawElements;
+ p[1].i = mode;
+ p[2].i = count;
+ p[3].i = type;
+ p[4].p = const_cast<void *>(indices);
c->gl_add_op(p);
}
-// Non standard functions
+void tglEnableClientState(TGLenum array) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+ TinyGL::GLParam p[2];
-void tglDebug(TGLenum mode) {
+ p[0].op = TinyGL::OP_EnableClientState;
+
+ switch (array) {
+ case TGL_VERTEX_ARRAY:
+ p[1].i = VERTEX_ARRAY;
+ break;
+ case TGL_NORMAL_ARRAY:
+ p[1].i = NORMAL_ARRAY;
+ break;
+ case TGL_COLOR_ARRAY:
+ p[1].i = COLOR_ARRAY;
+ break;
+ case TGL_TEXTURE_COORD_ARRAY:
+ p[1].i = TEXCOORD_ARRAY;
+ break;
+ default:
+ assert(0);
+ break;
+ }
+
+ c->gl_add_op(p);
+}
+
+void tglDisableClientState(TGLenum array) {
TinyGL::GLContext *c = TinyGL::gl_get_context();
- c->print_flag = mode;
+ TinyGL::GLParam p[2];
+
+ p[0].op = TinyGL::OP_DisableClientState;
+
+ switch (array) {
+ case TGL_VERTEX_ARRAY:
+ p[1].i = ~VERTEX_ARRAY;
+ break;
+ case TGL_NORMAL_ARRAY:
+ p[1].i = ~NORMAL_ARRAY;
+ break;
+ case TGL_COLOR_ARRAY:
+ p[1].i = ~COLOR_ARRAY;
+ break;
+ case TGL_TEXTURE_COORD_ARRAY:
+ p[1].i = ~TEXCOORD_ARRAY;
+ break;
+ default:
+ assert(0);
+ break;
+ }
+
+ c->gl_add_op(p);
+}
+
+void tglVertexPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+ TinyGL::GLParam p[5];
+
+ p[0].op = TinyGL::OP_VertexPointer;
+ p[1].i = size;
+ p[2].i = type;
+ p[3].i = stride;
+ p[4].p = const_cast<void *>(pointer);
+
+ c->gl_add_op(p);
+}
+
+void tglColorPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+ TinyGL::GLParam p[5];
+
+ p[0].op = TinyGL::OP_ColorPointer;
+ p[1].i = size;
+ p[2].i = type;
+ p[3].i = stride;
+ p[4].p = const_cast<void *>(pointer);
+
+ c->gl_add_op(p);
+}
+
+void tglNormalPointer(TGLenum type, TGLsizei stride, const TGLvoid *pointer) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+ TinyGL::GLParam p[4];
+
+ p[0].op = TinyGL::OP_NormalPointer;
+ p[1].i = type;
+ p[2].i = stride;
+ p[3].p = const_cast<void *>(pointer);
+
+ c->gl_add_op(p);
+}
+
+void tglTexCoordPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+ TinyGL::GLParam p[5];
+
+ p[0].op = TinyGL::OP_TexCoordPointer;
+ p[1].i = size;
+ p[2].i = type;
+ p[3].i = stride;
+ p[4].p = const_cast<void *>(pointer);
+
+ c->gl_add_op(p);
+}
+
+// gets
+
+void tglGetIntegerv(TGLenum pname, TGLint *data) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+
+ c->gl_GetIntegerv(pname, data);
+}
+
+void tglGetFloatv(TGLenum pname, TGLfloat *data) {
+ TinyGL::GLContext *c = TinyGL::gl_get_context();
+
+ c->gl_GetFloatv(pname, data);
}
diff --git a/graphics/tinygl/arrays.cpp b/graphics/tinygl/arrays.cpp
index 3d92abd223a..ad5fa1983d6 100644
--- a/graphics/tinygl/arrays.cpp
+++ b/graphics/tinygl/arrays.cpp
@@ -27,11 +27,6 @@
#include "graphics/tinygl/zgl.h"
-#define VERTEX_ARRAY 0x0001
-#define COLOR_ARRAY 0x0002
-#define NORMAL_ARRAY 0x0004
-#define TEXCOORD_ARRAY 0x0008
-
namespace TinyGL {
void GLContext::glopArrayElement(GLParam *param) {
@@ -381,125 +376,3 @@ void GLContext::glopTexCoordPointer(GLParam *p) {
}
} // end of namespace TinyGL
-
-void tglArrayElement(TGLint i) {
- TinyGL::GLContext *c = TinyGL::gl_get_context();
- TinyGL::GLParam p[2];
- p[0].op = TinyGL::OP_ArrayElement;
- p[1].i = i;
- c->gl_add_op(p);
-}
-
-void tglDrawArrays(TGLenum mode, TGLint first, TGLsizei count) {
- TinyGL::GLContext *c = TinyGL::gl_get_context();
- TinyGL::GLParam p[4];
- p[0].op = TinyGL::OP_DrawArrays;
- p[1].i = mode;
- p[2].i = first;
- p[3].i = count;
- c->gl_add_op(p);
-}
-
-void tglDrawElements(TGLenum mode, TGLsizei count, TGLenum type, const TGLvoid *indices) {
- TinyGL::GLContext *c = TinyGL::gl_get_context();
- TinyGL::GLParam p[5];
- p[0].op = TinyGL::OP_DrawElements;
- p[1].i = mode;
- p[2].i = count;
- p[3].i = type;
- p[4].p = const_cast<void *>(indices);
- c->gl_add_op(p);
-}
-
-void tglEnableClientState(TGLenum array) {
- TinyGL::GLContext *c = TinyGL::gl_get_context();
- TinyGL::GLParam p[2];
- p[0].op = TinyGL::OP_EnableClientState;
-
- switch (array) {
- case TGL_VERTEX_ARRAY:
- p[1].i = VERTEX_ARRAY;
- break;
- case TGL_NORMAL_ARRAY:
- p[1].i = NORMAL_ARRAY;
- break;
- case TGL_COLOR_ARRAY:
- p[1].i = COLOR_ARRAY;
- break;
- case TGL_TEXTURE_COORD_ARRAY:
- p[1].i = TEXCOORD_ARRAY;
- break;
- default:
- assert(0);
- break;
- }
- c->gl_add_op(p);
-}
-
-void tglDisableClientState(TGLenum array) {
- TinyGL::GLContext *c = TinyGL::gl_get_context();
- TinyGL::GLParam p[2];
- p[0].op = TinyGL::OP_DisableClientState;
-
- switch (array) {
- case TGL_VERTEX_ARRAY:
- p[1].i = ~VERTEX_ARRAY;
- break;
- case TGL_NORMAL_ARRAY:
- p[1].i = ~NORMAL_ARRAY;
- break;
- case TGL_COLOR_ARRAY:
- p[1].i = ~COLOR_ARRAY;
- break;
- case TGL_TEXTURE_COORD_ARRAY:
- p[1].i = ~TEXCOORD_ARRAY;
- break;
- default:
- assert(0);
- break;
- }
- c->gl_add_op(p);
-}
-
-void tglVertexPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer) {
- TinyGL::GLContext *c = TinyGL::gl_get_context();
- TinyGL::GLParam p[5];
- p[0].op = TinyGL::OP_VertexPointer;
- p[1].i = size;
- p[2].i = type;
- p[3].i = stride;
- p[4].p = const_cast<void *>(pointer);
- c->gl_add_op(p);
-}
-
-void tglColorPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer) {
- TinyGL::GLContext *c = TinyGL::gl_get_context();
- TinyGL::GLParam p[5];
- p[0].op = TinyGL::OP_ColorPointer;
- p[1].i = size;
- p[2].i = type;
- p[3].i = stride;
- p[4].p = const_cast<void *>(pointer);
- c->gl_add_op(p);
-}
-
-void tglNormalPointer(TGLenum type, TGLsizei stride, const TGLvoid *pointer) {
- TinyGL::GLContext *c = TinyGL::gl_get_context();
- TinyGL::GLParam p[4];
- p[0].op = TinyGL::OP_NormalPointer;
- p[1].i = type;
- p[2].i = stride;
- p[3].p = const_cast<void *>(pointer);
- c->gl_add_op(p);
-}
-
-void tglTexCoordPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer) {
- TinyGL::GLContext *c = TinyGL::gl_get_context();
- TinyGL::GLParam p[5];
- p[0].op = TinyGL::OP_TexCoordPointer;
- p[1].i = size;
- p[2].i = type;
- p[3].i = stride;
- p[4].p = const_cast<void *>(pointer);
- c->gl_add_op(p);
-}
diff --git a/graphics/tinygl/get.cpp b/graphics/tinygl/get.cpp
index f8360c3b3d1..12318db50e3 100644
--- a/graphics/tinygl/get.cpp
+++ b/graphics/tinygl/get.cpp
@@ -25,20 +25,17 @@
* It also has modifications by the ResidualVM-team, which are covered under the GPLv2 (or later).
*/
-#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf
-#define FORBIDDEN_SYMBOL_EXCEPTION_stderr
-
#include "graphics/tinygl/zgl.h"
-void tglGetIntegerv(TGLenum pname, TGLint *data) {
- TinyGL::GLContext *c = TinyGL::gl_get_context();
+namespace TinyGL {
+void GLContext::gl_GetIntegerv(TGLenum pname, TGLint *data) {
switch (pname) {
case TGL_VIEWPORT:
- data[0] = c->viewport.xmin;
- data[1] = c->viewport.ymin;
- data[2] = c->viewport.xsize;
- data[3] = c->viewport.ysize;
+ data[0] = viewport.xmin;
+ data[1] = viewport.ymin;
+ data[2] = viewport.xsize;
+ data[3] = viewport.ysize;
break;
case TGL_MAX_MODELVIEW_STACK_DEPTH:
*data = MAX_MODELVIEW_STACK_DEPTH;
@@ -50,22 +47,22 @@ void tglGetIntegerv(TGLenum pname, TGLint *data) {
*data = T_MAX_LIGHTS;
break;
case TGL_MAX_TEXTURE_SIZE:
- *data = c->_textureSize;
+ *data = _textureSize;
break;
case TGL_MAX_TEXTURE_STACK_DEPTH:
*data = MAX_TEXTURE_STACK_DEPTH;
break;
case TGL_BLEND:
- *data = c->blending_enabled;
+ *data = blending_enabled;
break;
case TGL_ALPHA_TEST:
- *data = c->alpha_test_enabled;
+ *data = alpha_test_enabled;
break;
case TGL_DEPTH_TEST:
- *data = c->depth_test_enabled;
+ *data = depth_test_enabled;
break;
case TGL_STENCIL_TEST:
- *data = c->stencil_test_enabled;
+ *data = stencil_test_enabled;
break;
default:
error("tglGet: option not implemented");
@@ -73,9 +70,9 @@ void tglGetIntegerv(TGLenum pname, TGLint *data) {
}
}
-void tglGetFloatv(TGLenum pname, TGLfloat *data) {
- int i, mnr = 0; // just a trick to return the correct matrix
- TinyGL::GLContext *c = TinyGL::gl_get_context();
+void GLContext::gl_GetFloatv(TGLenum pname, TGLfloat *data) {
+ int mnr = 0; // just a trick to return the correct matrix
+
switch (pname) {
case TGL_TEXTURE_MATRIX:
mnr++;
@@ -84,16 +81,16 @@ void tglGetFloatv(TGLenum pname, TGLfloat *data) {
mnr++;
// fall through
case TGL_MODELVIEW_MATRIX: {
- float *p = &c->matrix_stack_ptr[mnr]->_m[0][0];
- for (i = 0; i < 4; i++) {
- *data++ = p[0];
- *data++ = p[4];
- *data++ = p[8];
- *data++ = p[12];
- p++;
+ float *p = &matrix_stack_ptr[mnr]->_m[0][0];
+ for (int i = 0; i < 4; i++) {
+ *data++ = p[0];
+ *data++ = p[4];
+ *data++ = p[8];
+ *data++ = p[12];
+ p++;
+ }
}
- }
- break;
+ break;
case TGL_LINE_WIDTH:
*data = 1.0f;
break;
@@ -107,7 +104,9 @@ void tglGetFloatv(TGLenum pname, TGLfloat *data) {
data[0] = data[1] = 1.0f;
break;
default:
- fprintf(stderr, "warning: unknown pname in glGetFloatv()\n");
+ warning("gl_GetFloatv: unknown pname");
break;
}
}
+
+} // end of namespace TinyGL
diff --git a/graphics/tinygl/gl.h b/graphics/tinygl/gl.h
index 5e8c66481ea..4f8a07b2d47 100644
--- a/graphics/tinygl/gl.h
+++ b/graphics/tinygl/gl.h
@@ -821,19 +821,19 @@ void tglTexEnvi(TGLenum target, TGLenum pname, TGLint param);
void tglTexParameteri(TGLenum target, TGLenum pname, TGLint param);
void tglPixelStorei(TGLenum pname, TGLint param);
-// lighting
-
+// material
void tglMaterialfv(TGLenum mode, TGLenum type, const TGLfloat *v);
void tglMaterialf(TGLenum mode, TGLenum type, TGLfloat v);
void tglColorMaterial(TGLenum mode, TGLenum type);
+// lighting
void tglLightfv(TGLenum light, TGLenum type, const TGLfloat *v);
void tglLightf(TGLenum light, TGLenum type, const TGLfloat v);
void tglLightModeli(TGLenum pname, TGLint param);
void tglLightModelfv(TGLenum pname, const TGLfloat *param);
-// misc
+// misc
void tglFlush();
void tglHint(TGLenum target, TGLenum mode);
void tglGetIntegerv(TGLenum pname, TGLint *data);
@@ -859,7 +859,4 @@ void tglTexCoordPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoi
// polygon offset
void tglPolygonOffset(TGLfloat factor, TGLfloat units);
-// custom extensions
-void tglDebug(TGLenum mode);
-
#endif
diff --git a/graphics/tinygl/init.cpp b/graphics/tinygl/init.cpp
index 6b6e6c6e87d..a66abe60c59 100644
--- a/graphics/tinygl/init.cpp
+++ b/graphics/tinygl/init.cpp
@@ -145,7 +145,21 @@ void GLContext::init(int screenW, int screenH, Graphics::PixelFormat pixelFormat
color_material_enabled = 0;
// textures
- glInitTextures();
+ texture_2d_enabled = false;
+ current_texture = alloc_texture(0);
+ maxTextureName = 0;
+ texture_mag_filter = TGL_LINEAR;
+ texture_min_filter = TGL_NEAREST_MIPMAP_LINEAR;
+#if defined(SCUMM_LITTLE_ENDIAN)
+ colorAssociationList.push_back({Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), TGL_RGBA, TGL_UNSIGNED_BYTE});
+ colorAssociationList.push_back({Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0), TGL_RGB, TGL_UNSIGNED_BYTE});
+#else
+ colorAssociationList.push_back({Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), TGL_RGBA, TGL_UNSIGNED_BYTE});
+ colorAssociationList.push_back({Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0), TGL_RGB, TGL_UNSIGNED_BYTE});
+#endif
+ colorAssociationList.push_back({Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), TGL_RGB, TGL_UNSIGNED_SHORT_5_6_5});
+ colorAssociationList.push_back({Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0), TGL_RGBA, TGL_UNSIGNED_SHORT_5_5_5_1});
+ colorAssociationList.push_back({Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0), TGL_RGBA, TGL_UNSIGNED_SHORT_4_4_4_4});
// default state
current_color = Vector4(1.0f, 1.0f, 1.0f, 1.0f);
@@ -249,6 +263,10 @@ void GLContext::init(int screenW, int screenH, Graphics::PixelFormat pixelFormat
TinyGL::Internal::tglBlitResetScissorRect();
}
+GLContext *gl_get_context() {
+ return gl_ctx;
+}
+
void destroyContext() {
GLContext *c = gl_get_context();
assert(c);
diff --git a/graphics/tinygl/light.cpp b/graphics/tinygl/light.cpp
index 6c8001a385d..65b5d5797f3 100644
--- a/graphics/tinygl/light.cpp
+++ b/graphics/tinygl/light.cpp
@@ -166,15 +166,6 @@ void GLContext::glopLightModel(GLParam *p) {
}
}
-static inline float clampf(float a, float min, float max) {
- if (a < min)
- return min;
- else if (a > max)
- return max;
- else
- return a;
-}
-
void GLContext::gl_enable_disable_light(int light, int v) {
GLLight *l = &lights[light];
if (v && !l->enabled) {
diff --git a/graphics/tinygl/list.cpp b/graphics/tinygl/list.cpp
index 86b8270fd80..16adabcc0fb 100644
--- a/graphics/tinygl/list.cpp
+++ b/graphics/tinygl/list.cpp
@@ -52,19 +52,15 @@ static int op_table_size[] = {
#include "graphics/tinygl/opinfo.h"
};
-GLContext *gl_get_context() {
- return gl_ctx;
+GLList *GLContext::find_list(uint list) {
+ return shared_state.lists[list];
}
-static GLList *find_list(GLContext *c, uint list) {
- return c->shared_state.lists[list];
-}
-
-static void delete_list(GLContext *c, int list) {
+void GLContext::delete_list(int list) {
GLParamBuffer *pb, *pb1;
GLList *l;
- l = find_list(c, list);
+ l = find_list(list);
assert(l);
// free param buffer
@@ -76,10 +72,10 @@ static void delete_list(GLContext *c, int list) {
}
gl_free(l);
- c->shared_state.lists[list] = NULL;
+ shared_state.lists[list] = nullptr;
}
-static GLList *alloc_list(GLContext *c, int list) {
+GLList *GLContext::alloc_list(int list) {
GLList *l;
GLParamBuffer *ob;
@@ -91,7 +87,7 @@ static GLList *alloc_list(GLContext *c, int list) {
ob->ops[0].op = OP_EndList;
- c->shared_state.lists[list] = l;
+ shared_state.lists[list] = l;
return l;
}
@@ -186,7 +182,7 @@ void GLContext::glopCallList(GLParam *p) {
int list, op;
list = p[1].ui;
- l = find_list(this, list);
+ l = find_list(list);
if (!l)
error("list %d not defined", list);
p = l->first_op_buffer->ops;
@@ -204,60 +200,52 @@ void GLContext::glopCallList(GLParam *p) {
}
}
-void tglNewList(TGLuint list, TGLenum mode) {
- GLList *l;
- GLContext *c = gl_get_context();
-
+void GLContext::gl_NewList(TGLuint list, TGLenum mode) {
assert(mode == TGL_COMPILE || mode == TGL_COMPILE_AND_EXECUTE);
- assert(c->compile_flag == 0);
+ assert(compile_flag == 0);
- l = find_list(c, list);
+ GLList *l = find_list(list);
if (l)
- delete_list(c, list);
- l = alloc_list(c, list);
+ delete_list(list);
+ l = alloc_list(list);
- c->current_op_buffer = l->first_op_buffer;
- c->current_op_buffer_index = 0;
+ current_op_buffer = l->first_op_buffer;
+ current_op_buffer_index = 0;
- c->compile_flag = 1;
- c->exec_flag = (mode == TGL_COMPILE_AND_EXECUTE);
+ compile_flag = 1;
+ exec_flag = (mode == TGL_COMPILE_AND_EXECUTE);
}
-void tglEndList() {
- GLContext *c = gl_get_context();
+void GLContext::gl_EndList() {
GLParam p[1];
- assert(c->compile_flag == 1);
+ assert(compile_flag == 1);
// end of list
p[0].op = OP_EndList;
- c->gl_compile_op(p);
+ gl_compile_op(p);
- c->compile_flag = 0;
- c->exec_flag = 1;
+ compile_flag = 0;
+ exec_flag = 1;
}
-TGLboolean tglIsList(TGLuint list) {
- GLContext *c = gl_get_context();
- GLList *l = find_list(c, list);
+TGLboolean GLContext::gl_IsList(TGLuint list) {
+ GLList *l = find_list(list);
return (l != nullptr);
}
-TGLuint tglGenLists(TGLsizei range) {
- GLContext *c = gl_get_context();
- int count, list;
- GLList **lists;
+TGLuint GLContext::gl_GenLists(TGLsizei range) {
+ GLList **lists = shared_state.lists;
+ int count = 0;
- lists = c->shared_state.lists;
- count = 0;
for (int i = 0; i < MAX_DISPLAY_LISTS; i++) {
if (!lists[i]) {
count++;
if (count == range) {
- list = i - range + 1;
+ uint list = i - range + 1;
for (int j = 0; j < range; j++) {
- alloc_list(c, list + j);
+ alloc_list(list + j);
}
return list;
}
diff --git a/graphics/tinygl/matrix.cpp b/graphics/tinygl/matrix.cpp
index 578480f8d87..a9904224621 100644
--- a/graphics/tinygl/matrix.cpp
+++ b/graphics/tinygl/matrix.cpp
@@ -32,7 +32,7 @@
namespace TinyGL {
-void gl_print_matrix(const float *m) {
+void GLContext::gl_print_matrix(const float *m) {
for (int i = 0; i < 4; i++) {
fprintf(stderr, "%f %f %f %f\n", m[i], m[4 + i], m[8 + i], m[12 + i]);
}
@@ -100,7 +100,6 @@ void GLContext::glopMultMatrix(GLParam *p) {
gl_matrix_update(this);
}
-
void GLContext::glopPushMatrix(GLParam *) {
int n = matrix_mode;
Matrix4 *m;
diff --git a/graphics/tinygl/texture.cpp b/graphics/tinygl/texture.cpp
index 9187eb390f9..c511f7c7d02 100644
--- a/graphics/tinygl/texture.cpp
+++ b/graphics/tinygl/texture.cpp
@@ -33,10 +33,10 @@
namespace TinyGL {
-static GLTexture *find_texture(GLContext *c, uint h) {
+GLTexture *GLContext::find_texture(uint h) {
GLTexture *t;
- t = c->shared_state.texture_hash_table[h % TEXTURE_HASH_TABLE_SIZE];
+ t = shared_state.texture_hash_table[h % TEXTURE_HASH_TABLE_SIZE];
while (t) {
if (t->handle == h)
return t;
@@ -46,7 +46,7 @@ static GLTexture *find_texture(GLContext *c, uint h) {
}
void GLContext::free_texture(uint h) {
- free_texture(find_texture(this, h));
+ free_texture(find_texture(h));
}
void GLContext::free_texture(GLTexture *t) {
@@ -93,24 +93,6 @@ GLTexture *GLContext::alloc_texture(uint h) {
return t;
}
-void GLContext::glInitTextures() {
- texture_2d_enabled = 0;
- current_texture = find_texture(this, 0);
- maxTextureName = 0;
- texture_mag_filter = TGL_LINEAR;
- texture_min_filter = TGL_NEAREST_MIPMAP_LINEAR;
-#if defined(SCUMM_LITTLE_ENDIAN)
- colorAssociationList.push_back({Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), TGL_RGBA, TGL_UNSIGNED_BYTE});
- colorAssociationList.push_back({Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0), TGL_RGB, TGL_UNSIGNED_BYTE});
-#else
- colorAssociationList.push_back({Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), TGL_RGBA, TGL_UNSIGNED_BYTE});
- colorAssociationList.push_back({Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0), TGL_RGB, TGL_UNSIGNED_BYTE});
-#endif
- colorAssociationList.push_back({Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), TGL_RGB, TGL_UNSIGNED_SHORT_5_6_5});
- colorAssociationList.push_back({Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0), TGL_RGBA, TGL_UNSIGNED_SHORT_5_5_5_1});
- colorAssociationList.push_back({Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0), TGL_RGBA, TGL_UNSIGNED_SHORT_4_4_4_4});
-}
-
void GLContext::glopBindTexture(GLParam *p) {
int target = p[1].i;
int texture = p[2].i;
@@ -118,7 +100,7 @@ void GLContext::glopBindTexture(GLParam *p) {
assert(target == TGL_TEXTURE_2D && texture >= 0);
- t = find_texture(this, texture);
+ t = find_texture(texture);
if (!t) {
t = alloc_texture(texture);
}
@@ -286,28 +268,24 @@ void GLContext::glopPixelStore(GLParam *p) {
}
}
-} // end of namespace TinyGL
-
-void tglGenTextures(TGLsizei n, TGLuint *textures) {
- TinyGL::GLContext *c = TinyGL::gl_get_context();
-
+void GLContext::gl_GenTextures(TGLsizei n, TGLuint *textures) {
for (int i = 0; i < n; i++) {
- textures[i] = c->maxTextureName + i + 1;
+ textures[i] = maxTextureName + i + 1;
}
- c->maxTextureName += n;
+ maxTextureName += n;
}
-void tglDeleteTextures(TGLsizei n, const TGLuint *textures) {
- TinyGL::GLContext *c = TinyGL::gl_get_context();
- TinyGL::GLTexture *t;
-
+void GLContext::gl_DeleteTextures(TGLsizei n, const TGLuint *textures) {
for (int i = 0; i < n; i++) {
- t = TinyGL::find_texture(c, textures[i]);
+ TinyGL::GLTexture *t = find_texture(textures[i]);
if (t) {
- if (t == c->current_texture) {
- tglBindTexture(TGL_TEXTURE_2D, 0);
+ if (t == current_texture) {
+ current_texture = find_texture(0);
}
t->disposed = true;
}
}
}
+
+} // end of namespace TinyGL
+
diff --git a/graphics/tinygl/zdirtyrect.h b/graphics/tinygl/zdirtyrect.h
index 7b00ed1fb69..5f09466f4bc 100644
--- a/graphics/tinygl/zdirtyrect.h
+++ b/graphics/tinygl/zdirtyrect.h
@@ -138,7 +138,7 @@ private:
int stencilSfail;
int stencilDpfail;
int stencilDppass;
- TinyGL::GLTexture *texture;
+ GLTexture *texture;
uint wrapS, wrapT;
bool operator==(const RasterizationState &other) const;
diff --git a/graphics/tinygl/zgl.h b/graphics/tinygl/zgl.h
index 3dbedb6e546..31239179290 100644
--- a/graphics/tinygl/zgl.h
+++ b/graphics/tinygl/zgl.h
@@ -460,14 +460,18 @@ public:
void gl_enable_disable_light(int light, int v);
void gl_shade_vertex(GLVertex *v);
- void glInitTextures();
- void glEndTextures();
+ void gl_GetIntegerv(TGLenum pname, TGLint *data);
+ void gl_GetFloatv(TGLenum pname, TGLfloat *data);
+
GLTexture *alloc_texture(uint h);
+ GLTexture *find_texture(uint h);
void free_texture(uint h);
void free_texture(GLTexture *t);
+ void gl_GenTextures(TGLsizei n, TGLuint *textures);
+ void gl_DeleteTextures(TGLsizei n, const TGLuint *textures);
void gl_resizeImage(Graphics::PixelBuffer &dest, int xsize_dest, int ysize_dest,
- const Graphics::PixelBuffer &src, int xsize_src, int ysize_src);
+ const Graphics::PixelBuffer &src, int xsize_src, int ysize_src);
void gl_resizeImageNoInterpolate(Graphics::PixelBuffer &dest, int xsize_dest, int ysize_dest, const Graphics::PixelBuffer &src, int xsize_src, int ysize_src);
void issueDrawCall(DrawCall *drawCall);
@@ -480,24 +484,33 @@ public:
GLSpecBuf *specbuf_get_buffer(const int shininess_i, const float shininess);
void specbuf_cleanup();
+ GLList *alloc_list(int list);
+ GLList *find_list(uint list);
+ void delete_list(int list);
+ void gl_NewList(TGLuint list, TGLenum mode);
+ void gl_EndList();
+ TGLboolean gl_IsList(TGLuint list);
+ TGLuint gl_GenLists(TGLsizei range);
+
void initSharedState();
void endSharedState();
void init(int screenW, int screenH, Graphics::PixelFormat pixelFormat, int textureSize, bool enableStencilBuffer, bool dirtyRectsEnable = true);
void deinit();
+
+ void gl_print_matrix(const float *m);
+ void gl_debug(int mode) {
+ print_flag = mode;
+ }
};
extern GLContext *gl_ctx;
GLContext *gl_get_context();
-// matrix.c
-void gl_print_matrix(const float *m);
-
-#ifdef DEBUG
-#define dprintf fprintf
-#else
-#define dprintf
-#endif
+#define VERTEX_ARRAY 0x0001
+#define COLOR_ARRAY 0x0002
+#define NORMAL_ARRAY 0x0004
+#define TEXCOORD_ARRAY 0x0008
// this clip epsilon is needed to avoid some rounding errors after
// several clipping stages
@@ -511,6 +524,15 @@ static inline int gl_clipcode(float x, float y, float z, float w1) {
return (x < -w) | ((x > w) << 1) | ((y < -w) << 2) | ((y > w) << 3) | ((z < -w) << 4) | ((z > w) << 5);
}
+static inline float clampf(float a, float min, float max) {
+ if (a < min)
+ return min;
+ if (a > max)
+ return max;
+ else
+ return a;
+}
+
} // end of namespace TinyGL
#endif
Commit: fef0e04cb7b4c83aa0fe9d9af673bddc245a7300
https://github.com/scummvm/scummvm/commit/fef0e04cb7b4c83aa0fe9d9af673bddc245a7300
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2022-01-01T14:06:45+01:00
Commit Message:
TINYGL: No need to check for current_texture
Changed paths:
graphics/tinygl/clip.cpp
graphics/tinygl/texture.cpp
diff --git a/graphics/tinygl/clip.cpp b/graphics/tinygl/clip.cpp
index 568dbc4d0d6..8b2ca288016 100644
--- a/graphics/tinygl/clip.cpp
+++ b/graphics/tinygl/clip.cpp
@@ -396,7 +396,7 @@ void GLContext::gl_draw_triangle_fill(GLContext *c, GLVertex *p0, GLVertex *p1,
if (!c->color_mask_red && !c->color_mask_green && !c->color_mask_blue && !c->color_mask_alpha) {
c->fb->fillTriangleDepthOnly(&p0->zp, &p1->zp, &p2->zp);
- } else if (c->texture_2d_enabled && c->current_texture && c->current_texture->images[0].pixmap) {
+ } else if (c->texture_2d_enabled && c->current_texture->images[0].pixmap) {
#ifdef TINYGL_PROFILE
count_triangles_textured++;
#endif
diff --git a/graphics/tinygl/texture.cpp b/graphics/tinygl/texture.cpp
index c511f7c7d02..8c0ae5c1cd7 100644
--- a/graphics/tinygl/texture.cpp
+++ b/graphics/tinygl/texture.cpp
@@ -53,6 +53,8 @@ void GLContext::free_texture(GLTexture *t) {
GLTexture **ht;
GLImage *im;
+ assert(t);
+
if (!t->prev) {
ht = &shared_state.texture_hash_table[t->handle % TEXTURE_HASH_TABLE_SIZE];
*ht = t->next;
@@ -128,9 +130,8 @@ void GLContext::glopTexImage2D(GLParam *p) {
if (border != 0)
error("tglTexImage2D: invalid border");
- if (current_texture == nullptr) {
- return;
- }
+ assert (current_texture);
+
current_texture->versionNumber++;
im = ¤t_texture->images[level];
im->xsize = _textureSize;
Commit: 69198d5d3004524a296c68dc6867087c695c36a1
https://github.com/scummvm/scummvm/commit/69198d5d3004524a296c68dc6867087c695c36a1
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2022-01-01T14:07:07+01:00
Commit Message:
TINYGL: Corrected variable type
Changed paths:
graphics/tinygl/zgl.h
diff --git a/graphics/tinygl/zgl.h b/graphics/tinygl/zgl.h
index 31239179290..9c3e7079cb8 100644
--- a/graphics/tinygl/zgl.h
+++ b/graphics/tinygl/zgl.h
@@ -295,7 +295,7 @@ struct GLContext {
// textures
GLTexture *current_texture;
uint maxTextureName;
- int texture_2d_enabled;
+ bool texture_2d_enabled;
int texture_mag_filter;
int texture_min_filter;
uint texture_wrap_s;
More information about the Scummvm-git-logs
mailing list