[Scummvm-git-logs] scummvm master -> 3bb61e523bfbb8425325841968ec23ba73ac8857
aquadran
noreply at scummvm.org
Thu Oct 31 19:09:44 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:
3bb61e523b WINTERMUTE: More sync with original for renderer sprites
Commit: 3bb61e523bfbb8425325841968ec23ba73ac8857
https://github.com/scummvm/scummvm/commit/3bb61e523bfbb8425325841968ec23ba73ac8857
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2024-10-31T20:09:38+01:00
Commit Message:
WINTERMUTE: More sync with original for renderer sprites
Changed paths:
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
engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
engines/wintermute/base/gfx/opengl/shadow_volume_opengl.cpp
engines/wintermute/base/gfx/opengl/shadow_volume_opengl_shader.cpp
diff --git a/engines/wintermute/base/gfx/base_renderer3d.cpp b/engines/wintermute/base/gfx/base_renderer3d.cpp
index ec39098e8dc..f47ad8caa5c 100644
--- a/engines/wintermute/base/gfx/base_renderer3d.cpp
+++ b/engines/wintermute/base/gfx/base_renderer3d.cpp
@@ -36,9 +36,14 @@ BaseRenderer3D::BaseRenderer3D(Wintermute::BaseGame *inGame) : BaseRenderer(inGa
_nearClipPlane = DEFAULT_NEAR_PLANE;
_farClipPlane = DEFAULT_FAR_PLANE;
+ _lastTexture = nullptr;
+
_blendMode = Graphics::BLEND_UNKNOWN;
_spriteBatchMode = false;
+ _batchBlendMode = Graphics::BLEND_UNKNOWN;
+ _batchAlphaDisable = false;
+ _batchTexture = nullptr;
_ambientLightColor = 0x00000000;
_ambientLightOverride = false;
@@ -57,12 +62,12 @@ void BaseRenderer3D::initLoop() {
setup2D();
}
-bool BaseRenderer3D::drawSprite(BaseSurfaceOpenGL3D &tex, const Wintermute::Rect32 &rect,
+bool BaseRenderer3D::drawSprite(BaseSurface *texture, const Wintermute::Rect32 &rect,
float zoomX, float zoomY, const Wintermute::Vector2 &pos,
uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode,
bool mirrorX, bool mirrorY) {
Vector2 scale(zoomX / 100.0f, zoomY / 100.0f);
- return drawSpriteEx(tex, rect, pos, Vector2(0.0f, 0.0f), scale, 0.0f, color, alphaDisable, blendMode, mirrorX, mirrorY);
+ return drawSpriteEx(texture, rect, pos, Vector2(0.0f, 0.0f), scale, 0.0f, color, alphaDisable, blendMode, mirrorX, mirrorY);
}
bool BaseRenderer3D::getProjectionParams(float *resWidth, float *resHeight, float *layerWidth, float *layerHeight,
@@ -163,6 +168,7 @@ void BaseRenderer3D::flipVertical(Graphics::Surface *s) {
}
bool BaseRenderer3D::flip() {
+ _lastTexture = nullptr;
g_system->updateScreen();
return true;
}
diff --git a/engines/wintermute/base/gfx/base_renderer3d.h b/engines/wintermute/base/gfx/base_renderer3d.h
index 35b3968b2b4..83423b44c7b 100644
--- a/engines/wintermute/base/gfx/base_renderer3d.h
+++ b/engines/wintermute/base/gfx/base_renderer3d.h
@@ -76,7 +76,7 @@ public:
virtual bool disableShadows() = 0;
virtual bool stencilSupported() = 0;
virtual void displayShadow(BaseObject *object, const DXVector3 *light, bool lightPosRelative) = 0;
- //HRESULT InvalidateTexture(LPDIRECT3DTEXTURE Texture);
+ virtual bool invalidateTexture(BaseSurfaceOpenGL3D *texture) = 0;
Graphics::TSpriteBlendMode _blendMode;
virtual void setSpriteBlendMode(Graphics::TSpriteBlendMode blendMode, bool forceChange = false) = 0;
@@ -85,15 +85,16 @@ public:
// declared in sub class: virtual CBImage* TakeScreenshot();
// declared in sub class: virtual HRESULT SetViewport(int left, int top, int right, int bottom);
- // NOT declared in sub class: HRESULT InvalidateDeviceObjects();
+ bool invalidateDeviceObjects();
// NOT declared in sub class: HRESULT RestoreDeviceObjects();
+ BaseSurfaceOpenGL3D *_lastTexture;
void fade(uint16 alpha) override;
// declared in sub class: virtual HRESULT FadeToColor(DWORD Color, RECT* rect=NULL);
// declared in sub class: virtual HRESULT DrawLine(int X1, int Y1, int X2, int Y2, DWORD Color);
// declared in sub class: virtual HRESULT SetProjection();
- bool drawSprite(BaseSurfaceOpenGL3D &tex, const Rect32 &rect, float zoomX, float zoomY, const Vector2 &pos,
+ bool drawSprite(BaseSurface *texture, 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,
+ virtual bool drawSpriteEx(BaseSurface *texture, 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;
// declared in sub class: virtual HRESULT Setup3D(C3DCamera* Camera=NULL, bool Force=false);
// NOT declared in sub class: virtual HRESULT Setup3DCustom(D3DXMATRIX* ViewMat, D3DXMATRIX* ProjMat);
@@ -110,9 +111,9 @@ public:
// declared in sub class: virtual bool UsingStencilBuffer();
- // declared in sub class: virtual HRESULT StartSpriteBatch();
- // declared in sub class: virtual HRESULT EndSpriteBatch();
- // NOT declared in sub class: HRESULT CommitSpriteBatch();
+ virtual bool startSpriteBatch() override = 0;
+ virtual bool endSpriteBatch() override = 0;
+ virtual bool commitSpriteBatch() = 0;
// declared in sub class: virtual HRESULT DrawShaderQuad();
@@ -180,6 +181,9 @@ protected:
float _farClipPlane;
TRendererState _state;
bool _spriteBatchMode;
+ Graphics::TSpriteBlendMode _batchBlendMode;
+ bool _batchAlphaDisable;
+ BaseSurfaceOpenGL3D *_batchTexture;
// NOT declared in sub class: HRESULT CreateShaderQuad();
virtual void setAmbientLightRenderState() = 0;
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
index 46c05314b2d..c53aa024c52 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
@@ -297,16 +297,24 @@ bool BaseRenderOpenGL3D::setupLines() {
glEnable(GL_ALPHA_TEST);
glDisable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);
+ _lastTexture = nullptr;
}
return true;
}
-bool BaseRenderOpenGL3D::drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Wintermute::Rect32 &rect,
+bool BaseRenderOpenGL3D::drawSpriteEx(BaseSurface *tex, const Wintermute::Rect32 &rect,
const Wintermute::Vector2 &pos, const Wintermute::Vector2 &rot, const Wintermute::Vector2 &scale,
float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode,
bool mirrorX, bool mirrorY) {
- // original wme has a batch mode for sprites, we ignore this for the moment
+
+ BaseSurfaceOpenGL3D *texture = dynamic_cast<BaseSurfaceOpenGL3D *>(tex);
+
+ if (_spriteBatchMode) {
+ _batchTexture = texture;
+ _batchAlphaDisable = alphaDisable;
+ _batchBlendMode = blendMode;
+ }
if (_forceAlphaColor != 0) {
color = _forceAlphaColor;
@@ -315,16 +323,8 @@ bool BaseRenderOpenGL3D::drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Wintermute
float width = (rect.right - rect.left) * scale.x;
float height = (rect.bottom - rect.top) * scale.y;
- glBindTexture(GL_TEXTURE_2D, tex.getTextureName());
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- // for sprites we clamp to the edge, to avoid line fragments at the edges
- // this is not done by wme, though
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- int texWidth = tex.getGLTextureWidth();
- int texHeight = tex.getGLTextureHeight();
+ int texWidth = texture->getGLTextureWidth();
+ int texHeight = texture->getGLTextureHeight();
float texLeft = (float)rect.left / (float)texWidth;
float texTop = (float)rect.top / (float)texHeight;
@@ -344,6 +344,12 @@ bool BaseRenderOpenGL3D::drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Wintermute
SpriteVertex vertices[4] = {};
+ // batch mode
+ if (_spriteBatchMode) {
+ // TODO
+ commitSpriteBatch();
+ }
+
// texture coords
vertices[0].u = texLeft;
vertices[0].v = texTop;
@@ -400,36 +406,86 @@ bool BaseRenderOpenGL3D::drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Wintermute
}
}
- if (alphaDisable) {
- glDisable(GL_ALPHA_TEST);
- }
+ if (_spriteBatchMode) {
+ // TODO
+ } else {
+ setSpriteBlendMode(blendMode);
+ if (alphaDisable) {
+ glDisable(GL_ALPHA_TEST);
+ //glDisable(GL_BLEND);
+ }
- setSpriteBlendMode(blendMode);
+ if (_lastTexture != texture) {
+ _lastTexture = texture;
+ glBindTexture(GL_TEXTURE_2D, texture->getTextureName());
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ // for sprites we clamp to the edge, to avoid line fragments at the edges
+ // this is not done by wme, though
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glEnable(GL_TEXTURE_2D);
+ }
- glEnable(GL_TEXTURE_2D);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+
+ glVertexPointer(3, GL_FLOAT, sizeof(SpriteVertex), &vertices[0].x);
+ glTexCoordPointer(2, GL_FLOAT, sizeof(SpriteVertex), &vertices[0].u);
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(SpriteVertex), &vertices[0].r);
+
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+
+ if (alphaDisable) {
+ glEnable(GL_ALPHA_TEST);
+ glEnable(GL_BLEND);
+ }
+ }
- glEnableClientState(GL_COLOR_ARRAY);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
+ return true;
+}
- glVertexPointer(3, GL_FLOAT, sizeof(SpriteVertex), &vertices[0].x);
- glTexCoordPointer(2, GL_FLOAT, sizeof(SpriteVertex), &vertices[0].u);
- glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(SpriteVertex), &vertices[0].r);
+bool BaseRenderOpenGL3D::commitSpriteBatch() {
+ // render
+ setSpriteBlendMode(_batchBlendMode);
+ if (_batchAlphaDisable) {
+ glDisable(GL_ALPHA_TEST);
+ glDisable(GL_BLEND);
+ }
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ if (_lastTexture != _batchTexture) {
+ _lastTexture = _batchTexture;
+ glBindTexture(GL_TEXTURE_2D, _batchTexture->getTextureName());
+ }
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ // TODO
- if (alphaDisable) {
+ if (_batchAlphaDisable) {
glEnable(GL_ALPHA_TEST);
+ glEnable(GL_BLEND);
}
return true;
}
+bool BaseRenderOpenGL3D::startSpriteBatch() {
+ //_spriteBatchMode = true;
+ return true;
+}
+
+bool BaseRenderOpenGL3D::endSpriteBatch() {
+ if (!_spriteBatchMode)
+ return false;
+
+ _spriteBatchMode = false;
+ return commitSpriteBatch();
+}
+
bool BaseRenderOpenGL3D::setProjection() {
DXMatrix matProj;
@@ -530,6 +586,7 @@ void BaseRenderOpenGL3D::fadeToColor(byte r, byte g, byte b, byte a) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
+ _lastTexture = nullptr;
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
@@ -652,6 +709,15 @@ int BaseRenderOpenGL3D::getMaxActiveLights() {
return maxLightCount;
}
+bool BaseRenderOpenGL3D::invalidateTexture(BaseSurfaceOpenGL3D *texture) {
+ if (_lastTexture == texture)
+ _lastTexture = nullptr;
+ if (_batchTexture == texture)
+ _batchTexture = nullptr;
+
+ return true;
+}
+
// implements D3D LightEnable()
void BaseRenderOpenGL3D::lightEnable(int index, bool enable) {
if (enable)
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
index 25fb97a6139..eae7f93e10e 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
@@ -56,6 +56,8 @@ public:
BaseRenderOpenGL3D(BaseGame *inGame = nullptr);
~BaseRenderOpenGL3D() override;
+ bool invalidateTexture(BaseSurfaceOpenGL3D *texture) override;
+
void setSpriteBlendMode(Graphics::TSpriteBlendMode blendMode, bool forceChange = false) override;
void setAmbientLightRenderState() override;
@@ -111,14 +113,11 @@ public:
BaseSurface *createSurface() override;
- bool startSpriteBatch() override {
- return STATUS_OK;
- };
- bool endSpriteBatch() override {
- return STATUS_OK;
- };
+ bool startSpriteBatch() override;
+ bool endSpriteBatch() override;
+ bool commitSpriteBatch() override;
- bool drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Rect32 &rect, const Vector2 &pos, const Vector2 &rot, const Vector2 &scale,
+ bool drawSpriteEx(BaseSurface *texture, 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) override;
void renderSceneGeometry(const BaseArray<AdWalkplane *> &planes, const BaseArray<AdBlock *> &blocks,
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 6552c03f745..74db48588fb 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
@@ -288,12 +288,18 @@ bool BaseRenderOpenGL3DShader::setupLines() {
return true;
}
-bool BaseRenderOpenGL3DShader::drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Wintermute::Rect32 &rect,
+bool BaseRenderOpenGL3DShader::drawSpriteEx(BaseSurface *tex, const Wintermute::Rect32 &rect,
const Wintermute::Vector2 &pos, const Wintermute::Vector2 &rot,
const Wintermute::Vector2 &scale, float angle, uint32 color,
bool alphaDisable, Graphics::TSpriteBlendMode blendMode,
bool mirrorX, bool mirrorY) {
- // original wme has a batch mode for sprites, we ignore this for the moment
+ BaseSurfaceOpenGL3D *texture = dynamic_cast<BaseSurfaceOpenGL3D *>(tex);
+
+ if (_spriteBatchMode) {
+ _batchTexture = texture;
+ _batchAlphaDisable = alphaDisable;
+ _batchBlendMode = blendMode;
+ }
if (_forceAlphaColor != 0) {
color = _forceAlphaColor;
@@ -302,15 +308,15 @@ bool BaseRenderOpenGL3DShader::drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Wint
float width = (rect.right - rect.left) * scale.x;
float height = (rect.bottom - rect.top) * scale.y;
- glBindTexture(GL_TEXTURE_2D, tex.getTextureName());
+ glBindTexture(GL_TEXTURE_2D, texture->getTextureName());
// for sprites we clamp to the edge, to avoid line fragments at the edges
// this is not done by wme, though
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- int texWidth = tex.getGLTextureWidth();
- int texHeight = tex.getGLTextureHeight();
+ int texWidth = texture->getGLTextureWidth();
+ int texHeight = texture->getGLTextureHeight();
float texLeft = (float)rect.left / (float)texWidth;
float texTop = (float)rect.top / (float)texHeight;
@@ -330,6 +336,12 @@ bool BaseRenderOpenGL3DShader::drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Wint
SpriteVertexShader vertices[4] = {};
+ // batch mode
+ if (_spriteBatchMode) {
+ // TODO
+ commitSpriteBatch();
+ }
+
// texture coords
vertices[0].u = texLeft;
vertices[0].v = texTop;
@@ -388,13 +400,52 @@ bool BaseRenderOpenGL3DShader::drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Wint
glBindBuffer(GL_ARRAY_BUFFER, _spriteVBO);
glBufferSubData(GL_ARRAY_BUFFER, 0, 4 * sizeof(SpriteVertexShader), vertices);
- setSpriteBlendMode(blendMode);
+ if (_spriteBatchMode) {
+ // TODO
+ } else {
+ setSpriteBlendMode(blendMode);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ }
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ return true;
+}
+
+bool BaseRenderOpenGL3DShader::commitSpriteBatch() {
+ // render
+ setSpriteBlendMode(_batchBlendMode);
+ if (_batchAlphaDisable) {
+ glDisable(GL_ALPHA_TEST);
+ glDisable(GL_BLEND);
+ }
+
+ if (_lastTexture != _batchTexture) {
+ _lastTexture = _batchTexture;
+ glBindTexture(GL_TEXTURE_2D, _batchTexture->getTextureName());
+ }
+
+ // TODO
+
+ if (_batchAlphaDisable) {
+ glEnable(GL_ALPHA_TEST);
+ glEnable(GL_BLEND);
+ }
return true;
}
+bool BaseRenderOpenGL3DShader::startSpriteBatch() {
+ //_spriteBatchMode = true;
+ return true;
+}
+
+bool BaseRenderOpenGL3DShader::endSpriteBatch() {
+ if (!_spriteBatchMode)
+ return false;
+
+ _spriteBatchMode = false;
+ return commitSpriteBatch();
+}
+
bool BaseRenderOpenGL3DShader::setProjection() {
DXMatrix matProj;
@@ -487,6 +538,7 @@ void BaseRenderOpenGL3DShader::fadeToColor(byte r, byte g, byte b, byte a) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, 0);
glBindBuffer(GL_ARRAY_BUFFER, _fadeVBO);
+ _lastTexture = nullptr;
Math::Matrix4 projectionMatrix2d;
projectionMatrix2d.setData(_projectionMatrix2d);
@@ -568,6 +620,15 @@ int BaseRenderOpenGL3DShader::getMaxActiveLights() {
return 8;
}
+bool BaseRenderOpenGL3DShader::invalidateTexture(BaseSurfaceOpenGL3D *texture) {
+ if (_lastTexture == texture)
+ _lastTexture = nullptr;
+ if (_batchTexture == texture)
+ _batchTexture = nullptr;
+
+ return true;
+}
+
// implements D3D LightEnable()
void BaseRenderOpenGL3DShader::lightEnable(int index, bool enable) {
_xmodelShader->use();
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 d21df31773b..21231dc8a66 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
@@ -46,6 +46,8 @@ public:
BaseRenderOpenGL3DShader(BaseGame *inGame = nullptr);
~BaseRenderOpenGL3DShader() override;
+ bool invalidateTexture(BaseSurfaceOpenGL3D *texture) override;
+
void setSpriteBlendMode(Graphics::TSpriteBlendMode blendMode, bool forceChange = false) override;
void setAmbientLightRenderState() override;
@@ -100,14 +102,11 @@ public:
BaseSurface *createSurface() override;
- bool startSpriteBatch() override {
- return STATUS_OK;
- };
- bool endSpriteBatch() override {
- return STATUS_OK;
- };
+ bool startSpriteBatch() override;
+ bool endSpriteBatch() override;
+ bool commitSpriteBatch() override;
- bool drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Rect32 &rect, const Vector2 &pos, const Vector2 &rot, const Vector2 &scale,
+ bool drawSpriteEx(BaseSurface *texture, 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) override;
void renderSceneGeometry(const BaseArray<AdWalkplane *> &planes, const BaseArray<AdBlock *> &blocks,
diff --git a/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp b/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
index aa9b7da457d..45eb2bb121e 100644
--- a/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
@@ -39,11 +39,15 @@ BaseSurfaceOpenGL3D::BaseSurfaceOpenGL3D(BaseGame *game, BaseRenderer3D *rendere
BaseSurfaceOpenGL3D::~BaseSurfaceOpenGL3D() {
glDeleteTextures(1, &_tex);
+ _renderer->invalidateTexture(this);
+ _tex = 0;
delete[] _imageData;
}
bool BaseSurfaceOpenGL3D::invalidate() {
glDeleteTextures(1, &_tex);
+ _renderer->invalidateTexture(this);
+ _tex = 0;
_imageData->free();
delete[] _imageData;
_imageData = nullptr;
@@ -67,21 +71,21 @@ bool BaseSurfaceOpenGL3D::isTransparentAt(int x, int y) {
bool BaseSurfaceOpenGL3D::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
prepareToDraw();
- _renderer->drawSprite(*this, rect, zoomX, zoomY, Vector2(x, y), alpha, false, blendMode, mirrorX, mirrorY);
+ _renderer->drawSprite(dynamic_cast<BaseSurface *>(this), rect, zoomX, zoomY, Vector2(x, y), alpha, false, blendMode, mirrorX, mirrorY);
return true;
}
bool BaseSurfaceOpenGL3D::displayTrans(int x, int y, Rect32 rect, uint32 alpha, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) {
prepareToDraw();
- _renderer->drawSprite(*this, rect, 100, 100, Vector2(x + offsetX, y + offsetY), alpha, false, blendMode, mirrorX, mirrorY);
+ _renderer->drawSprite(dynamic_cast<BaseSurface *>(this), rect, 100, 100, Vector2(x + offsetX, y + offsetY), alpha, false, blendMode, mirrorX, mirrorY);
return true;
}
bool BaseSurfaceOpenGL3D::display(int x, int y, Rect32 rect, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
prepareToDraw();
- _renderer->drawSprite(*this, rect, 100, 100, Vector2(x, y), 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY);
+ _renderer->drawSprite(dynamic_cast<BaseSurface *>(this), rect, 100, 100, Vector2(x, y), 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY);
return true;
}
@@ -102,7 +106,7 @@ bool BaseSurfaceOpenGL3D::displayTransRotate(int x, int y, uint32 angle, int32 h
rotation.y = y + transform._hotspot.y * (transform._zoom.y / 100.0f);
Vector2 scale(transform._zoom.x / 100.0f, transform._zoom.y / 100.0f);
- _renderer->drawSpriteEx(*this, rect, position, rotation, scale, transform._angle, transform._rgbaMod, transform._alphaDisable, transform._blendMode, transform.getMirrorX(), transform.getMirrorY());
+ _renderer->drawSpriteEx(dynamic_cast<BaseSurface *>(this), rect, position, rotation, scale, transform._angle, transform._rgbaMod, transform._alphaDisable, transform._blendMode, transform.getMirrorX(), transform.getMirrorY());
return true;
}
@@ -110,7 +114,7 @@ bool BaseSurfaceOpenGL3D::displayTiled(int x, int y, Rect32 rect, int numTimesX,
prepareToDraw();
Vector2 scale(numTimesX, numTimesY);
- _renderer->drawSpriteEx(*this, rect, Vector2(x, y), Vector2(0, 0), scale, 0, 0xFFFFFFFF, true, Graphics::BLEND_NORMAL, false, false);
+ _renderer->drawSpriteEx(dynamic_cast<BaseSurface *>(this), rect, Vector2(x, y), Vector2(0, 0), scale, 0, 0xFFFFFFFF, true, Graphics::BLEND_NORMAL, false, false);
return true;
}
diff --git a/engines/wintermute/base/gfx/opengl/shadow_volume_opengl.cpp b/engines/wintermute/base/gfx/opengl/shadow_volume_opengl.cpp
index 97796b166b3..4ab7e4ecdf0 100644
--- a/engines/wintermute/base/gfx/opengl/shadow_volume_opengl.cpp
+++ b/engines/wintermute/base/gfx/opengl/shadow_volume_opengl.cpp
@@ -49,6 +49,7 @@ ShadowVolumeOpenGL::~ShadowVolumeOpenGL() {
bool ShadowVolumeOpenGL::render() {
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
+ _gameRef->_renderer3D->_lastTexture = nullptr;
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, _vertices.data());
diff --git a/engines/wintermute/base/gfx/opengl/shadow_volume_opengl_shader.cpp b/engines/wintermute/base/gfx/opengl/shadow_volume_opengl_shader.cpp
index 9892baf7180..0890b4d9bf0 100644
--- a/engines/wintermute/base/gfx/opengl/shadow_volume_opengl_shader.cpp
+++ b/engines/wintermute/base/gfx/opengl/shadow_volume_opengl_shader.cpp
@@ -74,6 +74,7 @@ ShadowVolumeOpenGLShader::~ShadowVolumeOpenGLShader() {
bool ShadowVolumeOpenGLShader::render() {
glBindTexture(GL_TEXTURE_2D, 0);
glDrawArrays(GL_TRIANGLES, 0, _vertices.size());
+ _gameRef->_renderer3D->_lastTexture = nullptr;
return true;
}
More information about the Scummvm-git-logs
mailing list