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

neuromancer noreply at scummvm.org
Mon Nov 7 17:58:47 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:
8aff2e5692 FREESCAPE: fixed small code format issue
1995762543 FREESCAPE: use glDrawArray for crossair and shoot rendering
e027de7252 FREESCAPE: use glDrawArray for texture rendering rendering


Commit: 8aff2e5692c5f79e4523e387422f6e854f38cbcf
    https://github.com/scummvm/scummvm/commit/8aff2e5692c5f79e4523e387422f6e854f38cbcf
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-07T18:59:44+01:00

Commit Message:
FREESCAPE: fixed small code format issue

Changed paths:
    engines/freescape/loaders/8bitBinaryLoader.cpp


diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index 7f4b99bdc76..877d195c7f9 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -503,7 +503,7 @@ void FreescapeEngine::load8bitBinary(Common::SeekableReadStream *file, int offse
 		}
 	}
 
-	delete [] fileOffsetForArea;
+	delete[] fileOffsetForArea;
 
 	if (!_areaMap.contains(startArea))
 		_startArea = newArea->getAreaID();


Commit: 1995762543f816fdb68562804245c95104a01f1f
    https://github.com/scummvm/scummvm/commit/1995762543f816fdb68562804245c95104a01f1f
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-07T18:59:44+01:00

Commit Message:
FREESCAPE: use glDrawArray for crossair and shoot rendering

Changed paths:
    engines/freescape/gfx_opengl.cpp
    engines/freescape/gfx_tinygl.cpp


diff --git a/engines/freescape/gfx_opengl.cpp b/engines/freescape/gfx_opengl.cpp
index 23f54e6200d..97c12a8fa67 100644
--- a/engines/freescape/gfx_opengl.cpp
+++ b/engines/freescape/gfx_opengl.cpp
@@ -182,13 +182,14 @@ void OpenGLRenderer::renderCrossair(byte color, const Common::Point position) {
 
 	glLineWidth(15); // It will not work in every OpenGL implementation since the
 					 // spec doesn't require support for line widths other than 1
-	glBegin(GL_LINES);
-	glVertex2f(position.x - 1, position.y);
-	glVertex2f(position.x + 3, position.y);
-
-	glVertex2f(position.x, position.y - 3);
-	glVertex2f(position.x, position.y + 3);
-	glEnd();
+	glEnableClientState(GL_VERTEX_ARRAY);
+	copyToVertexArray(0, Math::Vector3d(position.x - 1, position.y, 0));
+	copyToVertexArray(1, Math::Vector3d(position.x + 3, position.y, 0));
+	copyToVertexArray(2, Math::Vector3d(position.x, position.y - 3, 0));
+	copyToVertexArray(3, Math::Vector3d(position.x, position.y + 3, 0));
+	glVertexPointer(3, GL_FLOAT, 0, _verts);
+	glDrawArrays(GL_LINES, 0, 4);
+	glDisableClientState(GL_VERTEX_ARRAY);
 	glLineWidth(1);
 
 	glDepthMask(GL_TRUE);
@@ -215,20 +216,20 @@ void OpenGLRenderer::renderShoot(byte color, const Common::Point position) {
 
 	glLineWidth(10); // It will not work in every OpenGL implementation since the
 					 // spec doesn't require support for line widths other than 1
-	glBegin(GL_LINES);
-	glVertex2f(0, _screenH - 2);
-	glVertex2f(position.x, position.y);
-
-	glVertex2f(0, _screenH - 2);
-	glVertex2f(position.x, position.y);
-
-	glVertex2f(_screenW, _screenH - 2);
-	glVertex2f(position.x, position.y);
+	glEnableClientState(GL_VERTEX_ARRAY);
+	copyToVertexArray(0, Math::Vector3d(0, _screenH - 2, 0));
+	copyToVertexArray(1, Math::Vector3d(position.x, position.y, 0));
+	copyToVertexArray(2, Math::Vector3d(0, _screenH - 2, 0));
+	copyToVertexArray(3, Math::Vector3d(position.x, position.y, 0));
 
-	glVertex2f(_screenW, _screenH);
-	glVertex2f(position.x, position.y);
+	copyToVertexArray(4, Math::Vector3d(_screenW, _screenH - 2, 0));
+	copyToVertexArray(5, Math::Vector3d(position.x, position.y, 0));
+	copyToVertexArray(6, Math::Vector3d(_screenW, _screenH, 0));
+	copyToVertexArray(7, Math::Vector3d(position.x, position.y, 0));
 
-	glEnd();
+	glVertexPointer(3, GL_FLOAT, 0, _verts);
+	glDrawArrays(GL_LINES, 0, 8);
+	glDisableClientState(GL_VERTEX_ARRAY);
 	glLineWidth(1);
 
 	glEnable(GL_DEPTH_TEST);
diff --git a/engines/freescape/gfx_tinygl.cpp b/engines/freescape/gfx_tinygl.cpp
index 4185081b03f..a4b3949058e 100644
--- a/engines/freescape/gfx_tinygl.cpp
+++ b/engines/freescape/gfx_tinygl.cpp
@@ -137,13 +137,14 @@ void TinyGLRenderer::renderCrossair(byte color, const Common::Point position) {
 
 	tglColor3ub(r, g, b);
 
-	tglBegin(TGL_LINES);
-	tglVertex2f(position.x - 1, position.y);
-	tglVertex2f(position.x + 3, position.y);
-
-	tglVertex2f(position.x, position.y - 3);
-	tglVertex2f(position.x, position.y + 3);
-	tglEnd();
+	tglEnableClientState(TGL_VERTEX_ARRAY);
+	copyToVertexArray(0, Math::Vector3d(position.x - 1, position.y, 0));
+	copyToVertexArray(1, Math::Vector3d(position.x + 3, position.y, 0));
+	copyToVertexArray(2, Math::Vector3d(position.x, position.y - 3, 0));
+	copyToVertexArray(3, Math::Vector3d(position.x, position.y + 3, 0));
+	tglVertexPointer(3, TGL_FLOAT, 0, _verts);
+	tglDrawArrays(TGL_LINES, 0, 4);
+	tglDisableClientState(TGL_VERTEX_ARRAY);
 
 	tglDepthMask(TGL_TRUE);
 	tglEnable(TGL_DEPTH_TEST);
@@ -167,20 +168,20 @@ void TinyGLRenderer::renderShoot(byte color, const Common::Point position) {
 	int viewPort[4];
 	tglGetIntegerv(TGL_VIEWPORT, viewPort);
 
-	tglBegin(TGL_LINES);
-	tglVertex2f(0, _screenH - 2);
-	tglVertex2f(position.x, position.y);
-
-	tglVertex2f(0, _screenH - 2);
-	tglVertex2f(position.x, position.y);
-
-	tglVertex2f(_screenW, _screenH - 2);
-	tglVertex2f(position.x, position.y);
+	tglEnableClientState(TGL_VERTEX_ARRAY);
+	copyToVertexArray(0, Math::Vector3d(0, _screenH - 2, 0));
+	copyToVertexArray(1, Math::Vector3d(position.x, position.y, 0));
+	copyToVertexArray(2, Math::Vector3d(0, _screenH - 2, 0));
+	copyToVertexArray(3, Math::Vector3d(position.x, position.y, 0));
 
-	tglVertex2f(_screenW, _screenH);
-	tglVertex2f(position.x, position.y);
+	copyToVertexArray(4, Math::Vector3d(_screenW, _screenH - 2, 0));
+	copyToVertexArray(5, Math::Vector3d(position.x, position.y, 0));
+	copyToVertexArray(6, Math::Vector3d(_screenW, _screenH, 0));
+	copyToVertexArray(7, Math::Vector3d(position.x, position.y, 0));
 
-	tglEnd();
+	tglVertexPointer(3, TGL_FLOAT, 0, _verts);
+	tglDrawArrays(TGL_LINES, 0, 8);
+	tglDisableClientState(TGL_VERTEX_ARRAY);
 
 	tglEnable(TGL_DEPTH_TEST);
 	tglDepthMask(TGL_TRUE);


Commit: e027de7252b5ebce63130bbcf65f27ac05d3f5b0
    https://github.com/scummvm/scummvm/commit/e027de7252b5ebce63130bbcf65f27ac05d3f5b0
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-07T18:59:44+01:00

Commit Message:
FREESCAPE: use glDrawArray for texture rendering rendering

Changed paths:
    engines/freescape/gfx.h
    engines/freescape/gfx_opengl.cpp
    engines/freescape/gfx_opengl.h


diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index a31dfb4d324..440869b8345 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -33,6 +33,7 @@
 namespace Freescape {
 
 #define kVertexArraySize 20
+#define kCoordsArraySize 4
 
 typedef Common::Array<byte *> ColorMap;
 
diff --git a/engines/freescape/gfx_opengl.cpp b/engines/freescape/gfx_opengl.cpp
index 97c12a8fa67..7ac2564a555 100644
--- a/engines/freescape/gfx_opengl.cpp
+++ b/engines/freescape/gfx_opengl.cpp
@@ -39,6 +39,7 @@ Renderer *CreateGfxOpenGL(int screenW, int screenH, Common::RenderMode renderMod
 
 OpenGLRenderer::OpenGLRenderer(int screenW, int screenH, Common::RenderMode renderMode) : Renderer(screenW, screenH, renderMode) {
 	_verts = (Vertex *)malloc(sizeof(Vertex) * kVertexArraySize);
+	_coords = (Coord *)malloc(sizeof(Coord) * kCoordsArraySize);
 	_texturePixelFormat = OpenGLTexture::getRGBAPixelFormat();
 }
 
@@ -121,20 +122,26 @@ void OpenGLRenderer::drawTexturedRect2D(const Common::Rect &screenRect, const Co
 	glColor4f(1.0, 1.0, 1.0, 1.0);
 	glDepthMask(GL_FALSE);
 
-	glBindTexture(GL_TEXTURE_2D, glTexture->_id);
-	glBegin(GL_TRIANGLE_STRIP);
-	glTexCoord2f(tLeft, tTop + tHeight);
-	glVertex3f(sLeft + 0, sBottom, 1.0f);
+	glEnableClientState(GL_VERTEX_ARRAY);
+	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+
+	copyToVertexArray(0, Math::Vector3d(sLeft + 0, sBottom, 1.0f));
+	copyToVertexArray(1, Math::Vector3d(sRight, sBottom, 1.0f));
+	copyToVertexArray(2, Math::Vector3d(sLeft + 0, sTop + 0, 1.0f));
+	copyToVertexArray(3, Math::Vector3d(sRight, sTop + 0, 1.0));
+	glVertexPointer(3, GL_FLOAT, 0, _verts);
 
-	glTexCoord2f(tLeft + tWidth, tTop + tHeight);
-	glVertex3f(sRight, sBottom, 1.0f);
+	copyToCoordArray(0, Math::Vector2d(tLeft, tTop + tHeight));
+	copyToCoordArray(1, Math::Vector2d(tLeft + tWidth, tTop + tHeight));
+	copyToCoordArray(2, Math::Vector2d(tLeft, tTop));
+	copyToCoordArray(3, Math::Vector2d(tLeft + tWidth, tTop));
+	glTexCoordPointer(2, GL_FLOAT, 0, _coords);
 
-	glTexCoord2f(tLeft, tTop);
-	glVertex3f(sLeft + 0, sTop + 0, 1.0f);
+	glBindTexture(GL_TEXTURE_2D, glTexture->_id);
+	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 
-	glTexCoord2f(tLeft + tWidth, tTop);
-	glVertex3f(sRight, sTop + 0, 1.0f);
-	glEnd();
+	glDisableClientState(GL_VERTEX_ARRAY);
+	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 
 	glDisable(GL_BLEND);
 	glDepthMask(GL_TRUE);
diff --git a/engines/freescape/gfx_opengl.h b/engines/freescape/gfx_opengl.h
index 19d8e47fc98..f8878b39ec9 100644
--- a/engines/freescape/gfx_opengl.h
+++ b/engines/freescape/gfx_opengl.h
@@ -24,6 +24,7 @@
 
 #include "graphics/opengl/system_headers.h"
 #include "math/vector3d.h"
+#include "math/vector2d.h"
 
 #include "freescape/gfx.h"
 
@@ -47,6 +48,18 @@ public:
 
 	Vertex *_verts;
 
+	struct Coord {
+		GLfloat x;
+		GLfloat y;
+	};
+
+	Coord *_coords;
+
+	void copyToCoordArray(uint idx, const Math::Vector2d &src) {
+		assert(idx < kCoordsArraySize);
+		_coords[idx].x = src.getValue(0); _coords[idx].y = src.getValue(1);
+	}
+
 	virtual void init() override;
 	virtual void clear() override;
 	virtual void setViewport(const Common::Rect &rect) override;




More information about the Scummvm-git-logs mailing list