mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 21:59:17 +00:00
STARK: Fully separate bitmaps and textures
This commit is contained in:
parent
63a2dc4388
commit
5bd0ec43a6
70
engines/stark/gfx/bitmap.h
Normal file
70
engines/stark/gfx/bitmap.h
Normal file
@ -0,0 +1,70 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef STARK_GFX_BITMAP_H
|
||||
#define STARK_GFX_BITMAP_H
|
||||
|
||||
#include "common/hash-str.h"
|
||||
|
||||
namespace Graphics {
|
||||
struct Surface;
|
||||
}
|
||||
|
||||
namespace Stark {
|
||||
namespace Gfx {
|
||||
|
||||
/**
|
||||
* An abstract bitmap
|
||||
*/
|
||||
class Bitmap {
|
||||
public:
|
||||
Bitmap() : _width(0), _height(0) {}
|
||||
virtual ~Bitmap() {}
|
||||
|
||||
enum SamplingFilter {
|
||||
kNearest,
|
||||
kLinear
|
||||
};
|
||||
|
||||
/** Make the texture active */
|
||||
virtual void bind() const = 0;
|
||||
|
||||
/** Define or update the texture pixel data */
|
||||
virtual void update(const Graphics::Surface *surface, const byte *palette = nullptr) = 0;
|
||||
|
||||
/** Set the filter used when sampling the texture */
|
||||
virtual void setSamplingFilter(SamplingFilter filter) = 0;
|
||||
|
||||
/** Get the texture width */
|
||||
uint32 width() const { return _width; }
|
||||
|
||||
/** Get the texture height */
|
||||
uint32 height() const { return _height; }
|
||||
|
||||
protected:
|
||||
uint32 _width;
|
||||
uint32 _height;
|
||||
};
|
||||
|
||||
} // End of namespace Gfx
|
||||
} // End of namespace Stark
|
||||
|
||||
#endif // STARK_GFX_BITMAP_H
|
@ -38,6 +38,7 @@ namespace Gfx {
|
||||
|
||||
class SurfaceRenderer;
|
||||
class FadeRenderer;
|
||||
class Bitmap;
|
||||
class Texture;
|
||||
|
||||
class Driver {
|
||||
@ -67,15 +68,15 @@ public:
|
||||
* The caller is responsible for freeing it.
|
||||
*
|
||||
*/
|
||||
virtual Texture *createTexture(const Graphics::Surface *surface = nullptr, const byte *palette = nullptr) = 0;
|
||||
virtual Texture *createTexture() = 0;
|
||||
|
||||
/**
|
||||
* Create a new texture for 2D
|
||||
* Create a new bitmap for 2D
|
||||
*
|
||||
* The caller is responsible for freeing it.
|
||||
*
|
||||
*/
|
||||
virtual Texture *createBitmap(const Graphics::Surface *surface = nullptr, const byte *palette = nullptr) = 0;
|
||||
virtual Bitmap *createBitmap(const Graphics::Surface *surface = nullptr, const byte *palette = nullptr) = 0;
|
||||
|
||||
/**
|
||||
* Create a new actor renderer
|
||||
|
@ -28,6 +28,7 @@
|
||||
#if defined(USE_OPENGL_GAME)
|
||||
|
||||
#include "engines/stark/gfx/openglactor.h"
|
||||
#include "engines/stark/gfx/openglbitmap.h"
|
||||
#include "engines/stark/gfx/openglprop.h"
|
||||
#include "engines/stark/gfx/openglsurface.h"
|
||||
#include "engines/stark/gfx/openglfade.h"
|
||||
@ -188,18 +189,18 @@ void OpenGLDriver::setupLights(const LightEntryArray &lights) {
|
||||
}
|
||||
}
|
||||
|
||||
Texture *OpenGLDriver::createTexture(const Graphics::Surface *surface, const byte *palette) {
|
||||
OpenGlTexture *texture = new OpenGlTexture();
|
||||
|
||||
if (surface) {
|
||||
texture->update(surface, palette);
|
||||
}
|
||||
|
||||
return texture;
|
||||
Texture *OpenGLDriver::createTexture() {
|
||||
return new OpenGlTexture();
|
||||
}
|
||||
|
||||
Texture *OpenGLDriver::createBitmap(const Graphics::Surface *surface, const byte *palette) {
|
||||
return createTexture(surface, palette);
|
||||
Bitmap *OpenGLDriver::createBitmap(const Graphics::Surface *surface, const byte *palette) {
|
||||
OpenGlBitmap *bitmap = new OpenGlBitmap();
|
||||
|
||||
if (surface) {
|
||||
bitmap->update(surface, palette);
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
VisualActor *OpenGLDriver::createActorRenderer() {
|
||||
|
@ -48,8 +48,8 @@ public:
|
||||
void clearScreen() override;
|
||||
void flipBuffer() override;
|
||||
|
||||
Texture *createTexture(const Graphics::Surface *surface = nullptr, const byte *palette = nullptr) override;
|
||||
Texture *createBitmap(const Graphics::Surface *surface = nullptr, const byte *palette = nullptr) override;
|
||||
Texture *createTexture() override;
|
||||
Bitmap *createBitmap(const Graphics::Surface *surface = nullptr, const byte *palette = nullptr) override;
|
||||
VisualActor *createActorRenderer() override;
|
||||
VisualProp *createPropRenderer() override;
|
||||
SurfaceRenderer *createSurfaceRenderer() override;
|
||||
|
96
engines/stark/gfx/openglbitmap.cpp
Normal file
96
engines/stark/gfx/openglbitmap.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "engines/stark/gfx/openglbitmap.h"
|
||||
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
|
||||
#include "graphics/surface.h"
|
||||
|
||||
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
|
||||
|
||||
#include "graphics/opengl/context.h"
|
||||
|
||||
namespace Stark {
|
||||
namespace Gfx {
|
||||
|
||||
OpenGlBitmap::OpenGlBitmap() :
|
||||
Bitmap(),
|
||||
_id(0) {
|
||||
glGenTextures(1, &_id);
|
||||
|
||||
bind();
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
OpenGlBitmap::~OpenGlBitmap() {
|
||||
glDeleteTextures(1, &_id);
|
||||
}
|
||||
|
||||
void OpenGlBitmap::bind() const {
|
||||
glBindTexture(GL_TEXTURE_2D, _id);
|
||||
}
|
||||
|
||||
void OpenGlBitmap::update(const Graphics::Surface *surface, const byte *palette) {
|
||||
bind();
|
||||
|
||||
_width = surface->w;
|
||||
_height = surface->h;
|
||||
|
||||
if (surface->format.bytesPerPixel != 4) {
|
||||
// Convert the surface to texture format
|
||||
Graphics::Surface *convertedSurface = surface->convertTo(Driver::getRGBAPixelFormat(), palette);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, convertedSurface->w, convertedSurface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, convertedSurface->getPixels());
|
||||
|
||||
convertedSurface->free();
|
||||
delete convertedSurface;
|
||||
} else {
|
||||
assert(surface->format == Driver::getRGBAPixelFormat());
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->getPixels());
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGlBitmap::setSamplingFilter(Bitmap::SamplingFilter filter) {
|
||||
switch (filter) {
|
||||
case kNearest:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
break;
|
||||
case kLinear:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
default:
|
||||
warning("Unhandled sampling filter %d", filter);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Gfx
|
||||
} // End of namespace Stark
|
||||
|
||||
#endif // defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
|
56
engines/stark/gfx/openglbitmap.h
Normal file
56
engines/stark/gfx/openglbitmap.h
Normal file
@ -0,0 +1,56 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef STARK_GFX_OPENGL_BITMAP_H
|
||||
#define STARK_GFX_OPENGL_BITMAP_H
|
||||
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
|
||||
#include "graphics/opengl/system_headers.h"
|
||||
|
||||
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
|
||||
|
||||
namespace Stark {
|
||||
namespace Gfx {
|
||||
|
||||
/**
|
||||
* An OpenGL texture wrapper for 2D elements
|
||||
*/
|
||||
class OpenGlBitmap : public Bitmap {
|
||||
public:
|
||||
OpenGlBitmap();
|
||||
virtual ~OpenGlBitmap();
|
||||
|
||||
// Bitmap API
|
||||
void bind() const override;
|
||||
void update(const Graphics::Surface *surface, const byte *palette = nullptr) override;
|
||||
void setSamplingFilter(SamplingFilter filter) override;
|
||||
|
||||
protected:
|
||||
GLuint _id;
|
||||
};
|
||||
|
||||
} // End of namespace Gfx
|
||||
} // End of namespace Stark
|
||||
|
||||
#endif // defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
|
||||
|
||||
#endif // STARK_GFX_OPENGL_BITMAP_H
|
@ -28,6 +28,7 @@
|
||||
#if defined(USE_OPENGL_SHADERS)
|
||||
|
||||
#include "engines/stark/gfx/openglsactor.h"
|
||||
#include "engines/stark/gfx/openglbitmap.h"
|
||||
#include "engines/stark/gfx/openglsprop.h"
|
||||
#include "engines/stark/gfx/openglssurface.h"
|
||||
#include "engines/stark/gfx/openglsfade.h"
|
||||
@ -130,18 +131,18 @@ void OpenGLSDriver::flipBuffer() {
|
||||
g_system->updateScreen();
|
||||
}
|
||||
|
||||
Texture *OpenGLSDriver::createTexture(const Graphics::Surface *surface, const byte *palette) {
|
||||
OpenGlTexture *texture = new OpenGlTexture();
|
||||
|
||||
if (surface) {
|
||||
texture->update(surface, palette);
|
||||
}
|
||||
|
||||
return texture;
|
||||
Texture *OpenGLSDriver::createTexture() {
|
||||
return new OpenGlTexture();
|
||||
}
|
||||
|
||||
Texture *OpenGLSDriver::createBitmap(const Graphics::Surface *surface, const byte *palette) {
|
||||
return createTexture(surface, palette);
|
||||
Bitmap *OpenGLSDriver::createBitmap(const Graphics::Surface *surface, const byte *palette) {
|
||||
OpenGlBitmap *bitmap = new OpenGlBitmap();
|
||||
|
||||
if (surface) {
|
||||
bitmap->update(surface, palette);
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
VisualActor *OpenGLSDriver::createActorRenderer() {
|
||||
|
@ -50,8 +50,8 @@ public:
|
||||
void clearScreen() override;
|
||||
void flipBuffer() override;
|
||||
|
||||
Texture *createTexture(const Graphics::Surface *surface = nullptr, const byte *palette = nullptr) override;
|
||||
Texture *createBitmap(const Graphics::Surface *surface = nullptr, const byte *palette = nullptr) override;
|
||||
Texture *createTexture() override;
|
||||
Bitmap *createBitmap(const Graphics::Surface *surface = nullptr, const byte *palette = nullptr) override;
|
||||
VisualActor *createActorRenderer() override;
|
||||
VisualProp *createPropRenderer() override;
|
||||
SurfaceRenderer *createSurfaceRenderer() override;
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "engines/stark/gfx/openglssurface.h"
|
||||
|
||||
#include "engines/stark/gfx/opengls.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
|
||||
#if defined(USE_OPENGL_SHADERS)
|
||||
|
||||
@ -41,11 +41,11 @@ OpenGLSSurfaceRenderer::~OpenGLSSurfaceRenderer() {
|
||||
delete _shader;
|
||||
}
|
||||
|
||||
void OpenGLSSurfaceRenderer::render(const Texture *texture, const Common::Point &dest) {
|
||||
render(texture, dest, texture->width(), texture->height());
|
||||
void OpenGLSSurfaceRenderer::render(const Bitmap *bitmap, const Common::Point &dest) {
|
||||
render(bitmap, dest, bitmap->width(), bitmap->height());
|
||||
}
|
||||
|
||||
void OpenGLSSurfaceRenderer::render(const Texture *texture, const Common::Point &dest, uint width, uint height) {
|
||||
void OpenGLSSurfaceRenderer::render(const Bitmap *bitmap, const Common::Point &dest, uint width, uint height) {
|
||||
// Destination rectangle with given width and height
|
||||
_gfx->start2DMode();
|
||||
|
||||
@ -62,7 +62,7 @@ void OpenGLSSurfaceRenderer::render(const Texture *texture, const Common::Point
|
||||
Common::Rect nativeViewport = _gfx->getViewport();
|
||||
_shader->setUniform("viewport", Math::Vector2d(nativeViewport.width(), nativeViewport.height()));
|
||||
|
||||
texture->bind();
|
||||
bitmap->bind();
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
_shader->unbind();
|
||||
|
@ -36,7 +36,7 @@ namespace Stark {
|
||||
namespace Gfx {
|
||||
|
||||
class OpenGLSDriver;
|
||||
class Texture;
|
||||
class Bitmap;
|
||||
|
||||
/**
|
||||
* An programmable pipeline OpenGL surface renderer
|
||||
@ -47,8 +47,8 @@ public:
|
||||
virtual ~OpenGLSSurfaceRenderer();
|
||||
|
||||
// SurfaceRenderer API
|
||||
void render(const Texture *texture, const Common::Point &dest) override;
|
||||
void render(const Texture *texture, const Common::Point &dest, uint width, uint height) override;
|
||||
void render(const Bitmap *bitmap, const Common::Point &dest) override;
|
||||
void render(const Bitmap *bitmap, const Common::Point &dest, uint width, uint height) override;
|
||||
|
||||
private:
|
||||
Math::Vector2d normalizeOriginalCoordinates(int x, int y) const;
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "engines/stark/gfx/openglsurface.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
|
||||
#if defined(USE_OPENGL_GAME)
|
||||
|
||||
@ -43,11 +43,11 @@ OpenGLSurfaceRenderer::OpenGLSurfaceRenderer(OpenGLDriver *gfx) :
|
||||
OpenGLSurfaceRenderer::~OpenGLSurfaceRenderer() {
|
||||
}
|
||||
|
||||
void OpenGLSurfaceRenderer::render(const Texture *texture, const Common::Point &dest) {
|
||||
render(texture, dest, texture->width(), texture->height());
|
||||
void OpenGLSurfaceRenderer::render(const Bitmap *bitmap, const Common::Point &dest) {
|
||||
render(bitmap, dest, bitmap->width(), bitmap->height());
|
||||
}
|
||||
|
||||
void OpenGLSurfaceRenderer::render(const Texture *texture, const Common::Point &dest, uint width, uint height) {
|
||||
void OpenGLSurfaceRenderer::render(const Bitmap *bitmap, const Common::Point &dest, uint width, uint height) {
|
||||
// Destination rectangle with given width and height
|
||||
_gfx->start2DMode();
|
||||
|
||||
@ -104,7 +104,7 @@ void OpenGLSurfaceRenderer::render(const Texture *texture, const Common::Point &
|
||||
glTexCoordPointer(2, GL_FLOAT, 2 * sizeof(float), textCords);
|
||||
glColor3f(1.0f - _fadeLevel, 1.0f - _fadeLevel, 1.0f - _fadeLevel);
|
||||
|
||||
texture->bind();
|
||||
bitmap->bind();
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
@ -33,7 +33,7 @@ namespace Stark {
|
||||
namespace Gfx {
|
||||
|
||||
class OpenGLDriver;
|
||||
class Texture;
|
||||
class Bitmap;
|
||||
|
||||
struct _SurfaceVertex {
|
||||
float x;
|
||||
@ -50,8 +50,8 @@ public:
|
||||
virtual ~OpenGLSurfaceRenderer();
|
||||
|
||||
// SurfaceRenderer API
|
||||
void render(const Texture *texture, const Common::Point &dest) override;
|
||||
void render(const Texture *texture, const Common::Point &dest, uint width, uint height) override;
|
||||
void render(const Bitmap *bitmap, const Common::Point &dest) override;
|
||||
void render(const Bitmap *bitmap, const Common::Point &dest, uint width, uint height) override;
|
||||
|
||||
private:
|
||||
Math::Vector2d normalizeOriginalCoordinates(int x, int y) const;
|
||||
|
@ -56,11 +56,6 @@ void OpenGlTexture::bind() const {
|
||||
}
|
||||
|
||||
void OpenGlTexture::updateLevel(uint32 level, const Graphics::Surface *surface, const byte *palette) {
|
||||
if (level == 0) {
|
||||
_width = surface->w;
|
||||
_height = surface->h;
|
||||
}
|
||||
|
||||
if (surface->format.bytesPerPixel != 4) {
|
||||
// Convert the surface to texture format
|
||||
Graphics::Surface *convertedSurface = surface->convertTo(Driver::getRGBAPixelFormat(), palette);
|
||||
@ -76,28 +71,6 @@ void OpenGlTexture::updateLevel(uint32 level, const Graphics::Surface *surface,
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGlTexture::update(const Graphics::Surface *surface, const byte *palette) {
|
||||
bind();
|
||||
updateLevel(0, surface, palette);
|
||||
}
|
||||
|
||||
void OpenGlTexture::setSamplingFilter(Texture::SamplingFilter filter) {
|
||||
assert(_levelCount == 0);
|
||||
|
||||
switch (filter) {
|
||||
case kNearest:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
break;
|
||||
case kLinear:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
default:
|
||||
warning("Unhandled sampling filter %d", filter);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGlTexture::setLevelCount(uint32 count) {
|
||||
_levelCount = count;
|
||||
|
||||
|
@ -41,8 +41,6 @@ public:
|
||||
|
||||
// Texture API
|
||||
void bind() const override;
|
||||
void update(const Graphics::Surface *surface, const byte *palette = nullptr) override;
|
||||
void setSamplingFilter(SamplingFilter filter) override;
|
||||
void setLevelCount(uint32 count) override;
|
||||
void addLevel(uint32 level, const Graphics::Surface *surface, const byte *palette = nullptr) override;
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
namespace Stark {
|
||||
namespace Gfx {
|
||||
|
||||
class Texture;
|
||||
class Bitmap;
|
||||
|
||||
/**
|
||||
* A renderer to draw textures as two dimensional surfaces to the current viewport
|
||||
@ -38,14 +38,14 @@ public:
|
||||
virtual ~SurfaceRenderer();
|
||||
|
||||
/**
|
||||
* Draw a 2D surface from the specified texture
|
||||
* Draw a 2D surface from the specified bitmap
|
||||
*/
|
||||
virtual void render(const Texture *texture, const Common::Point &dest) = 0;
|
||||
virtual void render(const Bitmap *bitmap, const Common::Point &dest) = 0;
|
||||
|
||||
/**
|
||||
* Draw a 2D surface from the specified texture with given width and height
|
||||
* Draw a 2D surface from the specified bitmap with given width and height
|
||||
*/
|
||||
virtual void render(const Texture *texture, const Common::Point &dest, uint width, uint height) = 0;
|
||||
virtual void render(const Bitmap *bitmap, const Common::Point &dest, uint width, uint height) = 0;
|
||||
|
||||
/**
|
||||
* When this is set to true, the texture size is expected to be in current
|
||||
|
@ -26,14 +26,6 @@
|
||||
namespace Stark {
|
||||
namespace Gfx {
|
||||
|
||||
Texture::Texture() :
|
||||
_width(0),
|
||||
_height(0) {
|
||||
}
|
||||
|
||||
Texture::~Texture() {
|
||||
}
|
||||
|
||||
TextureSet::TextureSet() {
|
||||
}
|
||||
|
||||
|
@ -36,23 +36,12 @@ namespace Gfx {
|
||||
*/
|
||||
class Texture {
|
||||
public:
|
||||
Texture();
|
||||
virtual ~Texture();
|
||||
|
||||
enum SamplingFilter {
|
||||
kNearest,
|
||||
kLinear
|
||||
};
|
||||
Texture() {}
|
||||
virtual ~Texture() {}
|
||||
|
||||
/** Make the texture active */
|
||||
virtual void bind() const = 0;
|
||||
|
||||
/** Define or update the texture pixel data */
|
||||
virtual void update(const Graphics::Surface *surface, const byte *palette = nullptr) = 0;
|
||||
|
||||
/** Set the filter used when sampling the texture */
|
||||
virtual void setSamplingFilter(SamplingFilter filter) = 0;
|
||||
|
||||
/**
|
||||
* Define the total number of levels of details
|
||||
*
|
||||
@ -64,16 +53,6 @@ public:
|
||||
* Add a detail level to the texture
|
||||
*/
|
||||
virtual void addLevel(uint32 level, const Graphics::Surface *surface, const byte *palette = nullptr) = 0;
|
||||
|
||||
/** Get the texture width */
|
||||
uint32 width() const { return _width; }
|
||||
|
||||
/** Get the texture height */
|
||||
uint32 height() const { return _height; }
|
||||
|
||||
protected:
|
||||
uint32 _width;
|
||||
uint32 _height;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -26,11 +26,11 @@
|
||||
|
||||
#include "engines/stark/gfx/tinygl.h"
|
||||
#include "engines/stark/gfx/tinyglactor.h"
|
||||
#include "engines/stark/gfx/tinyglbitmap.h"
|
||||
#include "engines/stark/gfx/tinyglprop.h"
|
||||
#include "engines/stark/gfx/tinyglsurface.h"
|
||||
#include "engines/stark/gfx/tinyglfade.h"
|
||||
#include "engines/stark/gfx/tinygltexture.h"
|
||||
#include "engines/stark/gfx/tinyglbitmap.h"
|
||||
#include "engines/stark/scene.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
|
||||
@ -103,17 +103,11 @@ void TinyGLDriver::flipBuffer() {
|
||||
g_system->updateScreen();
|
||||
}
|
||||
|
||||
Texture *TinyGLDriver::createTexture(const Graphics::Surface *surface, const byte *palette) {
|
||||
TinyGlTexture *texture = new TinyGlTexture();
|
||||
|
||||
if (surface) {
|
||||
texture->update(surface, palette);
|
||||
}
|
||||
|
||||
return texture;
|
||||
Texture *TinyGLDriver::createTexture() {
|
||||
return new TinyGlTexture();
|
||||
}
|
||||
|
||||
Texture *TinyGLDriver::createBitmap(const Graphics::Surface *surface, const byte *palette) {
|
||||
Bitmap *TinyGLDriver::createBitmap(const Graphics::Surface *surface, const byte *palette) {
|
||||
TinyGlBitmap *texture = new TinyGlBitmap();
|
||||
|
||||
if (surface) {
|
||||
|
@ -47,8 +47,8 @@ public:
|
||||
void clearScreen() override;
|
||||
void flipBuffer() override;
|
||||
|
||||
Texture *createTexture(const Graphics::Surface *surface = nullptr, const byte *palette = nullptr) override;
|
||||
Texture *createBitmap(const Graphics::Surface *surface = nullptr, const byte *palette = nullptr) override;
|
||||
Texture *createTexture() override;
|
||||
Bitmap *createBitmap(const Graphics::Surface *surface = nullptr, const byte *palette = nullptr) override;
|
||||
VisualActor *createActorRenderer() override;
|
||||
VisualProp *createPropRenderer() override;
|
||||
SurfaceRenderer *createSurfaceRenderer() override;
|
||||
|
@ -28,8 +28,8 @@ namespace Stark {
|
||||
namespace Gfx {
|
||||
|
||||
TinyGlBitmap::TinyGlBitmap() :
|
||||
Texture(),
|
||||
_texture1x1Color(0) {
|
||||
Bitmap(),
|
||||
_1x1Color(0) {
|
||||
_blitImage = tglGenBlitImage();
|
||||
}
|
||||
|
||||
@ -40,41 +40,31 @@ TinyGlBitmap::~TinyGlBitmap() {
|
||||
void TinyGlBitmap::bind() const {
|
||||
}
|
||||
|
||||
void TinyGlBitmap::updateLevel(uint32 level, const Graphics::Surface *surface, const byte *palette) {
|
||||
void TinyGlBitmap::update(const Graphics::Surface *surface, const byte *palette) {
|
||||
_width = surface->w;
|
||||
_height = surface->h;
|
||||
|
||||
if (surface->format.bytesPerPixel != 4) {
|
||||
// Convert the surface to texture format
|
||||
// Convert the surface to bitmap format
|
||||
Graphics::Surface *convertedSurface = surface->convertTo(Driver::getRGBAPixelFormat(), palette);
|
||||
tglUploadBlitImage(_blitImage, *convertedSurface, 0, false);
|
||||
convertedSurface->free();
|
||||
delete convertedSurface;
|
||||
} else {
|
||||
assert(surface->format == Driver::getRGBAPixelFormat());
|
||||
// W/A for 1x1 size texture
|
||||
// store pixel color used later fo creating scalled texture
|
||||
// W/A for 1x1 size bitmap
|
||||
// store pixel color used later fo creating scalled bitmap
|
||||
if (_width == 1 && _height == 1) {
|
||||
_texture1x1Color = surface->getPixel(0, 0);
|
||||
_1x1Color = surface->getPixel(0, 0);
|
||||
}
|
||||
tglUploadBlitImage(_blitImage, *surface, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
void TinyGlBitmap::update(const Graphics::Surface *surface, const byte *palette) {
|
||||
updateLevel(0, surface, palette);
|
||||
void TinyGlBitmap::setSamplingFilter(Bitmap::SamplingFilter filter) {
|
||||
}
|
||||
|
||||
void TinyGlBitmap::setSamplingFilter(Texture::SamplingFilter filter) {
|
||||
}
|
||||
|
||||
void TinyGlBitmap::setLevelCount(uint32 count) {
|
||||
}
|
||||
|
||||
void TinyGlBitmap::addLevel(uint32 level, const Graphics::Surface *surface, const byte *palette) {
|
||||
}
|
||||
|
||||
TinyGL::BlitImage *TinyGlBitmap::getBlitTexture() const {
|
||||
TinyGL::BlitImage *TinyGlBitmap::getBlitImage() const {
|
||||
return _blitImage;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#ifndef STARK_GFX_TINYGL_BITMAP_H
|
||||
#define STARK_GFX_TINYGL_BITMAP_H
|
||||
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
|
||||
#include "graphics/tinygl/tinygl.h"
|
||||
|
||||
@ -32,25 +32,21 @@ namespace Gfx {
|
||||
/**
|
||||
* An TinyGL bitmap wrapper
|
||||
*/
|
||||
class TinyGlBitmap : public Texture {
|
||||
class TinyGlBitmap : public Bitmap {
|
||||
public:
|
||||
TinyGlBitmap();
|
||||
virtual ~TinyGlBitmap();
|
||||
|
||||
// Texture API
|
||||
// Bitmap API
|
||||
void bind() const override;
|
||||
TinyGL::BlitImage *getBlitTexture() const;
|
||||
TinyGL::BlitImage *getBlitImage() const;
|
||||
void update(const Graphics::Surface *surface, const byte *palette = nullptr) override;
|
||||
void setSamplingFilter(SamplingFilter filter) override;
|
||||
void setLevelCount(uint32 count) override;
|
||||
void addLevel(uint32 level, const Graphics::Surface *surface, const byte *palette = nullptr) override;
|
||||
uint32 getTexture1x1Color() { return _texture1x1Color; }
|
||||
uint32 get1x1Color() { return _1x1Color; }
|
||||
|
||||
protected:
|
||||
void updateLevel(uint32 level, const Graphics::Surface *surface, const byte *palette = nullptr);
|
||||
|
||||
TinyGL::BlitImage *_blitImage;
|
||||
uint32 _texture1x1Color;
|
||||
uint32 _1x1Color;
|
||||
};
|
||||
|
||||
} // End of namespace Gfx
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include "engines/stark/gfx/tinyglsurface.h"
|
||||
#include "engines/stark/gfx/tinyglbitmap.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
|
||||
#include "graphics/tinygl/tinygl.h"
|
||||
|
||||
@ -36,11 +35,11 @@ TinyGLSurfaceRenderer::TinyGLSurfaceRenderer(TinyGLDriver *gfx) :
|
||||
TinyGLSurfaceRenderer::~TinyGLSurfaceRenderer() {
|
||||
}
|
||||
|
||||
void TinyGLSurfaceRenderer::render(const Texture *texture, const Common::Point &dest) {
|
||||
render(texture, dest, texture->width(), texture->height());
|
||||
void TinyGLSurfaceRenderer::render(const Bitmap *bitmap, const Common::Point &dest) {
|
||||
render(bitmap, dest, bitmap->width(), bitmap->height());
|
||||
}
|
||||
|
||||
void TinyGLSurfaceRenderer::render(const Texture *texture, const Common::Point &dest, uint width, uint height) {
|
||||
void TinyGLSurfaceRenderer::render(const Bitmap *bitmap, const Common::Point &dest, uint width, uint height) {
|
||||
if (width == 0 || height == 0)
|
||||
return;
|
||||
_gfx->start2DMode();
|
||||
@ -54,25 +53,25 @@ void TinyGLSurfaceRenderer::render(const Texture *texture, const Common::Point &
|
||||
auto verOffsetXY = normalizeOriginalCoordinates(dest.x, dest.y);
|
||||
auto nativeViewport = _gfx->getViewport();
|
||||
auto viewport = Math::Vector2d(nativeViewport.width(), nativeViewport.height());
|
||||
auto blitImage = ((TinyGlBitmap *)const_cast<Texture *>(texture))->getBlitTexture();
|
||||
int blitTextureWidth, blitTextureHeight;
|
||||
tglGetBlitImageSize(blitImage, blitTextureWidth, blitTextureHeight);
|
||||
auto blitImage = ((TinyGlBitmap *)const_cast<Bitmap *>(bitmap))->getBlitImage();
|
||||
int blitImageWidth, blitImageHeight;
|
||||
tglGetBlitImageSize(blitImage, blitImageWidth, blitImageHeight);
|
||||
int posX = viewport.getX() * verOffsetXY.getX() + nativeViewport.left;
|
||||
int posY = viewport.getY() * verOffsetXY.getY() + nativeViewport.top;
|
||||
TinyGL::BlitTransform transform(posX, posY);
|
||||
|
||||
// W/A for not clipped textures in prompt dialog
|
||||
// W/A for not clipped bitmaps in prompt dialog
|
||||
if (width == 256 && height == 256) {
|
||||
blitTextureHeight = viewport.getY() - dest.y;
|
||||
blitTextureWidth = viewport.getX() - dest.x;
|
||||
blitImageHeight = viewport.getY() - dest.y;
|
||||
blitImageWidth = viewport.getX() - dest.x;
|
||||
}
|
||||
|
||||
transform.sourceRectangle(0, 0, blitTextureWidth, blitTextureHeight);
|
||||
transform.sourceRectangle(0, 0, blitImageWidth, blitImageHeight);
|
||||
|
||||
// W/A for 1x1 dimension texture
|
||||
// it needs new filled and scalled texture based on one pixel color
|
||||
if (blitTextureWidth == 1 && blitTextureHeight == 1) {
|
||||
auto pixelColor = ((TinyGlBitmap *)const_cast<Texture *>(texture))->getTexture1x1Color();
|
||||
// W/A for 1x1 dimension bitmap
|
||||
// it needs new filled and scaled bitmap based on one pixel color
|
||||
if (blitImageWidth == 1 && blitImageHeight == 1) {
|
||||
auto pixelColor = ((TinyGlBitmap *)const_cast<Bitmap *>(bitmap))->get1x1Color();
|
||||
Graphics::Surface surface;
|
||||
surface.create(width, height, Driver::getRGBAPixelFormat());
|
||||
surface.fillRect(Common::Rect(0, 0, width, height), pixelColor);
|
||||
|
@ -33,7 +33,7 @@ namespace Stark {
|
||||
namespace Gfx {
|
||||
|
||||
class TinyGLDriver;
|
||||
class Texture;
|
||||
class Bitmap;
|
||||
|
||||
/**
|
||||
* An programmable pipeline TinyGL surface renderer
|
||||
@ -44,8 +44,8 @@ public:
|
||||
virtual ~TinyGLSurfaceRenderer();
|
||||
|
||||
// SurfaceRenderer API
|
||||
void render(const Texture *texture, const Common::Point &dest) override;
|
||||
void render(const Texture *texture, const Common::Point &dest, uint width, uint height) override;
|
||||
void render(const Bitmap *bitmap, const Common::Point &dest) override;
|
||||
void render(const Bitmap *bitmap, const Common::Point &dest, uint width, uint height) override;
|
||||
|
||||
private:
|
||||
Math::Vector2d normalizeOriginalCoordinates(int x, int y) const;
|
||||
|
@ -51,11 +51,6 @@ void TinyGlTexture::bind() const {
|
||||
}
|
||||
|
||||
void TinyGlTexture::updateLevel(uint32 level, const Graphics::Surface *surface, const byte *palette) {
|
||||
if (level == 0) {
|
||||
_width = surface->w;
|
||||
_height = surface->h;
|
||||
}
|
||||
|
||||
if (surface->format.bytesPerPixel != 4) {
|
||||
// Convert the surface to texture format
|
||||
Graphics::Surface *convertedSurface = surface->convertTo(Driver::getRGBAPixelFormat(), palette);
|
||||
@ -70,28 +65,6 @@ void TinyGlTexture::updateLevel(uint32 level, const Graphics::Surface *surface,
|
||||
}
|
||||
}
|
||||
|
||||
void TinyGlTexture::update(const Graphics::Surface *surface, const byte *palette) {
|
||||
bind();
|
||||
updateLevel(0, surface, palette);
|
||||
}
|
||||
|
||||
void TinyGlTexture::setSamplingFilter(Texture::SamplingFilter filter) {
|
||||
assert(_levelCount == 0);
|
||||
|
||||
switch (filter) {
|
||||
case kNearest:
|
||||
tglTexParameteri(TGL_TEXTURE_2D, TGL_TEXTURE_MIN_FILTER, TGL_NEAREST);
|
||||
tglTexParameteri(TGL_TEXTURE_2D, TGL_TEXTURE_MAG_FILTER, TGL_NEAREST);
|
||||
break;
|
||||
case kLinear:
|
||||
tglTexParameteri(TGL_TEXTURE_2D, TGL_TEXTURE_MIN_FILTER, TGL_LINEAR);
|
||||
tglTexParameteri(TGL_TEXTURE_2D, TGL_TEXTURE_MAG_FILTER, TGL_LINEAR);
|
||||
break;
|
||||
default:
|
||||
warning("Unhandled sampling filter %d", filter);
|
||||
}
|
||||
}
|
||||
|
||||
void TinyGlTexture::setLevelCount(uint32 count) {
|
||||
_levelCount = count;
|
||||
|
||||
|
@ -39,8 +39,6 @@ public:
|
||||
|
||||
// Texture API
|
||||
void bind() const override;
|
||||
void update(const Graphics::Surface *surface, const byte *palette = nullptr) override;
|
||||
void setSamplingFilter(SamplingFilter filter) override;
|
||||
void setLevelCount(uint32 count) override;
|
||||
void addLevel(uint32 level, const Graphics::Surface *surface, const byte *palette = nullptr) override;
|
||||
|
||||
|
@ -10,6 +10,7 @@ MODULE_OBJS := \
|
||||
gfx/openglssurface.o \
|
||||
gfx/opengl.o \
|
||||
gfx/openglactor.o \
|
||||
gfx/openglbitmap.o \
|
||||
gfx/openglfade.o \
|
||||
gfx/openglprop.o \
|
||||
gfx/openglsurface.o \
|
||||
|
@ -358,7 +358,7 @@ void ImageText::resetVisual() {
|
||||
|
||||
VisualText *text = _visual->get<VisualText>();
|
||||
if (text) {
|
||||
text->resetTexture();
|
||||
text->reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,8 @@ bool Settings::shouldPreMultiplyReplacementPNGs() const {
|
||||
return ConfMan.getBool("replacement_png_premultiply_alpha");
|
||||
}
|
||||
|
||||
Gfx::Texture::SamplingFilter Settings::getImageSamplingFilter() const {
|
||||
return ConfMan.getBool("use_linear_filtering") ? Gfx::Texture::kLinear : Gfx::Texture::kNearest;
|
||||
Gfx::Bitmap::SamplingFilter Settings::getImageSamplingFilter() const {
|
||||
return ConfMan.getBool("use_linear_filtering") ? Gfx::Bitmap::kLinear : Gfx::Bitmap::kNearest;
|
||||
}
|
||||
|
||||
bool Settings::isFontAntialiasingEnabled() const {
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "common/language.h"
|
||||
#include "common/ustr.h"
|
||||
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
|
||||
struct ADGameDescription;
|
||||
@ -102,7 +102,7 @@ public:
|
||||
/**
|
||||
* Should the engine apply alpha pre-multiplication when loading replacement PNGs
|
||||
*
|
||||
* When rendering, textures are expected to be in pre-multiplied alpha format.
|
||||
* When rendering, bitmaps are expected to be in pre-multiplied alpha format.
|
||||
* It's best to have the PNGs in that format on file to speed up loading by removing
|
||||
* the need to convert them. However this option enables the conversion when loading
|
||||
* the files to they can be stored with regular alpha transparency for convenience
|
||||
@ -110,8 +110,8 @@ public:
|
||||
*/
|
||||
bool shouldPreMultiplyReplacementPNGs() const;
|
||||
|
||||
/** Should linear filtering be used when sampling the background image textures? */
|
||||
Gfx::Texture::SamplingFilter getImageSamplingFilter() const;
|
||||
/** Should linear filtering be used when sampling the background image bitmaps? */
|
||||
Gfx::Bitmap::SamplingFilter getImageSamplingFilter() const;
|
||||
|
||||
/** The codepage text is encoded in or this version of the game */
|
||||
Common::CodePage getTextCodePage() const;
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include "engines/stark/ui/cursor.h"
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/services/gameinterface.h"
|
||||
#include "engines/stark/services/global.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
@ -85,7 +84,7 @@ void Cursor::setItemActive(bool itemActive) {
|
||||
|
||||
void Cursor::onScreenChanged() {
|
||||
if (_mouseText) {
|
||||
_mouseText->resetTexture();
|
||||
_mouseText->reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "engines/stark/ui/dialogbox.h"
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/surfacerenderer.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
#include "engines/stark/services/fontprovider.h"
|
||||
#include "engines/stark/ui/cursor.h"
|
||||
@ -46,7 +46,7 @@ static const uint buttonVerticalMargin = 5;
|
||||
|
||||
DialogBox::DialogBox(StarkEngine *vm, Gfx::Driver *gfx, Cursor *cursor) :
|
||||
Window(gfx, cursor),
|
||||
_foregroundTexture(nullptr),
|
||||
_foreground(nullptr),
|
||||
_confirmCallback(nullptr) {
|
||||
_vm = vm;
|
||||
_surfaceRenderer = gfx->createSurfaceRenderer();
|
||||
@ -60,8 +60,8 @@ DialogBox::DialogBox(StarkEngine *vm, Gfx::Driver *gfx, Cursor *cursor) :
|
||||
uint32 blue = background->format.RGBToColor(26, 28, 57);
|
||||
background->fillRect(Common::Rect(256, 256), blue);
|
||||
}
|
||||
_backgroundTexture = gfx->createBitmap(background);
|
||||
_backgroundTexture->setSamplingFilter(Gfx::Texture::kLinear);
|
||||
_background = gfx->createBitmap(background);
|
||||
_background->setSamplingFilter(Gfx::Bitmap::kLinear);
|
||||
|
||||
background->free();
|
||||
delete background;
|
||||
@ -87,7 +87,7 @@ DialogBox::~DialogBox() {
|
||||
delete _confirmLabelVisual;
|
||||
delete _cancelLabelVisual;
|
||||
|
||||
delete _backgroundTexture;
|
||||
delete _background;
|
||||
|
||||
delete _surfaceRenderer;
|
||||
}
|
||||
@ -166,30 +166,30 @@ void DialogBox::recomputeLayout() {
|
||||
drawBevel(&foreground, _confirmButtonRect);
|
||||
drawBevel(&foreground, _cancelButtonRect);
|
||||
|
||||
_foregroundTexture = _gfx->createBitmap(&foreground);
|
||||
_foregroundTexture->setSamplingFilter(Gfx::Texture::kLinear);
|
||||
_foreground = _gfx->createBitmap(&foreground);
|
||||
_foreground->setSamplingFilter(Gfx::Bitmap::kLinear);
|
||||
|
||||
foreground.free();
|
||||
|
||||
Common::Point screenCenter(Gfx::Driver::kOriginalWidth / 2, Gfx::Driver::kOriginalHeight / 2);
|
||||
_position = Common::Rect::center(screenCenter.x, screenCenter.y,
|
||||
_foregroundTexture->width(), _foregroundTexture->height());
|
||||
_foreground->width(), _foreground->height());
|
||||
}
|
||||
|
||||
void DialogBox::freeForeground() {
|
||||
delete _foregroundTexture;
|
||||
_foregroundTexture = nullptr;
|
||||
delete _foreground;
|
||||
_foreground = nullptr;
|
||||
|
||||
if (_messageVisual) {
|
||||
_messageVisual->resetTexture();
|
||||
_messageVisual->reset();
|
||||
}
|
||||
|
||||
if (_confirmLabelVisual) {
|
||||
_confirmLabelVisual->resetTexture();
|
||||
_confirmLabelVisual->reset();
|
||||
}
|
||||
|
||||
if (_cancelLabelVisual) {
|
||||
_cancelLabelVisual->resetTexture();
|
||||
_cancelLabelVisual->reset();
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,12 +267,12 @@ Graphics::Surface *DialogBox::loadBackground() {
|
||||
}
|
||||
|
||||
void DialogBox::onRender() {
|
||||
uint32 backgroundRepeatX = ceil(_foregroundTexture->width() / (float)_backgroundTexture->width());
|
||||
uint32 backgroundRepeatX = ceil(_foreground->width() / (float)_background->width());
|
||||
for (uint i = 0; i < backgroundRepeatX; i++) {
|
||||
_surfaceRenderer->render(_backgroundTexture, Common::Point(i * _backgroundTexture->width(), 0));
|
||||
_surfaceRenderer->render(_background, Common::Point(i * _background->width(), 0));
|
||||
}
|
||||
|
||||
_surfaceRenderer->render(_foregroundTexture, Common::Point(0, 0));
|
||||
_surfaceRenderer->render(_foreground, Common::Point(0, 0));
|
||||
|
||||
_messageVisual->render(Common::Point(_messageRect.left, _messageRect.top));
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace Stark {
|
||||
|
||||
namespace Gfx {
|
||||
class SurfaceRenderer;
|
||||
class Texture;
|
||||
class Bitmap;
|
||||
}
|
||||
|
||||
typedef Common::Functor0<void> ConfirmCallback;
|
||||
@ -79,8 +79,8 @@ private:
|
||||
StarkEngine *_vm;
|
||||
|
||||
Gfx::SurfaceRenderer *_surfaceRenderer;
|
||||
Gfx::Texture *_backgroundTexture;
|
||||
Gfx::Texture *_foregroundTexture;
|
||||
Gfx::Bitmap *_background;
|
||||
Gfx::Bitmap *_foreground;
|
||||
|
||||
VisualText *_messageVisual;
|
||||
VisualText *_confirmLabelVisual;
|
||||
|
@ -384,7 +384,7 @@ void DialogTitleWidget::onClick() {
|
||||
}
|
||||
|
||||
void DialogTitleWidget::onScreenChanged() {
|
||||
_text.resetTexture();
|
||||
_text.reset();
|
||||
}
|
||||
|
||||
} // End of namespace Stark
|
||||
|
@ -96,7 +96,7 @@ public:
|
||||
uint getHeight() { return _text.getRect().bottom - _text.getRect().top; }
|
||||
|
||||
void render() { _text.render(_pos); }
|
||||
void onScreenChanged() { _text.resetTexture(); }
|
||||
void onScreenChanged() { _text.reset(); }
|
||||
|
||||
private:
|
||||
const Color _color = Color(0x68, 0x05, 0x04);
|
||||
@ -122,8 +122,8 @@ public:
|
||||
}
|
||||
|
||||
void onScreenChanged() {
|
||||
_nameText.resetTexture();
|
||||
_lineText.resetTexture();
|
||||
_nameText.reset();
|
||||
_lineText.reset();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -92,7 +92,7 @@ public:
|
||||
|
||||
void setTextColor(const Color &color) { _title.setColor(color); }
|
||||
|
||||
void onScreenChanged() { _title.resetTexture(); }
|
||||
void onScreenChanged() { _title.reset(); }
|
||||
|
||||
private:
|
||||
const Color _textColorHovered = Color(0x1E, 0x1E, 0x96);
|
||||
|
@ -242,7 +242,7 @@ void StaticLocationWidget::onScreenChanged() {
|
||||
|
||||
VisualText *text = _renderEntry->getText();
|
||||
if (text) {
|
||||
text->resetTexture();
|
||||
text->reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "engines/stark/services/gamechapter.h"
|
||||
#include "engines/stark/services/gamemessage.h"
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
#include "engines/stark/gfx/surfacerenderer.h"
|
||||
#include "engines/stark/stark.h"
|
||||
#include "engines/stark/savemetadata.h"
|
||||
@ -239,7 +239,7 @@ SaveDataWidget::SaveDataWidget(int slot, Gfx::Driver *gfx, SaveLoadMenuScreen *s
|
||||
_screen(screen),
|
||||
_thumbWidth(kThumbnailWidth),
|
||||
_thumbHeight(kThumbnailHeight),
|
||||
_texture(gfx->createBitmap()),
|
||||
_bitmap(gfx->createBitmap()),
|
||||
_outline(gfx->createBitmap()),
|
||||
_surfaceRenderer(gfx->createSurfaceRenderer()),
|
||||
_textDesc(gfx),
|
||||
@ -261,7 +261,7 @@ SaveDataWidget::SaveDataWidget(int slot, Gfx::Driver *gfx, SaveLoadMenuScreen *s
|
||||
_outlineColor.a, _outlineColor.r, _outlineColor.g, _outlineColor.b
|
||||
);
|
||||
|
||||
// Create the outline texture
|
||||
// Create the outline bitmap
|
||||
Graphics::Surface lineSurface;
|
||||
lineSurface.create(_thumbWidth, _thumbHeight, pixelFormat);
|
||||
lineSurface.drawThickLine(0, 0, _thumbWidth - 1, 0, 2, 2, outlineColor);
|
||||
@ -284,13 +284,13 @@ SaveDataWidget::SaveDataWidget(int slot, Gfx::Driver *gfx, SaveLoadMenuScreen *s
|
||||
}
|
||||
|
||||
SaveDataWidget::~SaveDataWidget() {
|
||||
delete _texture;
|
||||
delete _bitmap;
|
||||
delete _outline;
|
||||
delete _surfaceRenderer;
|
||||
}
|
||||
|
||||
void SaveDataWidget::render() {
|
||||
_surfaceRenderer->render(_texture, _thumbPos);
|
||||
_surfaceRenderer->render(_bitmap, _thumbPos);
|
||||
_textDesc.render(_textDescPos);
|
||||
_textTime.render(_textTimePos);
|
||||
if (_isMouseHovered) {
|
||||
@ -315,8 +315,8 @@ void SaveDataWidget::onMouseMove(const Common::Point &mousePos) {
|
||||
|
||||
void SaveDataWidget::onScreenChanged() {
|
||||
StaticLocationWidget::onScreenChanged();
|
||||
_textDesc.resetTexture();
|
||||
_textTime.resetTexture();
|
||||
_textDesc.reset();
|
||||
_textTime.reset();
|
||||
}
|
||||
|
||||
void SaveDataWidget::loadSaveDataElements() {
|
||||
@ -335,8 +335,8 @@ void SaveDataWidget::loadSaveDataElements() {
|
||||
// Obtain the thumbnail
|
||||
if (metadata.version >= 9) {
|
||||
Graphics::Surface *thumb = metadata.readGameScreenThumbnail(&stream);
|
||||
_texture->update(thumb);
|
||||
_texture->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
_bitmap->update(thumb);
|
||||
_bitmap->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
|
||||
thumb->free();
|
||||
delete thumb;
|
||||
|
@ -30,7 +30,7 @@
|
||||
namespace Stark {
|
||||
|
||||
namespace Gfx {
|
||||
class Texture;
|
||||
class Bitmap;
|
||||
class SurfaceRenderer;
|
||||
}
|
||||
|
||||
@ -165,8 +165,8 @@ private:
|
||||
Common::Point _thumbPos, _textDescPos, _textTimePos;
|
||||
int _thumbWidth, _thumbHeight;
|
||||
|
||||
Gfx::Texture *_texture;
|
||||
Gfx::Texture *_outline;
|
||||
Gfx::Bitmap *_bitmap;
|
||||
Gfx::Bitmap *_outline;
|
||||
Gfx::SurfaceRenderer *_surfaceRenderer;
|
||||
|
||||
VisualText _textDesc, _textTime;
|
||||
|
@ -244,7 +244,7 @@ void ActionMenu::onGameLoop() {
|
||||
}
|
||||
|
||||
void ActionMenu::onScreenChanged() {
|
||||
_itemDescription->resetTexture();
|
||||
_itemDescription->reset();
|
||||
}
|
||||
|
||||
} // End of namespace Stark
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "engines/stark/ui/world/button.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/visual/explodingimage.h"
|
||||
#include "engines/stark/visual/flashingimage.h"
|
||||
#include "engines/stark/visual/image.h"
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
void render();
|
||||
bool containsPoint(const Common::Point &point);
|
||||
|
||||
/** Reset the hint text visual so it is rebuilt with the appropriate texture size */
|
||||
/** Reset the hint text visual so it is rebuilt with the appropriate size */
|
||||
void resetHintVisual();
|
||||
|
||||
/** Move execution of the button's icon anim script to the specified item */
|
||||
|
@ -49,8 +49,8 @@ DialogPanel::DialogPanel(Gfx::Driver *gfx, Cursor *cursor) :
|
||||
|
||||
_visible = true;
|
||||
|
||||
_activeBackGroundTexture = StarkStaticProvider->getUIElement(StaticProvider::kTextBackgroundActive);
|
||||
_passiveBackGroundTexture = StarkStaticProvider->getUIElement(StaticProvider::kTextBackgroundPassive);
|
||||
_activeBackGroundImage = StarkStaticProvider->getUIElement(StaticProvider::kTextBackgroundActive);
|
||||
_passiveBackGroundImage = StarkStaticProvider->getUIElement(StaticProvider::kTextBackgroundPassive);
|
||||
_scrollUpArrowImage = StarkStaticProvider->getUIElement(StaticProvider::kTextScrollUpArrow);
|
||||
_scrollDownArrowImage = StarkStaticProvider->getUIElement(StaticProvider::kTextScrollDownArrow);
|
||||
_dialogOptionBullet = StarkStaticProvider->getUIImage(StaticProvider::kDialogOptionBullet);
|
||||
@ -142,12 +142,12 @@ void DialogPanel::onGameLoop() {
|
||||
void DialogPanel::onRender() {
|
||||
// Draw options if available
|
||||
if (!_options.empty()) {
|
||||
_activeBackGroundTexture->render(Common::Point(0, 0), false);
|
||||
_activeBackGroundImage->render(Common::Point(0, 0), false);
|
||||
|
||||
renderOptions();
|
||||
renderScrollArrows();
|
||||
} else {
|
||||
_passiveBackGroundTexture->render(Common::Point(0, 0), false);
|
||||
_passiveBackGroundImage->render(Common::Point(0, 0), false);
|
||||
|
||||
// Draw subtitle if available
|
||||
if (_subtitleVisual && StarkSettings->getBoolSetting(Settings::kSubtitle)) {
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
/** Abort the currently playing dialog */
|
||||
void reset();
|
||||
|
||||
/** The screen resolution changed, rebuild the text textures accordingly */
|
||||
/** The screen resolution changed, rebuild the text accordingly */
|
||||
void onScreenChanged();
|
||||
|
||||
/** Scroll up and down the panel */
|
||||
@ -83,8 +83,8 @@ private:
|
||||
void updateFirstVisibleOption();
|
||||
void updateLastVisibleOption();
|
||||
|
||||
VisualImageXMG *_passiveBackGroundTexture;
|
||||
VisualImageXMG *_activeBackGroundTexture;
|
||||
VisualImageXMG *_passiveBackGroundImage;
|
||||
VisualImageXMG *_activeBackGroundImage;
|
||||
VisualImageXMG *_scrollUpArrowImage;
|
||||
VisualImageXMG *_scrollDownArrowImage;
|
||||
VisualImageXMG *_dialogOptionBullet;
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "engines/stark/ui/world/fmvscreen.h"
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/surfacerenderer.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
#include "engines/stark/services/archiveloader.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
#include "engines/stark/services/userinterface.h"
|
||||
@ -41,15 +41,15 @@ FMVScreen::FMVScreen(Gfx::Driver *gfx, Cursor *cursor) :
|
||||
_decoder->setDefaultHighColorFormat(Gfx::Driver::getRGBAPixelFormat());
|
||||
_decoder->setSoundType(Audio::Mixer::kSFXSoundType);
|
||||
|
||||
_texture = _gfx->createBitmap();
|
||||
_texture->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
_bitmap = _gfx->createBitmap();
|
||||
_bitmap->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
|
||||
_surfaceRenderer = _gfx->createSurfaceRenderer();
|
||||
}
|
||||
|
||||
FMVScreen::~FMVScreen() {
|
||||
delete _decoder;
|
||||
delete _texture;
|
||||
delete _bitmap;
|
||||
delete _surfaceRenderer;
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ void FMVScreen::onGameLoop() {
|
||||
if (isPlaying()) {
|
||||
if (_decoder->needsUpdate()) {
|
||||
const Graphics::Surface *decodedSurface = _decoder->decodeNextFrame();
|
||||
_texture->update(decodedSurface);
|
||||
_bitmap->update(decodedSurface);
|
||||
}
|
||||
} else {
|
||||
stop();
|
||||
@ -97,7 +97,7 @@ void FMVScreen::onGameLoop() {
|
||||
}
|
||||
|
||||
void FMVScreen::onRender() {
|
||||
_surfaceRenderer->render(_texture, Common::Point(0, Gfx::Driver::kTopBorderHeight),
|
||||
_surfaceRenderer->render(_bitmap, Common::Point(0, Gfx::Driver::kTopBorderHeight),
|
||||
Gfx::Driver::kGameViewportWidth, Gfx::Driver::kGameViewportHeight);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace Stark {
|
||||
|
||||
namespace Gfx {
|
||||
class SurfaceRenderer;
|
||||
class Texture;
|
||||
class Bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,7 +59,7 @@ private:
|
||||
|
||||
Video::BinkDecoder *_decoder;
|
||||
Gfx::SurfaceRenderer *_surfaceRenderer;
|
||||
Gfx::Texture *_texture;
|
||||
Gfx::Bitmap *_bitmap;
|
||||
};
|
||||
|
||||
} // End of namespace Stark
|
||||
|
@ -48,10 +48,10 @@ InventoryWindow::InventoryWindow(Gfx::Driver *gfx, Cursor *cursor, ActionMenu *a
|
||||
_position = Common::Rect(Gfx::Driver::kGameViewportWidth, Gfx::Driver::kGameViewportHeight);
|
||||
_position.translate(0, Gfx::Driver::kTopBorderHeight);
|
||||
|
||||
_backgroundTexture = StarkStaticProvider->getUIImage(StaticProvider::kInventoryBg);
|
||||
_backgroundImage = StarkStaticProvider->getUIImage(StaticProvider::kInventoryBg);
|
||||
|
||||
// Center the background in the window
|
||||
_backgroundRect = Common::Rect(_backgroundTexture->getWidth(), _backgroundTexture->getHeight());
|
||||
_backgroundRect = Common::Rect(_backgroundImage->getWidth(), _backgroundImage->getHeight());
|
||||
_backgroundRect.translate((_position.width() - _backgroundRect.width()) / 2,
|
||||
(_position.height() - _backgroundRect.height()) / 2);
|
||||
|
||||
@ -121,7 +121,7 @@ Common::Rect InventoryWindow::getItemRect(uint32 slot, VisualImageXMG *image) co
|
||||
void InventoryWindow::onRender() {
|
||||
_renderEntries = StarkGlobal->getInventory()->getInventoryRenderEntries();
|
||||
|
||||
_backgroundTexture->render(Common::Point(_backgroundRect.left, _backgroundRect.top), false);
|
||||
_backgroundImage->render(Common::Point(_backgroundRect.left, _backgroundRect.top), false);
|
||||
drawScrollArrows();
|
||||
|
||||
for (uint i = _firstVisibleSlot; i < _renderEntries.size() && isSlotVisible(i); i++) {
|
||||
|
@ -73,7 +73,7 @@ protected:
|
||||
private:
|
||||
ActionMenu *_actionMenu;
|
||||
|
||||
VisualImageXMG *_backgroundTexture;
|
||||
VisualImageXMG *_backgroundImage;
|
||||
Common::Rect _backgroundRect;
|
||||
|
||||
VisualImageXMG *_scrollUpArrowImage;
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
void onMouseMove(const Common::Point &pos) override;
|
||||
void onClick(const Common::Point &pos) override;
|
||||
|
||||
/** The screen resolution changed, rebuild the text textures accordingly */
|
||||
/** The screen resolution changed, rebuild the text accordingly */
|
||||
void onScreenChanged();
|
||||
|
||||
/** A new item has been added to the player's inventory. Play relevant animation */
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/surfacerenderer.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
|
||||
#include "engines/stark/services/global.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
@ -70,8 +70,8 @@ void VisualEffectBubbles::render(const Common::Point &position) {
|
||||
drawBubble(_bubbles[i]);
|
||||
}
|
||||
|
||||
_texture->update(_surface);
|
||||
_surfaceRenderer->render(_texture, position);
|
||||
_bitmap->update(_surface);
|
||||
_surfaceRenderer->render(_bitmap, position);
|
||||
}
|
||||
|
||||
void VisualEffectBubbles::setParams(const Common::String ¶ms) {
|
||||
|
@ -32,7 +32,6 @@ namespace Stark {
|
||||
namespace Gfx {
|
||||
class Driver;
|
||||
class SurfaceRenderer;
|
||||
class Texture;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/surfacerenderer.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
#include "engines/stark/services/settings.h"
|
||||
|
||||
@ -40,8 +40,8 @@ VisualEffect::VisualEffect(VisualType type, const Common::Point &size, Gfx::Driv
|
||||
_surface = new Graphics::Surface();
|
||||
_surface->create(size.x, size.y, Gfx::Driver::getRGBAPixelFormat());
|
||||
|
||||
_texture = _gfx->createBitmap(_surface);
|
||||
_texture->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
_bitmap = _gfx->createBitmap(_surface);
|
||||
_bitmap->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
|
||||
_surfaceRenderer = _gfx->createSurfaceRenderer();
|
||||
}
|
||||
@ -51,7 +51,7 @@ VisualEffect::~VisualEffect() {
|
||||
_surface->free();
|
||||
}
|
||||
delete _surface;
|
||||
delete _texture;
|
||||
delete _bitmap;
|
||||
delete _surfaceRenderer;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace Stark {
|
||||
namespace Gfx {
|
||||
class Driver;
|
||||
class SurfaceRenderer;
|
||||
class Texture;
|
||||
class Bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +53,7 @@ public:
|
||||
protected:
|
||||
Gfx::Driver *_gfx;
|
||||
Gfx::SurfaceRenderer *_surfaceRenderer;
|
||||
Gfx::Texture *_texture;
|
||||
Gfx::Bitmap *_bitmap;
|
||||
Graphics::Surface *_surface;
|
||||
|
||||
uint _timeBetweenTwoUpdates;
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/surfacerenderer.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
|
||||
#include "engines/stark/services/global.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
@ -64,8 +64,8 @@ void VisualEffectFireFlies::render(const Common::Point &position) {
|
||||
drawFireFly(_fireFlies[i]);
|
||||
}
|
||||
|
||||
_texture->update(_surface);
|
||||
_surfaceRenderer->render(_texture, position);
|
||||
_bitmap->update(_surface);
|
||||
_surfaceRenderer->render(_bitmap, position);
|
||||
}
|
||||
|
||||
void VisualEffectFireFlies::setParams(const Common::String ¶ms) {
|
||||
|
@ -32,7 +32,6 @@ namespace Stark {
|
||||
namespace Gfx {
|
||||
class Driver;
|
||||
class SurfaceRenderer;
|
||||
class Texture;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/surfacerenderer.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
|
||||
#include "engines/stark/services/global.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
@ -75,8 +75,8 @@ void VisualEffectFish::render(const Common::Point &position) {
|
||||
drawFish(_fishList[i]);
|
||||
}
|
||||
|
||||
_texture->update(_surface);
|
||||
_surfaceRenderer->render(_texture, position);
|
||||
_bitmap->update(_surface);
|
||||
_surfaceRenderer->render(_bitmap, position);
|
||||
}
|
||||
|
||||
void VisualEffectFish::setParams(const Common::String ¶ms) {
|
||||
|
@ -32,7 +32,6 @@ namespace Stark {
|
||||
namespace Gfx {
|
||||
class Driver;
|
||||
class SurfaceRenderer;
|
||||
class Texture;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/surfacerenderer.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
|
||||
#include "engines/stark/services/global.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
@ -37,7 +37,7 @@ namespace Stark {
|
||||
VisualExplodingImage::VisualExplodingImage(Gfx::Driver *gfx) :
|
||||
Visual(TYPE),
|
||||
_gfx(gfx),
|
||||
_texture(nullptr),
|
||||
_bitmap(nullptr),
|
||||
_surface(nullptr),
|
||||
_originalWidth(0),
|
||||
_originalHeight(0) {
|
||||
@ -49,20 +49,20 @@ VisualExplodingImage::~VisualExplodingImage() {
|
||||
_surface->free();
|
||||
}
|
||||
delete _surface;
|
||||
delete _texture;
|
||||
delete _bitmap;
|
||||
delete _surfaceRenderer;
|
||||
}
|
||||
|
||||
void VisualExplodingImage::initFromSurface(const Graphics::Surface *surface, uint originalWidth, uint originalHeight) {
|
||||
assert(!_surface && !_texture);
|
||||
assert(!_surface && !_bitmap);
|
||||
|
||||
_surface = new Graphics::Surface();
|
||||
_surface->copyFrom(*surface);
|
||||
_originalWidth = originalWidth;
|
||||
_originalHeight = originalHeight;
|
||||
|
||||
_texture = _gfx->createBitmap(_surface);
|
||||
_texture->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
_bitmap = _gfx->createBitmap(_surface);
|
||||
_bitmap->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
|
||||
// Create an explosion unit for each pixel in the surface
|
||||
_units.resize(_surface->w * _surface->h);
|
||||
@ -91,8 +91,8 @@ void VisualExplodingImage::render(const Common::Point &position) {
|
||||
_units[i].draw(_surface);
|
||||
}
|
||||
|
||||
_texture->update(_surface);
|
||||
_surfaceRenderer->render(_texture, position, _originalWidth, _originalHeight);
|
||||
_bitmap->update(_surface);
|
||||
_surfaceRenderer->render(_bitmap, position, _originalWidth, _originalHeight);
|
||||
}
|
||||
|
||||
VisualExplodingImage::ExplosionUnit::ExplosionUnit() :
|
||||
|
@ -40,7 +40,7 @@ namespace Stark {
|
||||
namespace Gfx {
|
||||
class Driver;
|
||||
class SurfaceRenderer;
|
||||
class Texture;
|
||||
class Bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,7 +84,7 @@ private:
|
||||
|
||||
Gfx::Driver *_gfx;
|
||||
Gfx::SurfaceRenderer *_surfaceRenderer;
|
||||
Gfx::Texture *_texture;
|
||||
Gfx::Bitmap *_bitmap;
|
||||
Graphics::Surface *_surface;
|
||||
|
||||
uint _originalWidth;
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/surfacerenderer.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
|
||||
#include "engines/stark/services/global.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
@ -39,7 +39,7 @@ const float VisualFlashingImage::_fadeValueMax = 0.55f;
|
||||
VisualFlashingImage::VisualFlashingImage(Gfx::Driver *gfx) :
|
||||
Visual(TYPE),
|
||||
_gfx(gfx),
|
||||
_texture(nullptr),
|
||||
_bitmap(nullptr),
|
||||
_fadeLevelIncreasing(true),
|
||||
_fadeLevel(0),
|
||||
_flashingTimeRemaining(150 * 33),
|
||||
@ -49,18 +49,18 @@ VisualFlashingImage::VisualFlashingImage(Gfx::Driver *gfx) :
|
||||
}
|
||||
|
||||
VisualFlashingImage::~VisualFlashingImage() {
|
||||
delete _texture;
|
||||
delete _bitmap;
|
||||
delete _surfaceRenderer;
|
||||
}
|
||||
|
||||
void VisualFlashingImage::initFromSurface(const Graphics::Surface *surface, uint originalWidth, uint originalHeight) {
|
||||
assert(!_texture);
|
||||
assert(!_bitmap);
|
||||
|
||||
_originalWidth = originalWidth;
|
||||
_originalHeight = originalHeight;
|
||||
|
||||
_texture = _gfx->createBitmap(surface);
|
||||
_texture->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
_bitmap = _gfx->createBitmap(surface);
|
||||
_bitmap->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
}
|
||||
|
||||
void VisualFlashingImage::updateFadeLevel() {
|
||||
@ -86,7 +86,7 @@ void VisualFlashingImage::render(const Common::Point &position) {
|
||||
updateFadeLevel();
|
||||
|
||||
_surfaceRenderer->setFadeLevel(_fadeLevel);
|
||||
_surfaceRenderer->render(_texture, position, _originalWidth, _originalHeight);
|
||||
_surfaceRenderer->render(_bitmap, position, _originalWidth, _originalHeight);
|
||||
}
|
||||
|
||||
} // End of namespace Stark
|
||||
|
@ -40,7 +40,7 @@ namespace Stark {
|
||||
namespace Gfx {
|
||||
class Driver;
|
||||
class SurfaceRenderer;
|
||||
class Texture;
|
||||
class Bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,7 +66,7 @@ private:
|
||||
|
||||
Gfx::Driver *_gfx;
|
||||
Gfx::SurfaceRenderer *_surfaceRenderer;
|
||||
Gfx::Texture *_texture;
|
||||
Gfx::Bitmap *_bitmap;
|
||||
|
||||
uint _originalWidth;
|
||||
uint _originalHeight;
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "engines/stark/formats/xmg.h"
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/surfacerenderer.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
#include "engines/stark/services/settings.h"
|
||||
|
||||
@ -36,7 +36,7 @@ namespace Stark {
|
||||
VisualImageXMG::VisualImageXMG(Gfx::Driver *gfx) :
|
||||
Visual(TYPE),
|
||||
_gfx(gfx),
|
||||
_texture(nullptr),
|
||||
_bitmap(nullptr),
|
||||
_surface(nullptr),
|
||||
_originalWidth(0),
|
||||
_originalHeight(0) {
|
||||
@ -48,7 +48,7 @@ VisualImageXMG::~VisualImageXMG() {
|
||||
_surface->free();
|
||||
}
|
||||
delete _surface;
|
||||
delete _texture;
|
||||
delete _bitmap;
|
||||
delete _surfaceRenderer;
|
||||
}
|
||||
|
||||
@ -57,12 +57,12 @@ void VisualImageXMG::setHotSpot(const Common::Point &hotspot) {
|
||||
}
|
||||
|
||||
void VisualImageXMG::load(Common::ReadStream *stream) {
|
||||
assert(!_surface && !_texture);
|
||||
assert(!_surface && !_bitmap);
|
||||
|
||||
// Decode the XMG
|
||||
_surface = Formats::XMGDecoder::decode(stream);
|
||||
_texture = _gfx->createBitmap(_surface);
|
||||
_texture->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
_bitmap = _gfx->createBitmap(_surface);
|
||||
_bitmap->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
|
||||
_originalWidth = _surface->w;
|
||||
_originalHeight = _surface->h;
|
||||
@ -73,7 +73,7 @@ void VisualImageXMG::readOriginalSize(Common::ReadStream *stream) {
|
||||
}
|
||||
|
||||
bool VisualImageXMG::loadPNG(Common::SeekableReadStream *stream) {
|
||||
assert(!_surface && !_texture);
|
||||
assert(!_surface && !_bitmap);
|
||||
|
||||
// Decode the XMG
|
||||
Image::PNGDecoder pngDecoder;
|
||||
@ -94,8 +94,8 @@ bool VisualImageXMG::loadPNG(Common::SeekableReadStream *stream) {
|
||||
_surface = pngDecoder.getSurface()->convertTo(Gfx::Driver::getRGBAPixelFormat());
|
||||
}
|
||||
|
||||
_texture = _gfx->createBitmap(_surface);
|
||||
_texture->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
_bitmap = _gfx->createBitmap(_surface);
|
||||
_bitmap->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -143,9 +143,9 @@ void VisualImageXMG::render(const Common::Point &position, bool useOffset, bool
|
||||
if (!unscaled) {
|
||||
uint width = _gfx->scaleWidthOriginalToCurrent(_originalWidth);
|
||||
uint height = _gfx->scaleHeightOriginalToCurrent(_originalHeight);
|
||||
_surfaceRenderer->render(_texture, drawPos, width, height);
|
||||
_surfaceRenderer->render(_bitmap, drawPos, width, height);
|
||||
} else {
|
||||
_surfaceRenderer->render(_texture, drawPos, _originalWidth, _originalHeight);
|
||||
_surfaceRenderer->render(_bitmap, drawPos, _originalWidth, _originalHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace Stark {
|
||||
namespace Gfx {
|
||||
class Driver;
|
||||
class SurfaceRenderer;
|
||||
class Texture;
|
||||
class Bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +95,7 @@ private:
|
||||
|
||||
Gfx::Driver *_gfx;
|
||||
Gfx::SurfaceRenderer *_surfaceRenderer;
|
||||
Gfx::Texture *_texture;
|
||||
Gfx::Bitmap *_bitmap;
|
||||
Graphics::Surface *_surface;
|
||||
Common::Point _hotspot;
|
||||
uint _originalWidth;
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/surfacerenderer.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
#include "engines/stark/scene.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
#include "engines/stark/services/settings.h"
|
||||
@ -40,7 +40,7 @@ VisualSmacker::VisualSmacker(Gfx::Driver *gfx) :
|
||||
Visual(TYPE),
|
||||
_gfx(gfx),
|
||||
_surface(nullptr),
|
||||
_texture(nullptr),
|
||||
_bitmap(nullptr),
|
||||
_decoder(nullptr),
|
||||
_position(0, 0),
|
||||
_originalWidth(0),
|
||||
@ -50,13 +50,13 @@ VisualSmacker::VisualSmacker(Gfx::Driver *gfx) :
|
||||
}
|
||||
|
||||
VisualSmacker::~VisualSmacker() {
|
||||
delete _texture;
|
||||
delete _bitmap;
|
||||
delete _decoder;
|
||||
delete _surfaceRenderer;
|
||||
}
|
||||
|
||||
void VisualSmacker::loadSmacker(Common::SeekableReadStream *stream) {
|
||||
delete _texture;
|
||||
delete _bitmap;
|
||||
delete _decoder;
|
||||
|
||||
_decoder = new Video::SmackerDecoder();
|
||||
@ -67,7 +67,7 @@ void VisualSmacker::loadSmacker(Common::SeekableReadStream *stream) {
|
||||
}
|
||||
|
||||
void VisualSmacker::loadBink(Common::SeekableReadStream *stream) {
|
||||
delete _texture;
|
||||
delete _bitmap;
|
||||
delete _decoder;
|
||||
|
||||
_decoder = new Video::BinkDecoder();
|
||||
@ -84,8 +84,8 @@ void VisualSmacker::init() {
|
||||
|
||||
rewind();
|
||||
|
||||
_texture = _gfx->createBitmap();
|
||||
_texture->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
_bitmap = _gfx->createBitmap();
|
||||
_bitmap->setSamplingFilter(StarkSettings->getImageSamplingFilter());
|
||||
|
||||
update();
|
||||
}
|
||||
@ -102,7 +102,7 @@ void VisualSmacker::render(const Common::Point &position) {
|
||||
assert(_decoder->getCurFrame() >= 0);
|
||||
|
||||
// The position argument contains the scroll offset
|
||||
_surfaceRenderer->render(_texture, _position - position, _originalWidth, _originalHeight);
|
||||
_surfaceRenderer->render(_bitmap, _position - position, _originalWidth, _originalHeight);
|
||||
}
|
||||
|
||||
void VisualSmacker::update() {
|
||||
@ -141,11 +141,11 @@ void VisualSmacker::update() {
|
||||
}
|
||||
}
|
||||
|
||||
_texture->update(&convertedSurface);
|
||||
_bitmap->update(&convertedSurface);
|
||||
|
||||
convertedSurface.free();
|
||||
} else {
|
||||
_texture->update(_surface);
|
||||
_bitmap->update(_surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace Stark {
|
||||
namespace Gfx {
|
||||
class Driver;
|
||||
class SurfaceRenderer;
|
||||
class Texture;
|
||||
class Bitmap;
|
||||
}
|
||||
|
||||
class VisualSmacker : public Visual {
|
||||
@ -97,7 +97,7 @@ private:
|
||||
|
||||
Gfx::Driver *_gfx;
|
||||
Gfx::SurfaceRenderer *_surfaceRenderer;
|
||||
Gfx::Texture *_texture;
|
||||
Gfx::Bitmap *_bitmap;
|
||||
int32 _overridenFramerate;
|
||||
};
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "engines/stark/debug.h"
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/surfacerenderer.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
#include "engines/stark/gfx/bitmap.h"
|
||||
#include "engines/stark/scene.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
#include "engines/stark/services/settings.h"
|
||||
@ -40,8 +40,8 @@ namespace Stark {
|
||||
VisualText::VisualText(Gfx::Driver *gfx) :
|
||||
Visual(TYPE),
|
||||
_gfx(gfx),
|
||||
_texture(nullptr),
|
||||
_bgTexture(nullptr),
|
||||
_bitmap(nullptr),
|
||||
_bgBitmap(nullptr),
|
||||
_color(Color(0, 0, 0)),
|
||||
_backgroundColor(Color(0, 0, 0, 0)),
|
||||
_align(Graphics::kTextAlignLeft),
|
||||
@ -55,20 +55,20 @@ VisualText::VisualText(Gfx::Driver *gfx) :
|
||||
}
|
||||
|
||||
VisualText::~VisualText() {
|
||||
freeTexture();
|
||||
freeBitmap();
|
||||
delete _surfaceRenderer;
|
||||
}
|
||||
|
||||
Common::Rect VisualText::getRect() {
|
||||
if (!_texture) {
|
||||
createTexture();
|
||||
if (!_bitmap) {
|
||||
createBitmap();
|
||||
}
|
||||
return _originalRect;
|
||||
}
|
||||
|
||||
void VisualText::setText(const Common::String &text) {
|
||||
if (_text != text) {
|
||||
freeTexture();
|
||||
freeBitmap();
|
||||
_text = text;
|
||||
}
|
||||
}
|
||||
@ -78,7 +78,7 @@ void VisualText::setColor(const Color &color) {
|
||||
return;
|
||||
}
|
||||
|
||||
freeTexture();
|
||||
freeBitmap();
|
||||
_color = color;
|
||||
}
|
||||
|
||||
@ -87,34 +87,34 @@ void VisualText::setBackgroundColor(const Color &color) {
|
||||
return;
|
||||
}
|
||||
|
||||
freeTexture();
|
||||
freeBitmap();
|
||||
_backgroundColor = color;
|
||||
}
|
||||
|
||||
void VisualText::setAlign(Graphics::TextAlign align) {
|
||||
if (align != _align) {
|
||||
freeTexture();
|
||||
freeBitmap();
|
||||
_align = align;
|
||||
}
|
||||
}
|
||||
|
||||
void VisualText::setTargetWidth(uint32 width) {
|
||||
if (width != _targetWidth) {
|
||||
freeTexture();
|
||||
freeBitmap();
|
||||
_targetWidth = width;
|
||||
}
|
||||
}
|
||||
|
||||
void VisualText::setTargetHeight(uint32 height) {
|
||||
if (height != _targetHeight) {
|
||||
freeTexture();
|
||||
freeBitmap();
|
||||
_targetHeight = height;
|
||||
}
|
||||
}
|
||||
|
||||
void VisualText::setFont(FontProvider::FontType type, int32 customFontIndex) {
|
||||
if (type != _fontType || customFontIndex != _fontCustomIndex) {
|
||||
freeTexture();
|
||||
freeBitmap();
|
||||
_fontType = type;
|
||||
_fontCustomIndex = customFontIndex;
|
||||
}
|
||||
@ -237,7 +237,7 @@ static void blendWithColor(Graphics::Surface *source, const Color &color) {
|
||||
}
|
||||
}
|
||||
|
||||
void VisualText::createTexture() {
|
||||
void VisualText::createBitmap() {
|
||||
Common::CodePage codePage = StarkSettings->getTextCodePage();
|
||||
Common::U32String unicodeText = Common::convertToU32String(_text.c_str(), codePage);
|
||||
|
||||
@ -292,13 +292,13 @@ void VisualText::createTexture() {
|
||||
blendWithColor(&surface, _color);
|
||||
multiplyColorWithAlpha(&surface);
|
||||
|
||||
// Create a texture from the surface
|
||||
_texture = _gfx->createBitmap(&surface);
|
||||
_texture->setSamplingFilter(Gfx::Texture::kNearest);
|
||||
// Create a bitmap from the surface
|
||||
_bitmap = _gfx->createBitmap(&surface);
|
||||
_bitmap->setSamplingFilter(Gfx::Bitmap::kNearest);
|
||||
|
||||
surface.free();
|
||||
|
||||
// If we have a background color, generate a 1x1px texture of that color
|
||||
// If we have a background color, generate a 1x1px bitmap of that color
|
||||
if (_backgroundColor.a != 0) {
|
||||
surface.create(1, 1, Gfx::Driver::getRGBAPixelFormat());
|
||||
|
||||
@ -309,33 +309,33 @@ void VisualText::createTexture() {
|
||||
surface.fillRect(Common::Rect(surface.w, surface.h), bgColor);
|
||||
multiplyColorWithAlpha(&surface);
|
||||
|
||||
_bgTexture = _gfx->createBitmap(&surface);
|
||||
_bgBitmap = _gfx->createBitmap(&surface);
|
||||
|
||||
surface.free();
|
||||
}
|
||||
}
|
||||
|
||||
void VisualText::freeTexture() {
|
||||
delete _texture;
|
||||
_texture = nullptr;
|
||||
delete _bgTexture;
|
||||
_bgTexture = nullptr;
|
||||
void VisualText::freeBitmap() {
|
||||
delete _bitmap;
|
||||
_bitmap = nullptr;
|
||||
delete _bgBitmap;
|
||||
_bgBitmap = nullptr;
|
||||
}
|
||||
|
||||
void VisualText::render(const Common::Point &position) {
|
||||
if (!_texture) {
|
||||
createTexture();
|
||||
if (!_bitmap) {
|
||||
createBitmap();
|
||||
}
|
||||
|
||||
if (_bgTexture) {
|
||||
_surfaceRenderer->render(_bgTexture, position, _texture->width(), _texture->height());
|
||||
if (_bgBitmap) {
|
||||
_surfaceRenderer->render(_bgBitmap, position, _bitmap->width(), _bitmap->height());
|
||||
}
|
||||
|
||||
_surfaceRenderer->render(_texture, position);
|
||||
_surfaceRenderer->render(_bitmap, position);
|
||||
}
|
||||
|
||||
void VisualText::resetTexture() {
|
||||
freeTexture();
|
||||
void VisualText::reset() {
|
||||
freeBitmap();
|
||||
}
|
||||
|
||||
bool VisualText::isBlank() {
|
||||
|
@ -34,7 +34,7 @@ namespace Stark {
|
||||
namespace Gfx {
|
||||
class Driver;
|
||||
class SurfaceRenderer;
|
||||
class Texture;
|
||||
class Bitmap;
|
||||
}
|
||||
|
||||
struct Color {
|
||||
@ -78,19 +78,19 @@ public:
|
||||
uint getTargetHeight() { return _targetHeight; }
|
||||
|
||||
void render(const Common::Point &position);
|
||||
void resetTexture();
|
||||
void reset();
|
||||
|
||||
private:
|
||||
void createTexture();
|
||||
void freeTexture();
|
||||
void createBitmap();
|
||||
void freeBitmap();
|
||||
|
||||
/** Check whether the text is blank */
|
||||
bool isBlank();
|
||||
|
||||
Gfx::Driver *_gfx;
|
||||
Gfx::SurfaceRenderer *_surfaceRenderer;
|
||||
Gfx::Texture *_texture;
|
||||
Gfx::Texture *_bgTexture;
|
||||
Gfx::Bitmap *_bitmap;
|
||||
Gfx::Bitmap *_bgBitmap;
|
||||
|
||||
Common::String _text;
|
||||
Color _color;
|
||||
|
Loading…
Reference in New Issue
Block a user