[Scummvm-git-logs] scummvm master -> b60ac3e5f181803cb3d21290da3fc1e40eae0378
aquadran
noreply at scummvm.org
Tue Oct 15 16:31:43 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:
b60ac3e5f1 WINTERMUTE: Sync function name and placement in renderer 3d base class
Commit: b60ac3e5f181803cb3d21290da3fc1e40eae0378
https://github.com/scummvm/scummvm/commit/b60ac3e5f181803cb3d21290da3fc1e40eae0378
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2024-10-15T18:31:36+02:00
Commit Message:
WINTERMUTE: Sync function name and placement in renderer 3d base class
Changed paths:
engines/wintermute/ad/ad_scene_geometry.cpp
engines/wintermute/base/base_game.cpp
engines/wintermute/base/gfx/base_renderer3d.cpp
engines/wintermute/base/gfx/base_renderer3d.h
engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
diff --git a/engines/wintermute/ad/ad_scene_geometry.cpp b/engines/wintermute/ad/ad_scene_geometry.cpp
index fb4e3ae639a..a8b3de4a8ef 100644
--- a/engines/wintermute/ad/ad_scene_geometry.cpp
+++ b/engines/wintermute/ad/ad_scene_geometry.cpp
@@ -838,11 +838,11 @@ bool AdSceneGeometry::initLoop() {
//////////////////////////////////////////////////////////////////////////
bool AdSceneGeometry::createLights() {
// disable all lights
- for (int i = 0; i < _gameRef->_renderer3D->maximumLightsCount(); i++) {
+ for (int i = 0; i < _gameRef->_renderer3D->getMaxActiveLights(); i++) {
_gameRef->_renderer3D->disableLight(i);
}
- int lightCount = MIN(static_cast<int>(_lights.size()), _gameRef->_renderer3D->maximumLightsCount());
+ int lightCount = MIN(static_cast<int>(_lights.size()), _gameRef->_renderer3D->getMaxActiveLights());
for (int i = 0; i < lightCount; i++) {
_lights[i]->setLight(i);
@@ -868,13 +868,13 @@ bool AdSceneGeometry::enableLights(Math::Vector3d point, BaseArray<char *> &igno
}
}
- if (activeLightCount <= _gameRef->_renderer3D->maximumLightsCount()) {
+ if (activeLightCount <= _gameRef->_renderer3D->getMaxActiveLights()) {
for (uint i = 0; i < _lights.size(); i++) {
_lights[i]->_isAvailable = true;
}
} else {
if (!_maxLightsWarning) {
- _gameRef->LOG(0, "Warning: Using more lights than the hardware supports (%d)", _gameRef->_renderer3D->maximumLightsCount());
+ _gameRef->LOG(0, "Warning: Using more lights than the hardware supports (%d)", _gameRef->_renderer3D->getMaxActiveLights());
_maxLightsWarning = true;
}
@@ -905,7 +905,7 @@ bool AdSceneGeometry::enableLights(Math::Vector3d point, BaseArray<char *> &igno
Common::sort(activeLights.begin(), activeLights.end(), compareLights);
for (uint i = 0; i < activeLights.size(); i++) {
- activeLights[i]->_isAvailable = static_cast<int>(i) < _gameRef->_renderer3D->maximumLightsCount();
+ activeLights[i]->_isAvailable = static_cast<int>(i) < _gameRef->_renderer3D->getMaxActiveLights();
}
}
}
@@ -918,7 +918,7 @@ bool AdSceneGeometry::enableLights(Math::Vector3d point, BaseArray<char *> &igno
activeLightCount = 0;
for (uint i = 0; i < _lights.size(); i++) {
- if (activeLightCount >= _gameRef->_renderer3D->maximumLightsCount()) {
+ if (activeLightCount >= _gameRef->_renderer3D->getMaxActiveLights()) {
break;
}
diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp
index e5829c5cd3f..89ee1e36a24 100644
--- a/engines/wintermute/base/base_game.cpp
+++ b/engines/wintermute/base/base_game.cpp
@@ -2783,7 +2783,7 @@ ScValue *BaseGame::scGetProperty(const Common::String &name) {
//////////////////////////////////////////////////////////////////////////
else if (name == "MaxActiveLights") {
if (_useD3D) {
- _scValue->setInt(_renderer3D->maximumLightsCount());
+ _scValue->setInt(_renderer3D->getMaxActiveLights());
} else {
_scValue->setInt(0);
}
diff --git a/engines/wintermute/base/gfx/base_renderer3d.cpp b/engines/wintermute/base/gfx/base_renderer3d.cpp
index b26d8b4a624..22818b417e3 100644
--- a/engines/wintermute/base/gfx/base_renderer3d.cpp
+++ b/engines/wintermute/base/gfx/base_renderer3d.cpp
@@ -42,10 +42,11 @@ BaseRenderer3D::BaseRenderer3D(Wintermute::BaseGame *inGame) : BaseRenderer(inGa
}
BaseRenderer3D::~BaseRenderer3D() {
+ _camera = nullptr; // ref only
}
void BaseRenderer3D::initLoop() {
- deleteRectList();
+ BaseRenderer::initLoop();
setup2D();
}
@@ -115,14 +116,14 @@ Math::Ray BaseRenderer3D::rayIntoScene(int x, int y) {
bool BaseRenderer3D::setAmbientLightColor(uint32 color) {
_ambientLightColor = color;
_ambientLightOverride = true;
- setAmbientLight();
+ setAmbientLightRenderState();
return true;
}
bool BaseRenderer3D::setDefaultAmbientLightColor() {
_ambientLightColor = 0x00000000;
_ambientLightOverride = false;
- setAmbientLight();
+ setAmbientLightRenderState();
return true;
}
diff --git a/engines/wintermute/base/gfx/base_renderer3d.h b/engines/wintermute/base/gfx/base_renderer3d.h
index b48f5968e92..8ccfe6a319a 100644
--- a/engines/wintermute/base/gfx/base_renderer3d.h
+++ b/engines/wintermute/base/gfx/base_renderer3d.h
@@ -61,35 +61,43 @@ public:
bool getProjectionParams(float *resWidth, float *resHeight, float *layerWidth, float *layerHeight,
float *modWidth, float *modHeight, bool *customViewport);
+ virtual int getMaxActiveLights() = 0;
bool setAmbientLightColor(uint32 color);
bool setDefaultAmbientLightColor();
- virtual void setAmbientLight() = 0;
uint32 _ambientLightColor;
bool _ambientLightOverride;
- virtual int maximumLightsCount() = 0;
+ virtual bool enableShadows() = 0;
+ virtual bool disableShadows() = 0;
+ virtual bool stencilSupported() = 0;
+ virtual void displayShadow(BaseObject *object, const Math::Vector3d &light, bool lightPosRelative) = 0;
+
+ virtual void setSpriteBlendMode(Graphics::TSpriteBlendMode blendMode) = 0;
+
+ void fade(uint16 alpha) override;
+ bool drawSprite(BaseSurfaceOpenGL3D &tex, const Rect32 &rect, float zoomX, float zoomY, const Vector2 &pos,
+ uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY);
+ virtual bool drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Rect32 &rect, const Vector2 &pos, const Vector2 &rot, const Vector2 &scale,
+ float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) = 0;
+ void initLoop() override;
+
+
+
+ // ScummVM specific methods:
+
virtual void enableLight(int index) = 0;
virtual void disableLight(int index) = 0;
virtual void setLightParameters(int index, const Math::Vector3d &position, const Math::Vector3d &direction,
const Math::Vector4d &diffuse, bool spotlight) = 0;
- virtual void setSpriteBlendMode(Graphics::TSpriteBlendMode blendMode) = 0;
-
virtual void enableCulling() = 0;
virtual void disableCulling() = 0;
- virtual bool enableShadows() = 0;
- virtual bool disableShadows() = 0;
- virtual void displayShadow(BaseObject *object, const Math::Vector3d &light, bool lightPosRelative) = 0;
- virtual bool stencilSupported() = 0;
Rect32 getViewPort() override;
Graphics::PixelFormat getPixelFormat() const override;
- void fade(uint16 alpha) override;
-
- void initLoop() override;
virtual bool setProjection2D() = 0;
@@ -127,10 +135,6 @@ public:
virtual XMesh *createXMesh() = 0;
virtual ShadowVolume *createShadowVolume() = 0;
- bool drawSprite(BaseSurfaceOpenGL3D &tex, const Rect32 &rect, float zoomX, float zoomY, const Vector2 &pos,
- uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY);
- virtual bool drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Rect32 &rect, const Vector2 &pos, const Vector2 &rot, const Vector2 &scale,
- float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) = 0;
virtual void renderSceneGeometry(const BaseArray<AdWalkplane *> &planes, const BaseArray<AdBlock *> &blocks,
const BaseArray<AdGeneric *> &generics, const BaseArray<Light3D *> &lights, Camera3D *camera) = 0;
@@ -151,6 +155,9 @@ protected:
TRendererState _state;
bool _spriteBatchMode;
+ virtual void setAmbientLightRenderState() = 0;
+
+ // ScummVM specific methods:
void flipVertical(Graphics::Surface *s);
};
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
index 79b3cfdfcf7..040e6d169a2 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
@@ -50,8 +50,8 @@ BaseRenderer3D *makeOpenGL3DRenderer(BaseGame *inGame) {
BaseRenderOpenGL3D::BaseRenderOpenGL3D(BaseGame *inGame) : BaseRenderer3D(inGame) {
setDefaultAmbientLightColor();
- _lightPositions.resize(maximumLightsCount());
- _lightDirections.resize(maximumLightsCount());
+ _lightPositions.resize(getMaxActiveLights());
+ _lightDirections.resize(getMaxActiveLights());
}
BaseRenderOpenGL3D::~BaseRenderOpenGL3D() {
@@ -78,7 +78,7 @@ void BaseRenderOpenGL3D::setSpriteBlendMode(Graphics::TSpriteBlendMode blendMode
}
}
-void BaseRenderOpenGL3D::setAmbientLight() {
+void BaseRenderOpenGL3D::setAmbientLightRenderState() {
byte a = 0;
byte r = 0;
byte g = 0;
@@ -102,7 +102,7 @@ void BaseRenderOpenGL3D::setAmbientLight() {
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, value);
}
-int BaseRenderOpenGL3D::maximumLightsCount() {
+int BaseRenderOpenGL3D::getMaxActiveLights() {
GLint maxLightCount = 0;
glGetIntegerv(GL_MAX_LIGHTS, &maxLightCount);
return maxLightCount;
@@ -488,7 +488,7 @@ bool BaseRenderOpenGL3D::setup3D(Camera3D *camera, bool force) {
// 8 / 255 ~ 0.0313
glAlphaFunc(GL_GEQUAL, 0.0313f);
- setAmbientLight();
+ setAmbientLightRenderState();
glEnable(GL_NORMALIZE);
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
index 796830f1305..8c312594adc 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
@@ -58,9 +58,9 @@ public:
void setSpriteBlendMode(Graphics::TSpriteBlendMode blendMode) override;
- void setAmbientLight() override;
+ void setAmbientLightRenderState() override;
- int maximumLightsCount() override;
+ int getMaxActiveLights() override;
void enableLight(int index) override;
void disableLight(int index) override;
void setLightParameters(int index, const Math::Vector3d &position, const Math::Vector3d &direction, const Math::Vector4d &diffuse, bool spotlight) override;
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
index fdf18963a78..ae1c96d4e8d 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
@@ -89,7 +89,7 @@ void BaseRenderOpenGL3DShader::setSpriteBlendMode(Graphics::TSpriteBlendMode ble
}
}
-void BaseRenderOpenGL3DShader::setAmbientLight() {
+void BaseRenderOpenGL3DShader::setAmbientLightRenderState() {
byte a = RGBCOLGetA(_ambientLightColor);
byte r = RGBCOLGetR(_ambientLightColor);
byte g = RGBCOLGetG(_ambientLightColor);
@@ -114,7 +114,7 @@ void BaseRenderOpenGL3DShader::setAmbientLight() {
_xmodelShader->setUniform("ambientLight", value);
}
-int BaseRenderOpenGL3DShader::maximumLightsCount() {
+int BaseRenderOpenGL3DShader::getMaxActiveLights() {
return 8;
}
@@ -523,7 +523,7 @@ bool BaseRenderOpenGL3DShader::initRenderer(int width, int height, bool windowed
setDefaultAmbientLightColor();
- for (int i = 0; i < maximumLightsCount(); ++i) {
+ for (int i = 0; i < getMaxActiveLights(); ++i) {
setLightParameters(i, Math::Vector3d(0, 0, 0), Math::Vector3d(0, 0, 0), Math::Vector4d(0, 0, 0, 0), false);
disableLight(i);
}
@@ -619,7 +619,7 @@ bool BaseRenderOpenGL3DShader::setup3D(Camera3D *camera, bool force) {
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
- setAmbientLight();
+ setAmbientLightRenderState();
if (camera)
_camera = camera;
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
index 7214348aa60..aa51e71ae17 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
@@ -48,9 +48,9 @@ public:
void setSpriteBlendMode(Graphics::TSpriteBlendMode blendMode) override;
- void setAmbientLight() override;
+ void setAmbientLightRenderState() override;
- int maximumLightsCount() override;
+ int getMaxActiveLights() override;
void enableLight(int index) override;
void disableLight(int index) override;
void setLightParameters(int index, const Math::Vector3d &position, const Math::Vector3d &direction, const Math::Vector4d &diffuse, bool spotlight) override;
More information about the Scummvm-git-logs
mailing list