WINTERMUTE: Fix formatting, add license headers
This commit is contained in:
parent
2e77063c7c
commit
cbc313020a
5 changed files with 158 additions and 77 deletions
|
@ -1,3 +1,25 @@
|
|||
/* ResidualVM - A 3D game interpreter
|
||||
*
|
||||
* ResidualVM 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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "base_render_opengl3d.h"
|
||||
|
||||
#include "../../../../../graphics/opengl/system_headers.h"
|
||||
|
@ -5,26 +27,24 @@
|
|||
#include "math/glmath.h"
|
||||
|
||||
namespace Wintermute {
|
||||
BaseRenderer *makeOpenGL3DRenderer(BaseGame* inGame) {
|
||||
BaseRenderer *makeOpenGL3DRenderer(BaseGame *inGame) {
|
||||
return new BaseRenderOpenGL3D(inGame);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Wintermute::BaseRenderOpenGL3D::BaseRenderOpenGL3D(Wintermute::BaseGame* inGame)
|
||||
: _spriteBatchMode(false) {
|
||||
} // namespace Wintermute
|
||||
|
||||
Wintermute::BaseRenderOpenGL3D::BaseRenderOpenGL3D(Wintermute::BaseGame *inGame)
|
||||
: _spriteBatchMode(false) {
|
||||
}
|
||||
|
||||
Wintermute::BaseRenderOpenGL3D::~BaseRenderOpenGL3D() {
|
||||
|
||||
}
|
||||
|
||||
Wintermute::BaseImage* Wintermute::BaseRenderOpenGL3D::takeScreenshot() {
|
||||
Wintermute::BaseImage *Wintermute::BaseRenderOpenGL3D::takeScreenshot() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Wintermute::BaseRenderOpenGL3D::saveScreenShot(const Common::String& filename, int sizeX, int sizeY) {
|
||||
bool Wintermute::BaseRenderOpenGL3D::saveScreenShot(const Common::String &filename, int sizeX, int sizeY) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -34,7 +54,7 @@ bool Wintermute::BaseRenderOpenGL3D::setViewport(int left, int top, int right, i
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Wintermute::BaseRenderOpenGL3D::setViewport(Wintermute::Rect32* rect) {
|
||||
bool Wintermute::BaseRenderOpenGL3D::setViewport(Wintermute::Rect32 *rect) {
|
||||
return setViewport(rect->left, rect->top, rect->right, rect->bottom);
|
||||
}
|
||||
|
||||
|
@ -43,7 +63,6 @@ Wintermute::Rect32 Wintermute::BaseRenderOpenGL3D::getViewPort() {
|
|||
}
|
||||
|
||||
void Wintermute::BaseRenderOpenGL3D::setWindowed(bool windowed) {
|
||||
|
||||
}
|
||||
|
||||
Graphics::PixelFormat Wintermute::BaseRenderOpenGL3D::getPixelFormat() const {
|
||||
|
@ -62,18 +81,18 @@ void Wintermute::BaseRenderOpenGL3D::fadeToColor(byte r, byte g, byte b, byte a)
|
|||
int vertex_size = 16;
|
||||
byte vertices[4 * vertex_size];
|
||||
|
||||
*reinterpret_cast<float*>(vertices + 4) = _viewportRect.left;
|
||||
*reinterpret_cast<float*>(vertices + 8) = _viewportRect.bottom;
|
||||
*reinterpret_cast<float*>(vertices + 12) = 0.0f;
|
||||
*reinterpret_cast<float*>(vertices + vertex_size + 4) = _viewportRect.left;
|
||||
*reinterpret_cast<float*>(vertices + vertex_size + 8) = _viewportRect.top;
|
||||
*reinterpret_cast<float*>(vertices + vertex_size + 12) = 0.0f;
|
||||
*reinterpret_cast<float*>(vertices + 2 * vertex_size + 4) = _viewportRect.right;
|
||||
*reinterpret_cast<float*>(vertices + 2 * vertex_size + 8) = _viewportRect.bottom;
|
||||
*reinterpret_cast<float*>(vertices + 2 * vertex_size + 12) = 0.0f;
|
||||
*reinterpret_cast<float*>(vertices + 3 * vertex_size + 4) = _viewportRect.right;
|
||||
*reinterpret_cast<float*>(vertices + 3 * vertex_size + 8) = _viewportRect.top;
|
||||
*reinterpret_cast<float*>(vertices + 3 * vertex_size + 12) = 0.0f;
|
||||
*reinterpret_cast<float *>(vertices + 4) = _viewportRect.left;
|
||||
*reinterpret_cast<float *>(vertices + 8) = _viewportRect.bottom;
|
||||
*reinterpret_cast<float *>(vertices + 12) = 0.0f;
|
||||
*reinterpret_cast<float *>(vertices + vertex_size + 4) = _viewportRect.left;
|
||||
*reinterpret_cast<float *>(vertices + vertex_size + 8) = _viewportRect.top;
|
||||
*reinterpret_cast<float *>(vertices + vertex_size + 12) = 0.0f;
|
||||
*reinterpret_cast<float *>(vertices + 2 * vertex_size + 4) = _viewportRect.right;
|
||||
*reinterpret_cast<float *>(vertices + 2 * vertex_size + 8) = _viewportRect.bottom;
|
||||
*reinterpret_cast<float *>(vertices + 2 * vertex_size + 12) = 0.0f;
|
||||
*reinterpret_cast<float *>(vertices + 3 * vertex_size + 4) = _viewportRect.right;
|
||||
*reinterpret_cast<float *>(vertices + 3 * vertex_size + 8) = _viewportRect.top;
|
||||
*reinterpret_cast<float *>(vertices + 3 * vertex_size + 12) = 0.0f;
|
||||
|
||||
*(vertices) = r;
|
||||
*(vertices + 1) = g;
|
||||
|
@ -129,7 +148,7 @@ bool Wintermute::BaseRenderOpenGL3D::setProjection() {
|
|||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-right, right, -right*aspect_ratio, right*aspect_ratio, near_plane, far_plane);
|
||||
glFrustum(-right, right, -right * aspect_ratio, right * aspect_ratio, near_plane, far_plane);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
return true;
|
||||
|
@ -148,14 +167,13 @@ bool Wintermute::BaseRenderOpenGL3D::windowedBlt() {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Wintermute::BaseRenderOpenGL3D::fill(byte r, byte g, byte b, Common::Rect* rect) {
|
||||
bool Wintermute::BaseRenderOpenGL3D::fill(byte r, byte g, byte b, Common::Rect *rect) {
|
||||
glClearColor(float(r) / 255.0f, float(g) / 255.0f, float(b) / 255.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Wintermute::BaseRenderOpenGL3D::onWindowChange() {
|
||||
|
||||
}
|
||||
|
||||
bool Wintermute::BaseRenderOpenGL3D::initRenderer(int width, int height, bool windowed) {
|
||||
|
@ -197,7 +215,7 @@ bool Wintermute::BaseRenderOpenGL3D::setup2D(bool force) {
|
|||
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDepthMask(false);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_STENCIL);
|
||||
glDisable(GL_CLIP_PLANE0);
|
||||
glDisable(GL_FOG);
|
||||
|
@ -207,7 +225,7 @@ bool Wintermute::BaseRenderOpenGL3D::setup2D(bool force) {
|
|||
glCullFace(GL_CCW);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glAlphaFunc(GL_GEQUAL, 0x00);
|
||||
glAlphaFunc(GL_GEQUAL, 0.0f);
|
||||
glPolygonMode(GL_FRONT, GL_FILL);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
@ -238,26 +256,25 @@ bool Wintermute::BaseRenderOpenGL3D::setupLines() {
|
|||
return true;
|
||||
}
|
||||
|
||||
Wintermute::BaseSurface* Wintermute::BaseRenderOpenGL3D::createSurface() {
|
||||
Wintermute::BaseSurface *Wintermute::BaseRenderOpenGL3D::createSurface() {
|
||||
return new BaseSurfaceOpenGL3D(nullptr, this);
|
||||
}
|
||||
|
||||
void Wintermute::BaseRenderOpenGL3D::endSaveLoad() {
|
||||
|
||||
}
|
||||
|
||||
bool Wintermute::BaseRenderOpenGL3D::drawSprite(const OpenGL::Texture& tex, const Wintermute::Rect32& rect,
|
||||
float zoomX, float zoomY, const Wintermute::Vector2& pos,
|
||||
uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode,
|
||||
bool mirrorX, bool mirrorY) {
|
||||
bool Wintermute::BaseRenderOpenGL3D::drawSprite(const OpenGL::Texture &tex, const Wintermute::Rect32 &rect,
|
||||
float zoomX, float zoomY, const Wintermute::Vector2 &pos,
|
||||
uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode,
|
||||
bool mirrorX, bool mirrorY) {
|
||||
Vector2 scale(zoomX / 100.0f, zoomY / 100.0f);
|
||||
return drawSpriteEx(tex, rect, pos, Vector2(0.0f, 0.0f), scale, 0.0f, color, alphaDisable, blendMode, mirrorX, mirrorY);
|
||||
}
|
||||
|
||||
bool Wintermute::BaseRenderOpenGL3D::drawSpriteEx(const OpenGL::Texture& tex, const Wintermute::Rect32& rect,
|
||||
const Wintermute::Vector2& pos, const Wintermute::Vector2& rot, const Wintermute::Vector2& scale,
|
||||
float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode,
|
||||
bool mirrorX, bool mirrorY) {
|
||||
bool Wintermute::BaseRenderOpenGL3D::drawSpriteEx(const OpenGL::Texture &tex, const Wintermute::Rect32 &rect,
|
||||
const Wintermute::Vector2 &pos, const Wintermute::Vector2 &rot, const Wintermute::Vector2 &scale,
|
||||
float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode,
|
||||
bool mirrorX, bool mirrorY) {
|
||||
// original wme has a batch mode for sprites, we ignore this for the moment
|
||||
|
||||
// The ShaderSurfaceRenderer sets an array buffer which appearently conflicts with us
|
||||
|
@ -266,21 +283,19 @@ bool Wintermute::BaseRenderOpenGL3D::drawSpriteEx(const OpenGL::Texture& tex, co
|
|||
float width = (rect.right - rect.left) * scale.x;
|
||||
float height = (rect.bottom - rect.top) * scale.y;
|
||||
|
||||
float tex_left = (float) rect.left / (float) tex.getWidth();
|
||||
float tex_top = (float) rect.top / (float) tex.getHeight();
|
||||
float tex_right = (float) rect.right / (float) tex.getWidth();
|
||||
float tex_bottom = (float) rect.bottom / (float) tex.getHeight();
|
||||
float tex_left = (float)rect.left / (float)tex.getWidth();
|
||||
float tex_top = (float)rect.top / (float)tex.getHeight();
|
||||
float tex_right = (float)rect.right / (float)tex.getWidth();
|
||||
float tex_bottom = (float)rect.bottom / (float)tex.getHeight();
|
||||
|
||||
float offset = _viewportRect.height() / 2.0f;
|
||||
float corrected_y = (pos.y - offset) * -1.0f + offset;
|
||||
float corrected_y = (pos.y - offset) * -1.0f + offset;
|
||||
|
||||
// to be implemented
|
||||
if (mirrorX) {
|
||||
|
||||
}
|
||||
|
||||
if (mirrorY) {
|
||||
|
||||
}
|
||||
|
||||
// provide space for 3d position coords, 2d texture coords and a 32 bit colot value
|
||||
|
@ -292,28 +307,28 @@ bool Wintermute::BaseRenderOpenGL3D::drawSpriteEx(const OpenGL::Texture& tex, co
|
|||
}
|
||||
|
||||
// texture coords
|
||||
*reinterpret_cast<float*>(vertices) = tex_left;
|
||||
*reinterpret_cast<float*>(vertices + 4) = tex_top;
|
||||
*reinterpret_cast<float*>(vertices + vertex_size) = tex_left;
|
||||
*reinterpret_cast<float*>(vertices + vertex_size + 4) = tex_bottom;
|
||||
*reinterpret_cast<float*>(vertices + 2 * vertex_size) = tex_right;
|
||||
*reinterpret_cast<float*>(vertices + 2 * vertex_size + 4) = tex_top;
|
||||
*reinterpret_cast<float*>(vertices + 3 * vertex_size) = tex_right;
|
||||
*reinterpret_cast<float*>(vertices + 3 * vertex_size + 4) = tex_bottom;
|
||||
*reinterpret_cast<float *>(vertices) = tex_left;
|
||||
*reinterpret_cast<float *>(vertices + 4) = tex_top;
|
||||
*reinterpret_cast<float *>(vertices + vertex_size) = tex_left;
|
||||
*reinterpret_cast<float *>(vertices + vertex_size + 4) = tex_bottom;
|
||||
*reinterpret_cast<float *>(vertices + 2 * vertex_size) = tex_right;
|
||||
*reinterpret_cast<float *>(vertices + 2 * vertex_size + 4) = tex_top;
|
||||
*reinterpret_cast<float *>(vertices + 3 * vertex_size) = tex_right;
|
||||
*reinterpret_cast<float *>(vertices + 3 * vertex_size + 4) = tex_bottom;
|
||||
|
||||
// position coords
|
||||
*reinterpret_cast<float*>(vertices + 12) = pos.x - 0.5f;
|
||||
*reinterpret_cast<float*>(vertices + 12 + 4) = corrected_y - 0.5f;
|
||||
*reinterpret_cast<float*>(vertices + 12 + 8) = -1.1f;
|
||||
*reinterpret_cast<float*>(vertices + vertex_size + 12) = pos.x -0.5f;
|
||||
*reinterpret_cast<float*>(vertices + vertex_size + 12 + 4) = corrected_y - height - 0.5f;
|
||||
*reinterpret_cast<float*>(vertices + vertex_size + 12 + 8) = -1.1f;
|
||||
*reinterpret_cast<float*>(vertices + 2 * vertex_size + 12) = pos.x + width - 0.5f;
|
||||
*reinterpret_cast<float*>(vertices + 2 * vertex_size + 12 + 4) = corrected_y - 0.5f;
|
||||
*reinterpret_cast<float*>(vertices + 2 * vertex_size + 12 + 8) = -1.1f;
|
||||
*reinterpret_cast<float*>(vertices + 3 * vertex_size + 12) = pos.x + width - 0.5f;
|
||||
*reinterpret_cast<float*>(vertices + 3 * vertex_size + 12 + 4) = corrected_y - height - 0.5;
|
||||
*reinterpret_cast<float*>(vertices + 3 * vertex_size + 12 + 8) = -1.1f;
|
||||
*reinterpret_cast<float *>(vertices + 12) = pos.x - 0.5f;
|
||||
*reinterpret_cast<float *>(vertices + 12 + 4) = corrected_y - 0.5f;
|
||||
*reinterpret_cast<float *>(vertices + 12 + 8) = -1.1f;
|
||||
*reinterpret_cast<float *>(vertices + vertex_size + 12) = pos.x - 0.5f;
|
||||
*reinterpret_cast<float *>(vertices + vertex_size + 12 + 4) = corrected_y - height - 0.5f;
|
||||
*reinterpret_cast<float *>(vertices + vertex_size + 12 + 8) = -1.1f;
|
||||
*reinterpret_cast<float *>(vertices + 2 * vertex_size + 12) = pos.x + width - 0.5f;
|
||||
*reinterpret_cast<float *>(vertices + 2 * vertex_size + 12 + 4) = corrected_y - 0.5f;
|
||||
*reinterpret_cast<float *>(vertices + 2 * vertex_size + 12 + 8) = -1.1f;
|
||||
*reinterpret_cast<float *>(vertices + 3 * vertex_size + 12) = pos.x + width - 0.5f;
|
||||
*reinterpret_cast<float *>(vertices + 3 * vertex_size + 12 + 4) = corrected_y - height - 0.5;
|
||||
*reinterpret_cast<float *>(vertices + 3 * vertex_size + 12 + 8) = -1.1f;
|
||||
|
||||
// not exactly sure about the color format, but this seems to work
|
||||
byte a = RGBCOLGetA(color);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue