WINTERMUTE: Fix formatting, add license headers

This commit is contained in:
Gunnar Birke 2020-05-29 13:11:53 +02:00 committed by Paweł Kołodziejski
parent 2e77063c7c
commit cbc313020a
5 changed files with 158 additions and 77 deletions

View file

@ -231,8 +231,10 @@ private:
}; };
BaseRenderer *makeOSystemRenderer(BaseGame *inGame); // Implemented in BRenderSDL.cpp BaseRenderer *makeOSystemRenderer(BaseGame *inGame); // Implemented in BRenderSDL.cpp
#ifdef ENABLE_WME3D
BaseRenderer *makeOpenGLTextureRenderer(BaseGame *inGame); BaseRenderer *makeOpenGLTextureRenderer(BaseGame *inGame);
BaseRenderer *makeOpenGL3DRenderer(BaseGame* inGame); BaseRenderer *makeOpenGL3DRenderer(BaseGame* inGame);
#endif
} // End of namespace Wintermute } // End of namespace Wintermute

View file

@ -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 "base_render_opengl3d.h"
#include "../../../../../graphics/opengl/system_headers.h" #include "../../../../../graphics/opengl/system_headers.h"
@ -5,26 +27,24 @@
#include "math/glmath.h" #include "math/glmath.h"
namespace Wintermute { namespace Wintermute {
BaseRenderer *makeOpenGL3DRenderer(BaseGame* inGame) { BaseRenderer *makeOpenGL3DRenderer(BaseGame *inGame) {
return new BaseRenderOpenGL3D(inGame); return new BaseRenderOpenGL3D(inGame);
} }
} } // namespace Wintermute
Wintermute::BaseRenderOpenGL3D::BaseRenderOpenGL3D(Wintermute::BaseGame* inGame)
: _spriteBatchMode(false) {
Wintermute::BaseRenderOpenGL3D::BaseRenderOpenGL3D(Wintermute::BaseGame *inGame)
: _spriteBatchMode(false) {
} }
Wintermute::BaseRenderOpenGL3D::~BaseRenderOpenGL3D() { Wintermute::BaseRenderOpenGL3D::~BaseRenderOpenGL3D() {
} }
Wintermute::BaseImage* Wintermute::BaseRenderOpenGL3D::takeScreenshot() { Wintermute::BaseImage *Wintermute::BaseRenderOpenGL3D::takeScreenshot() {
return nullptr; 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; return true;
} }
@ -34,7 +54,7 @@ bool Wintermute::BaseRenderOpenGL3D::setViewport(int left, int top, int right, i
return true; 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); 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) { void Wintermute::BaseRenderOpenGL3D::setWindowed(bool windowed) {
} }
Graphics::PixelFormat Wintermute::BaseRenderOpenGL3D::getPixelFormat() const { 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; int vertex_size = 16;
byte vertices[4 * vertex_size]; byte vertices[4 * vertex_size];
*reinterpret_cast<float*>(vertices + 4) = _viewportRect.left; *reinterpret_cast<float *>(vertices + 4) = _viewportRect.left;
*reinterpret_cast<float*>(vertices + 8) = _viewportRect.bottom; *reinterpret_cast<float *>(vertices + 8) = _viewportRect.bottom;
*reinterpret_cast<float*>(vertices + 12) = 0.0f; *reinterpret_cast<float *>(vertices + 12) = 0.0f;
*reinterpret_cast<float*>(vertices + vertex_size + 4) = _viewportRect.left; *reinterpret_cast<float *>(vertices + vertex_size + 4) = _viewportRect.left;
*reinterpret_cast<float*>(vertices + vertex_size + 8) = _viewportRect.top; *reinterpret_cast<float *>(vertices + vertex_size + 8) = _viewportRect.top;
*reinterpret_cast<float*>(vertices + vertex_size + 12) = 0.0f; *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 + 4) = _viewportRect.right;
*reinterpret_cast<float*>(vertices + 2 * vertex_size + 8) = _viewportRect.bottom; *reinterpret_cast<float *>(vertices + 2 * vertex_size + 8) = _viewportRect.bottom;
*reinterpret_cast<float*>(vertices + 2 * vertex_size + 12) = 0.0f; *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 + 4) = _viewportRect.right;
*reinterpret_cast<float*>(vertices + 3 * vertex_size + 8) = _viewportRect.top; *reinterpret_cast<float *>(vertices + 3 * vertex_size + 8) = _viewportRect.top;
*reinterpret_cast<float*>(vertices + 3 * vertex_size + 12) = 0.0f; *reinterpret_cast<float *>(vertices + 3 * vertex_size + 12) = 0.0f;
*(vertices) = r; *(vertices) = r;
*(vertices + 1) = g; *(vertices + 1) = g;
@ -129,7 +148,7 @@ bool Wintermute::BaseRenderOpenGL3D::setProjection() {
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); 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); glMatrixMode(GL_MODELVIEW);
return true; return true;
@ -148,14 +167,13 @@ bool Wintermute::BaseRenderOpenGL3D::windowedBlt() {
return true; 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); 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); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
return true; return true;
} }
void Wintermute::BaseRenderOpenGL3D::onWindowChange() { void Wintermute::BaseRenderOpenGL3D::onWindowChange() {
} }
bool Wintermute::BaseRenderOpenGL3D::initRenderer(int width, int height, bool windowed) { 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_LIGHTING);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glDepthMask(false); glDepthMask(GL_FALSE);
glDisable(GL_STENCIL); glDisable(GL_STENCIL);
glDisable(GL_CLIP_PLANE0); glDisable(GL_CLIP_PLANE0);
glDisable(GL_FOG); glDisable(GL_FOG);
@ -207,7 +225,7 @@ bool Wintermute::BaseRenderOpenGL3D::setup2D(bool force) {
glCullFace(GL_CCW); glCullFace(GL_CCW);
glEnable(GL_ALPHA_TEST); glEnable(GL_ALPHA_TEST);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glAlphaFunc(GL_GEQUAL, 0x00); glAlphaFunc(GL_GEQUAL, 0.0f);
glPolygonMode(GL_FRONT, GL_FILL); glPolygonMode(GL_FRONT, GL_FILL);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -238,26 +256,25 @@ bool Wintermute::BaseRenderOpenGL3D::setupLines() {
return true; return true;
} }
Wintermute::BaseSurface* Wintermute::BaseRenderOpenGL3D::createSurface() { Wintermute::BaseSurface *Wintermute::BaseRenderOpenGL3D::createSurface() {
return new BaseSurfaceOpenGL3D(nullptr, this); return new BaseSurfaceOpenGL3D(nullptr, this);
} }
void Wintermute::BaseRenderOpenGL3D::endSaveLoad() { void Wintermute::BaseRenderOpenGL3D::endSaveLoad() {
} }
bool Wintermute::BaseRenderOpenGL3D::drawSprite(const OpenGL::Texture& tex, const Wintermute::Rect32& rect, bool Wintermute::BaseRenderOpenGL3D::drawSprite(const OpenGL::Texture &tex, const Wintermute::Rect32 &rect,
float zoomX, float zoomY, const Wintermute::Vector2& pos, float zoomX, float zoomY, const Wintermute::Vector2 &pos,
uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode,
bool mirrorX, bool mirrorY) { bool mirrorX, bool mirrorY) {
Vector2 scale(zoomX / 100.0f, zoomY / 100.0f); Vector2 scale(zoomX / 100.0f, zoomY / 100.0f);
return drawSpriteEx(tex, rect, pos, Vector2(0.0f, 0.0f), scale, 0.0f, color, alphaDisable, blendMode, mirrorX, mirrorY); return drawSpriteEx(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, bool Wintermute::BaseRenderOpenGL3D::drawSpriteEx(const OpenGL::Texture &tex, const Wintermute::Rect32 &rect,
const Wintermute::Vector2& pos, const Wintermute::Vector2& rot, const Wintermute::Vector2& scale, const Wintermute::Vector2 &pos, const Wintermute::Vector2 &rot, const Wintermute::Vector2 &scale,
float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode,
bool mirrorX, bool mirrorY) { bool mirrorX, bool mirrorY) {
// original wme has a batch mode for sprites, we ignore this for the moment // 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 // 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 width = (rect.right - rect.left) * scale.x;
float height = (rect.bottom - rect.top) * scale.y; float height = (rect.bottom - rect.top) * scale.y;
float tex_left = (float) rect.left / (float) tex.getWidth(); float tex_left = (float)rect.left / (float)tex.getWidth();
float tex_top = (float) rect.top / (float) tex.getHeight(); float tex_top = (float)rect.top / (float)tex.getHeight();
float tex_right = (float) rect.right / (float) tex.getWidth(); float tex_right = (float)rect.right / (float)tex.getWidth();
float tex_bottom = (float) rect.bottom / (float) tex.getHeight(); float tex_bottom = (float)rect.bottom / (float)tex.getHeight();
float offset = _viewportRect.height() / 2.0f; 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 // to be implemented
if (mirrorX) { if (mirrorX) {
} }
if (mirrorY) { if (mirrorY) {
} }
// provide space for 3d position coords, 2d texture coords and a 32 bit colot value // 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 // texture coords
*reinterpret_cast<float*>(vertices) = tex_left; *reinterpret_cast<float *>(vertices) = tex_left;
*reinterpret_cast<float*>(vertices + 4) = tex_top; *reinterpret_cast<float *>(vertices + 4) = tex_top;
*reinterpret_cast<float*>(vertices + vertex_size) = tex_left; *reinterpret_cast<float *>(vertices + vertex_size) = tex_left;
*reinterpret_cast<float*>(vertices + vertex_size + 4) = tex_bottom; *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) = tex_right;
*reinterpret_cast<float*>(vertices + 2 * vertex_size + 4) = tex_top; *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) = tex_right;
*reinterpret_cast<float*>(vertices + 3 * vertex_size + 4) = tex_bottom; *reinterpret_cast<float *>(vertices + 3 * vertex_size + 4) = tex_bottom;
// position coords // position coords
*reinterpret_cast<float*>(vertices + 12) = pos.x - 0.5f; *reinterpret_cast<float *>(vertices + 12) = pos.x - 0.5f;
*reinterpret_cast<float*>(vertices + 12 + 4) = corrected_y - 0.5f; *reinterpret_cast<float *>(vertices + 12 + 4) = corrected_y - 0.5f;
*reinterpret_cast<float*>(vertices + 12 + 8) = -1.1f; *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) = pos.x - 0.5f;
*reinterpret_cast<float*>(vertices + vertex_size + 12 + 4) = corrected_y - height - 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 + 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) = 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 + 4) = corrected_y - 0.5f;
*reinterpret_cast<float*>(vertices + 2 * vertex_size + 12 + 8) = -1.1f; *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) = 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 + 4) = corrected_y - height - 0.5;
*reinterpret_cast<float*>(vertices + 3 * vertex_size + 12 + 8) = -1.1f; *reinterpret_cast<float *>(vertices + 3 * vertex_size + 12 + 8) = -1.1f;
// not exactly sure about the color format, but this seems to work // not exactly sure about the color format, but this seems to work
byte a = RGBCOLGetA(color); byte a = RGBCOLGetA(color);

