[Scummvm-git-logs] scummvm master -> d5c1d5219869144237c0bbd41344315b29425618

aquadran aquadran at gmail.com
Wed Oct 20 20:20:34 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d5c1d52198 TINYGL: Added tglDrawElements


Commit: d5c1d5219869144237c0bbd41344315b29425618
    https://github.com/scummvm/scummvm/commit/d5c1d5219869144237c0bbd41344315b29425618
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2021-10-20T22:20:28+02:00

Commit Message:
TINYGL: Added tglDrawElements

Changed paths:
    graphics/tinygl/Changelog
    graphics/tinygl/LICENSE
    graphics/tinygl/arrays.cpp
    graphics/tinygl/gl.h
    graphics/tinygl/opinfo.h
    graphics/tinygl/zblit.cpp
    graphics/tinygl/zblit.h


diff --git a/graphics/tinygl/Changelog b/graphics/tinygl/Changelog
index 02513ee5cb..c39c8fe895 100644
--- a/graphics/tinygl/Changelog
+++ b/graphics/tinygl/Changelog
@@ -1,8 +1,8 @@
-This is a modified version of TinyGL 0.4 intended for use with ResidualVM.
+This is a modified version of TinyGL 0.4 intended for use with ScummVM.
 The changes made from the original version of TinyGL 0.4 are:
 
 * Changed file extensions from *.c to *.cpp to compile as C++.
-* Included only files needed by ResidualVM.
+* Included only files needed by ScummVM.
 * Changed include paths in source files.
 * Added needed type casts and fixes for proper compile.
 * Added 't/T' prefix to prevent OpenGL name clashes.
@@ -31,5 +31,6 @@ The changes made from the original version of TinyGL 0.4 are:
 * Added an API that enables the user to perform color and z buffer blitting.
 * Implemented a system that enables to defer draw calls.
 * Implemented dirty rectangle system that prevents redrawing of unchanged region of the screen.
+* Added implementation of tglDrawElements
 
-For more information refer to log changes in github: https://github.com/residualvm/residualvm
+For more information refer to log changes in github: https://github.com/scummvm/scummvm
diff --git a/graphics/tinygl/LICENSE b/graphics/tinygl/LICENSE
index 91b5f1a608..fa113118b1 100644
--- a/graphics/tinygl/LICENSE
+++ b/graphics/tinygl/LICENSE
@@ -1,5 +1,5 @@
 NOTE: This implementation of TinyGL contains additional code and
-modifications added only for ResidualVM project.
+modifications added only for ScummVM project.
 Look into the source code file "Changelog" for more info.
 
 Copyright notice:
diff --git a/graphics/tinygl/arrays.cpp b/graphics/tinygl/arrays.cpp
index b9c513175a..2b82ef5756 100644
--- a/graphics/tinygl/arrays.cpp
+++ b/graphics/tinygl/arrays.cpp
@@ -80,15 +80,45 @@ void glopArrayElement(GLContext *c, GLParam *param) {
 void glopDrawArrays(GLContext *c, GLParam *p) {
 	GLParam array_element[2];
 	GLParam begin[2];
+
 	begin[1].i = p[1].i;
 	glopBegin(c, begin);
-	for (int i=0; i < p[3].i; i++) {
+	for (int i = 0; i < p[3].i; i++) {
 		array_element[1].i = p[2].i + i;
 		glopArrayElement(c, array_element);
 	}
 	glopEnd(c, NULL);
 }
 
+void glopDrawElements(GLContext *c, GLParam *p) {
+	GLParam array_element[2];
+	char *indices;
+	GLParam begin[2];
+
+	indices = (char *)p[4].p;
+	begin[1].i = p[1].i;
+
+	glopBegin(c, begin);
+	for (int i = 0; i < p[2].i; i++) {
+		switch (p[3].i) {
+		case TGL_UNSIGNED_BYTE:
+			array_element[1].i = *(TGLbyte *)(indices + i * sizeof(TGLbyte));
+			break;
+		case TGL_UNSIGNED_SHORT:
+			array_element[1].i = *(TGLshort *)(indices + i * sizeof(TGLshort));
+			break;
+		case TGL_UNSIGNED_INT:
+			array_element[1].i = *(TGLint *)(indices + i * sizeof(TGLint));
+			break;
+		default:
+			assert(0);
+			break;
+		}
+		glopArrayElement(c, array_element);
+	}
+	glopEnd(c, NULL);
+}
+
 void glopEnableClientState(GLContext *c, GLParam *p) {
 	c->client_states |= p[1].i;
 }
@@ -138,6 +168,16 @@ void tglDrawArrays(TGLenum mode, TGLint first, TGLsizei count) {
 	gl_add_op(p);
 }
 
+void tglDrawElements(TGLenum mode, TGLsizei count, TGLenum type, const TGLvoid *indices) {
+	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);
+	gl_add_op(p);
+}
+
 void tglEnableClientState(TGLenum array) {
 	TinyGL::GLParam p[2];
 	p[0].op = TinyGL::OP_EnableClientState;
diff --git a/graphics/tinygl/gl.h b/graphics/tinygl/gl.h
index 1a4a410d28..8cba057c1a 100644
--- a/graphics/tinygl/gl.h
+++ b/graphics/tinygl/gl.h
@@ -833,24 +833,24 @@ void tglBlendFunc(TGLenum sfactor, TGLenum dfactor);
 void tglAlphaFunc(TGLenum func, float ref);
 void tglDepthFunc(TGLenum func);
 
-void tglSetShadowMaskBuf(unsigned char *buf);
-void tglSetShadowColor(unsigned char r, unsigned char g, unsigned char b);
-
-// opengl 1.2 arrays
+// arrays
 void tglEnableClientState(TGLenum array);
 void tglDisableClientState(TGLenum array);
 void tglArrayElement(TGLint i);
 void tglDrawArrays(TGLenum mode, TGLint first, TGLsizei count);
+void tglDrawElements(TGLenum mode, TGLsizei count, TGLenum type, const TGLvoid *indices);
 void tglVertexPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer);
 void tglColorPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer);
 void tglNormalPointer(TGLenum type, TGLsizei stride, const TGLvoid *pointer);
 void tglTexCoordPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer);
 
-// opengl 1.2 polygon offset
+// polygon offset
 void tglPolygonOffset(TGLfloat factor, TGLfloat units);
 
+// custom extension
+void tglSetShadowMaskBuf(unsigned char *buf);
+void tglSetShadowColor(unsigned char r, unsigned char g, unsigned char b);
 void tglEnableDirtyRects(bool enable);
-
 void tglDebug(int mode);
 
 namespace TinyGL {
diff --git a/graphics/tinygl/opinfo.h b/graphics/tinygl/opinfo.h
index 548aff4959..137b5e6732 100644
--- a/graphics/tinygl/opinfo.h
+++ b/graphics/tinygl/opinfo.h
@@ -92,6 +92,7 @@ ADD_OP(NextBuffer, 1, "%p")
 // opengl 1.1 arrays
 ADD_OP(ArrayElement, 1, "%d")
 ADD_OP(DrawArrays, 3, "%C %d %d")
+ADD_OP(DrawElements, 4, "%C %d %C %p")
 ADD_OP(EnableClientState, 1, "%C")
 ADD_OP(DisableClientState, 1, "%C")
 ADD_OP(VertexPointer, 4, "%d %C %d %p")
diff --git a/graphics/tinygl/zblit.cpp b/graphics/tinygl/zblit.cpp
index f7b3bafdd1..4d649540fc 100644
--- a/graphics/tinygl/zblit.cpp
+++ b/graphics/tinygl/zblit.cpp
@@ -761,7 +761,7 @@ Common::Rect rotateRectangle(int x, int y, int width, int height, int rotation,
 	Common::Point nw, ne, sw, se;
 	nw = transformPoint(x - originX, y - originY, rotation);
 	ne = transformPoint(x + width - originX, y - originY, rotation);
-	sw = transformPoint(x + width - originX, y + height -	 originY, rotation);
+	sw = transformPoint(x + width - originX, y + height - originY, rotation);
 	se = transformPoint(x - originX, y + height - originY, rotation);
 
 	float top = MIN(nw.y, MIN(ne.y, MIN(sw.y, se.y)));
diff --git a/graphics/tinygl/zblit.h b/graphics/tinygl/zblit.h
index ff358a2234..aebc7d1459 100644
--- a/graphics/tinygl/zblit.h
+++ b/graphics/tinygl/zblit.h
@@ -38,7 +38,7 @@ struct BlitTransform {
 	BlitTransform(int dstX, int dstY) : _rotation(0), _originX(0), _originY(0), _aTint(1.0f),
 				_rTint(1.0f), _gTint(1.0f), _bTint(1.0), _flipHorizontally(false),
 				_flipVertically(false) {
-		_destinationRectangle.translate(dstX,dstY);
+		_destinationRectangle.translate(dstX, dstY);
 	}
 
 	void sourceRectangle(int srcX, int srcY, int srcWidth, int srcHeight) {




More information about the Scummvm-git-logs mailing list