[Scummvm-git-logs] scummvm master -> d18d32109246acb0e281fb6b9c0deabeecb0462d
aquadran
noreply at scummvm.org
Sun Dec 5 19:28:27 UTC 2021
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9bd82872bd MYST3: Replace the Renderer::freeTexture function
d18d321092 MYST3: Split TinyGLTexture into two separate subclasses
Commit: 9bd82872bd36b89f49bdc59f2db80406ea35696f
https://github.com/scummvm/scummvm/commit/9bd82872bd36b89f49bdc59f2db80406ea35696f
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-12-05T20:28:23+01:00
Commit Message:
MYST3: Replace the Renderer::freeTexture function
Changed paths:
engines/myst3/cursor.cpp
engines/myst3/gfx.cpp
engines/myst3/gfx.h
engines/myst3/gfx_opengl.cpp
engines/myst3/gfx_opengl.h
engines/myst3/gfx_opengl_shaders.cpp
engines/myst3/gfx_opengl_shaders.h
engines/myst3/gfx_tinygl.cpp
engines/myst3/gfx_tinygl.h
engines/myst3/inventory.cpp
engines/myst3/menu.cpp
engines/myst3/movie.cpp
engines/myst3/node.cpp
engines/myst3/subtitles.cpp
engines/myst3/transition.cpp
diff --git a/engines/myst3/cursor.cpp b/engines/myst3/cursor.cpp
index 203a5fa2b5..7184024b0d 100644
--- a/engines/myst3/cursor.cpp
+++ b/engines/myst3/cursor.cpp
@@ -126,7 +126,7 @@ void Cursor::loadAvailableCursors() {
Cursor::~Cursor() {
// Free cursors textures
for (TextureMap::iterator it = _textures.begin(); it != _textures.end(); it++) {
- _vm->_gfx->freeTexture(it->_value);
+ delete it->_value;
}
}
diff --git a/engines/myst3/gfx.cpp b/engines/myst3/gfx.cpp
index be1ec771d7..f61c811971 100644
--- a/engines/myst3/gfx.cpp
+++ b/engines/myst3/gfx.cpp
@@ -86,7 +86,7 @@ void Renderer::initFont(const Graphics::Surface *surface) {
void Renderer::freeFont() {
if (_font) {
- freeTexture(_font);
+ delete _font;
_font = nullptr;
}
}
diff --git a/engines/myst3/gfx.h b/engines/myst3/gfx.h
index f817fe8900..9216c0ee14 100644
--- a/engines/myst3/gfx.h
+++ b/engines/myst3/gfx.h
@@ -93,6 +93,8 @@ public:
class Texture {
public:
+ virtual ~Texture() {}
+
uint width;
uint height;
Graphics::PixelFormat format;
@@ -101,9 +103,6 @@ public:
virtual void updatePartial(const Graphics::Surface *surface, const Common::Rect &rect) = 0;
static const Graphics::PixelFormat getRGBAPixelFormat();
-protected:
- Texture() {}
- virtual ~Texture() {}
};
class Renderer {
@@ -123,7 +122,6 @@ public:
virtual void freeFont();
virtual Texture *createTexture(const Graphics::Surface *surface) = 0;
- virtual void freeTexture(Texture *texture) = 0;
virtual void drawRect2D(const Common::Rect &rect, uint8 a, uint8 r, uint8 g, uint8 b) = 0;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture,
diff --git a/engines/myst3/gfx_opengl.cpp b/engines/myst3/gfx_opengl.cpp
index bb7ffbe6d3..f84fcf17e7 100644
--- a/engines/myst3/gfx_opengl.cpp
+++ b/engines/myst3/gfx_opengl.cpp
@@ -49,11 +49,6 @@ Texture *OpenGLRenderer::createTexture(const Graphics::Surface *surface) {
return new OpenGLTexture(surface);
}
-void OpenGLRenderer::freeTexture(Texture *texture) {
- OpenGLTexture *glTexture = static_cast<OpenGLTexture *>(texture);
- delete glTexture;
-}
-
void OpenGLRenderer::init() {
debug("Initializing OpenGL Renderer");
diff --git a/engines/myst3/gfx_opengl.h b/engines/myst3/gfx_opengl.h
index 5e2c6ed4f0..9e36d479d6 100644
--- a/engines/myst3/gfx_opengl.h
+++ b/engines/myst3/gfx_opengl.h
@@ -42,7 +42,6 @@ public:
void selectTargetWindow(Window *window, bool is3D, bool scaled) override;
Texture *createTexture(const Graphics::Surface *surface) override;
- void freeTexture(Texture *texture) override;
void drawRect2D(const Common::Rect &rect, uint8 a, uint8 r, uint8 g, uint8 b) override;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture,
diff --git a/engines/myst3/gfx_opengl_shaders.cpp b/engines/myst3/gfx_opengl_shaders.cpp
index b4807bbb93..d946665cb9 100644
--- a/engines/myst3/gfx_opengl_shaders.cpp
+++ b/engines/myst3/gfx_opengl_shaders.cpp
@@ -119,11 +119,6 @@ Texture *ShaderRenderer::createTexture(const Graphics::Surface *surface) {
return new OpenGLTexture(surface);
}
-void ShaderRenderer::freeTexture(Texture *texture) {
- OpenGLTexture *glTexture = static_cast<OpenGLTexture *>(texture);
- delete glTexture;
-}
-
void ShaderRenderer::init() {
debug("Initializing OpenGL Renderer with shaders");
diff --git a/engines/myst3/gfx_opengl_shaders.h b/engines/myst3/gfx_opengl_shaders.h
index 49e3777433..1f691ee82c 100644
--- a/engines/myst3/gfx_opengl_shaders.h
+++ b/engines/myst3/gfx_opengl_shaders.h
@@ -43,7 +43,6 @@ public:
void selectTargetWindow(Window *window, bool is3D, bool scaled) override;
Texture *createTexture(const Graphics::Surface *surface) override;
- void freeTexture(Texture *texture) override;
void drawRect2D(const Common::Rect &rect, uint8 a, uint8 r, uint8 g, uint8 b) override;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture,
diff --git a/engines/myst3/gfx_tinygl.cpp b/engines/myst3/gfx_tinygl.cpp
index 3b098c226d..a965fa994b 100644
--- a/engines/myst3/gfx_tinygl.cpp
+++ b/engines/myst3/gfx_tinygl.cpp
@@ -52,10 +52,6 @@ Texture *TinyGLRenderer::createTexture(const Graphics::Surface *surface) {
return new TinyGLTexture(surface);
}
-void TinyGLRenderer::freeTexture(Texture *texture) {
- TinyGLTexture *glTexture = static_cast<TinyGLTexture *>(texture);
- delete glTexture;
-}
void TinyGLRenderer::init() {
debug("Initializing Software 3D Renderer");
diff --git a/engines/myst3/gfx_tinygl.h b/engines/myst3/gfx_tinygl.h
index e65e5d0013..9d40deae6a 100644
--- a/engines/myst3/gfx_tinygl.h
+++ b/engines/myst3/gfx_tinygl.h
@@ -43,7 +43,6 @@ public:
void selectTargetWindow(Window *window, bool is3D, bool scaled) override;
Texture *createTexture(const Graphics::Surface *surface) override;
- void freeTexture(Texture *texture) override;
void drawRect2D(const Common::Rect &rect, uint8 a, uint8 r, uint8 g, uint8 b) override;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture,
diff --git a/engines/myst3/inventory.cpp b/engines/myst3/inventory.cpp
index 586fabb0f2..4c9b6b3dcf 100644
--- a/engines/myst3/inventory.cpp
+++ b/engines/myst3/inventory.cpp
@@ -49,7 +49,7 @@ Inventory::Inventory(Myst3Engine *vm) :
}
Inventory::~Inventory() {
- _vm->_gfx->freeTexture(_texture);
+ delete _texture;
}
void Inventory::initializeTexture() {
@@ -349,7 +349,7 @@ DragItem::DragItem(Myst3Engine *vm, uint id):
}
DragItem::~DragItem() {
- _vm->_gfx->freeTexture(_texture);
+ delete _texture;
}
void DragItem::drawOverlay() {
diff --git a/engines/myst3/menu.cpp b/engines/myst3/menu.cpp
index 894b1c0165..b91dda5abb 100644
--- a/engines/myst3/menu.cpp
+++ b/engines/myst3/menu.cpp
@@ -69,7 +69,7 @@ Dialog::Dialog(Myst3Engine *vm, uint id):
}
Dialog::~Dialog() {
- _vm->_gfx->freeTexture(_texture);
+ delete _texture;
}
void Dialog::draw() {
diff --git a/engines/myst3/movie.cpp b/engines/myst3/movie.cpp
index 7006dc3232..7f9201a953 100644
--- a/engines/myst3/movie.cpp
+++ b/engines/myst3/movie.cpp
@@ -205,7 +205,7 @@ void Movie::pause(bool p) {
Movie::~Movie() {
if (_texture)
- _vm->_gfx->freeTexture(_texture);
+ delete _texture;
delete _subtitles;
}
diff --git a/engines/myst3/node.cpp b/engines/myst3/node.cpp
index 9295f6112f..5846c41bbd 100644
--- a/engines/myst3/node.cpp
+++ b/engines/myst3/node.cpp
@@ -81,7 +81,7 @@ Face::~Face() {
}
if (_texture) {
- _vm->_gfx->freeTexture(_texture);
+ delete _texture;
}
}
diff --git a/engines/myst3/subtitles.cpp b/engines/myst3/subtitles.cpp
index f79f524e30..1a782e31b9 100644
--- a/engines/myst3/subtitles.cpp
+++ b/engines/myst3/subtitles.cpp
@@ -517,7 +517,7 @@ Subtitles *Subtitles::create(Myst3Engine *vm, uint32 id) {
void Subtitles::freeTexture() {
if (_texture) {
- _vm->_gfx->freeTexture(_texture);
+ delete _texture;
_texture = nullptr;
}
}
diff --git a/engines/myst3/transition.cpp b/engines/myst3/transition.cpp
index a694d9924f..49b368522d 100644
--- a/engines/myst3/transition.cpp
+++ b/engines/myst3/transition.cpp
@@ -46,8 +46,7 @@ Transition::Transition(Myst3Engine *vm) :
}
Transition::~Transition() {
- _vm->_gfx->freeTexture(_sourceScreenshot);
-
+ delete _sourceScreenshot;
delete _frameLimiter;
}
@@ -124,8 +123,8 @@ void Transition::draw(TransitionType type) {
}
}
- _vm->_gfx->freeTexture(targetScreenshot);
- _vm->_gfx->freeTexture(_sourceScreenshot);
+ delete targetScreenshot;
+ delete _sourceScreenshot;
_sourceScreenshot = nullptr;
}
Commit: d18d32109246acb0e281fb6b9c0deabeecb0462d
https://github.com/scummvm/scummvm/commit/d18d32109246acb0e281fb6b9c0deabeecb0462d
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-12-05T20:28:23+01:00
Commit Message:
MYST3: Split TinyGLTexture into two separate subclasses
Changed paths:
engines/myst3/cursor.cpp
engines/myst3/gfx.cpp
engines/myst3/gfx.h
engines/myst3/gfx_opengl.cpp
engines/myst3/gfx_opengl.h
engines/myst3/gfx_opengl_shaders.cpp
engines/myst3/gfx_opengl_shaders.h
engines/myst3/gfx_tinygl.cpp
engines/myst3/gfx_tinygl.h
engines/myst3/gfx_tinygl_texture.cpp
engines/myst3/gfx_tinygl_texture.h
engines/myst3/inventory.cpp
engines/myst3/menu.cpp
engines/myst3/movie.cpp
engines/myst3/node.cpp
engines/myst3/node.h
engines/myst3/nodecube.cpp
engines/myst3/subtitles.cpp
diff --git a/engines/myst3/cursor.cpp b/engines/myst3/cursor.cpp
index 7184024b0d..06a4bf259d 100644
--- a/engines/myst3/cursor.cpp
+++ b/engines/myst3/cursor.cpp
@@ -116,7 +116,7 @@ void Cursor::loadAvailableCursors() {
}
// Create and store the texture
- _textures.setVal(availableCursors[i].nodeID, _vm->_gfx->createTexture(surfaceRGBA));
+ _textures.setVal(availableCursors[i].nodeID, _vm->_gfx->createTexture2D(surfaceRGBA));
surfaceRGBA->free();
delete surfaceRGBA;
diff --git a/engines/myst3/gfx.cpp b/engines/myst3/gfx.cpp
index f61c811971..b8f2f35e8e 100644
--- a/engines/myst3/gfx.cpp
+++ b/engines/myst3/gfx.cpp
@@ -81,7 +81,7 @@ Renderer::~Renderer() {
}
void Renderer::initFont(const Graphics::Surface *surface) {
- _font = createTexture(surface);
+ _font = createTexture2D(surface);
}
void Renderer::freeFont() {
@@ -94,7 +94,7 @@ void Renderer::freeFont() {
Texture *Renderer::copyScreenshotToTexture() {
Graphics::Surface *surface = getScreenshot();
- Texture *texture = createTexture(surface);
+ Texture *texture = createTexture2D(surface);
surface->free();
delete surface;
diff --git a/engines/myst3/gfx.h b/engines/myst3/gfx.h
index 9216c0ee14..7aa17ee303 100644
--- a/engines/myst3/gfx.h
+++ b/engines/myst3/gfx.h
@@ -121,7 +121,8 @@ public:
virtual void initFont(const Graphics::Surface *surface);
virtual void freeFont();
- virtual Texture *createTexture(const Graphics::Surface *surface) = 0;
+ virtual Texture *createTexture3D(const Graphics::Surface *surface) = 0;
+ virtual Texture *createTexture2D(const Graphics::Surface *surface) { return createTexture3D(surface); }
virtual void drawRect2D(const Common::Rect &rect, uint8 a, uint8 r, uint8 g, uint8 b) = 0;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture,
diff --git a/engines/myst3/gfx_opengl.cpp b/engines/myst3/gfx_opengl.cpp
index f84fcf17e7..9ceeb96e9d 100644
--- a/engines/myst3/gfx_opengl.cpp
+++ b/engines/myst3/gfx_opengl.cpp
@@ -45,7 +45,7 @@ OpenGLRenderer::OpenGLRenderer(OSystem *system) :
OpenGLRenderer::~OpenGLRenderer() {
}
-Texture *OpenGLRenderer::createTexture(const Graphics::Surface *surface) {
+Texture *OpenGLRenderer::createTexture3D(const Graphics::Surface *surface) {
return new OpenGLTexture(surface);
}
diff --git a/engines/myst3/gfx_opengl.h b/engines/myst3/gfx_opengl.h
index 9e36d479d6..cd90daac15 100644
--- a/engines/myst3/gfx_opengl.h
+++ b/engines/myst3/gfx_opengl.h
@@ -41,7 +41,7 @@ public:
void clear() override;
void selectTargetWindow(Window *window, bool is3D, bool scaled) override;
- Texture *createTexture(const Graphics::Surface *surface) override;
+ Texture *createTexture3D(const Graphics::Surface *surface) override;
void drawRect2D(const Common::Rect &rect, uint8 a, uint8 r, uint8 g, uint8 b) override;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture,
diff --git a/engines/myst3/gfx_opengl_shaders.cpp b/engines/myst3/gfx_opengl_shaders.cpp
index d946665cb9..5b4e3b0656 100644
--- a/engines/myst3/gfx_opengl_shaders.cpp
+++ b/engines/myst3/gfx_opengl_shaders.cpp
@@ -115,7 +115,7 @@ ShaderRenderer::~ShaderRenderer() {
delete _textShader;
}
-Texture *ShaderRenderer::createTexture(const Graphics::Surface *surface) {
+Texture *ShaderRenderer::createTexture3D(const Graphics::Surface *surface) {
return new OpenGLTexture(surface);
}
diff --git a/engines/myst3/gfx_opengl_shaders.h b/engines/myst3/gfx_opengl_shaders.h
index 1f691ee82c..bc796d552a 100644
--- a/engines/myst3/gfx_opengl_shaders.h
+++ b/engines/myst3/gfx_opengl_shaders.h
@@ -42,7 +42,7 @@ public:
void clear() override;
void selectTargetWindow(Window *window, bool is3D, bool scaled) override;
- Texture *createTexture(const Graphics::Surface *surface) override;
+ Texture *createTexture3D(const Graphics::Surface *surface) override;
void drawRect2D(const Common::Rect &rect, uint8 a, uint8 r, uint8 g, uint8 b) override;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture,
diff --git a/engines/myst3/gfx_tinygl.cpp b/engines/myst3/gfx_tinygl.cpp
index a965fa994b..c50479dfc4 100644
--- a/engines/myst3/gfx_tinygl.cpp
+++ b/engines/myst3/gfx_tinygl.cpp
@@ -48,8 +48,12 @@ TinyGLRenderer::TinyGLRenderer(OSystem *system) :
TinyGLRenderer::~TinyGLRenderer() {
}
-Texture *TinyGLRenderer::createTexture(const Graphics::Surface *surface) {
- return new TinyGLTexture(surface);
+Texture *TinyGLRenderer::createTexture2D(const Graphics::Surface *surface) {
+ return new TinyGLTexture2D(surface);
+}
+
+Texture *TinyGLRenderer::createTexture3D(const Graphics::Surface *surface) {
+ return new TinyGLTexture3D(surface);
}
@@ -147,6 +151,8 @@ void TinyGLRenderer::drawRect2D(const Common::Rect &rect, uint8 a, uint8 r, uint
void TinyGLRenderer::drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect,
Texture *texture, float transparency, bool additiveBlending) {
+ TinyGLTexture2D *glTexture = static_cast<TinyGLTexture2D *>(texture);
+
const float sLeft = screenRect.left;
const float sTop = screenRect.top;
const float sWidth = screenRect.width();
@@ -173,14 +179,14 @@ void TinyGLRenderer::drawTexturedRect2D(const Common::Rect &screenRect, const Co
Graphics::BlitTransform transform(sLeft + viewPort[0], sTop + viewPort[1]);
transform.sourceRectangle(textureRect.left, textureRect.top, sWidth, sHeight);
transform.tint(transparency);
- tglBlit(((TinyGLTexture *)texture)->getBlitTexture(), transform);
+ tglBlit(glTexture->getBlitTexture(), transform);
tglDisable(TGL_BLEND);
tglDepthMask(TGL_TRUE);
}
void TinyGLRenderer::draw2DText(const Common::String &text, const Common::Point &position) {
- TinyGLTexture *glFont = static_cast<TinyGLTexture *>(_font);
+ TinyGLTexture2D *glFont = static_cast<TinyGLTexture2D *>(_font);
// The font only has uppercase letters
Common::String textToDraw = text;
@@ -193,7 +199,6 @@ void TinyGLRenderer::draw2DText(const Common::String &text, const Common::Point
tglDepthMask(TGL_FALSE);
tglColor3f(1.0f, 1.0f, 1.0f);
- tglBindTexture(TGL_TEXTURE_2D, glFont->id);
int x = position.x;
int y = position.y;
@@ -217,7 +222,7 @@ void TinyGLRenderer::draw2DText(const Common::String &text, const Common::Point
}
void TinyGLRenderer::drawFace(uint face, Texture *texture) {
- TinyGLTexture *glTexture = static_cast<TinyGLTexture *>(texture);
+ TinyGLTexture3D *glTexture = static_cast<TinyGLTexture3D *>(texture);
tglBindTexture(TGL_TEXTURE_2D, glTexture->id);
tglBegin(TGL_TRIANGLE_STRIP);
@@ -242,7 +247,7 @@ void TinyGLRenderer::drawCube(Texture **textures) {
void TinyGLRenderer::drawTexturedRect3D(const Math::Vector3d &topLeft, const Math::Vector3d &bottomLeft,
const Math::Vector3d &topRight, const Math::Vector3d &bottomRight, Texture *texture) {
- TinyGLTexture *glTexture = static_cast<TinyGLTexture *>(texture);
+ TinyGLTexture3D *glTexture = static_cast<TinyGLTexture3D *>(texture);
tglBlendFunc(TGL_SRC_ALPHA, TGL_ONE_MINUS_SRC_ALPHA);
tglEnable(TGL_BLEND);
diff --git a/engines/myst3/gfx_tinygl.h b/engines/myst3/gfx_tinygl.h
index 9d40deae6a..9caceb26e9 100644
--- a/engines/myst3/gfx_tinygl.h
+++ b/engines/myst3/gfx_tinygl.h
@@ -42,7 +42,8 @@ public:
void clear() override;
void selectTargetWindow(Window *window, bool is3D, bool scaled) override;
- Texture *createTexture(const Graphics::Surface *surface) override;
+ Texture *createTexture2D(const Graphics::Surface *surface) override;
+ Texture *createTexture3D(const Graphics::Surface *surface) override;
void drawRect2D(const Common::Rect &rect, uint8 a, uint8 r, uint8 g, uint8 b) override;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture,
diff --git a/engines/myst3/gfx_tinygl_texture.cpp b/engines/myst3/gfx_tinygl_texture.cpp
index a6b410aac3..03d31a8011 100644
--- a/engines/myst3/gfx_tinygl_texture.cpp
+++ b/engines/myst3/gfx_tinygl_texture.cpp
@@ -25,7 +25,34 @@
namespace Myst3 {
-TinyGLTexture::TinyGLTexture(const Graphics::Surface *surface) {
+TinyGLTexture2D::TinyGLTexture2D(const Graphics::Surface *surface) {
+ width = surface->w;
+ height = surface->h;
+ format = surface->format;
+
+ _blitImage = Graphics::tglGenBlitImage();
+
+ update(surface);
+}
+
+TinyGLTexture2D::~TinyGLTexture2D() {
+ tglDeleteBlitImage(_blitImage);
+}
+
+void TinyGLTexture2D::update(const Graphics::Surface *surface) {
+ Graphics::tglUploadBlitImage(_blitImage, *surface, 0, false);
+}
+
+void TinyGLTexture2D::updatePartial(const Graphics::Surface *surface, const Common::Rect &rect) {
+ // FIXME: TinyGL does not support partial texture update
+ update(surface);
+}
+
+Graphics::BlitImage *TinyGLTexture2D::getBlitTexture() const {
+ return _blitImage;
+}
+
+TinyGLTexture3D::TinyGLTexture3D(const Graphics::Surface *surface) {
width = surface->w;
height = surface->h;
format = surface->format;
@@ -48,30 +75,22 @@ TinyGLTexture::TinyGLTexture(const Graphics::Surface *surface) {
// NOTE: TinyGL doesn't have issues with white lines so doesn't need use TGL_CLAMP_TO_EDGE
tglTexParameteri(TGL_TEXTURE_2D, TGL_TEXTURE_WRAP_S, TGL_REPEAT);
tglTexParameteri(TGL_TEXTURE_2D, TGL_TEXTURE_WRAP_T, TGL_REPEAT);
- _blitImage = Graphics::tglGenBlitImage();
-
update(surface);
}
-TinyGLTexture::~TinyGLTexture() {
+TinyGLTexture3D::~TinyGLTexture3D() {
tglDeleteTextures(1, &id);
- tglDeleteBlitImage(_blitImage);
}
-void TinyGLTexture::update(const Graphics::Surface *surface) {
+void TinyGLTexture3D::update(const Graphics::Surface *surface) {
tglBindTexture(TGL_TEXTURE_2D, id);
tglTexImage2D(TGL_TEXTURE_2D, 0, internalFormat, width, height, 0,
internalFormat, sourceFormat, const_cast<void *>(surface->getPixels())); // TESTME: Not sure if it works.
- Graphics::tglUploadBlitImage(_blitImage, *surface, 0, false);
}
-void TinyGLTexture::updatePartial(const Graphics::Surface *surface, const Common::Rect &rect) {
+void TinyGLTexture3D::updatePartial(const Graphics::Surface *surface, const Common::Rect &rect) {
// FIXME: TinyGL does not support partial texture update
update(surface);
}
-Graphics::BlitImage *TinyGLTexture::getBlitTexture() const {
- return _blitImage;
-}
-
} // End of namespace Myst3
diff --git a/engines/myst3/gfx_tinygl_texture.h b/engines/myst3/gfx_tinygl_texture.h
index b80b836dfb..7676cdc845 100644
--- a/engines/myst3/gfx_tinygl_texture.h
+++ b/engines/myst3/gfx_tinygl_texture.h
@@ -32,21 +32,31 @@
namespace Myst3 {
-class TinyGLTexture : public Texture {
+class TinyGLTexture2D : public Texture {
public:
- TinyGLTexture(const Graphics::Surface *surface);
- virtual ~TinyGLTexture();
+ TinyGLTexture2D(const Graphics::Surface *surface);
+ virtual ~TinyGLTexture2D();
Graphics::BlitImage *getBlitTexture() const;
void update(const Graphics::Surface *surface) override;
void updatePartial(const Graphics::Surface *surface, const Common::Rect &rect) override;
+private:
+ Graphics::BlitImage *_blitImage;
+};
+
+class TinyGLTexture3D : public Texture {
+public:
+ TinyGLTexture3D(const Graphics::Surface *surface);
+ virtual ~TinyGLTexture3D();
+
+ void update(const Graphics::Surface *surface) override;
+ void updatePartial(const Graphics::Surface *surface, const Common::Rect &rect) override;
+
TGLuint id;
TGLuint internalFormat;
TGLuint sourceFormat;
-private:
- Graphics::BlitImage *_blitImage;
};
} // End of namespace Myst3
diff --git a/engines/myst3/inventory.cpp b/engines/myst3/inventory.cpp
index 4c9b6b3dcf..64a13e7593 100644
--- a/engines/myst3/inventory.cpp
+++ b/engines/myst3/inventory.cpp
@@ -55,7 +55,7 @@ Inventory::~Inventory() {
void Inventory::initializeTexture() {
Graphics::Surface *s = _vm->loadTexture(1204);
- _texture = _vm->_gfx->createTexture(s);
+ _texture = _vm->_gfx->createTexture2D(s);
s->free();
delete s;
@@ -345,7 +345,7 @@ DragItem::DragItem(Myst3Engine *vm, uint id):
_bink.start();
const Graphics::Surface *frame = _bink.decodeNextFrame();
- _texture = _vm->_gfx->createTexture(frame);
+ _texture = _vm->_gfx->createTexture2D(frame);
}
DragItem::~DragItem() {
diff --git a/engines/myst3/menu.cpp b/engines/myst3/menu.cpp
index b91dda5abb..3943f77e79 100644
--- a/engines/myst3/menu.cpp
+++ b/engines/myst3/menu.cpp
@@ -63,7 +63,7 @@ Dialog::Dialog(Myst3Engine *vm, uint id):
_bink.start();
const Graphics::Surface *frame = _bink.decodeNextFrame();
- _texture = _vm->_gfx->createTexture(frame);
+ _texture = _vm->_gfx->createTexture2D(frame);
_vm->_sound->playEffect(699, 10);
}
diff --git a/engines/myst3/movie.cpp b/engines/myst3/movie.cpp
index 7f9201a953..6b49784b50 100644
--- a/engines/myst3/movie.cpp
+++ b/engines/myst3/movie.cpp
@@ -96,6 +96,7 @@ void Movie::loadPosition(const ResourceDescription::VideoData &videoData) {
static const float scale = 50.0f;
_is3D = _vm->_state->getViewType() == kCube;
+ assert(!_texture);
Math::Vector3d planeDirection = videoData.v1;
planeDirection.normalize();
@@ -171,8 +172,10 @@ void Movie::drawNextFrameToTexture() {
if (frame) {
if (_texture)
_texture->update(frame);
+ else if (_is3D)
+ _texture = _vm->_gfx->createTexture3D(frame);
else
- _texture = _vm->_gfx->createTexture(frame);
+ _texture = _vm->_gfx->createTexture2D(frame);
}
}
@@ -213,6 +216,8 @@ Movie::~Movie() {
void Movie::setForce2d(bool b) {
_force2d = b;
if (_force2d) {
+ if (_is3D)
+ delete _texture;
_is3D = false;
}
}
@@ -560,8 +565,10 @@ void ProjectorMovie::update() {
if (_texture)
_texture->update(_frame);
+ else if (_is3D)
+ _texture = _vm->_gfx->createTexture3D(_frame);
else
- _texture = _vm->_gfx->createTexture(_frame);
+ _texture = _vm->_gfx->createTexture2D(_frame);
}
} // End of namespace Myst3
diff --git a/engines/myst3/node.cpp b/engines/myst3/node.cpp
index 5846c41bbd..a1b62d5f8f 100644
--- a/engines/myst3/node.cpp
+++ b/engines/myst3/node.cpp
@@ -35,14 +35,19 @@ namespace Myst3 {
void Face::setTextureFromJPEG(const ResourceDescription *jpegDesc) {
_bitmap = Myst3Engine::decodeJpeg(jpegDesc);
- _texture = _vm->_gfx->createTexture(_bitmap);
+ if (_is3D) {
+ _texture = _vm->_gfx->createTexture3D(_bitmap);
+ } else {
+ _texture = _vm->_gfx->createTexture2D(_bitmap);
+ }
// Set the whole texture as dirty
addTextureDirtyRect(Common::Rect(_bitmap->w, _bitmap->h));
}
-Face::Face(Myst3Engine *vm) :
+Face::Face(Myst3Engine *vm, bool is3D) :
_vm(vm),
+ _is3D(is3D),
_textureDirty(true),
_texture(nullptr),
_bitmap(nullptr),
diff --git a/engines/myst3/node.h b/engines/myst3/node.h
index 3290ec304b..a21a7566ab 100644
--- a/engines/myst3/node.h
+++ b/engines/myst3/node.h
@@ -44,7 +44,7 @@ public:
Graphics::Surface *_finalBitmap;
Texture *_texture;
- Face(Myst3Engine *vm);
+ Face(Myst3Engine *vm, bool is3D = false);
~Face();
void setTextureFromJPEG(const ResourceDescription *jpegDesc);
@@ -59,6 +59,7 @@ private:
Common::Rect _textureDirtyRect;
Myst3Engine *_vm;
+ bool _is3D;
};
class SpotItemFace {
diff --git a/engines/myst3/nodecube.cpp b/engines/myst3/nodecube.cpp
index 18e9d2cc23..fc561a6d4f 100644
--- a/engines/myst3/nodecube.cpp
+++ b/engines/myst3/nodecube.cpp
@@ -38,7 +38,7 @@ NodeCube::NodeCube(Myst3Engine *vm, uint16 id) :
if (!jpegDesc.isValid())
error("Face %d does not exist", id);
- _faces[i] = new Face(_vm);
+ _faces[i] = new Face(_vm, true);
_faces[i]->setTextureFromJPEG(&jpegDesc);
}
}
diff --git a/engines/myst3/subtitles.cpp b/engines/myst3/subtitles.cpp
index 1a782e31b9..104785421c 100644
--- a/engines/myst3/subtitles.cpp
+++ b/engines/myst3/subtitles.cpp
@@ -239,7 +239,7 @@ void FontSubtitles::createTexture() {
}
if (!_texture) {
- _texture = _vm->_gfx->createTexture(_surface);
+ _texture = _vm->_gfx->createTexture2D(_surface);
}
}
@@ -376,7 +376,7 @@ void MovieSubtitles::drawToTexture(const Phrase *phrase) {
const Graphics::Surface *surface = _bink.decodeNextFrame();
if (!_texture) {
- _texture = _vm->_gfx->createTexture(surface);
+ _texture = _vm->_gfx->createTexture2D(surface);
} else {
_texture->update(surface);
}
More information about the Scummvm-git-logs
mailing list