TINYGL: Janitorial
This commit is contained in:
parent
c98fe1c61c
commit
b673e0adf5
16 changed files with 138 additions and 131 deletions
|
@ -698,7 +698,7 @@ void tglInitNames() {
|
||||||
c->gl_add_op(p);
|
c->gl_add_op(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tglPushName(unsigned int name) {
|
void tglPushName(uint name) {
|
||||||
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
||||||
TinyGL::GLParam p[2];
|
TinyGL::GLParam p[2];
|
||||||
|
|
||||||
|
@ -717,7 +717,7 @@ void tglPopName() {
|
||||||
c->gl_add_op(p);
|
c->gl_add_op(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tglLoadName(unsigned int name) {
|
void tglLoadName(uint name) {
|
||||||
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
||||||
TinyGL::GLParam p[2];
|
TinyGL::GLParam p[2];
|
||||||
|
|
||||||
|
@ -740,7 +740,7 @@ void tglPolygonOffset(TGLfloat factor, TGLfloat units) {
|
||||||
|
|
||||||
// Special Functions
|
// Special Functions
|
||||||
|
|
||||||
void tglCallList(unsigned int list) {
|
void tglCallList(uint list) {
|
||||||
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
||||||
TinyGL::GLParam p[2];
|
TinyGL::GLParam p[2];
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,8 @@ void GLContext::glopClear(GLParam *p) {
|
||||||
int s = (int)(clear_stencil);
|
int s = (int)(clear_stencil);
|
||||||
|
|
||||||
issueDrawCall(new ClearBufferDrawCall(mask & TGL_DEPTH_BUFFER_BIT, z,
|
issueDrawCall(new ClearBufferDrawCall(mask & TGL_DEPTH_BUFFER_BIT, z,
|
||||||
mask & TGL_COLOR_BUFFER_BIT, r, g, b,
|
mask & TGL_COLOR_BUFFER_BIT, r, g, b,
|
||||||
mask & TGL_STENCIL_BUFFER_BIT, s));
|
mask & TGL_STENCIL_BUFFER_BIT, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of namespace TinyGL
|
} // end of namespace TinyGL
|
||||||
|
|
|
@ -42,7 +42,7 @@ static inline int interpolate(int v00, int v01, int v10, int xf, int yf) {
|
||||||
// TODO: more accurate resampling
|
// TODO: more accurate resampling
|
||||||
|
|
||||||
void GLContext::gl_resizeImage(Graphics::PixelBuffer &dest, int xsize_dest, int ysize_dest,
|
void GLContext::gl_resizeImage(Graphics::PixelBuffer &dest, int xsize_dest, int ysize_dest,
|
||||||
const Graphics::PixelBuffer &src, int xsize_src, int ysize_src) {
|
const Graphics::PixelBuffer &src, int xsize_src, int ysize_src) {
|
||||||
int point1_offset, point2_offset, point3_offset, dest_offset = 0;
|
int point1_offset, point2_offset, point3_offset, dest_offset = 0;
|
||||||
int point_y_offset, point_offset;
|
int point_y_offset, point_offset;
|
||||||
float x1, y1, x1inc, y1inc;
|
float x1, y1, x1inc, y1inc;
|
||||||
|
@ -111,7 +111,7 @@ void GLContext::gl_resizeImage(Graphics::PixelBuffer &dest, int xsize_dest, int
|
||||||
|
|
||||||
// resizing with no interlating nor nearest pixel
|
// resizing with no interlating nor nearest pixel
|
||||||
void GLContext::gl_resizeImageNoInterpolate(Graphics::PixelBuffer &dest, int xsize_dest, int ysize_dest,
|
void GLContext::gl_resizeImageNoInterpolate(Graphics::PixelBuffer &dest, int xsize_dest, int ysize_dest,
|
||||||
const Graphics::PixelBuffer &src, int xsize_src, int ysize_src) {
|
const Graphics::PixelBuffer &src, int xsize_src, int ysize_src) {
|
||||||
int dest_offset = 0;
|
int dest_offset = 0;
|
||||||
int x1, y1, x1inc, y1inc;
|
int x1, y1, x1inc, y1inc;
|
||||||
int yi;
|
int yi;
|
||||||
|
|
|
@ -58,7 +58,7 @@ GLContext *gl_get_context() {
|
||||||
return gl_ctx;
|
return gl_ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLList *find_list(GLContext *c, unsigned int list) {
|
static GLList *find_list(GLContext *c, uint list) {
|
||||||
return c->shared_state.lists[list];
|
return c->shared_state.lists[list];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ void GLContext::glopCallList(GLParam *p) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tglNewList(unsigned int list, int mode) {
|
void tglNewList(uint list, int mode) {
|
||||||
GLList *l;
|
GLList *l;
|
||||||
GLContext *c = gl_get_context();
|
GLContext *c = gl_get_context();
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ void tglEndList() {
|
||||||
c->exec_flag = 1;
|
c->exec_flag = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tglIsList(unsigned int list) {
|
int tglIsList(uint list) {
|
||||||
GLContext *c = gl_get_context();
|
GLContext *c = gl_get_context();
|
||||||
GLList *l = find_list(c, list);
|
GLList *l = find_list(c, list);
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ int tglRenderMode(int mode) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tglSelectBuffer(int size, unsigned int *buf) {
|
void tglSelectBuffer(int size, uint *buf) {
|
||||||
GLContext *c = gl_get_context();
|
GLContext *c = gl_get_context();
|
||||||
|
|
||||||
assert(c->render_mode != TGL_SELECT);
|
assert(c->render_mode != TGL_SELECT);
|
||||||
|
@ -108,8 +108,8 @@ void GLContext::glopLoadName(GLParam *p) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLContext::gl_add_select(unsigned int zmin, unsigned int zmax) {
|
void GLContext::gl_add_select(uint zmin, uint zmax) {
|
||||||
unsigned int *ptr;
|
uint *ptr;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (!select_overflow) {
|
if (!select_overflow) {
|
||||||
|
|
|
@ -25,12 +25,12 @@
|
||||||
#include "graphics/tinygl/zbuffer.h"
|
#include "graphics/tinygl/zbuffer.h"
|
||||||
#include "graphics/tinygl/texelbuffer.h"
|
#include "graphics/tinygl/texelbuffer.h"
|
||||||
|
|
||||||
namespace Graphics {
|
namespace TinyGL {
|
||||||
|
|
||||||
#define ZB_POINT_ST_UNIT (1 << ZB_POINT_ST_FRAC_BITS)
|
#define ZB_POINT_ST_UNIT (1 << ZB_POINT_ST_FRAC_BITS)
|
||||||
#define ZB_POINT_ST_FRAC_MASK (ZB_POINT_ST_UNIT - 1)
|
#define ZB_POINT_ST_FRAC_MASK (ZB_POINT_ST_UNIT - 1)
|
||||||
|
|
||||||
TexelBuffer::TexelBuffer(unsigned int width, unsigned int height, unsigned int textureSize) {
|
TexelBuffer::TexelBuffer(uint width, uint height, uint textureSize) {
|
||||||
assert(width);
|
assert(width);
|
||||||
assert(height);
|
assert(height);
|
||||||
assert(textureSize);
|
assert(textureSize);
|
||||||
|
@ -43,7 +43,7 @@ TexelBuffer::TexelBuffer(unsigned int width, unsigned int height, unsigned int t
|
||||||
_heightRatio = (float) height / textureSize;
|
_heightRatio = (float) height / textureSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned int wrap(unsigned int wrap_mode, int coord, unsigned int _fracTextureUnit, unsigned int _fracTextureMask) {
|
static inline uint wrap(uint wrap_mode, int coord, uint _fracTextureUnit, uint _fracTextureMask) {
|
||||||
switch (wrap_mode) {
|
switch (wrap_mode) {
|
||||||
case TGL_MIRRORED_REPEAT:
|
case TGL_MIRRORED_REPEAT:
|
||||||
if (coord & _fracTextureUnit)
|
if (coord & _fracTextureUnit)
|
||||||
|
@ -52,7 +52,7 @@ static inline unsigned int wrap(unsigned int wrap_mode, int coord, unsigned int
|
||||||
case TGL_CLAMP_TO_EDGE:
|
case TGL_CLAMP_TO_EDGE:
|
||||||
if (coord < 0)
|
if (coord < 0)
|
||||||
return 0;
|
return 0;
|
||||||
if ((unsigned int) coord > _fracTextureMask)
|
if ((uint) coord > _fracTextureMask)
|
||||||
return _fracTextureMask;
|
return _fracTextureMask;
|
||||||
return coord;
|
return coord;
|
||||||
default:
|
default:
|
||||||
|
@ -63,11 +63,11 @@ static inline unsigned int wrap(unsigned int wrap_mode, int coord, unsigned int
|
||||||
}
|
}
|
||||||
|
|
||||||
void TexelBuffer::getARGBAt(
|
void TexelBuffer::getARGBAt(
|
||||||
unsigned int wrap_s, unsigned int wrap_t,
|
uint wrap_s, uint wrap_t,
|
||||||
int s, int t,
|
int s, int t,
|
||||||
uint8 &a, uint8 &r, uint8 &g, uint8 &b
|
uint8 &a, uint8 &r, uint8 &g, uint8 &b
|
||||||
) const {
|
) const {
|
||||||
unsigned int x, y;
|
uint x, y;
|
||||||
x = wrap(wrap_s, s, _fracTextureUnit, _fracTextureMask) * _widthRatio;
|
x = wrap(wrap_s, s, _fracTextureUnit, _fracTextureMask) * _widthRatio;
|
||||||
y = wrap(wrap_t, t, _fracTextureUnit, _fracTextureMask) * _heightRatio;
|
y = wrap(wrap_t, t, _fracTextureUnit, _fracTextureMask) * _heightRatio;
|
||||||
getARGBAt(
|
getARGBAt(
|
||||||
|
@ -78,9 +78,9 @@ void TexelBuffer::getARGBAt(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nearest: store texture in original size.
|
// Nearest: store texture in original size.
|
||||||
NearestTexelBuffer::NearestTexelBuffer(const PixelBuffer &buf, unsigned int width, unsigned int height, unsigned int textureSize) : TexelBuffer(width, height, textureSize) {
|
NearestTexelBuffer::NearestTexelBuffer(const Graphics::PixelBuffer &buf, uint width, uint height, uint textureSize) : TexelBuffer(width, height, textureSize) {
|
||||||
unsigned int pixel_count = _width * _height;
|
uint pixel_count = _width * _height;
|
||||||
_buf = PixelBuffer(buf.getFormat(), pixel_count, DisposeAfterUse::NO);
|
_buf = Graphics::PixelBuffer(buf.getFormat(), pixel_count, DisposeAfterUse::NO);
|
||||||
_buf.copyBuffer(0, pixel_count, buf);
|
_buf.copyBuffer(0, pixel_count, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@ NearestTexelBuffer::~NearestTexelBuffer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NearestTexelBuffer::getARGBAt(
|
void NearestTexelBuffer::getARGBAt(
|
||||||
unsigned int pixel,
|
uint pixel,
|
||||||
unsigned int, unsigned int,
|
uint, uint,
|
||||||
uint8 &a, uint8 &r, uint8 &g, uint8 &b
|
uint8 &a, uint8 &r, uint8 &g, uint8 &b
|
||||||
) const {
|
) const {
|
||||||
_buf.getARGBAt(pixel, a, r, g, b);
|
_buf.getARGBAt(pixel, a, r, g, b);
|
||||||
|
@ -112,14 +112,14 @@ void NearestTexelBuffer::getARGBAt(
|
||||||
#define P11_OFFSET 3
|
#define P11_OFFSET 3
|
||||||
#define PIXEL_PER_TEXEL_SHIFT 2
|
#define PIXEL_PER_TEXEL_SHIFT 2
|
||||||
|
|
||||||
BilinearTexelBuffer::BilinearTexelBuffer(const PixelBuffer &buf, unsigned int width, unsigned int height, unsigned int textureSize) : TexelBuffer(width, height, textureSize) {
|
BilinearTexelBuffer::BilinearTexelBuffer(const Graphics::PixelBuffer &buf, uint width, uint height, uint textureSize) : TexelBuffer(width, height, textureSize) {
|
||||||
unsigned int pixel00_offset = 0, pixel11_offset, pixel01_offset, pixel10_offset;
|
uint pixel00_offset = 0, pixel11_offset, pixel01_offset, pixel10_offset;
|
||||||
uint8 *texel8;
|
uint8 *texel8;
|
||||||
uint32 *texel32;
|
uint32 *texel32;
|
||||||
|
|
||||||
texel32 = _texels = new uint32[_width * _height << PIXEL_PER_TEXEL_SHIFT];
|
texel32 = _texels = new uint32[_width * _height << PIXEL_PER_TEXEL_SHIFT];
|
||||||
for (unsigned int y = 0; y < _height; y++) {
|
for (uint y = 0; y < _height; y++) {
|
||||||
for (unsigned int x = 0; x < _width; x++) {
|
for (uint x = 0; x < _width; x++) {
|
||||||
texel8 = (uint8 *)texel32;
|
texel8 = (uint8 *)texel32;
|
||||||
pixel11_offset = pixel00_offset + _width + 1;
|
pixel11_offset = pixel00_offset + _width + 1;
|
||||||
buf.getARGBAt(
|
buf.getARGBAt(
|
||||||
|
@ -175,11 +175,11 @@ static inline int interpolate(int v00, int v01, int v10, int xf, int yf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BilinearTexelBuffer::getARGBAt(
|
void BilinearTexelBuffer::getARGBAt(
|
||||||
unsigned int pixel,
|
uint pixel,
|
||||||
unsigned int ds, unsigned int dt,
|
uint ds, uint dt,
|
||||||
uint8 &a, uint8 &r, uint8 &g, uint8 &b
|
uint8 &a, uint8 &r, uint8 &g, uint8 &b
|
||||||
) const {
|
) const {
|
||||||
unsigned int p00_offset, p01_offset, p10_offset;
|
uint p00_offset, p01_offset, p10_offset;
|
||||||
uint8 *texel = (uint8 *)(_texels + (pixel << PIXEL_PER_TEXEL_SHIFT));
|
uint8 *texel = (uint8 *)(_texels + (pixel << PIXEL_PER_TEXEL_SHIFT));
|
||||||
if ((ds + dt) > ZB_POINT_ST_UNIT) {
|
if ((ds + dt) > ZB_POINT_ST_UNIT) {
|
||||||
p00_offset = P11_OFFSET;
|
p00_offset = P11_OFFSET;
|
||||||
|
@ -222,4 +222,4 @@ void BilinearTexelBuffer::getARGBAt(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // end of namespace TinyGL
|
||||||
|
|
|
@ -25,54 +25,54 @@
|
||||||
|
|
||||||
#include "graphics/tinygl/pixelbuffer.h"
|
#include "graphics/tinygl/pixelbuffer.h"
|
||||||
|
|
||||||
namespace Graphics {
|
namespace TinyGL {
|
||||||
|
|
||||||
class TexelBuffer {
|
class TexelBuffer {
|
||||||
public:
|
public:
|
||||||
TexelBuffer(unsigned int width, unsigned int height, unsigned int textureSize);
|
TexelBuffer(uint width, uint height, uint textureSize);
|
||||||
virtual ~TexelBuffer() {};
|
virtual ~TexelBuffer() {};
|
||||||
|
|
||||||
void getARGBAt(
|
void getARGBAt(
|
||||||
unsigned int wrap_s, unsigned int wrap_t,
|
uint wrap_s, uint wrap_t,
|
||||||
int s, int t,
|
int s, int t,
|
||||||
uint8 &a, uint8 &r, uint8 &g, uint8 &b
|
uint8 &a, uint8 &r, uint8 &g, uint8 &b
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void getARGBAt(
|
virtual void getARGBAt(
|
||||||
unsigned int pixel,
|
uint pixel,
|
||||||
unsigned int ds, unsigned int dt,
|
uint ds, uint dt,
|
||||||
uint8 &a, uint8 &r, uint8 &g, uint8 &b
|
uint8 &a, uint8 &r, uint8 &g, uint8 &b
|
||||||
) const = 0;
|
) const = 0;
|
||||||
unsigned int _width, _height, _fracTextureUnit, _fracTextureMask;
|
uint _width, _height, _fracTextureUnit, _fracTextureMask;
|
||||||
float _widthRatio, _heightRatio;
|
float _widthRatio, _heightRatio;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NearestTexelBuffer : public TexelBuffer {
|
class NearestTexelBuffer : public TexelBuffer {
|
||||||
public:
|
public:
|
||||||
NearestTexelBuffer(const PixelBuffer &buf, unsigned int width, unsigned int height, unsigned int textureSize);
|
NearestTexelBuffer(const Graphics::PixelBuffer &buf, uint width, uint height, uint textureSize);
|
||||||
~NearestTexelBuffer();
|
~NearestTexelBuffer();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void getARGBAt(
|
void getARGBAt(
|
||||||
unsigned int pixel,
|
uint pixel,
|
||||||
unsigned int, unsigned int,
|
uint, uint,
|
||||||
uint8 &a, uint8 &r, uint8 &g, uint8 &b
|
uint8 &a, uint8 &r, uint8 &g, uint8 &b
|
||||||
) const override;
|
) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PixelBuffer _buf;
|
Graphics::PixelBuffer _buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BilinearTexelBuffer : public TexelBuffer {
|
class BilinearTexelBuffer : public TexelBuffer {
|
||||||
public:
|
public:
|
||||||
BilinearTexelBuffer(const PixelBuffer &buf, unsigned int width, unsigned int height, unsigned int textureSize);
|
BilinearTexelBuffer(const Graphics::PixelBuffer &buf, uint width, uint height, uint textureSize);
|
||||||
~BilinearTexelBuffer();
|
~BilinearTexelBuffer();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void getARGBAt(
|
void getARGBAt(
|
||||||
unsigned int pixel,
|
uint pixel,
|
||||||
unsigned int ds, unsigned int dt,
|
uint ds, uint dt,
|
||||||
uint8 &a, uint8 &r, uint8 &g, uint8 &b
|
uint8 &a, uint8 &r, uint8 &g, uint8 &b
|
||||||
) const override;
|
) const override;
|
||||||
|
|
||||||
|
@ -80,6 +80,6 @@ private:
|
||||||
uint32 *_texels;
|
uint32 *_texels;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // end of namespace TinyGL
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -159,7 +159,7 @@ void GLContext::glopTexImage2D(GLParam *p) {
|
||||||
im->pixmap = nullptr;
|
im->pixmap = nullptr;
|
||||||
}
|
}
|
||||||
if (pixels != NULL) {
|
if (pixels != NULL) {
|
||||||
unsigned int filter;
|
uint filter;
|
||||||
Graphics::PixelFormat pf;
|
Graphics::PixelFormat pf;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
Common::Array<struct tglColorAssociation>::const_iterator it = colorAssociationList.begin();
|
Common::Array<struct tglColorAssociation>::const_iterator it = colorAssociationList.begin();
|
||||||
|
@ -196,14 +196,14 @@ void GLContext::glopTexImage2D(GLParam *p) {
|
||||||
case TGL_LINEAR_MIPMAP_NEAREST:
|
case TGL_LINEAR_MIPMAP_NEAREST:
|
||||||
case TGL_LINEAR_MIPMAP_LINEAR:
|
case TGL_LINEAR_MIPMAP_LINEAR:
|
||||||
case TGL_LINEAR:
|
case TGL_LINEAR:
|
||||||
im->pixmap = new Graphics::BilinearTexelBuffer(
|
im->pixmap = new BilinearTexelBuffer(
|
||||||
srcInternal,
|
srcInternal,
|
||||||
width, height,
|
width, height,
|
||||||
_textureSize
|
_textureSize
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
im->pixmap = new Graphics::NearestTexelBuffer(
|
im->pixmap = new NearestTexelBuffer(
|
||||||
srcInternal,
|
srcInternal,
|
||||||
width, height,
|
width, height,
|
||||||
_textureSize
|
_textureSize
|
||||||
|
@ -289,7 +289,7 @@ void GLContext::glopPixelStore(GLParam *p) {
|
||||||
|
|
||||||
} // end of namespace TinyGL
|
} // end of namespace TinyGL
|
||||||
|
|
||||||
void tglGenTextures(int n, unsigned int *textures) {
|
void tglGenTextures(int n, uint *textures) {
|
||||||
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
|
@ -298,7 +298,7 @@ void tglGenTextures(int n, unsigned int *textures) {
|
||||||
c->maxTextureName += n;
|
c->maxTextureName += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tglDeleteTextures(int n, const unsigned int *textures) {
|
void tglDeleteTextures(int n, const uint *textures) {
|
||||||
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
||||||
TinyGL::GLTexture *t;
|
TinyGL::GLTexture *t;
|
||||||
|
|
||||||
|
|
|
@ -103,8 +103,9 @@ public:
|
||||||
Graphics::PixelBuffer _buf; // This is needed for the conversion.
|
Graphics::PixelBuffer _buf; // This is needed for the conversion.
|
||||||
|
|
||||||
Line() : _x(0), _y(0), _length(0), _pixels(nullptr) { }
|
Line() : _x(0), _y(0), _length(0), _pixels(nullptr) { }
|
||||||
Line(int x, int y, int length, byte *pixels, const Graphics::PixelFormat &textureFormat) : _buf(gl_get_context()->fb->getPixelFormat(), length, DisposeAfterUse::NO),
|
Line(int x, int y, int length, byte *pixels, const Graphics::PixelFormat &textureFormat) :
|
||||||
_x(x), _y(y), _length(length) {
|
_buf(gl_get_context()->fb->getPixelFormat(), length, DisposeAfterUse::NO),
|
||||||
|
_x(x), _y(y), _length(length) {
|
||||||
// Performing texture to screen conversion.
|
// Performing texture to screen conversion.
|
||||||
Graphics::PixelBuffer srcBuf(textureFormat, pixels);
|
Graphics::PixelBuffer srcBuf(textureFormat, pixels);
|
||||||
_buf.copyBuffer(0, 0, length, srcBuf);
|
_buf.copyBuffer(0, 0, length, srcBuf);
|
||||||
|
@ -223,7 +224,7 @@ public:
|
||||||
|
|
||||||
template <bool kDisableBlending, bool kDisableColoring, bool kFlipVertical, bool kFlipHorizontal>
|
template <bool kDisableBlending, bool kDisableColoring, bool kFlipVertical, bool kFlipHorizontal>
|
||||||
FORCEINLINE void tglBlitRotoScale(int dstX, int dstY, int width, int height, int srcX, int srcY, int srcWidth, int srcHeight, int rotation,
|
FORCEINLINE void tglBlitRotoScale(int dstX, int dstY, int width, int height, int srcX, int srcY, int srcWidth, int srcHeight, int rotation,
|
||||||
int originX, int originY, float aTint, float rTint, float gTint, float bTint);
|
int originX, int originY, float aTint, float rTint, float gTint, float bTint);
|
||||||
|
|
||||||
//Utility function that calls the correct blitting function.
|
//Utility function that calls the correct blitting function.
|
||||||
template <bool kDisableBlending, bool kDisableColoring, bool kDisableTransform, bool kFlipVertical, bool kFlipHorizontal, bool kEnableAlphaBlending>
|
template <bool kDisableBlending, bool kDisableColoring, bool kDisableTransform, bool kFlipVertical, bool kFlipHorizontal, bool kEnableAlphaBlending>
|
||||||
|
@ -362,7 +363,6 @@ FORCEINLINE void BlitImage::tglBlitRLE(int dstX, int dstY, int srcX, int srcY, i
|
||||||
c->fb->writePixel((dstX + x) + (dstY + (l._y - srcY)) * fbWidth, aDst * aTint, rDst * rTint, gDst * gTint, bDst * bTint);
|
c->fb->writePixel((dstX + x) + (dstY + (l._y - srcY)) * fbWidth, aDst * aTint, rDst * rTint, gDst * gTint, bDst * bTint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lineIndex++;
|
lineIndex++;
|
||||||
|
@ -458,7 +458,7 @@ FORCEINLINE void BlitImage::tglBlitSimple(int dstX, int dstY, int srcX, int srcY
|
||||||
// filter to scale the blit image before copying it to the screen.
|
// filter to scale the blit image before copying it to the screen.
|
||||||
template <bool kDisableBlending, bool kDisableColoring, bool kFlipVertical, bool kFlipHorizontal>
|
template <bool kDisableBlending, bool kDisableColoring, bool kFlipVertical, bool kFlipHorizontal>
|
||||||
FORCEINLINE void BlitImage::tglBlitScale(int dstX, int dstY, int width, int height, int srcX, int srcY, int srcWidth, int srcHeight,
|
FORCEINLINE void BlitImage::tglBlitScale(int dstX, int dstY, int width, int height, int srcX, int srcY, int srcWidth, int srcHeight,
|
||||||
float aTint, float rTint, float gTint, float bTint) {
|
float aTint, float rTint, float gTint, float bTint) {
|
||||||
GLContext *c = gl_get_context();
|
GLContext *c = gl_get_context();
|
||||||
|
|
||||||
int clampWidth, clampHeight;
|
int clampWidth, clampHeight;
|
||||||
|
@ -548,7 +548,7 @@ systems.
|
||||||
|
|
||||||
template <bool kDisableBlending, bool kDisableColoring, bool kFlipVertical, bool kFlipHorizontal>
|
template <bool kDisableBlending, bool kDisableColoring, bool kFlipVertical, bool kFlipHorizontal>
|
||||||
FORCEINLINE void BlitImage::tglBlitRotoScale(int dstX, int dstY, int width, int height, int srcX, int srcY, int srcWidth, int srcHeight, int rotation,
|
FORCEINLINE void BlitImage::tglBlitRotoScale(int dstX, int dstY, int width, int height, int srcX, int srcY, int srcWidth, int srcHeight, int rotation,
|
||||||
int originX, int originY, float aTint, float rTint, float gTint, float bTint) {
|
int originX, int originY, float aTint, float rTint, float gTint, float bTint) {
|
||||||
GLContext *c = gl_get_context();
|
GLContext *c = gl_get_context();
|
||||||
|
|
||||||
int clampWidth, clampHeight;
|
int clampWidth, clampHeight;
|
||||||
|
|
|
@ -53,8 +53,9 @@ namespace Internal {
|
||||||
@brief Sets up a scissor rectangle for blit calls: every blit call is affected by this rectangle.
|
@brief Sets up a scissor rectangle for blit calls: every blit call is affected by this rectangle.
|
||||||
*/
|
*/
|
||||||
void tglBlitSetScissorRect(const Common::Rect &rect);
|
void tglBlitSetScissorRect(const Common::Rect &rect);
|
||||||
void tglBlitResetScissorRect(void);
|
void tglBlitResetScissorRect();
|
||||||
} // end of namespace Internal
|
} // end of namespace Internal
|
||||||
|
|
||||||
} // end of namespace TinyGL
|
} // end of namespace TinyGL
|
||||||
|
|
||||||
#endif // GRAPHICS_TINYGL_ZBLIT_H_
|
#endif // GRAPHICS_TINYGL_ZBLIT_H_
|
||||||
|
|
|
@ -31,8 +31,8 @@ namespace TinyGL {
|
||||||
|
|
||||||
struct BlitTransform {
|
struct BlitTransform {
|
||||||
BlitTransform(int dstX, int dstY) : _rotation(0), _originX(0), _originY(0), _aTint(1.0f),
|
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),
|
_rTint(1.0f), _gTint(1.0f), _bTint(1.0), _flipHorizontally(false),
|
||||||
_flipVertically(false) {
|
_flipVertically(false) {
|
||||||
_destinationRectangle.translate(dstX, dstY);
|
_destinationRectangle.translate(dstX, dstY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,8 @@ struct BlitTransform {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const BlitTransform &other) const {
|
bool operator==(const BlitTransform &other) const {
|
||||||
return _sourceRectangle == other._sourceRectangle && _destinationRectangle == other._destinationRectangle &&
|
return
|
||||||
|
_sourceRectangle == other._sourceRectangle && _destinationRectangle == other._destinationRectangle &&
|
||||||
_rotation == other._rotation && _originX == other._originX && _originY == other._originY &&
|
_rotation == other._rotation && _originX == other._originX && _originY == other._originY &&
|
||||||
_aTint == other._aTint && _rTint == other._rTint && _gTint == other._gTint && _bTint == other._bTint &&
|
_aTint == other._aTint && _rTint == other._rTint && _gTint == other._gTint && _bTint == other._bTint &&
|
||||||
_flipHorizontally == other._flipHorizontally && _flipVertically == other._flipVertically;
|
_flipHorizontally == other._flipHorizontally && _flipVertically == other._flipVertically;
|
||||||
|
|
|
@ -39,10 +39,10 @@ namespace TinyGL {
|
||||||
// adr must be aligned on an 'int'
|
// adr must be aligned on an 'int'
|
||||||
static void memset_s(void *adr, int val, int count) {
|
static void memset_s(void *adr, int val, int count) {
|
||||||
int n, v;
|
int n, v;
|
||||||
unsigned int *p;
|
uint *p;
|
||||||
unsigned short *q;
|
unsigned short *q;
|
||||||
|
|
||||||
p = (unsigned int *)adr;
|
p = (uint *)adr;
|
||||||
v = val | (val << 16);
|
v = val | (val << 16);
|
||||||
|
|
||||||
n = count >> 3;
|
n = count >> 3;
|
||||||
|
@ -62,9 +62,9 @@ static void memset_s(void *adr, int val, int count) {
|
||||||
|
|
||||||
static void memset_l(void *adr, int val, int count) {
|
static void memset_l(void *adr, int val, int count) {
|
||||||
int n, v;
|
int n, v;
|
||||||
unsigned int *p;
|
uint *p;
|
||||||
|
|
||||||
p = (unsigned int *)adr;
|
p = (uint *)adr;
|
||||||
v = val;
|
v = val;
|
||||||
n = count >> 2;
|
n = count >> 2;
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
|
@ -122,7 +122,7 @@ void FrameBuffer::clear(int clearZ, int z, int clearColor, int r, int g, int b,
|
||||||
bool clearStencil, int stencilValue) {
|
bool clearStencil, int stencilValue) {
|
||||||
if (clearZ) {
|
if (clearZ) {
|
||||||
const uint8 *zc = (const uint8 *)&z;
|
const uint8 *zc = (const uint8 *)&z;
|
||||||
unsigned int i;
|
uint i;
|
||||||
for (i = 1; i < sizeof(z) && zc[0] == zc[i]; i++) { ; }
|
for (i = 1; i < sizeof(z) && zc[0] == zc[i]; i++) { ; }
|
||||||
if (i == sizeof(z)) {
|
if (i == sizeof(z)) {
|
||||||
// All "z" bytes are identical, use memset (fast)
|
// All "z" bytes are identical, use memset (fast)
|
||||||
|
@ -136,7 +136,7 @@ void FrameBuffer::clear(int clearZ, int z, int clearColor, int r, int g, int b,
|
||||||
byte *pp = _pbuf.getRawBuffer();
|
byte *pp = _pbuf.getRawBuffer();
|
||||||
uint32 color = _pbufFormat.RGBToColor(r, g, b);
|
uint32 color = _pbufFormat.RGBToColor(r, g, b);
|
||||||
const uint8 *colorc = (uint8 *)&color;
|
const uint8 *colorc = (uint8 *)&color;
|
||||||
unsigned int i;
|
uint i;
|
||||||
for (i = 1; i < sizeof(color) && colorc[0] == colorc[i]; i++) { ; }
|
for (i = 1; i < sizeof(color) && colorc[0] == colorc[i]; i++) { ; }
|
||||||
if (i == sizeof(color)) {
|
if (i == sizeof(color)) {
|
||||||
// All "color" bytes are identical, use memset (fast)
|
// All "color" bytes are identical, use memset (fast)
|
||||||
|
@ -164,9 +164,9 @@ void FrameBuffer::clearRegion(int x, int y, int w, int h, bool clearZ, int z,
|
||||||
bool clearColor, int r, int g, int b, bool clearStencil, int stencilValue) {
|
bool clearColor, int r, int g, int b, bool clearStencil, int stencilValue) {
|
||||||
if (clearZ) {
|
if (clearZ) {
|
||||||
int height = h;
|
int height = h;
|
||||||
unsigned int *zbuf = _zbuf + (y * _pbufWidth);
|
uint *zbuf = _zbuf + (y * _pbufWidth);
|
||||||
const uint8 *zc = (const uint8 *)&z;
|
const uint8 *zc = (const uint8 *)&z;
|
||||||
unsigned int i;
|
uint i;
|
||||||
for (i = 1; i < sizeof(z) && zc[0] == zc[i]; i++) { ; }
|
for (i = 1; i < sizeof(z) && zc[0] == zc[i]; i++) { ; }
|
||||||
if (i == sizeof(z)) {
|
if (i == sizeof(z)) {
|
||||||
// All "z" bytes are identical, use memset (fast)
|
// All "z" bytes are identical, use memset (fast)
|
||||||
|
@ -187,7 +187,7 @@ void FrameBuffer::clearRegion(int x, int y, int w, int h, bool clearZ, int z,
|
||||||
byte *pp = _pbuf.getRawBuffer() + y * _pbufPitch + x * _pbufBpp;
|
byte *pp = _pbuf.getRawBuffer() + y * _pbufPitch + x * _pbufBpp;
|
||||||
uint32 color = _pbufFormat.RGBToColor(r, g, b);
|
uint32 color = _pbufFormat.RGBToColor(r, g, b);
|
||||||
const uint8 *colorc = (uint8 *)&color;
|
const uint8 *colorc = (uint8 *)&color;
|
||||||
unsigned int i;
|
uint i;
|
||||||
for (i = 1; i < sizeof(color) && colorc[0] == colorc[i]; i++) { ; }
|
for (i = 1; i < sizeof(color) && colorc[0] == colorc[i]; i++) { ; }
|
||||||
if (i == sizeof(color)) {
|
if (i == sizeof(color)) {
|
||||||
// All "color" bytes are identical, use memset (fast)
|
// All "color" bytes are identical, use memset (fast)
|
||||||
|
@ -221,8 +221,8 @@ void FrameBuffer::clearRegion(int x, int y, int w, int h, bool clearZ, int z,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static void blitPixel(uint8 offset, unsigned int *from_z, unsigned int *to_z, unsigned int z_length, byte *from_color, byte *to_color, unsigned int color_length) {
|
inline static void blitPixel(uint8 offset, uint *from_z, uint *to_z, uint z_length, byte *from_color, byte *to_color, uint color_length) {
|
||||||
const unsigned int d = from_z[offset];
|
const uint d = from_z[offset];
|
||||||
if (d > to_z[offset]) {
|
if (d > to_z[offset]) {
|
||||||
memcpy(to_color + offset, from_color + offset, color_length);
|
memcpy(to_color + offset, from_color + offset, color_length);
|
||||||
memcpy(to_z + offset, &d, z_length);
|
memcpy(to_z + offset, &d, z_length);
|
||||||
|
@ -237,8 +237,8 @@ void FrameBuffer::blitOffscreenBuffer(Buffer *buf) {
|
||||||
const int unrolled_pixel_bytes = pixel_bytes * UNROLL_COUNT;
|
const int unrolled_pixel_bytes = pixel_bytes * UNROLL_COUNT;
|
||||||
byte *to = _pbuf.getRawBuffer();
|
byte *to = _pbuf.getRawBuffer();
|
||||||
byte *from = buf->pbuf;
|
byte *from = buf->pbuf;
|
||||||
unsigned int *to_z = _zbuf;
|
uint *to_z = _zbuf;
|
||||||
unsigned int *from_z = buf->zbuf;
|
uint *from_z = buf->zbuf;
|
||||||
int count = _pbufWidth * _pbufHeight;
|
int count = _pbufWidth * _pbufHeight;
|
||||||
while (count >= UNROLL_COUNT) {
|
while (count >= UNROLL_COUNT) {
|
||||||
blitPixel(0x0, from_z, to_z, sizeof(int), from, to, pixel_bytes);
|
blitPixel(0x0, from_z, to_z, sizeof(int), from, to, pixel_bytes);
|
||||||
|
|
|
@ -88,15 +88,16 @@ struct ZBufferPoint {
|
||||||
float sz, tz; // temporary coordinates for mapping
|
float sz, tz; // temporary coordinates for mapping
|
||||||
|
|
||||||
bool operator==(const ZBufferPoint &other) const {
|
bool operator==(const ZBufferPoint &other) const {
|
||||||
return x == other.x &&
|
return
|
||||||
y == other.y &&
|
x == other.x &&
|
||||||
z == other.z &&
|
y == other.y &&
|
||||||
s == other.s &&
|
z == other.z &&
|
||||||
t == other.t &&
|
s == other.s &&
|
||||||
r == other.r &&
|
t == other.t &&
|
||||||
g == other.g &&
|
r == other.r &&
|
||||||
b == other.b &&
|
g == other.g &&
|
||||||
a == other.a;
|
b == other.b &&
|
||||||
|
a == other.a;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -282,7 +283,7 @@ 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, uint z) {
|
||||||
if (kBlendingEnabled == false) {
|
if (kBlendingEnabled == false) {
|
||||||
_pbuf.setPixelAt(pixel, value);
|
_pbuf.setPixelAt(pixel, value);
|
||||||
if (kDepthWrite) {
|
if (kDepthWrite) {
|
||||||
|
@ -310,10 +311,10 @@ private:
|
||||||
int &dzdx, int &drdx, int &dgdx, int &dbdx, uint dadx);
|
int &dzdx, int &drdx, int &dgdx, int &dbdx, uint dadx);
|
||||||
|
|
||||||
template <bool kDepthWrite, bool kLightsMode, bool kSmoothMode, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending, bool kStencilEnabled, bool kDepthTestEnabled>
|
template <bool kDepthWrite, bool kLightsMode, bool kSmoothMode, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending, bool kStencilEnabled, bool kDepthTestEnabled>
|
||||||
FORCEINLINE void putPixelTexture(int fbOffset, const Graphics::TexelBuffer *texture,
|
FORCEINLINE void putPixelTexture(int fbOffset, const TexelBuffer *texture,
|
||||||
uint wrap_s, uint wrap_t, uint *pz, byte *ps, int _a,
|
uint wrap_s, uint wrap_t, uint *pz, byte *ps, int _a,
|
||||||
int x, int y, uint &z, int &t, int &s,
|
int x, int y, uint &z, int &t, int &s,
|
||||||
uint &r, uint &g, uint &b, uint &a,
|
uint &r, uint &g, uint &b, uint &a,
|
||||||
int &dzdx, int &dsdx, int &dtdx, int &drdx, int &dgdx, int &dbdx, uint dadx);
|
int &dzdx, int &dsdx, int &dtdx, int &drdx, int &dgdx, int &dbdx, uint dadx);
|
||||||
|
|
||||||
template <bool kDepthWrite, bool kEnableScissor, bool kStencilEnabled, bool kDepthTestEnabled>
|
template <bool kDepthWrite, bool kEnableScissor, bool kStencilEnabled, bool kDepthTestEnabled>
|
||||||
|
@ -364,7 +365,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool kEnableAlphaTest, bool kBlendingEnabled, bool kDepthWrite>
|
template <bool kEnableAlphaTest, bool kBlendingEnabled, bool kDepthWrite>
|
||||||
FORCEINLINE void writePixel(int pixel, byte aSrc, byte rSrc, byte gSrc, byte bSrc, unsigned int z) {
|
FORCEINLINE void writePixel(int pixel, byte aSrc, byte rSrc, byte gSrc, byte bSrc, uint z) {
|
||||||
if (kEnableAlphaTest) {
|
if (kEnableAlphaTest) {
|
||||||
if (!checkAlphaTest(aSrc))
|
if (!checkAlphaTest(aSrc))
|
||||||
return;
|
return;
|
||||||
|
@ -464,13 +465,18 @@ private:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int finalR, finalG, finalB;
|
int finalR = rDst + rSrc;
|
||||||
finalR = rDst + rSrc;
|
int finalG = gDst + gSrc;
|
||||||
finalG = gDst + gSrc;
|
int finalB = bDst + bSrc;
|
||||||
finalB = bDst + bSrc;
|
if (finalR > 255) {
|
||||||
if (finalR > 255) { finalR = 255; }
|
finalR = 255;
|
||||||
if (finalG > 255) { finalG = 255; }
|
}
|
||||||
if (finalB > 255) { finalB = 255; }
|
if (finalG > 255) {
|
||||||
|
finalG = 255;
|
||||||
|
}
|
||||||
|
if (finalB > 255) {
|
||||||
|
finalB = 255;
|
||||||
|
}
|
||||||
_pbuf.setPixelAt(pixel, 255, finalR, finalG, finalB);
|
_pbuf.setPixelAt(pixel, 255, finalR, finalG, finalB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -553,7 +559,7 @@ public:
|
||||||
_offsetUnits = offsetUnits;
|
_offsetUnits = offsetUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE void setTexture(const Graphics::TexelBuffer *texture, unsigned int wraps, unsigned int wrapt) {
|
FORCEINLINE void setTexture(const TexelBuffer *texture, uint wraps, uint wrapt) {
|
||||||
_currentTexture = texture;
|
_currentTexture = texture;
|
||||||
_wrapS = wraps;
|
_wrapS = wraps;
|
||||||
_wrapT = wrapt;
|
_wrapT = wrapt;
|
||||||
|
@ -578,13 +584,13 @@ private:
|
||||||
void clearOffscreenBuffer(Buffer *buffer);
|
void clearOffscreenBuffer(Buffer *buffer);
|
||||||
|
|
||||||
template <bool kInterpRGB, bool kInterpZ, bool kInterpST, bool kInterpSTZ, int kSmoothMode,
|
template <bool kInterpRGB, bool kInterpZ, bool kInterpST, bool kInterpSTZ, int kSmoothMode,
|
||||||
bool kDepthWrite, bool kAlphaTestEnabled, bool kEnableScissor, bool kBlendingEnabled,
|
bool kDepthWrite, bool kAlphaTestEnabled, bool kEnableScissor, bool kBlendingEnabled,
|
||||||
bool kStencilEnabled, bool kDepthTestEnabled>
|
bool kStencilEnabled, bool kDepthTestEnabled>
|
||||||
void fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2);
|
void fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2);
|
||||||
|
|
||||||
template <bool kInterpRGB, bool kInterpZ, bool kInterpST, bool kInterpSTZ, int kSmoothMode,
|
template <bool kInterpRGB, bool kInterpZ, bool kInterpST, bool kInterpSTZ, int kSmoothMode,
|
||||||
bool kDepthWrite, bool kAlphaTestEnabled, bool kEnableScissor, bool kBlendingEnabled,
|
bool kDepthWrite, bool kAlphaTestEnabled, bool kEnableScissor, bool kBlendingEnabled,
|
||||||
bool kStencilEnabled>
|
bool kStencilEnabled>
|
||||||
void fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2);
|
void fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2);
|
||||||
|
|
||||||
template <bool kInterpRGB, bool kInterpZ, bool kInterpST, bool kInterpSTZ, int kDrawLogic, bool kDepthWrite, bool enableAlphaTest, bool kEnableScissor, bool kBlendingEnabled>
|
template <bool kInterpRGB, bool kInterpZ, bool kInterpST, bool kInterpSTZ, int kDrawLogic, bool kDepthWrite, bool enableAlphaTest, bool kEnableScissor, bool kBlendingEnabled>
|
||||||
|
@ -622,13 +628,13 @@ private:
|
||||||
void fillLineInterp(ZBufferPoint *p1, ZBufferPoint *p2);
|
void fillLineInterp(ZBufferPoint *p1, ZBufferPoint *p2);
|
||||||
|
|
||||||
template <bool kDepthWrite>
|
template <bool kDepthWrite>
|
||||||
FORCEINLINE void putPixel(unsigned int pixelOffset, int color, int x, int y, unsigned int z);
|
FORCEINLINE void putPixel(uint pixelOffset, int color, int x, int y, uint z);
|
||||||
|
|
||||||
template <bool kDepthWrite, bool kEnableScissor>
|
template <bool kDepthWrite, bool kEnableScissor>
|
||||||
FORCEINLINE void putPixel(unsigned int pixelOffset, int color, int x, int y, unsigned int z);
|
FORCEINLINE void putPixel(uint pixelOffset, int color, int x, int y, uint z);
|
||||||
|
|
||||||
template <bool kEnableScissor>
|
template <bool kEnableScissor>
|
||||||
FORCEINLINE void putPixel(unsigned int pixelOffset, int color, int x, int y);
|
FORCEINLINE void putPixel(uint pixelOffset, int color, int x, int y);
|
||||||
|
|
||||||
template <bool kInterpRGB, bool kInterpZ, bool kDepthWrite>
|
template <bool kInterpRGB, bool kInterpZ, bool kDepthWrite>
|
||||||
FORCEINLINE void drawLine(const ZBufferPoint *p1, const ZBufferPoint *p2);
|
FORCEINLINE void drawLine(const ZBufferPoint *p1, const ZBufferPoint *p2);
|
||||||
|
@ -654,8 +660,8 @@ private:
|
||||||
Common::Rect _clipRectangle;
|
Common::Rect _clipRectangle;
|
||||||
bool _enableScissor;
|
bool _enableScissor;
|
||||||
|
|
||||||
const Graphics::TexelBuffer *_currentTexture;
|
const TexelBuffer *_currentTexture;
|
||||||
unsigned int _wrapS, _wrapT;
|
uint _wrapS, _wrapT;
|
||||||
bool _blendingEnabled;
|
bool _blendingEnabled;
|
||||||
int _sourceBlendingFactor;
|
int _sourceBlendingFactor;
|
||||||
int _destinationBlendingFactor;
|
int _destinationBlendingFactor;
|
||||||
|
|
|
@ -114,7 +114,6 @@ struct GLMaterial {
|
||||||
Vector4 specular;
|
Vector4 specular;
|
||||||
bool has_specular;
|
bool has_specular;
|
||||||
float shininess;
|
float shininess;
|
||||||
|
|
||||||
// computed values
|
// computed values
|
||||||
int shininess_i;
|
int shininess_i;
|
||||||
int do_specular;
|
int do_specular;
|
||||||
|
@ -132,7 +131,7 @@ union GLParam {
|
||||||
int op;
|
int op;
|
||||||
float f;
|
float f;
|
||||||
int i;
|
int i;
|
||||||
unsigned int ui;
|
uint ui;
|
||||||
void *p;
|
void *p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -177,7 +176,7 @@ struct GLVertex {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GLImage {
|
struct GLImage {
|
||||||
Graphics::TexelBuffer *pixmap;
|
TexelBuffer *pixmap;
|
||||||
int xsize, ysize;
|
int xsize, ysize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -187,7 +186,7 @@ struct GLImage {
|
||||||
|
|
||||||
struct GLTexture {
|
struct GLTexture {
|
||||||
GLImage images[MAX_TEXTURE_LEVELS];
|
GLImage images[MAX_TEXTURE_LEVELS];
|
||||||
unsigned int handle;
|
uint handle;
|
||||||
int versionNumber;
|
int versionNumber;
|
||||||
struct GLTexture *next, *prev;
|
struct GLTexture *next, *prev;
|
||||||
bool disposed;
|
bool disposed;
|
||||||
|
@ -244,7 +243,7 @@ public:
|
||||||
}
|
}
|
||||||
size_t returnPos = _memoryPosition;
|
size_t returnPos = _memoryPosition;
|
||||||
_memoryPosition += size;
|
_memoryPosition += size;
|
||||||
return ((char *)_memoryBuffer) + returnPos;
|
return ((byte *)_memoryBuffer) + returnPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
|
@ -300,8 +299,8 @@ struct GLContext {
|
||||||
int texture_2d_enabled;
|
int texture_2d_enabled;
|
||||||
int texture_mag_filter;
|
int texture_mag_filter;
|
||||||
int texture_min_filter;
|
int texture_min_filter;
|
||||||
unsigned int texture_wrap_s;
|
uint texture_wrap_s;
|
||||||
unsigned int texture_wrap_t;
|
uint texture_wrap_t;
|
||||||
Common::Array<struct tglColorAssociation> colorAssociationList;
|
Common::Array<struct tglColorAssociation> colorAssociationList;
|
||||||
|
|
||||||
// shared state
|
// shared state
|
||||||
|
@ -340,14 +339,14 @@ struct GLContext {
|
||||||
|
|
||||||
// selection
|
// selection
|
||||||
int render_mode;
|
int render_mode;
|
||||||
unsigned int *select_buffer;
|
uint *select_buffer;
|
||||||
int select_size;
|
int select_size;
|
||||||
unsigned int *select_ptr, *select_hit;
|
uint *select_ptr, *select_hit;
|
||||||
int select_overflow;
|
int select_overflow;
|
||||||
int select_hits;
|
int select_hits;
|
||||||
|
|
||||||
// names
|
// names
|
||||||
unsigned int name_stack[MAX_NAME_STACK_DEPTH];
|
uint name_stack[MAX_NAME_STACK_DEPTH];
|
||||||
int name_stack_size;
|
int name_stack_size;
|
||||||
|
|
||||||
// clear
|
// clear
|
||||||
|
@ -457,7 +456,7 @@ public:
|
||||||
static void gl_draw_triangle_select(GLContext *c, GLVertex *p0, GLVertex *p1, GLVertex *p2);
|
static void gl_draw_triangle_select(GLContext *c, GLVertex *p0, GLVertex *p1, GLVertex *p2);
|
||||||
void gl_draw_triangle_clip(GLVertex *p0, GLVertex *p1, GLVertex *p2, int clip_bit);
|
void gl_draw_triangle_clip(GLVertex *p0, GLVertex *p1, GLVertex *p2, int clip_bit);
|
||||||
|
|
||||||
void gl_add_select(unsigned int zmin, unsigned int zmax);
|
void gl_add_select(uint zmin, uint zmax);
|
||||||
void gl_add_select1(int z1, int z2, int z3);
|
void gl_add_select1(int z1, int z2, int z3);
|
||||||
void gl_enable_disable_light(int light, int v);
|
void gl_enable_disable_light(int light, int v);
|
||||||
void gl_shade_vertex(GLVertex *v);
|
void gl_shade_vertex(GLVertex *v);
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
namespace TinyGL {
|
namespace TinyGL {
|
||||||
|
|
||||||
template <bool kDepthWrite>
|
template <bool kDepthWrite>
|
||||||
FORCEINLINE void FrameBuffer::putPixel(unsigned int pixelOffset, int color, int x, int y, unsigned int z) {
|
FORCEINLINE void FrameBuffer::putPixel(uint pixelOffset, int color, int x, int y, uint z) {
|
||||||
if (_enableScissor)
|
if (_enableScissor)
|
||||||
putPixel<kDepthWrite, true>(pixelOffset, color, x, y, z);
|
putPixel<kDepthWrite, true>(pixelOffset, color, x, y, z);
|
||||||
else
|
else
|
||||||
|
@ -39,18 +39,18 @@ FORCEINLINE void FrameBuffer::putPixel(unsigned int pixelOffset, int color, int
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool kDepthWrite, bool kEnableScissor>
|
template <bool kDepthWrite, bool kEnableScissor>
|
||||||
FORCEINLINE void FrameBuffer::putPixel(unsigned int pixelOffset, int color, int x, int y, unsigned int z) {
|
FORCEINLINE void FrameBuffer::putPixel(uint pixelOffset, int color, int x, int y, uint z) {
|
||||||
if (kEnableScissor && scissorPixel(x, y)) {
|
if (kEnableScissor && scissorPixel(x, y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
unsigned int *pz = _zbuf + pixelOffset;
|
uint *pz = _zbuf + pixelOffset;
|
||||||
if (compareDepth(z, *pz)) {
|
if (compareDepth(z, *pz)) {
|
||||||
writePixel<true, true, kDepthWrite>(pixelOffset, color, z);
|
writePixel<true, true, kDepthWrite>(pixelOffset, color, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool kEnableScissor>
|
template <bool kEnableScissor>
|
||||||
FORCEINLINE void FrameBuffer::putPixel(unsigned int pixelOffset, int color, int x, int y) {
|
FORCEINLINE void FrameBuffer::putPixel(uint pixelOffset, int color, int x, int y) {
|
||||||
if (kEnableScissor && scissorPixel(x, y)) {
|
if (kEnableScissor && scissorPixel(x, y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -142,9 +142,9 @@ void FrameBuffer::drawLine(const ZBufferPoint *p1, const ZBufferPoint *p2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBuffer::plot(ZBufferPoint *p) {
|
void FrameBuffer::plot(ZBufferPoint *p) {
|
||||||
const unsigned int pixelOffset = p->y * _pbufWidth + p->x;
|
const uint pixelOffset = p->y * _pbufWidth + p->x;
|
||||||
const int col = RGB_TO_PIXEL(p->r, p->g, p->b);
|
const int col = RGB_TO_PIXEL(p->r, p->g, p->b);
|
||||||
const unsigned int z = p->z;
|
const uint z = p->z;
|
||||||
if (_depthWrite && _depthTestEnabled)
|
if (_depthWrite && _depthTestEnabled)
|
||||||
putPixel<true>(pixelOffset, col, p->x, p->y, z);
|
putPixel<true>(pixelOffset, col, p->x, p->y, z);
|
||||||
else
|
else
|
||||||
|
|
|
@ -37,8 +37,8 @@ static const int NB_INTERP = 8;
|
||||||
|
|
||||||
template <bool kDepthWrite, bool kSmoothMode, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending, bool kStencilEnabled, bool kDepthTestEnabled>
|
template <bool kDepthWrite, bool kSmoothMode, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending, bool kStencilEnabled, bool kDepthTestEnabled>
|
||||||
FORCEINLINE void FrameBuffer::putPixelNoTexture(int fbOffset, uint *pz, byte *ps, int _a,
|
FORCEINLINE void FrameBuffer::putPixelNoTexture(int fbOffset, uint *pz, byte *ps, int _a,
|
||||||
int x, int y, uint &z, uint &r, uint &g, uint &b, uint &a,
|
int x, int y, uint &z, uint &r, uint &g, uint &b, uint &a,
|
||||||
int &dzdx, int &drdx, int &dgdx, int &dbdx, uint dadx) {
|
int &dzdx, int &drdx, int &dgdx, int &dbdx, uint dadx) {
|
||||||
if (kEnableScissor && scissorPixel(x + _a, y)) {
|
if (kEnableScissor && scissorPixel(x + _a, y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -71,11 +71,11 @@ FORCEINLINE void FrameBuffer::putPixelNoTexture(int fbOffset, uint *pz, byte *ps
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool kDepthWrite, bool kLightsMode, bool kSmoothMode, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending, bool kStencilEnabled, bool kDepthTestEnabled>
|
template <bool kDepthWrite, bool kLightsMode, bool kSmoothMode, bool kEnableAlphaTest, bool kEnableScissor, bool kEnableBlending, bool kStencilEnabled, bool kDepthTestEnabled>
|
||||||
FORCEINLINE void FrameBuffer::putPixelTexture(int fbOffset, const Graphics::TexelBuffer *texture,
|
FORCEINLINE void FrameBuffer::putPixelTexture(int fbOffset, const TexelBuffer *texture,
|
||||||
uint wrap_s, uint wrap_t, uint *pz, byte *ps, int _a,
|
uint wrap_s, uint wrap_t, uint *pz, byte *ps, int _a,
|
||||||
int x, int y, uint &z, int &t, int &s,
|
int x, int y, uint &z, int &t, int &s,
|
||||||
uint &r, uint &g, uint &b, uint &a,
|
uint &r, uint &g, uint &b, uint &a,
|
||||||
int &dzdx, int &dsdx, int &dtdx, int &drdx, int &dgdx, int &dbdx, uint dadx) {
|
int &dzdx, int &dsdx, int &dtdx, int &drdx, int &dgdx, int &dbdx, uint dadx) {
|
||||||
if (kEnableScissor && scissorPixel(x + _a, y)) {
|
if (kEnableScissor && scissorPixel(x + _a, y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ template <bool kInterpRGB, bool kInterpZ, bool kInterpST, bool kInterpSTZ, int k
|
||||||
bool kDepthWrite, bool kAlphaTestEnabled, bool kEnableScissor, bool kBlendingEnabled,
|
bool kDepthWrite, bool kAlphaTestEnabled, bool kEnableScissor, bool kBlendingEnabled,
|
||||||
bool kStencilEnabled, bool kDepthTestEnabled>
|
bool kStencilEnabled, bool kDepthTestEnabled>
|
||||||
void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2) {
|
void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2) {
|
||||||
const Graphics::TexelBuffer *texture;
|
const TexelBuffer *texture;
|
||||||
float fdzdx = 0, fndzdx = 0, ndszdx = 0, ndtzdx = 0;
|
float fdzdx = 0, fndzdx = 0, ndszdx = 0, ndtzdx = 0;
|
||||||
|
|
||||||
ZBufferPoint *tp, *pr1 = 0, *pr2 = 0, *l1 = 0, *l2 = 0;
|
ZBufferPoint *tp, *pr1 = 0, *pr2 = 0, *l1 = 0, *l2 = 0;
|
||||||
|
@ -520,7 +520,7 @@ void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint
|
||||||
}
|
}
|
||||||
for (int _a = 0; _a < NB_INTERP; _a++) {
|
for (int _a = 0; _a < NB_INTERP; _a++) {
|
||||||
putPixelTexture<kDepthWrite, kInterpRGB, kSmoothMode, kAlphaTestEnabled, kEnableScissor, kBlendingEnabled, kStencilEnabled, kDepthTestEnabled>
|
putPixelTexture<kDepthWrite, kInterpRGB, kSmoothMode, kAlphaTestEnabled, kEnableScissor, kBlendingEnabled, kStencilEnabled, kDepthTestEnabled>
|
||||||
(pp, texture, _wrapS, _wrapT, pz, ps, _a, x, y, z, t, s, r, g, b, a, dzdx, dsdx, dtdx, drdx, dgdx, dbdx, dadx);
|
(pp, texture, _wrapS, _wrapT, pz, ps, _a, x, y, z, t, s, r, g, b, a, dzdx, dsdx, dtdx, drdx, dgdx, dbdx, dadx);
|
||||||
}
|
}
|
||||||
pp += NB_INTERP;
|
pp += NB_INTERP;
|
||||||
if (kInterpZ) {
|
if (kInterpZ) {
|
||||||
|
@ -547,7 +547,7 @@ void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint
|
||||||
|
|
||||||
while (n >= 0) {
|
while (n >= 0) {
|
||||||
putPixelTexture<kDepthWrite, kInterpRGB, kSmoothMode, kAlphaTestEnabled, kEnableScissor, kBlendingEnabled, kStencilEnabled, kDepthTestEnabled>
|
putPixelTexture<kDepthWrite, kInterpRGB, kSmoothMode, kAlphaTestEnabled, kEnableScissor, kBlendingEnabled, kStencilEnabled, kDepthTestEnabled>
|
||||||
(pp, texture, _wrapS, _wrapT, pz, ps, 0, x, y, z, t, s, r, g, b, a, dzdx, dsdx, dtdx, drdx, dgdx, dbdx, dadx);
|
(pp, texture, _wrapS, _wrapT, pz, ps, 0, x, y, z, t, s, r, g, b, a, dzdx, dsdx, dtdx, drdx, dgdx, dbdx, dadx);
|
||||||
pp += 1;
|
pp += 1;
|
||||||
if (kInterpZ) {
|
if (kInterpZ) {
|
||||||
pz += 1;
|
pz += 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue