[Scummvm-git-logs] scummvm master -> 542cb473a3b869be583b6e74412b2215fdb40482
neuromancer
noreply at scummvm.org
Sat Jan 13 12:48:57 UTC 2024
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:
542cb473a3 FREESCAPE: initial rendering of the solar eclipse in eclipse
Commit: 542cb473a3b869be583b6e74412b2215fdb40482
https://github.com/scummvm/scummvm/commit/542cb473a3b869be583b6e74412b2215fdb40482
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-01-13T13:49:02+01:00
Commit Message:
FREESCAPE: initial rendering of the solar eclipse in eclipse
Changed paths:
engines/freescape/freescape.cpp
engines/freescape/freescape.h
engines/freescape/games/eclipse/eclipse.cpp
engines/freescape/games/eclipse/eclipse.h
engines/freescape/gfx.cpp
engines/freescape/gfx.h
engines/freescape/gfx_opengl.cpp
engines/freescape/gfx_opengl.h
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 9df22ccf8f8..0d577502792 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -294,11 +294,15 @@ void FreescapeEngine::takeDamageFromSensor() {
_gameStateVars[k8bitVariableShield]--;
}
-void FreescapeEngine::drawBackground() {
+void FreescapeEngine::clearBackground() {
_gfx->clear(0, 0, 0, true);
_gfx->setViewport(_fullscreenViewArea);
_gfx->drawBackground(_currentArea->_usualBackgroundColor);
_gfx->setViewport(_viewArea);
+}
+
+void FreescapeEngine::drawBackground() {
+ clearBackground();
_gfx->drawBackground(_currentArea->_skyColor);
}
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 511a62178ba..e42dd10aaf8 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -144,7 +144,8 @@ public:
virtual void processBorder();
void drawBorder();
void drawTitle();
- void drawBackground();
+ virtual void drawBackground();
+ void clearBackground();
virtual void drawUI();
virtual void drawInfoMenu();
void drawBorderScreenAndWait(Graphics::Surface *surface);
diff --git a/engines/freescape/games/eclipse/eclipse.cpp b/engines/freescape/games/eclipse/eclipse.cpp
index af02e8070f5..848663f49ca 100644
--- a/engines/freescape/games/eclipse/eclipse.cpp
+++ b/engines/freescape/games/eclipse/eclipse.cpp
@@ -139,13 +139,20 @@ void EclipseEngine::gotoArea(uint16 areaID, int entranceID) {
_gfx->_keyColor = 255;
swapPalette(areaID);
- if (isDemo())
- _currentArea->_skyColor = 27;
_currentArea->_usualBackgroundColor = isCPC() ? 1 : 0;
resetInput();
}
+void EclipseEngine::drawBackground() {
+ clearBackground();
+ _gfx->drawBackground(_currentArea->_skyColor);
+ if (_currentArea && _currentArea->getAreaID() == 1) {
+ _gfx->drawEclipse(15, 10);
+ }
+}
+
+
void EclipseEngine::borderScreen() {
if (_border) {
drawBorder();
diff --git a/engines/freescape/games/eclipse/eclipse.h b/engines/freescape/games/eclipse/eclipse.h
index 47c479564bf..2a935274c5e 100644
--- a/engines/freescape/games/eclipse/eclipse.h
+++ b/engines/freescape/games/eclipse/eclipse.h
@@ -45,6 +45,8 @@ public:
void initGameState() override;
void executePrint(FCLInstruction &instruction) override;
+
+ void drawBackground() override;
void drawDOSUI(Graphics::Surface *surface) override;
void drawCPCUI(Graphics::Surface *surface) override;
void drawZXUI(Graphics::Surface *surface) override;
diff --git a/engines/freescape/gfx.cpp b/engines/freescape/gfx.cpp
index 0c95a923e6c..2b601e5ecb1 100644
--- a/engines/freescape/gfx.cpp
+++ b/engines/freescape/gfx.cpp
@@ -982,9 +982,18 @@ void Renderer::drawBackground(uint8 color) {
if (_colorRemaps && _colorRemaps->contains(color)) {
color = (*_colorRemaps)[color];
}
- uint8 r, g, b;
- readFromPalette(color, r, g, b);
- clear(r, g, b);
+
+ if (color == 0) {
+ clear(0, 0, 0);
+ return;
+ }
+
+ uint8 r1, g1, b1;
+ uint8 r2, g2, b2;
+ byte *stipple = nullptr;
+
+ getRGBAt(color, r1, g1, b1, r2, g2, b2, stipple);
+ clear(r1, g1, b1);
}
Graphics::RendererType determinateRenderType() {
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index db2d3b9b1d4..3e84e863186 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -98,6 +98,7 @@ public:
virtual void clear(uint8 r, uint8 g, uint8 b, bool ignoreViewport = false) = 0;
virtual void drawFloor(uint8 color) = 0;
virtual void drawBackground(uint8 color);
+ virtual void drawEclipse(uint8 color1, uint8 color2) {};
Common::Rect viewport() const;
virtual Common::Point nativeResolution() { return Common::Point(_screenW, _screenH); }
diff --git a/engines/freescape/gfx_opengl.cpp b/engines/freescape/gfx_opengl.cpp
index c985e2b5aa1..cdea6a65f6d 100644
--- a/engines/freescape/gfx_opengl.cpp
+++ b/engines/freescape/gfx_opengl.cpp
@@ -278,6 +278,101 @@ void OpenGLRenderer::renderPlayerShootRay(byte color, const Common::Point positi
glDepthMask(GL_TRUE);
}
+void OpenGLRenderer::drawCelestialBody(Math::Vector3d position, float radius, byte color) {
+ uint8 r1, g1, b1, r2, g2, b2;
+ byte *stipple = nullptr;
+ getRGBAt(color, r1, g1, b1, r2, g2, b2, stipple);
+ glColor3ub(r1, g1, b1);
+
+ int triangleAmount = 20;
+ float twicePi = (float)(2.0 * M_PI);
+
+ glDisable(GL_DEPTH_TEST);
+ glDepthMask(GL_FALSE);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ copyToVertexArray(0, position);
+
+ for(int i = 0; i <= triangleAmount; i++) {
+ copyToVertexArray(i + 1,
+ Math::Vector3d(position.x(), position.y() + (radius * cos(i * twicePi / triangleAmount)),
+ position.z() + (radius * sin(i * twicePi / triangleAmount)))
+ );
+ }
+
+ glVertexPointer(3, GL_FLOAT, 0, _verts);
+ glDrawArrays(GL_TRIANGLE_FAN, 0, triangleAmount + 2);
+ glDisableClientState(GL_VERTEX_ARRAY);
+
+ glEnable(GL_DEPTH_TEST);
+ glDepthMask(GL_TRUE);
+
+ /*uint8 r, g, b;
+
+ GLfloat m[16];
+ GLfloat p[16];
+
+ glGetFloatv(GL_MODELVIEW_MATRIX, m);
+ glGetFloatv(GL_PROJECTION_MATRIX, p);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
+ glMatrixMode(GL_PROJECTION);
+
+ Math::Matrix4 lookMatrix = Math::makeLookAtMatrix(pos, interest, up_vec);
+ glMultMatrixf(lookMatrix.getData());
+ //glLoadIdentity();
+ //glOrtho(0, _screenW, _screenH, 0, 0, 1);
+
+
+ r = 0xff;
+ g = 0xff;
+ b = 0x55;
+
+ glDisable(GL_DEPTH_TEST);
+ glDepthMask(GL_FALSE);
+
+ glColor3ub(r, g, b);
+ int triangleAmount = 20;
+ float twicePi = (float)(2.0 * M_PI);
+ float radius = 10.0;
+
+ Common::Point ball_position(320 / 2, 200 / 2);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ copyToVertexArray(0, Math::Vector3d(ball_position.x, ball_position.y, 0));
+
+ for(int i = 0; i <= triangleAmount; i++) {
+ copyToVertexArray(i + 1,
+ Math::Vector3d(ball_position.x + (radius * cos(i * twicePi / triangleAmount)),
+ ball_position.y + (radius * sin(i * twicePi / triangleAmount)), 0)
+ );
+ }
+
+ glVertexPointer(3, GL_FLOAT, 0, _verts);
+ glDrawArrays(GL_TRIANGLE_FAN, 0, triangleAmount + 2);
+ glDisableClientState(GL_VERTEX_ARRAY);
+
+ glEnable(GL_DEPTH_TEST);
+ glDepthMask(GL_TRUE);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadMatrixf(m);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadMatrixf(p);*/
+}
+
+void OpenGLRenderer::drawEclipse(byte color1, byte color2) {
+ Math::Vector3d sunPosition(-5000, 2000, 500);
+ float radius = 750.0;
+ drawCelestialBody(sunPosition, radius, color1);
+
+ Math::Vector3d moonPosition(-5000, 2000, 1500);
+ drawCelestialBody(moonPosition, radius, color2);
+}
+
void OpenGLRenderer::renderPlayerShootBall(byte color, const Common::Point position, int frame, const Common::Rect viewArea) {
uint8 r, g, b;
diff --git a/engines/freescape/gfx_opengl.h b/engines/freescape/gfx_opengl.h
index 0b616a0b96a..e932af50f21 100644
--- a/engines/freescape/gfx_opengl.h
+++ b/engines/freescape/gfx_opengl.h
@@ -107,6 +107,8 @@ public:
virtual void flipBuffer() override;
virtual void drawFloor(uint8 color) override;
+ virtual void drawEclipse(uint8 color1, uint8 color2) override;
+ void drawCelestialBody(Math::Vector3d position, float radius, uint8 color);
virtual Graphics::Surface *getScreenshot() override;
};
More information about the Scummvm-git-logs
mailing list