View file

@ -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.
*
*/
#ifndef WINTERMUTE_BASE_RENDER_OPENGL3D_H #ifndef WINTERMUTE_BASE_RENDER_OPENGL3D_H
#define WINTERMUTE_BASE_RENDER_OPENGL3D_H #define WINTERMUTE_BASE_RENDER_OPENGL3D_H

View file

@ -1,13 +1,33 @@
/* 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_surface_opengl3d.h" #include "base_surface_opengl3d.h"
#include "../base_image.h" #include "../base_image.h"
#include "base_render_opengl3d.h" #include "base_render_opengl3d.h"
#include "graphics/transparent_surface.h" #include "graphics/transparent_surface.h"
Wintermute::BaseSurfaceOpenGL3D::BaseSurfaceOpenGL3D(Wintermute::BaseGame* game, BaseRenderOpenGL3D* renderer) Wintermute::BaseSurfaceOpenGL3D::BaseSurfaceOpenGL3D(Wintermute::BaseGame *game, BaseRenderOpenGL3D *renderer)
: BaseSurface(game), tex(nullptr), renderer(renderer), pixelOpReady(false) : BaseSurface(game), tex(nullptr), renderer(renderer), pixelOpReady(false) {
{
} }
bool Wintermute::BaseSurfaceOpenGL3D::invalidate() { bool Wintermute::BaseSurfaceOpenGL3D::invalidate() {
@ -40,7 +60,7 @@ bool Wintermute::BaseSurfaceOpenGL3D::display(int x, int y, Wintermute::Rect32 r
return true; return true;
} }
bool Wintermute::BaseSurfaceOpenGL3D::displayTransform(int x, int y, Wintermute::Rect32 rect, Wintermute::Rect32 newRect, const Graphics::TransformStruct& transform) { bool Wintermute::BaseSurfaceOpenGL3D::displayTransform(int x, int y, Wintermute::Rect32 rect, Wintermute::Rect32 newRect, const Graphics::TransformStruct &transform) {
return true; return true;
} }
@ -58,8 +78,8 @@ bool Wintermute::BaseSurfaceOpenGL3D::restore() {
return true; return true;
} }
bool Wintermute::BaseSurfaceOpenGL3D::create(const Common::String& filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { bool Wintermute::BaseSurfaceOpenGL3D::create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
BaseImage img = BaseImage(); BaseImage img = BaseImage();
if (!img.loadFile(filename)) { if (!img.loadFile(filename)) {
return false; return false;
} }
@ -71,9 +91,9 @@ bool Wintermute::BaseSurfaceOpenGL3D::create(const Common::String& filename, boo
_filename = filename; _filename = filename;
if (defaultCK) { if (defaultCK) {
ckRed = 255; ckRed = 255;
ckGreen = 0; ckGreen = 0;
ckBlue = 255; ckBlue = 255;
} }
_ckDefault = defaultCK; _ckDefault = defaultCK;
@ -84,7 +104,7 @@ bool Wintermute::BaseSurfaceOpenGL3D::create(const Common::String& filename, boo
bool needsColorKey = false; bool needsColorKey = false;
bool replaceAlpha = true; bool replaceAlpha = true;
Graphics::Surface* surf = img.getSurface()->convertTo(OpenGL::Texture::getRGBAPixelFormat(), img.getPalette()); Graphics::Surface *surf = img.getSurface()->convertTo(OpenGL::Texture::getRGBAPixelFormat(), img.getPalette());
if (_filename.hasSuffix(".bmp") && img.getSurface()->format.bytesPerPixel == 4) { if (_filename.hasSuffix(".bmp") && img.getSurface()->format.bytesPerPixel == 4) {
// 32 bpp BMPs have nothing useful in their alpha-channel -> color-key // 32 bpp BMPs have nothing useful in their alpha-channel -> color-key
@ -126,7 +146,7 @@ bool Wintermute::BaseSurfaceOpenGL3D::putPixel(int x, int y, byte r, byte g, byt
return true; return true;
} }
bool Wintermute::BaseSurfaceOpenGL3D::getPixel(int x, int y, byte* r, byte* g, byte* b, byte* a) { bool Wintermute::BaseSurfaceOpenGL3D::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) {
return true; return true;
} }
@ -153,12 +173,12 @@ bool Wintermute::BaseSurfaceOpenGL3D::isTransparentAtLite(int x, int y) {
return false; return false;
} }
uint8* image_data = nullptr; uint8 *image_data = nullptr;
// assume 32 bit rgba for now // assume 32 bit rgba for now
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data);
uint32 pixel = *reinterpret_cast<uint32*>(image_data + y * tex->getWidth() * 4 + x * 4); uint32 pixel = *reinterpret_cast<uint32 *>(image_data + y * tex->getWidth() * 4 + x * 4);
pixel &= 0x000000FF; pixel &= 0x000000FF;
return pixel == 0; return pixel == 0;
} }

View file

@ -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.
*
*/
#ifndef WINTERMUTE_BASE_SURFACE_OPENGL3D_H #ifndef WINTERMUTE_BASE_SURFACE_OPENGL3D_H
#define WINTERMUTE_BASE_SURFACE_OPENGL3D_H #define WINTERMUTE_BASE_SURFACE_OPENGL3D_H