MYST3: Fix the OpenGL with shaders renderer initialization
... and make it slightly harder to break
This commit is contained in:
parent
bb760d4a47
commit
de7392c1b5
8 changed files with 42 additions and 51 deletions
|
@ -54,8 +54,6 @@ class Renderer {
|
|||
virtual void init(Graphics::PixelBuffer &screenBuffer) = 0;
|
||||
virtual void initFont(const Graphics::Surface *surface) = 0;
|
||||
|
||||
static Renderer *createRenderer(OSystem *system);
|
||||
|
||||
virtual void clear() = 0;
|
||||
virtual void setupCameraOrtho2D() = 0;
|
||||
virtual void setupCameraPerspective(float pitch, float heading, float fov) = 0;
|
||||
|
|
|
@ -42,10 +42,6 @@
|
|||
|
||||
namespace Myst3 {
|
||||
|
||||
Renderer *Renderer::createRenderer(OSystem *system) {
|
||||
return new OpenGLRenderer(system);
|
||||
}
|
||||
|
||||
static const GLfloat cubeFacesVertices[][12] = {
|
||||
// X Y Z
|
||||
{ -320.0f, -320.0f, -320.0f,
|
||||
|
|
|
@ -36,28 +36,28 @@ public:
|
|||
OpenGLRenderer(OSystem *_system);
|
||||
virtual ~OpenGLRenderer();
|
||||
|
||||
virtual void init(Graphics::PixelBuffer &screenBuffer);
|
||||
virtual void init(Graphics::PixelBuffer &screenBuffer) override;
|
||||
|
||||
virtual void clear();
|
||||
virtual void setupCameraOrtho2D();
|
||||
virtual void setupCameraPerspective(float pitch, float heading, float fov);
|
||||
virtual void clear() override;
|
||||
virtual void setupCameraOrtho2D() override;
|
||||
virtual void setupCameraPerspective(float pitch, float heading, float fov) override;
|
||||
|
||||
Texture *createTexture(const Graphics::Surface *surface);
|
||||
void freeTexture(Texture *texture);
|
||||
Texture *createTexture(const Graphics::Surface *surface) override;
|
||||
void freeTexture(Texture *texture) override;
|
||||
|
||||
virtual void drawRect2D(const Common::Rect &rect, uint32 color);
|
||||
virtual void drawRect2D(const Common::Rect &rect, uint32 color) override;
|
||||
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture,
|
||||
float transparency = -1.0, bool additiveBlending = false);
|
||||
float transparency = -1.0, bool additiveBlending = false) override;
|
||||
virtual void drawTexturedRect3D(const Math::Vector3d &topLeft, const Math::Vector3d &bottomLeft,
|
||||
const Math::Vector3d &topRight, const Math::Vector3d &bottomRight,
|
||||
Texture *texture);
|
||||
Texture *texture) override;
|
||||
|
||||
virtual void drawCube(Texture **textures);
|
||||
virtual void draw2DText(const Common::String &text, const Common::Point &position);
|
||||
virtual void drawCube(Texture **textures) override;
|
||||
virtual void draw2DText(const Common::String &text, const Common::Point &position) override;
|
||||
|
||||
virtual Graphics::Surface *getScreenshot();
|
||||
virtual Graphics::Surface *getScreenshot() override;
|
||||
|
||||
virtual void screenPosToDirection(const Common::Point screen, float &pitch, float &heading);
|
||||
virtual void screenPosToDirection(const Common::Point screen, float &pitch, float &heading) override;
|
||||
|
||||
private:
|
||||
void drawFace(uint face, Texture *texture);
|
||||
|
|
|
@ -66,10 +66,6 @@ Renderer *CreateGfxOpenGLShader(OSystem *system) {
|
|||
return new ShaderRenderer(system);
|
||||
}
|
||||
|
||||
Renderer *Renderer::createRenderer(OSystem *system) {
|
||||
return new ShaderRenderer(system);
|
||||
}
|
||||
|
||||
static const GLfloat box_vertices[] = {
|
||||
// XS YT
|
||||
0.0, 0.0,
|
||||
|
@ -143,7 +139,7 @@ void ShaderRenderer::freeTexture(Texture *texture) {
|
|||
delete glTexture;
|
||||
}
|
||||
|
||||
void ShaderRenderer::init() {
|
||||
void ShaderRenderer::init(Graphics::PixelBuffer &screenBuffer) {
|
||||
#ifndef USE_GLES2
|
||||
GLenum err = glewInit();
|
||||
if (err != GLEW_OK) {
|
||||
|
|
|
@ -37,28 +37,28 @@ public:
|
|||
ShaderRenderer(OSystem *_system);
|
||||
virtual ~ShaderRenderer();
|
||||
|
||||
virtual void init();
|
||||
virtual void init(Graphics::PixelBuffer &screenBuffer) override;
|
||||
|
||||
virtual void clear();
|
||||
virtual void setupCameraOrtho2D();
|
||||
virtual void setupCameraPerspective(float pitch, float heading, float fov);
|
||||
virtual void clear() override;
|
||||
virtual void setupCameraOrtho2D() override;
|
||||
virtual void setupCameraPerspective(float pitch, float heading, float fov) override;
|
||||
|
||||
virtual Texture *createTexture(const Graphics::Surface *surface);
|
||||
virtual void freeTexture(Texture *texture);
|
||||
virtual Texture *createTexture(const Graphics::Surface *surface) override;
|
||||
virtual void freeTexture(Texture *texture) override;
|
||||
|
||||
virtual void drawRect2D(const Common::Rect &rect, uint32 color);
|
||||
virtual void drawRect2D(const Common::Rect &rect, uint32 color) override;
|
||||
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture,
|
||||
float transparency = -1.0, bool additiveBlending = false);
|
||||
float transparency = -1.0, bool additiveBlending = false) override;
|
||||
virtual void drawTexturedRect3D(const Math::Vector3d &topLeft, const Math::Vector3d &bottomLeft,
|
||||
const Math::Vector3d &topRight, const Math::Vector3d &bottomRight,
|
||||
Texture *texture);
|
||||
Texture *texture) override;
|
||||
|
||||
virtual void drawCube(Texture **textures);
|
||||
virtual void draw2DText(const Common::String &text, const Common::Point &position);
|
||||
virtual void drawCube(Texture **textures) override;
|
||||
virtual void draw2DText(const Common::String &text, const Common::Point &position) override;
|
||||
|
||||
virtual Graphics::Surface *getScreenshot();
|
||||
virtual Graphics::Surface *getScreenshot() override;
|
||||
|
||||
virtual void screenPosToDirection(const Common::Point screen, float &pitch, float &heading);
|
||||
virtual void screenPosToDirection(const Common::Point screen, float &pitch, float &heading) override;
|
||||
|
||||
private:
|
||||
void setupQuadEBO();
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
OpenGLTexture(const Graphics::Surface *surface, bool nonPoTSupport = false);
|
||||
virtual ~OpenGLTexture();
|
||||
|
||||
void update(const Graphics::Surface *surface);
|
||||
void update(const Graphics::Surface *surface) override;
|
||||
|
||||
GLuint id;
|
||||
GLuint internalFormat;
|
||||
|
|
|
@ -37,27 +37,28 @@ public:
|
|||
TinyGLRenderer(OSystem *_system);
|
||||
virtual ~TinyGLRenderer();
|
||||
|
||||
virtual void init(Graphics::PixelBuffer &screenBuffer);
|
||||
virtual void init(Graphics::PixelBuffer &screenBuffer) override;
|
||||
|
||||
virtual void clear();
|
||||
virtual void setupCameraOrtho2D();
|
||||
virtual void setupCameraPerspective(float pitch, float heading, float fov);
|
||||
virtual void clear() override;
|
||||
virtual void setupCameraOrtho2D() override;
|
||||
virtual void setupCameraPerspective(float pitch, float heading, float fov) override;
|
||||
|
||||
Texture *createTexture(const Graphics::Surface *surface);
|
||||
void freeTexture(Texture *texture);
|
||||
Texture *createTexture(const Graphics::Surface *surface) override;
|
||||
void freeTexture(Texture *texture) override;
|
||||
|
||||
virtual void drawRect2D(const Common::Rect &rect, uint32 color);
|
||||
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture, float transparency = -1.0, bool additiveBlending = false);
|
||||
virtual void drawRect2D(const Common::Rect &rect, uint32 color) override;
|
||||
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture,
|
||||
float transparency = -1.0, bool additiveBlending = false) override;
|
||||
virtual void drawTexturedRect3D(const Math::Vector3d &topLeft, const Math::Vector3d &bottomLeft,
|
||||
const Math::Vector3d &topRight, const Math::Vector3d &bottomRight,
|
||||
Texture *texture);
|
||||
|
||||
virtual void drawCube(Texture **textures);
|
||||
virtual void draw2DText(const Common::String &text, const Common::Point &position);
|
||||
virtual void drawCube(Texture **textures) override;
|
||||
virtual void draw2DText(const Common::String &text, const Common::Point &position) override;
|
||||
|
||||
virtual Graphics::Surface *getScreenshot();
|
||||
virtual Graphics::Surface *getScreenshot() override;
|
||||
|
||||
virtual void screenPosToDirection(const Common::Point screen, float &pitch, float &heading);
|
||||
virtual void screenPosToDirection(const Common::Point screen, float &pitch, float &heading) override;
|
||||
|
||||
private:
|
||||
void drawFace(uint face, Texture *texture);
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
TinyGLTexture(const Graphics::Surface *surface, bool nonPoTSupport = false);
|
||||
virtual ~TinyGLTexture();
|
||||
|
||||
void update(const Graphics::Surface *surface);
|
||||
void update(const Graphics::Surface *surface) override;
|
||||
|
||||
Graphics::PixelBuffer buffer;
|
||||
TGLuint id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue