TINYGL: Rearrange access to TinyGL
This commit is contained in:
parent
5abcf1cb6b
commit
3b9f9804ee
32 changed files with 328 additions and 270 deletions
|
@ -829,7 +829,6 @@ void GfxTinyGL::disableLights() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GfxTinyGL::setupLight(Light *light, int lightId) {
|
void GfxTinyGL::setupLight(Light *light, int lightId) {
|
||||||
assert(lightId < T_MAX_LIGHTS);
|
|
||||||
tglEnable(TGL_LIGHTING);
|
tglEnable(TGL_LIGHTING);
|
||||||
float lightColor[] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
float lightColor[] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||||
float lightPos[] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
float lightPos[] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "engines/grim/gfx_base.h"
|
#include "engines/grim/gfx_base.h"
|
||||||
|
|
||||||
#include "graphics/tinygl/zgl.h"
|
#include "graphics/tinygl/tinygl.h"
|
||||||
|
|
||||||
namespace Graphics {
|
namespace Graphics {
|
||||||
struct Surface;
|
struct Surface;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "common/textconsole.h"
|
#include "common/textconsole.h"
|
||||||
|
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
|
#include "graphics/tinygl/tinygl.h"
|
||||||
|
|
||||||
#include "math/vector2d.h"
|
#include "math/vector2d.h"
|
||||||
#include "math/glmath.h"
|
#include "math/glmath.h"
|
||||||
|
@ -32,7 +33,6 @@
|
||||||
#include "engines/myst3/gfx.h"
|
#include "engines/myst3/gfx.h"
|
||||||
#include "engines/myst3/gfx_tinygl.h"
|
#include "engines/myst3/gfx_tinygl.h"
|
||||||
#include "engines/myst3/gfx_tinygl_texture.h"
|
#include "engines/myst3/gfx_tinygl_texture.h"
|
||||||
#include "graphics/tinygl/zblit.h"
|
|
||||||
|
|
||||||
namespace Myst3 {
|
namespace Myst3 {
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,12 @@
|
||||||
|
|
||||||
#include "common/rect.h"
|
#include "common/rect.h"
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
|
|
||||||
#include "math/vector3d.h"
|
#include "math/vector3d.h"
|
||||||
|
|
||||||
#include "engines/myst3/gfx.h"
|
#include "engines/myst3/gfx.h"
|
||||||
#include "graphics/tinygl/zgl.h"
|
|
||||||
|
#include "graphics/tinygl/tinygl.h"
|
||||||
|
|
||||||
namespace Myst3 {
|
namespace Myst3 {
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "engines/myst3/gfx_tinygl_texture.h"
|
#include "engines/myst3/gfx_tinygl_texture.h"
|
||||||
#include "graphics/tinygl/zblit.h"
|
|
||||||
|
#include "graphics/tinygl/tinygl.h"
|
||||||
|
|
||||||
namespace Myst3 {
|
namespace Myst3 {
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,12 @@
|
||||||
#ifndef GFX_TINYGL_TEXTURE_H
|
#ifndef GFX_TINYGL_TEXTURE_H
|
||||||
#define GFX_TINYGL_TEXTURE_H
|
#define GFX_TINYGL_TEXTURE_H
|
||||||
|
|
||||||
#include "graphics/surface.h"
|
|
||||||
#include "graphics/tinygl/zgl.h"
|
|
||||||
#include "common/textconsole.h"
|
#include "common/textconsole.h"
|
||||||
|
|
||||||
|
#include "graphics/surface.h"
|
||||||
|
#include "graphics/tinygl/tinygl.h"
|
||||||
|
|
||||||
#include "engines/myst3/gfx.h"
|
#include "engines/myst3/gfx.h"
|
||||||
#include "graphics/tinygl/zblit.h"
|
|
||||||
|
|
||||||
namespace Myst3 {
|
namespace Myst3 {
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "common/textconsole.h"
|
#include "common/textconsole.h"
|
||||||
|
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
#include "graphics/tinygl/zblit.h"
|
#include "graphics/tinygl/tinygl.h"
|
||||||
|
|
||||||
#include "math/vector2d.h"
|
#include "math/vector2d.h"
|
||||||
#include "math/glmath.h"
|
#include "math/glmath.h"
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#include "math/vector3d.h"
|
#include "math/vector3d.h"
|
||||||
|
|
||||||
#include "graphics/tinygl/zgl.h"
|
#include "graphics/tinygl/tinygl.h"
|
||||||
|
|
||||||
#include "engines/playground3d/gfx.h"
|
#include "engines/playground3d/gfx.h"
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "engines/stark/gfx/tinygl.h"
|
|
||||||
|
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
|
|
||||||
#include "math/matrix4.h"
|
#include "math/matrix4.h"
|
||||||
|
|
||||||
|
#include "engines/stark/gfx/tinygl.h"
|
||||||
#include "engines/stark/gfx/tinyglactor.h"
|
#include "engines/stark/gfx/tinyglactor.h"
|
||||||
#include "engines/stark/gfx/tinyglprop.h"
|
#include "engines/stark/gfx/tinyglprop.h"
|
||||||
#include "engines/stark/gfx/tinyglsurface.h"
|
#include "engines/stark/gfx/tinyglsurface.h"
|
||||||
|
|
|
@ -24,12 +24,13 @@
|
||||||
#define STARK_GFX_TINYGL_H
|
#define STARK_GFX_TINYGL_H
|
||||||
|
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
|
|
||||||
#include "math/vector3d.h"
|
#include "math/vector3d.h"
|
||||||
|
|
||||||
#include "engines/stark/gfx/driver.h"
|
#include "engines/stark/gfx/driver.h"
|
||||||
#include "engines/stark/gfx/renderentry.h"
|
#include "engines/stark/gfx/renderentry.h"
|
||||||
|
|
||||||
#include "graphics/tinygl/zgl.h"
|
#include "graphics/tinygl/tinygl.h"
|
||||||
|
|
||||||
namespace Stark {
|
namespace Stark {
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "engines/stark/gfx/tinyglactor.h"
|
#include "engines/stark/gfx/tinyglactor.h"
|
||||||
|
|
||||||
#include "engines/stark/model/model.h"
|
#include "engines/stark/model/model.h"
|
||||||
#include "engines/stark/model/animhandler.h"
|
#include "engines/stark/model/animhandler.h"
|
||||||
#include "engines/stark/scene.h"
|
#include "engines/stark/scene.h"
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "engines/stark/visual/actor.h"
|
#include "engines/stark/visual/actor.h"
|
||||||
#include "engines/stark/gfx/tinygl.h"
|
#include "engines/stark/gfx/tinygl.h"
|
||||||
|
|
||||||
#include "graphics/tinygl/zgl.h"
|
#include "graphics/tinygl/tinygl.h"
|
||||||
|
|
||||||
#include "common/hashmap.h"
|
#include "common/hashmap.h"
|
||||||
#include "common/hash-ptr.h"
|
#include "common/hash-ptr.h"
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "engines/stark/gfx/tinyglbitmap.h"
|
#include "engines/stark/gfx/tinyglbitmap.h"
|
||||||
|
|
||||||
#include "engines/stark/gfx/driver.h"
|
#include "engines/stark/gfx/driver.h"
|
||||||
|
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "engines/stark/gfx/texture.h"
|
#include "engines/stark/gfx/texture.h"
|
||||||
|
|
||||||
#include "graphics/tinygl/zgl.h"
|
#include "graphics/tinygl/tinygl.h"
|
||||||
|
|
||||||
namespace Stark {
|
namespace Stark {
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "engines/stark/gfx/tinyglfade.h"
|
#include "engines/stark/gfx/tinyglfade.h"
|
||||||
|
|
||||||
#include "engines/stark/gfx/tinygl.h"
|
#include "engines/stark/gfx/tinygl.h"
|
||||||
|
|
||||||
namespace Stark {
|
namespace Stark {
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "engines/stark/gfx/faderenderer.h"
|
#include "engines/stark/gfx/faderenderer.h"
|
||||||
|
|
||||||
#include "graphics/tinygl/zgl.h"
|
#include "graphics/tinygl/tinygl.h"
|
||||||
|
|
||||||
namespace Stark {
|
namespace Stark {
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "engines/stark/gfx/tinyglprop.h"
|
#include "engines/stark/gfx/tinyglprop.h"
|
||||||
|
|
||||||
#include "engines/stark/gfx/texture.h"
|
#include "engines/stark/gfx/texture.h"
|
||||||
#include "engines/stark/formats/biffmesh.h"
|
#include "engines/stark/formats/biffmesh.h"
|
||||||
#include "engines/stark/scene.h"
|
#include "engines/stark/scene.h"
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "engines/stark/visual/prop.h"
|
#include "engines/stark/visual/prop.h"
|
||||||
#include "engines/stark/gfx/tinygl.h"
|
#include "engines/stark/gfx/tinygl.h"
|
||||||
|
|
||||||
#include "graphics/tinygl/zgl.h"
|
#include "graphics/tinygl/tinygl.h"
|
||||||
|
|
||||||
#include "common/hashmap.h"
|
#include "common/hashmap.h"
|
||||||
#include "common/hash-ptr.h"
|
#include "common/hash-ptr.h"
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "engines/stark/gfx/tinyglbitmap.h"
|
#include "engines/stark/gfx/tinyglbitmap.h"
|
||||||
#include "engines/stark/gfx/texture.h"
|
#include "engines/stark/gfx/texture.h"
|
||||||
|
|
||||||
#include "graphics/tinygl/zblit.h"
|
#include "graphics/tinygl/tinygl.h"
|
||||||
|
|
||||||
namespace Stark {
|
namespace Stark {
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
|
@ -26,8 +26,7 @@
|
||||||
#include "engines/stark/gfx/surfacerenderer.h"
|
#include "engines/stark/gfx/surfacerenderer.h"
|
||||||
#include "engines/stark/gfx/tinygl.h"
|
#include "engines/stark/gfx/tinygl.h"
|
||||||
|
|
||||||
#include "graphics/tinygl/zgl.h"
|
#include "graphics/tinygl/tinygl.h"
|
||||||
#include "graphics/tinygl/zblit.h"
|
|
||||||
|
|
||||||
#include "math/vector2d.h"
|
#include "math/vector2d.h"
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "engines/stark/gfx/tinygltexture.h"
|
#include "engines/stark/gfx/tinygltexture.h"
|
||||||
|
|
||||||
#include "engines/stark/gfx/driver.h"
|
#include "engines/stark/gfx/driver.h"
|
||||||
|
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "engines/stark/gfx/texture.h"
|
#include "engines/stark/gfx/texture.h"
|
||||||
|
|
||||||
#include "graphics/tinygl/zgl.h"
|
#include "graphics/tinygl/tinygl.h"
|
||||||
|
|
||||||
namespace Stark {
|
namespace Stark {
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
|
@ -849,16 +849,10 @@ void tglTexCoordPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoi
|
||||||
// polygon offset
|
// polygon offset
|
||||||
void tglPolygonOffset(TGLfloat factor, TGLfloat units);
|
void tglPolygonOffset(TGLfloat factor, TGLfloat units);
|
||||||
|
|
||||||
// custom extension
|
// custom extensions
|
||||||
void tglSetShadowMaskBuf(unsigned char *buf);
|
void tglSetShadowMaskBuf(unsigned char *buf);
|
||||||
void tglSetShadowColor(unsigned char r, unsigned char g, unsigned char b);
|
void tglSetShadowColor(unsigned char r, unsigned char g, unsigned char b);
|
||||||
void tglEnableDirtyRects(bool enable);
|
void tglEnableDirtyRects(bool enable);
|
||||||
void tglDebug(int mode);
|
void tglDebug(int mode);
|
||||||
|
|
||||||
namespace TinyGL {
|
|
||||||
|
|
||||||
void presentBuffer();
|
|
||||||
|
|
||||||
} // end of namespace TinyGL
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
41
graphics/tinygl/tinygl.h
Normal file
41
graphics/tinygl/tinygl.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/* 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 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 GRAPHICS_TINYGL_H
|
||||||
|
#define GRAPHICS_TINYGL_H
|
||||||
|
|
||||||
|
#include "graphics/pixelformat.h"
|
||||||
|
#include "graphics/surface.h"
|
||||||
|
#include "graphics/tinygl/gl.h"
|
||||||
|
#include "graphics/tinygl/zblit_public.h"
|
||||||
|
|
||||||
|
namespace TinyGL {
|
||||||
|
|
||||||
|
void createContext(int screenW, int screenH, Graphics::PixelFormat pixelFormat, int textureSize, bool dirtyRectsEnable = true);
|
||||||
|
void destroyContext();
|
||||||
|
void presentBuffer();
|
||||||
|
void getSurfaceRef(Graphics::Surface &surface);
|
||||||
|
Graphics::Surface *copyToBuffer(const Graphics::PixelFormat &dstFormat);
|
||||||
|
|
||||||
|
} // end of namespace TinyGL
|
||||||
|
|
||||||
|
#endif
|
|
@ -20,12 +20,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is based on, or a modified version of code from TinyGL (C) 1997-1998 Fabrice Bellard,
|
|
||||||
* which is licensed under the zlib-license (see LICENSE).
|
|
||||||
* It also has modifications by the ResidualVM-team, which are covered under the GPLv2 (or later).
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
|
|
||||||
#include "graphics/tinygl/zblit.h"
|
#include "graphics/tinygl/zblit.h"
|
||||||
|
@ -33,6 +27,7 @@
|
||||||
#include "graphics/tinygl/pixelbuffer.h"
|
#include "graphics/tinygl/pixelbuffer.h"
|
||||||
#include "graphics/tinygl/zdirtyrect.h"
|
#include "graphics/tinygl/zdirtyrect.h"
|
||||||
#include "graphics/tinygl/gl.h"
|
#include "graphics/tinygl/gl.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
namespace TinyGL {
|
namespace TinyGL {
|
||||||
|
|
|
@ -20,154 +20,18 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is based on, or a modified version of code from TinyGL (C) 1997-1998 Fabrice Bellard,
|
|
||||||
* which is licensed under the zlib-license (see LICENSE).
|
|
||||||
* It also has modifications by the ResidualVM-team, which are covered under the GPLv2 (or later).
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GRAPHICS_TINYGL_ZBLIT_H_
|
#ifndef GRAPHICS_TINYGL_ZBLIT_H_
|
||||||
#define GRAPHICS_TINYGL_ZBLIT_H_
|
#define GRAPHICS_TINYGL_ZBLIT_H_
|
||||||
|
|
||||||
#include "graphics/surface.h"
|
|
||||||
#include "common/rect.h"
|
#include "common/rect.h"
|
||||||
|
|
||||||
|
#include "graphics/surface.h"
|
||||||
|
#include "graphics/tinygl/zblit_public.h"
|
||||||
|
|
||||||
namespace TinyGL {
|
namespace TinyGL {
|
||||||
|
|
||||||
struct BlitTransform {
|
|
||||||
BlitTransform(int dstX, int dstY) : _rotation(0), _originX(0), _originY(0), _aTint(1.0f),
|
|
||||||
_rTint(1.0f), _gTint(1.0f), _bTint(1.0), _flipHorizontally(false),
|
|
||||||
_flipVertically(false) {
|
|
||||||
_destinationRectangle.translate(dstX, dstY);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sourceRectangle(int srcX, int srcY, int srcWidth, int srcHeight) {
|
|
||||||
_sourceRectangle.left = srcX;
|
|
||||||
_sourceRectangle.top = srcY;
|
|
||||||
_sourceRectangle.setWidth(srcWidth);
|
|
||||||
_sourceRectangle.setHeight(srcHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tint(float aTint, float rTint = 1.0f, float gTint = 1.0f, float bTint = 1.0f) {
|
|
||||||
_aTint = aTint;
|
|
||||||
_rTint = rTint;
|
|
||||||
_gTint = gTint;
|
|
||||||
_bTint = bTint;
|
|
||||||
}
|
|
||||||
|
|
||||||
void scale(int width, int height) {
|
|
||||||
_destinationRectangle.setWidth(width);
|
|
||||||
_destinationRectangle.setHeight(height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void rotate(int rotation, int originX, int originY) {
|
|
||||||
_rotation = rotation;
|
|
||||||
_originX = originX;
|
|
||||||
_originY = originY;
|
|
||||||
}
|
|
||||||
|
|
||||||
void flip(bool verticalFlip, bool horizontalFlip) {
|
|
||||||
_flipVertically = verticalFlip;
|
|
||||||
_flipHorizontally = horizontalFlip;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const BlitTransform &other) const {
|
|
||||||
return _sourceRectangle == other._sourceRectangle && _destinationRectangle == other._destinationRectangle &&
|
|
||||||
_rotation == other._rotation && _originX == other._originX && _originY == other._originY &&
|
|
||||||
_aTint == other._aTint && _rTint == other._rTint && _gTint == other._gTint && _bTint == other._bTint &&
|
|
||||||
_flipHorizontally == other._flipHorizontally && _flipVertically == other._flipVertically;
|
|
||||||
}
|
|
||||||
|
|
||||||
Common::Rect _sourceRectangle;
|
|
||||||
Common::Rect _destinationRectangle;
|
|
||||||
int _rotation;
|
|
||||||
int _originX, _originY;
|
|
||||||
float _aTint, _rTint, _gTint, _bTint;
|
|
||||||
bool _flipHorizontally, _flipVertically;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BlitImage;
|
struct BlitImage;
|
||||||
|
|
||||||
} // end of namespace TinyGL
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Generates a new blit image.
|
|
||||||
@return returns an opaque pointer to the blit image.
|
|
||||||
*/
|
|
||||||
TinyGL::BlitImage *tglGenBlitImage();
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Copies a surface data into the provided blit image.
|
|
||||||
@param pointer to the blit image.
|
|
||||||
@param referece to the surface that's being copied
|
|
||||||
@param color key value for alpha color keying
|
|
||||||
@param boolean that enables alpha color keying
|
|
||||||
*/
|
|
||||||
void tglUploadBlitImage(TinyGL::BlitImage *blitImage, const Graphics::Surface &surface, uint32 colorKey, bool applyColorKey);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Destroys an instance of blit image.
|
|
||||||
@param pointer to the blit image.
|
|
||||||
*/
|
|
||||||
void tglDeleteBlitImage(TinyGL::BlitImage *blitImage);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Getter for current blit image width and height
|
|
||||||
@param pointer to the blit image.
|
|
||||||
@param reference to the width variable
|
|
||||||
@param reference to the height variable
|
|
||||||
*/
|
|
||||||
void tglGetBlitImageSize(TinyGL::BlitImage *blitImage, int &width, int &height);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Provides a way to check if the image has been updated.
|
|
||||||
@param pointer to the blit image.
|
|
||||||
@param boolean that enables alpha color keying
|
|
||||||
*/
|
|
||||||
int tglGetBlitImageVersion(TinyGL::BlitImage *blitImage);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Blits an image to the color buffer.
|
|
||||||
@param pointer to the blit image.
|
|
||||||
@param blit transform information.
|
|
||||||
*/
|
|
||||||
void tglBlit(TinyGL::BlitImage *blitImage, const TinyGL::BlitTransform &transform);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Blits an image to the color buffer.
|
|
||||||
@param pointer to the blit image.
|
|
||||||
@param x destination coordinate.
|
|
||||||
@param y destination coordinate.
|
|
||||||
*/
|
|
||||||
void tglBlit(TinyGL::BlitImage *blitImage, int x, int y);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Blits an image to the color buffer without performing any type of blending.
|
|
||||||
@param pointer to the blit image.
|
|
||||||
@param blit transform information.
|
|
||||||
*/
|
|
||||||
void tglBlitNoBlend(TinyGL::BlitImage *blitImage, const TinyGL::BlitTransform &transform);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Blits an image to the color buffer without performinc any type of blending, image transformation or tinting.
|
|
||||||
@param pointer to the blit image.
|
|
||||||
@param x destination coordinate.
|
|
||||||
@param y destination coordinate.
|
|
||||||
*/
|
|
||||||
void tglBlitFast(TinyGL::BlitImage *blitImage, int x, int y);
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Blits an image to the depth buffer.
|
|
||||||
@param pointer to the blit image.
|
|
||||||
@param x destination coordinate.
|
|
||||||
@param y destination coordinate.
|
|
||||||
*/
|
|
||||||
void tglBlitZBuffer(TinyGL::BlitImage *blitImage, int x, int y);
|
|
||||||
|
|
||||||
void tglIncBlitImageRef(TinyGL::BlitImage *blitImage);
|
|
||||||
|
|
||||||
namespace TinyGL {
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
/**
|
/**
|
||||||
@brief Performs a cleanup of disposed blit images.
|
@brief Performs a cleanup of disposed blit images.
|
||||||
|
|
164
graphics/tinygl/zblit_public.h
Normal file
164
graphics/tinygl/zblit_public.h
Normal file
|
@ -0,0 +1,164 @@
|
||||||
|
/* 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 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 GRAPHICS_TINYGL_ZBLIT_PUBLIC_H
|
||||||
|
#define GRAPHICS_TINYGL_ZBLIT_PUBLIC_H
|
||||||
|
|
||||||
|
#include "common/rect.h"
|
||||||
|
|
||||||
|
#include "graphics/surface.h"
|
||||||
|
|
||||||
|
namespace TinyGL {
|
||||||
|
|
||||||
|
struct BlitTransform {
|
||||||
|
BlitTransform(int dstX, int dstY) : _rotation(0), _originX(0), _originY(0), _aTint(1.0f),
|
||||||
|
_rTint(1.0f), _gTint(1.0f), _bTint(1.0), _flipHorizontally(false),
|
||||||
|
_flipVertically(false) {
|
||||||
|
_destinationRectangle.translate(dstX, dstY);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sourceRectangle(int srcX, int srcY, int srcWidth, int srcHeight) {
|
||||||
|
_sourceRectangle.left = srcX;
|
||||||
|
_sourceRectangle.top = srcY;
|
||||||
|
_sourceRectangle.setWidth(srcWidth);
|
||||||
|
_sourceRectangle.setHeight(srcHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tint(float aTint, float rTint = 1.0f, float gTint = 1.0f, float bTint = 1.0f) {
|
||||||
|
_aTint = aTint;
|
||||||
|
_rTint = rTint;
|
||||||
|
_gTint = gTint;
|
||||||
|
_bTint = bTint;
|
||||||
|
}
|
||||||
|
|
||||||
|
void scale(int width, int height) {
|
||||||
|
_destinationRectangle.setWidth(width);
|
||||||
|
_destinationRectangle.setHeight(height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rotate(int rotation, int originX, int originY) {
|
||||||
|
_rotation = rotation;
|
||||||
|
_originX = originX;
|
||||||
|
_originY = originY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void flip(bool verticalFlip, bool horizontalFlip) {
|
||||||
|
_flipVertically = verticalFlip;
|
||||||
|
_flipHorizontally = horizontalFlip;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const BlitTransform &other) const {
|
||||||
|
return _sourceRectangle == other._sourceRectangle && _destinationRectangle == other._destinationRectangle &&
|
||||||
|
_rotation == other._rotation && _originX == other._originX && _originY == other._originY &&
|
||||||
|
_aTint == other._aTint && _rTint == other._rTint && _gTint == other._gTint && _bTint == other._bTint &&
|
||||||
|
_flipHorizontally == other._flipHorizontally && _flipVertically == other._flipVertically;
|
||||||
|
}
|
||||||
|
|
||||||
|
Common::Rect _sourceRectangle;
|
||||||
|
Common::Rect _destinationRectangle;
|
||||||
|
int _rotation;
|
||||||
|
int _originX, _originY;
|
||||||
|
float _aTint, _rTint, _gTint, _bTint;
|
||||||
|
bool _flipHorizontally, _flipVertically;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BlitImage;
|
||||||
|
|
||||||
|
} // end of namespace TinyGL
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Generates a new blit image.
|
||||||
|
@return returns an opaque pointer to the blit image.
|
||||||
|
*/
|
||||||
|
TinyGL::BlitImage *tglGenBlitImage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Copies a surface data into the provided blit image.
|
||||||
|
@param pointer to the blit image.
|
||||||
|
@param referece to the surface that's being copied
|
||||||
|
@param color key value for alpha color keying
|
||||||
|
@param boolean that enables alpha color keying
|
||||||
|
*/
|
||||||
|
void tglUploadBlitImage(TinyGL::BlitImage *blitImage, const Graphics::Surface &surface, uint32 colorKey, bool applyColorKey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Destroys an instance of blit image.
|
||||||
|
@param pointer to the blit image.
|
||||||
|
*/
|
||||||
|
void tglDeleteBlitImage(TinyGL::BlitImage *blitImage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Getter for current blit image width and height
|
||||||
|
@param pointer to the blit image.
|
||||||
|
@param reference to the width variable
|
||||||
|
@param reference to the height variable
|
||||||
|
*/
|
||||||
|
void tglGetBlitImageSize(TinyGL::BlitImage *blitImage, int &width, int &height);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Provides a way to check if the image has been updated.
|
||||||
|
@param pointer to the blit image.
|
||||||
|
@param boolean that enables alpha color keying
|
||||||
|
*/
|
||||||
|
int tglGetBlitImageVersion(TinyGL::BlitImage *blitImage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Blits an image to the color buffer.
|
||||||
|
@param pointer to the blit image.
|
||||||
|
@param blit transform information.
|
||||||
|
*/
|
||||||
|
void tglBlit(TinyGL::BlitImage *blitImage, const TinyGL::BlitTransform &transform);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Blits an image to the color buffer.
|
||||||
|
@param pointer to the blit image.
|
||||||
|
@param x destination coordinate.
|
||||||
|
@param y destination coordinate.
|
||||||
|
*/
|
||||||
|
void tglBlit(TinyGL::BlitImage *blitImage, int x, int y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Blits an image to the color buffer without performing any type of blending.
|
||||||
|
@param pointer to the blit image.
|
||||||
|
@param blit transform information.
|
||||||
|
*/
|
||||||
|
void tglBlitNoBlend(TinyGL::BlitImage *blitImage, const TinyGL::BlitTransform &transform);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Blits an image to the color buffer without performinc any type of blending, image transformation or tinting.
|
||||||
|
@param pointer to the blit image.
|
||||||
|
@param x destination coordinate.
|
||||||
|
@param y destination coordinate.
|
||||||
|
*/
|
||||||
|
void tglBlitFast(TinyGL::BlitImage *blitImage, int x, int y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Blits an image to the depth buffer.
|
||||||
|
@param pointer to the blit image.
|
||||||
|
@param x destination coordinate.
|
||||||
|
@param y destination coordinate.
|
||||||
|
*/
|
||||||
|
void tglBlitZBuffer(TinyGL::BlitImage *blitImage, int x, int y);
|
||||||
|
|
||||||
|
void tglIncBlitImageRef(TinyGL::BlitImage *blitImage);
|
||||||
|
|
||||||
|
#endif // GRAPHICS_TINYGL_ZBLIT_PUBLIC_H
|
|
@ -106,16 +106,6 @@ struct FrameBuffer {
|
||||||
FrameBuffer(int xsize, int ysize, const Graphics::PixelFormat &format);
|
FrameBuffer(int xsize, int ysize, const Graphics::PixelFormat &format);
|
||||||
~FrameBuffer();
|
~FrameBuffer();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
Buffer *genOffscreenBuffer();
|
|
||||||
void delOffscreenBuffer(Buffer *buffer);
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void clear(int clear_z, int z, int clear_color, int r, int g, int b);
|
|
||||||
void clearRegion(int x, int y, int w, int h,int clear_z, int z, int clear_color, int r, int g, int b);
|
|
||||||
|
|
||||||
Graphics::PixelFormat getPixelFormat() {
|
Graphics::PixelFormat getPixelFormat() {
|
||||||
return _pbufFormat;
|
return _pbufFormat;
|
||||||
}
|
}
|
||||||
|
@ -132,15 +122,23 @@ public:
|
||||||
return _pbufHeight;
|
return _pbufHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int *getZBuffer() {
|
const uint *getZBuffer() {
|
||||||
return _zbuf;
|
return _zbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE void readPixelRGB(int pixel, byte &r, byte &g, byte &b) {
|
Graphics::Surface *copyToBuffer(const Graphics::PixelFormat &dstFormat) {
|
||||||
_pbuf.getRGBAt(pixel, r, g, b);
|
Graphics::Surface tmp;
|
||||||
|
tmp.init(_pbufWidth, _pbufHeight, _pbufPitch, _pbuf.getRawBuffer(), _pbufFormat);
|
||||||
|
return tmp.convertTo(dstFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE bool compareDepth(unsigned int &zSrc, unsigned int &zDst) {
|
void getSurfaceRef(Graphics::Surface &surface) {
|
||||||
|
surface.init(_pbufWidth, _pbufHeight, _pbufPitch, _pbuf.getRawBuffer(), _pbufFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
FORCEINLINE bool compareDepth(uint &zSrc, uint &zDst) {
|
||||||
if (!_depthTestEnabled)
|
if (!_depthTestEnabled)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -177,8 +175,6 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
FORCEINLINE bool checkAlphaTest(byte aSrc) {
|
FORCEINLINE bool checkAlphaTest(byte aSrc) {
|
||||||
if (!_alphaTestEnabled)
|
if (!_alphaTestEnabled)
|
||||||
return true;
|
return true;
|
||||||
|
@ -216,15 +212,11 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
template <bool kEnableAlphaTest, bool kBlendingEnabled>
|
template <bool kEnableAlphaTest, bool kBlendingEnabled>
|
||||||
FORCEINLINE void writePixel(int pixel, int value) {
|
FORCEINLINE void writePixel(int pixel, int value) {
|
||||||
writePixel<kEnableAlphaTest, kBlendingEnabled, false>(pixel, value, 0);
|
writePixel<kEnableAlphaTest, kBlendingEnabled, false>(pixel, value, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
template <bool kEnableAlphaTest, bool kBlendingEnabled, bool kDepthWrite>
|
template <bool kEnableAlphaTest, bool kBlendingEnabled, bool kDepthWrite>
|
||||||
FORCEINLINE void writePixel(int pixel, int value, unsigned int z) {
|
FORCEINLINE void writePixel(int pixel, int value, unsigned int z) {
|
||||||
if (kBlendingEnabled == false) {
|
if (kBlendingEnabled == false) {
|
||||||
|
@ -248,6 +240,29 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <bool kDepthWrite, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending>
|
||||||
|
FORCEINLINE void putPixelFlat(FrameBuffer *buffer, int buf, unsigned int *pz, int _a,
|
||||||
|
int x, int y, unsigned int &z, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a, int &dzdx);
|
||||||
|
|
||||||
|
template <bool kDepthWrite, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending>
|
||||||
|
FORCEINLINE void putPixelSmooth(FrameBuffer *buffer, int buf, unsigned int *pz, int _a,
|
||||||
|
int x, int y, unsigned int &z, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a,
|
||||||
|
int &dzdx, int &drdx, int &dgdx, int &dbdx, unsigned int dadx);
|
||||||
|
|
||||||
|
template <bool kDepthWrite, bool kEnableScissor>
|
||||||
|
FORCEINLINE void putPixelDepth(FrameBuffer *buffer, int buf, unsigned int *pz, int _a, int x, int y, unsigned int &z, int &dzdx);
|
||||||
|
|
||||||
|
template <bool kDepthWrite, bool kAlphaTestEnabled, bool kEnableScissor, bool kBlendingEnabled>
|
||||||
|
FORCEINLINE void putPixelShadow(FrameBuffer *buffer, int buf, unsigned int *pz, int _a, int x, int y, unsigned int &z,
|
||||||
|
unsigned int &r, unsigned int &g, unsigned int &b, int &dzdx, unsigned char *pm);
|
||||||
|
|
||||||
|
template <bool kDepthWrite, bool kLightsMode, bool kSmoothMode, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending>
|
||||||
|
FORCEINLINE void putPixelTextureMappingPerspective(FrameBuffer *buffer, int buf, const Graphics::TexelBuffer *texture,
|
||||||
|
unsigned int wrap_s, unsigned int wrap_t, unsigned int *pz, int _a,
|
||||||
|
int x, int y, unsigned int &z, int &t, int &s,
|
||||||
|
unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a,
|
||||||
|
int &dzdx, int &dsdx, int &dtdx, int &drdx, int &dgdx, int &dbdx, unsigned int dadx);
|
||||||
|
|
||||||
template <bool kEnableAlphaTest>
|
template <bool kEnableAlphaTest>
|
||||||
FORCEINLINE void writePixel(int pixel, int value) {
|
FORCEINLINE void writePixel(int pixel, int value) {
|
||||||
if (_blendingEnabled) {
|
if (_blendingEnabled) {
|
||||||
|
@ -261,12 +276,12 @@ private:
|
||||||
writePixel(pixel, 255, rSrc, gSrc, bSrc);
|
writePixel(pixel, 255, rSrc, gSrc, bSrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
FORCEINLINE bool scissorPixel(int x, int y) {
|
FORCEINLINE bool scissorPixel(int x, int y) {
|
||||||
return !_clipRectangle.contains(x, y);
|
return !_clipRectangle.contains(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
FORCEINLINE void writePixel(int pixel, byte aSrc, byte rSrc, byte gSrc, byte bSrc) {
|
FORCEINLINE void writePixel(int pixel, byte aSrc, byte rSrc, byte gSrc, byte bSrc) {
|
||||||
if (_alphaTestEnabled) {
|
if (_alphaTestEnabled) {
|
||||||
writePixel<true>(pixel, aSrc, rSrc, gSrc, bSrc);
|
writePixel<true>(pixel, aSrc, rSrc, gSrc, bSrc);
|
||||||
|
@ -275,6 +290,8 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
template <bool kEnableAlphaTest>
|
template <bool kEnableAlphaTest>
|
||||||
FORCEINLINE void writePixel(int pixel, byte aSrc, byte rSrc, byte gSrc, byte bSrc) {
|
FORCEINLINE void writePixel(int pixel, byte aSrc, byte rSrc, byte gSrc, byte bSrc) {
|
||||||
if (_blendingEnabled) {
|
if (_blendingEnabled) {
|
||||||
|
@ -401,93 +418,92 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Graphics::Surface *copyToBuffer(const Graphics::PixelFormat &dstFormat) {
|
public:
|
||||||
Graphics::Surface tmp;
|
|
||||||
tmp.init(_pbufWidth, _pbufHeight, _pbufPitch, _pbuf.getRawBuffer(), _pbufFormat);
|
|
||||||
return tmp.convertTo(dstFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
void getSurfaceRef(Graphics::Surface &surface) {
|
void clear(int clear_z, int z, int clear_color, int r, int g, int b);
|
||||||
surface.init(_pbufWidth, _pbufHeight, _pbufPitch, _pbuf.getRawBuffer(), _pbufFormat);
|
void clearRegion(int x, int y, int w, int h,int clear_z, int z, int clear_color, int r, int g, int b);
|
||||||
}
|
|
||||||
|
|
||||||
void setScissorRectangle(const Common::Rect &rect) {
|
FORCEINLINE void setScissorRectangle(const Common::Rect &rect) {
|
||||||
_clipRectangle = rect;
|
_clipRectangle = rect;
|
||||||
_enableScissor = true;
|
_enableScissor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetScissorRectangle() {
|
FORCEINLINE void resetScissorRectangle() {
|
||||||
_enableScissor = false;
|
_enableScissor = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setShadowMaskBuf(byte *shadowBuffer) {
|
FORCEINLINE void setShadowMaskBuf(byte *shadowBuffer) {
|
||||||
_shadowMaskBuf = shadowBuffer;
|
_shadowMaskBuf = shadowBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setShadowRGB(int r, int g, int b) {
|
FORCEINLINE void setShadowRGB(int r, int g, int b) {
|
||||||
_shadowColorR = r;
|
_shadowColorR = r;
|
||||||
_shadowColorG = g;
|
_shadowColorG = g;
|
||||||
_shadowColorB = b;
|
_shadowColorB = b;
|
||||||
}
|
}
|
||||||
void enableBlending(bool enable) {
|
|
||||||
|
FORCEINLINE void enableBlending(bool enable) {
|
||||||
_blendingEnabled = enable;
|
_blendingEnabled = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableDepthTest(bool enable) {
|
FORCEINLINE void setBlendingFactors(int sFactor, int dFactor) {
|
||||||
_depthTestEnabled = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setOffsetStates(int offsetStates) {
|
|
||||||
_offsetStates = offsetStates;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setOffsetFactor(float offsetFactor) {
|
|
||||||
_offsetFactor = offsetFactor;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setOffsetUnits(float offsetUnits) {
|
|
||||||
_offsetUnits = offsetUnits;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBlendingFactors(int sFactor, int dFactor) {
|
|
||||||
_sourceBlendingFactor = sFactor;
|
_sourceBlendingFactor = sFactor;
|
||||||
_destinationBlendingFactor = dFactor;
|
_destinationBlendingFactor = dFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableAlphaTest(bool enable) {
|
FORCEINLINE void enableAlphaTest(bool enable) {
|
||||||
_alphaTestEnabled = enable;
|
_alphaTestEnabled = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAlphaTestFunc(int func, int ref) {
|
FORCEINLINE void setAlphaTestFunc(int func, int ref) {
|
||||||
_alphaTestFunc = func;
|
_alphaTestFunc = func;
|
||||||
_alphaTestRefVal = ref;
|
_alphaTestRefVal = ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDepthFunc(int func) {
|
FORCEINLINE void enableDepthTest(bool enable) {
|
||||||
|
_depthTestEnabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCEINLINE void setDepthFunc(int func) {
|
||||||
_depthFunc = func;
|
_depthFunc = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableDepthWrite(bool enable) {
|
FORCEINLINE void enableDepthWrite(bool enable) {
|
||||||
_depthWrite = enable;
|
_depthWrite = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTexture(const Graphics::TexelBuffer *texture, unsigned int wraps, unsigned int wrapt) {
|
FORCEINLINE void setOffsetStates(int offsetStates) {
|
||||||
|
_offsetStates = offsetStates;
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCEINLINE void setOffsetFactor(float offsetFactor) {
|
||||||
|
_offsetFactor = offsetFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCEINLINE void setOffsetUnits(float offsetUnits) {
|
||||||
|
_offsetUnits = offsetUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCEINLINE void setTexture(const Graphics::TexelBuffer *texture, unsigned int wraps, unsigned int wrapt) {
|
||||||
_currentTexture = texture;
|
_currentTexture = texture;
|
||||||
_wrapS = wraps;
|
_wrapS = wraps;
|
||||||
_wrapT = wrapt;
|
_wrapT = wrapt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTextureSizeAndMask(int textureSize, int textureSizeMask) {
|
FORCEINLINE void setTextureSizeAndMask(int textureSize, int textureSizeMask) {
|
||||||
_textureSize = textureSize;
|
_textureSize = textureSize;
|
||||||
_textureSizeMask = textureSizeMask;
|
_textureSizeMask = textureSizeMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blit the buffer to the screen buffer, checking the depth of the pixels.
|
* Blit the buffer to the screen buffer, checking the depth of the pixels.
|
||||||
* Eack pixel is copied if and only if its depth value is bigger than the
|
* Eack pixel is copied if and only if its depth value is bigger than the
|
||||||
* depth value of the screen pixel, so if it is 'above'.
|
* depth value of the screen pixel, so if it is 'above'.
|
||||||
*/
|
*/
|
||||||
|
Buffer *genOffscreenBuffer();
|
||||||
|
void delOffscreenBuffer(Buffer *buffer);
|
||||||
void blitOffscreenBuffer(Buffer *buffer);
|
void blitOffscreenBuffer(Buffer *buffer);
|
||||||
void selectOffscreenBuffer(Buffer *buffer);
|
void selectOffscreenBuffer(Buffer *buffer);
|
||||||
void clearOffscreenBuffer(Buffer *buffer);
|
void clearOffscreenBuffer(Buffer *buffer);
|
||||||
|
@ -538,10 +554,10 @@ private:
|
||||||
FORCEINLINE void putPixel(unsigned int pixelOffset, int color, int x, int y);
|
FORCEINLINE void putPixel(unsigned int pixelOffset, int color, int x, int y);
|
||||||
|
|
||||||
template <bool kInterpRGB, bool kInterpZ, bool kDepthWrite>
|
template <bool kInterpRGB, bool kInterpZ, bool kDepthWrite>
|
||||||
void drawLine(const ZBufferPoint *p1, const ZBufferPoint *p2);
|
FORCEINLINE void drawLine(const ZBufferPoint *p1, const ZBufferPoint *p2);
|
||||||
|
|
||||||
template <bool kInterpRGB, bool kInterpZ, bool kDepthWrite, bool kEnableScissor>
|
template <bool kInterpRGB, bool kInterpZ, bool kDepthWrite, bool kEnableScissor>
|
||||||
void drawLine(const ZBufferPoint *p1, const ZBufferPoint *p2);
|
FORCEINLINE void drawLine(const ZBufferPoint *p1, const ZBufferPoint *p2);
|
||||||
|
|
||||||
Buffer _offscreenBuffer;
|
Buffer _offscreenBuffer;
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,10 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is based on, or a modified version of code from TinyGL (C) 1997-1998 Fabrice Bellard,
|
|
||||||
* which is licensed under the zlib-license (see LICENSE).
|
|
||||||
* It also has modifications by the ResidualVM-team, which are covered under the GPLv2 (or later).
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "graphics/tinygl/zdirtyrect.h"
|
#include "graphics/tinygl/zdirtyrect.h"
|
||||||
#include "graphics/tinygl/zgl.h"
|
#include "graphics/tinygl/zgl.h"
|
||||||
#include "graphics/tinygl/gl.h"
|
#include "graphics/tinygl/gl.h"
|
||||||
|
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
#include "common/math.h"
|
#include "common/math.h"
|
||||||
|
|
||||||
|
|
|
@ -20,19 +20,14 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
#ifndef GRAPHICS_TINYGL_ZRECT_H
|
||||||
* This file is based on, or a modified version of code from TinyGL (C) 1997-1998 Fabrice Bellard,
|
#define GRAPHICS_TINYGL_ZRECT_H
|
||||||
* which is licensed under the zlib-license (see LICENSE).
|
|
||||||
* It also has modifications by the ResidualVM-team, which are covered under the GPLv2 (or later).
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GRAPHICS_TINYGL_ZRECT_H_
|
|
||||||
#define GRAPHICS_TINYGL_ZRECT_H_
|
|
||||||
|
|
||||||
#include "common/rect.h"
|
#include "common/rect.h"
|
||||||
#include "graphics/tinygl/zblit.h"
|
|
||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
|
|
||||||
|
#include "graphics/tinygl/zblit.h"
|
||||||
|
|
||||||
namespace TinyGL {
|
namespace TinyGL {
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
#include "common/list.h"
|
#include "common/list.h"
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
|
|
||||||
|
#include "graphics/pixelformat.h"
|
||||||
|
#include "graphics/surface.h"
|
||||||
#include "graphics/tinygl/gl.h"
|
#include "graphics/tinygl/gl.h"
|
||||||
#include "graphics/tinygl/zbuffer.h"
|
#include "graphics/tinygl/zbuffer.h"
|
||||||
#include "graphics/tinygl/zmath.h"
|
#include "graphics/tinygl/zmath.h"
|
||||||
|
@ -486,13 +488,6 @@ GLContext *gl_get_context();
|
||||||
// matrix.c
|
// matrix.c
|
||||||
void gl_print_matrix(const float *m);
|
void gl_print_matrix(const float *m);
|
||||||
|
|
||||||
void getSurfaceRef(Graphics::Surface &surface);
|
|
||||||
|
|
||||||
Graphics::Surface *copyToBuffer(const Graphics::PixelFormat &dstFormat);
|
|
||||||
|
|
||||||
void createContext(int screenW, int screenH, Graphics::PixelFormat pixelFormat, int textureSize, bool dirtyRectsEnable = true);
|
|
||||||
void destroyContext();
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define dprintf fprintf
|
#define dprintf fprintf
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -36,8 +36,8 @@ namespace TinyGL {
|
||||||
static const int NB_INTERP = 8;
|
static const int NB_INTERP = 8;
|
||||||
|
|
||||||
template <bool kDepthWrite, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending>
|
template <bool kDepthWrite, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending>
|
||||||
FORCEINLINE static void putPixelFlat(FrameBuffer *buffer, int buf, unsigned int *pz, int _a,
|
FORCEINLINE void FrameBuffer::putPixelFlat(FrameBuffer *buffer, int buf, unsigned int *pz, int _a,
|
||||||
int x, int y, unsigned int &z, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a, int &dzdx) {
|
int x, int y, unsigned int &z, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a, int &dzdx) {
|
||||||
if ((!kEnableScissor || !buffer->scissorPixel(x + _a, y)) && buffer->compareDepth(z, pz[_a])) {
|
if ((!kEnableScissor || !buffer->scissorPixel(x + _a, y)) && buffer->compareDepth(z, pz[_a])) {
|
||||||
buffer->writePixel<kEnableAlphaTest, kEnableBlending, kDepthWrite>(buf + _a, a >> (ZB_POINT_ALPHA_BITS - 8), r >> (ZB_POINT_RED_BITS - 8), g >> (ZB_POINT_GREEN_BITS - 8), b >> (ZB_POINT_BLUE_BITS - 8), z);
|
buffer->writePixel<kEnableAlphaTest, kEnableBlending, kDepthWrite>(buf + _a, a >> (ZB_POINT_ALPHA_BITS - 8), r >> (ZB_POINT_RED_BITS - 8), g >> (ZB_POINT_GREEN_BITS - 8), b >> (ZB_POINT_BLUE_BITS - 8), z);
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,9 @@ FORCEINLINE static void putPixelFlat(FrameBuffer *buffer, int buf, unsigned int
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool kDepthWrite, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending>
|
template <bool kDepthWrite, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending>
|
||||||
FORCEINLINE static void putPixelSmooth(FrameBuffer *buffer, int buf, unsigned int *pz, int _a,
|
FORCEINLINE void FrameBuffer::putPixelSmooth(FrameBuffer *buffer, int buf, unsigned int *pz, int _a,
|
||||||
int x, int y, unsigned int &z, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a,
|
int x, int y, unsigned int &z, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a,
|
||||||
int &dzdx, int &drdx, int &dgdx, int &dbdx, unsigned int dadx) {
|
int &dzdx, int &drdx, int &dgdx, int &dbdx, unsigned int dadx) {
|
||||||
if ((!kEnableScissor || !buffer->scissorPixel(x + _a, y)) && buffer->compareDepth(z, pz[_a])) {
|
if ((!kEnableScissor || !buffer->scissorPixel(x + _a, y)) && buffer->compareDepth(z, pz[_a])) {
|
||||||
buffer->writePixel<kEnableAlphaTest, kEnableBlending, kDepthWrite>(buf + _a, a >> (ZB_POINT_ALPHA_BITS - 8), r >> (ZB_POINT_RED_BITS - 8), g >> (ZB_POINT_GREEN_BITS - 8), b >> (ZB_POINT_BLUE_BITS - 8), z);
|
buffer->writePixel<kEnableAlphaTest, kEnableBlending, kDepthWrite>(buf + _a, a >> (ZB_POINT_ALPHA_BITS - 8), r >> (ZB_POINT_RED_BITS - 8), g >> (ZB_POINT_GREEN_BITS - 8), b >> (ZB_POINT_BLUE_BITS - 8), z);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ FORCEINLINE static void putPixelSmooth(FrameBuffer *buffer, int buf, unsigned in
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool kDepthWrite, bool kEnableScissor>
|
template <bool kDepthWrite, bool kEnableScissor>
|
||||||
FORCEINLINE static void putPixelDepth(FrameBuffer *buffer, int buf, unsigned int *pz, int _a, int x, int y, unsigned int &z, int &dzdx) {
|
FORCEINLINE void FrameBuffer::putPixelDepth(FrameBuffer *buffer, int buf, unsigned int *pz, int _a, int x, int y, unsigned int &z, int &dzdx) {
|
||||||
if ((!kEnableScissor || !buffer->scissorPixel(x + _a, y)) && buffer->compareDepth(z, pz[_a])) {
|
if ((!kEnableScissor || !buffer->scissorPixel(x + _a, y)) && buffer->compareDepth(z, pz[_a])) {
|
||||||
if (kDepthWrite) {
|
if (kDepthWrite) {
|
||||||
pz[_a] = z;
|
pz[_a] = z;
|
||||||
|
@ -69,7 +69,8 @@ FORCEINLINE static void putPixelDepth(FrameBuffer *buffer, int buf, unsigned int
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool kDepthWrite, bool kAlphaTestEnabled, bool kEnableScissor, bool kBlendingEnabled>
|
template <bool kDepthWrite, bool kAlphaTestEnabled, bool kEnableScissor, bool kBlendingEnabled>
|
||||||
FORCEINLINE static void putPixelShadow(FrameBuffer *buffer, int buf, unsigned int *pz, int _a, int x, int y, unsigned int &z, unsigned int &r, unsigned int &g, unsigned int &b, int &dzdx, unsigned char *pm) {
|
FORCEINLINE void FrameBuffer::putPixelShadow(FrameBuffer *buffer, int buf, unsigned int *pz, int _a, int x, int y, unsigned int &z,
|
||||||
|
unsigned int &r, unsigned int &g, unsigned int &b, int &dzdx, unsigned char *pm) {
|
||||||
if ((!kEnableScissor || !buffer->scissorPixel(x + _a, y)) && buffer->compareDepth(z, pz[_a]) && pm[_a]) {
|
if ((!kEnableScissor || !buffer->scissorPixel(x + _a, y)) && buffer->compareDepth(z, pz[_a]) && pm[_a]) {
|
||||||
buffer->writePixel<kAlphaTestEnabled, kBlendingEnabled, kDepthWrite>(buf + _a, 255, r >> (ZB_POINT_RED_BITS - 8), g >> (ZB_POINT_GREEN_BITS - 8), b >> (ZB_POINT_BLUE_BITS - 8), z);
|
buffer->writePixel<kAlphaTestEnabled, kBlendingEnabled, kDepthWrite>(buf + _a, 255, r >> (ZB_POINT_RED_BITS - 8), g >> (ZB_POINT_GREEN_BITS - 8), b >> (ZB_POINT_BLUE_BITS - 8), z);
|
||||||
}
|
}
|
||||||
|
@ -77,10 +78,11 @@ FORCEINLINE static void putPixelShadow(FrameBuffer *buffer, int buf, unsigned in
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool kDepthWrite, bool kLightsMode, bool kSmoothMode, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending>
|
template <bool kDepthWrite, bool kLightsMode, bool kSmoothMode, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending>
|
||||||
FORCEINLINE static void putPixelTextureMappingPerspective(FrameBuffer *buffer, int buf,
|
FORCEINLINE void FrameBuffer::putPixelTextureMappingPerspective(FrameBuffer *buffer, int buf, const Graphics::TexelBuffer *texture,
|
||||||
const Graphics::TexelBuffer *texture, unsigned int wrap_s, unsigned int wrap_t, unsigned int *pz, int _a,
|
unsigned int wrap_s, unsigned int wrap_t, unsigned int *pz, int _a,
|
||||||
int x, int y, unsigned int &z, int &t, int &s, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a,
|
int x, int y, unsigned int &z, int &t, int &s,
|
||||||
int &dzdx, int &dsdx, int &dtdx, int &drdx, int &dgdx, int &dbdx, unsigned int dadx) {
|
unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a,
|
||||||
|
int &dzdx, int &dsdx, int &dtdx, int &drdx, int &dgdx, int &dbdx, unsigned int dadx) {
|
||||||
if ((!kEnableScissor || !buffer->scissorPixel(x + _a, y)) && buffer->compareDepth(z, pz[_a])) {
|
if ((!kEnableScissor || !buffer->scissorPixel(x + _a, y)) && buffer->compareDepth(z, pz[_a])) {
|
||||||
uint8 c_a, c_r, c_g, c_b;
|
uint8 c_a, c_r, c_g, c_b;
|
||||||
texture->getARGBAt(wrap_s, wrap_t, s, t, c_a, c_r, c_g, c_b);
|
texture->getARGBAt(wrap_s, wrap_t, s, t, c_a, c_r, c_g, c_b);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue