TINYGL: Janitorial

This commit is contained in:
Paweł Kołodziejski 2021-12-15 23:55:36 +01:00
parent c98fe1c61c
commit b673e0adf5
No known key found for this signature in database
GPG key ID: 0BDADC9E74440FF7
16 changed files with 138 additions and 131 deletions

View file

@ -698,7 +698,7 @@ void tglInitNames() {
c->gl_add_op(p);
}
void tglPushName(unsigned int name) {
void tglPushName(uint name) {
TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2];
@ -717,7 +717,7 @@ void tglPopName() {
c->gl_add_op(p);
}
void tglLoadName(unsigned int name) {
void tglLoadName(uint name) {
TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2];
@ -740,7 +740,7 @@ void tglPolygonOffset(TGLfloat factor, TGLfloat units) {
// Special Functions
void tglCallList(unsigned int list) {
void tglCallList(uint list) {
TinyGL::GLContext *c = TinyGL::gl_get_context();
TinyGL::GLParam p[2];

View file

@ -58,7 +58,7 @@ GLContext *gl_get_context() {
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];
}
@ -206,7 +206,7 @@ void GLContext::glopCallList(GLParam *p) {
}
}
void tglNewList(unsigned int list, int mode) {
void tglNewList(uint list, int mode) {
GLList *l;
GLContext *c = gl_get_context();
@ -239,7 +239,7 @@ void tglEndList() {
c->exec_flag = 1;
}
int tglIsList(unsigned int list) {
int tglIsList(uint list) {
GLContext *c = gl_get_context();
GLList *l = find_list(c, list);

View file

@ -68,7 +68,7 @@ int tglRenderMode(int mode) {
return result;
}
void tglSelectBuffer(int size, unsigned int *buf) {
void tglSelectBuffer(int size, uint *buf) {
GLContext *c = gl_get_context();
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) {
unsigned int *ptr;
void GLContext::gl_add_select(uint zmin, uint zmax) {
uint *ptr;
int n;
if (!select_overflow) {

View file

@ -25,12 +25,12 @@
#include "graphics/tinygl/zbuffer.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_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(height);
assert(textureSize);
@ -43,7 +43,7 @@ TexelBuffer::TexelBuffer(unsigned int width, unsigned int height, unsigned int t
_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) {
case TGL_MIRRORED_REPEAT:
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:
if (coord < 0)
return 0;
if ((unsigned int) coord > _fracTextureMask)
if ((uint) coord > _fracTextureMask)
return _fracTextureMask;
return coord;
default:
@ -63,11 +63,11 @@ static inline unsigned int wrap(unsigned int wrap_mode, int coord, unsigned int
}
void TexelBuffer::getARGBAt(
unsigned int wrap_s, unsigned int wrap_t,
uint wrap_s, uint wrap_t,
int s, int t,
uint8 &a, uint8 &r, uint8 &g, uint8 &b
) const {
unsigned int x, y;
uint x, y;
x = wrap(wrap_s, s, _fracTextureUnit, _fracTextureMask) * _widthRatio;
y = wrap(wrap_t, t, _fracTextureUnit, _fracTextureMask) * _heightRatio;
getARGBAt(
@ -78,9 +78,9 @@ void TexelBuffer::getARGBAt(
}
// Nearest: store texture in original size.
NearestTexelBuffer::NearestTexelBuffer(const PixelBuffer &buf, unsigned int width, unsigned int height, unsigned int textureSize) : TexelBuffer(width, height, textureSize) {
unsigned int pixel_count = _width * _height;
_buf = PixelBuffer(buf.getFormat(), pixel_count, DisposeAfterUse::NO);
NearestTexelBuffer::NearestTexelBuffer(const Graphics::PixelBuffer &buf, uint width, uint height, uint textureSize) : TexelBuffer(width, height, textureSize) {
uint pixel_count = _width * _height;
_buf = Graphics::PixelBuffer(buf.getFormat(), pixel_count, DisposeAfterUse::NO);
_buf.copyBuffer(0, pixel_count, buf);
}
@ -89,8 +89,8 @@ NearestTexelBuffer::~NearestTexelBuffer() {
}
void NearestTexelBuffer::getARGBAt(
unsigned int pixel,
unsigned int, unsigned int,
uint pixel,
uint, uint,
uint8 &a, uint8 &r, uint8 &g, uint8 &b
) const {
_buf.getARGBAt(pixel, a, r, g, b);
@ -112,14 +112,14 @@ void NearestTexelBuffer::getARGBAt(
#define P11_OFFSET 3
#define PIXEL_PER_TEXEL_SHIFT 2
BilinearTexelBuffer::BilinearTexelBuffer(const PixelBuffer &buf, unsigned int width, unsigned int height, unsigned int textureSize) : TexelBuffer(width, height, textureSize) {
unsigned int pixel00_offset = 0, pixel11_offset, pixel01_offset, pixel10_offset;
BilinearTexelBuffer::BilinearTexelBuffer(const Graphics::PixelBuffer &buf, uint width, uint height, uint textureSize) : TexelBuffer(width, height, textureSize) {
uint pixel00_offset = 0, pixel11_offset, pixel01_offset, pixel10_offset;
uint8 *texel8;
uint32 *texel32;
texel32 = _texels = new uint32[_width * _height << PIXEL_PER_TEXEL_SHIFT];
for (unsigned int y = 0; y < _height; y++) {
for (unsigned int x = 0; x < _width; x++) {
for (uint y = 0; y < _height; y++) {
for (uint x = 0; x < _width; x++) {
texel8 = (uint8 *)texel32;
pixel11_offset = pixel00_offset + _width + 1;
buf.getARGBAt(
@ -175,11 +175,11 @@ static inline int interpolate(int v00, int v01, int v10, int xf, int yf) {
}
void BilinearTexelBuffer::getARGBAt(
unsigned int pixel,
unsigned int ds, unsigned int dt,
uint pixel,
uint ds, uint dt,
uint8 &a, uint8 &r, uint8 &g, uint8 &b
) 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));
if ((ds + dt) > ZB_POINT_ST_UNIT) {
p00_offset = P11_OFFSET;
@ -222,4 +222,4 @@ void BilinearTexelBuffer::getARGBAt(
);
}
}
} // end of namespace TinyGL

View file

@ -25,54 +25,54 @@
#include "graphics/tinygl/pixelbuffer.h"
namespace Graphics {
namespace TinyGL {
class TexelBuffer {
public:
TexelBuffer(unsigned int width, unsigned int height, unsigned int textureSize);
TexelBuffer(uint width, uint height, uint textureSize);
virtual ~TexelBuffer() {};
void getARGBAt(
unsigned int wrap_s, unsigned int wrap_t,
uint wrap_s, uint wrap_t,
int s, int t,
uint8 &a, uint8 &r, uint8 &g, uint8 &b
) const;
protected:
virtual void getARGBAt(
unsigned int pixel,
unsigned int ds, unsigned int dt,
uint pixel,
uint ds, uint dt,
uint8 &a, uint8 &r, uint8 &g, uint8 &b
) const = 0;
unsigned int _width, _height, _fracTextureUnit, _fracTextureMask;
uint _width, _height, _fracTextureUnit, _fracTextureMask;
float _widthRatio, _heightRatio;
};
class NearestTexelBuffer : public TexelBuffer {
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();
protected:
void getARGBAt(
unsigned int pixel,
unsigned int, unsigned int,
uint pixel,
uint, uint,
uint8 &a, uint8 &r, uint8 &g, uint8 &b
) const override;
private:
PixelBuffer _buf;
Graphics::PixelBuffer _buf;
};
class BilinearTexelBuffer : public TexelBuffer {
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();
protected:
void getARGBAt(
unsigned int pixel,
unsigned int ds, unsigned int dt,
uint pixel,
uint ds, uint dt,
uint8 &a, uint8 &r, uint8 &g, uint8 &b
) const override;
@ -80,6 +80,6 @@ private:
uint32 *_texels;
};
}
} // end of namespace TinyGL
#endif

View file

@ -159,7 +159,7 @@ void GLContext::glopTexImage2D(GLParam *p) {
im->pixmap = nullptr;
}
if (pixels != NULL) {
unsigned int filter;
uint filter;
Graphics::PixelFormat pf;
bool found = false;
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_LINEAR:
case TGL_LINEAR:
im->pixmap = new Graphics::BilinearTexelBuffer(
im->pixmap = new BilinearTexelBuffer(
srcInternal,
width, height,
_textureSize
);
break;
default:
im->pixmap = new Graphics::NearestTexelBuffer(
im->pixmap = new NearestTexelBuffer(
srcInternal,
width, height,
_textureSize
@ -289,7 +289,7 @@ void GLContext::glopPixelStore(GLParam *p) {
} // end of namespace TinyGL
void tglGenTextures(int n, unsigned int *textures) {
void tglGenTextures(int n, uint *textures) {
TinyGL::GLContext *c = TinyGL::gl_get_context();
for (int i = 0; i < n; i++) {
@ -298,7 +298,7 @@ void tglGenTextures(int n, unsigned int *textures) {
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::GLTexture *t;

View file

@ -103,7 +103,8 @@ public:
Graphics::PixelBuffer _buf; // This is needed for the conversion.
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) :
_buf(gl_get_context()->fb->getPixelFormat(), length, DisposeAfterUse::NO),
_x(x), _y(y), _length(length) {
// Performing texture to screen conversion.
Graphics::PixelBuffer srcBuf(textureFormat, pixels);
@ -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);
}
}
}
}
lineIndex++;

View file

@ -53,8 +53,9 @@ namespace Internal {
@brief Sets up a scissor rectangle for blit calls: every blit call is affected by this rectangle.
*/
void tglBlitSetScissorRect(const Common::Rect &rect);
void tglBlitResetScissorRect(void);
void tglBlitResetScissorRect();
} // end of namespace Internal
} // end of namespace TinyGL
#endif // GRAPHICS_TINYGL_ZBLIT_H_

View file

@ -67,7 +67,8 @@ struct BlitTransform {
}
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 &&
_aTint == other._aTint && _rTint == other._rTint && _gTint == other._gTint && _bTint == other._bTint &&
_flipHorizontally == other._flipHorizontally && _flipVertically == other._flipVertically;

View file

@ -39,10 +39,10 @@ namespace TinyGL {
// adr must be aligned on an 'int'
static void memset_s(void *adr, int val, int count) {
int n, v;
unsigned int *p;
uint *p;
unsigned short *q;
p = (unsigned int *)adr;
p = (uint *)adr;
v = val | (val << 16);
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) {
int n, v;
unsigned int *p;
uint *p;
p = (unsigned int *)adr;
p = (uint *)adr;
v = val;
n = count >> 2;
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) {
if (clearZ) {
const uint8 *zc = (const uint8 *)&z;
unsigned int i;
uint i;
for (i = 1; i < sizeof(z) && zc[0] == zc[i]; i++) { ; }
if (i == sizeof(z)) {
// 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();
uint32 color = _pbufFormat.RGBToColor(r, g, b);
const uint8 *colorc = (uint8 *)&color;
unsigned int i;
uint i;
for (i = 1; i < sizeof(color) && colorc[0] == colorc[i]; i++) { ; }
if (i == sizeof(color)) {
// 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) {
if (clearZ) {
int height = h;
unsigned int *zbuf = _zbuf + (y * _pbufWidth);
uint *zbuf = _zbuf + (y * _pbufWidth);
const uint8 *zc = (const uint8 *)&z;
unsigned int i;
uint i;
for (i = 1; i < sizeof(z) && zc[0] == zc[i]; i++) { ; }
if (i == sizeof(z)) {
// 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;
uint32 color = _pbufFormat.RGBToColor(r, g, b);
const uint8 *colorc = (uint8 *)&color;
unsigned int i;
uint i;
for (i = 1; i < sizeof(color) && colorc[0] == colorc[i]; i++) { ; }
if (i == sizeof(color)) {
// 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) {
const unsigned int d = from_z[offset];
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 uint d = from_z[offset];
if (d > to_z[offset]) {
memcpy(to_color + offset, from_color + offset, color_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;
byte *to = _pbuf.getRawBuffer();
byte *from = buf->pbuf;
unsigned int *to_z = _zbuf;
unsigned int *from_z = buf->zbuf;
uint *to_z = _zbuf;
uint *from_z = buf->zbuf;
int count = _pbufWidth * _pbufHeight;
while (count >= UNROLL_COUNT) {
blitPixel(0x0, from_z, to_z, sizeof(int), from, to, pixel_bytes);

View file

@ -88,7 +88,8 @@ struct ZBufferPoint {
float sz, tz; // temporary coordinates for mapping
bool operator==(const ZBufferPoint &other) const {
return x == other.x &&
return
x == other.x &&
y == other.y &&
z == other.z &&
s == other.s &&
@ -282,7 +283,7 @@ private:
}
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) {
_pbuf.setPixelAt(pixel, value);
if (kDepthWrite) {
@ -310,7 +311,7 @@ private:
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>
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,
int x, int y, uint &z, int &t, int &s,
uint &r, uint &g, uint &b, uint &a,
@ -364,7 +365,7 @@ private:
}
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 (!checkAlphaTest(aSrc))
return;
@ -464,13 +465,18 @@ private:
default:
break;
}
int finalR, finalG, finalB;
finalR = rDst + rSrc;
finalG = gDst + gSrc;
finalB = bDst + bSrc;
if (finalR > 255) { finalR = 255; }
if (finalG > 255) { finalG = 255; }
if (finalB > 255) { finalB = 255; }
int finalR = rDst + rSrc;
int finalG = gDst + gSrc;
int finalB = bDst + bSrc;
if (finalR > 255) {
finalR = 255;
}
if (finalG > 255) {
finalG = 255;
}
if (finalB > 255) {
finalB = 255;
}
_pbuf.setPixelAt(pixel, 255, finalR, finalG, finalB);
}
}
@ -553,7 +559,7 @@ public:
_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;
_wrapS = wraps;
_wrapT = wrapt;
@ -622,13 +628,13 @@ private:
void fillLineInterp(ZBufferPoint *p1, ZBufferPoint *p2);
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>
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>
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>
FORCEINLINE void drawLine(const ZBufferPoint *p1, const ZBufferPoint *p2);
@ -654,8 +660,8 @@ private:
Common::Rect _clipRectangle;
bool _enableScissor;
const Graphics::TexelBuffer *_currentTexture;
unsigned int _wrapS, _wrapT;
const TexelBuffer *_currentTexture;
uint _wrapS, _wrapT;
bool _blendingEnabled;
int _sourceBlendingFactor;
int _destinationBlendingFactor;

View file

@ -114,7 +114,6 @@ struct GLMaterial {
Vector4 specular;
bool has_specular;
float shininess;
// computed values
int shininess_i;
int do_specular;
@ -132,7 +131,7 @@ union GLParam {
int op;
float f;
int i;
unsigned int ui;
uint ui;
void *p;
};
@ -177,7 +176,7 @@ struct GLVertex {
};
struct GLImage {
Graphics::TexelBuffer *pixmap;
TexelBuffer *pixmap;
int xsize, ysize;
};
@ -187,7 +186,7 @@ struct GLImage {
struct GLTexture {
GLImage images[MAX_TEXTURE_LEVELS];
unsigned int handle;
uint handle;
int versionNumber;
struct GLTexture *next, *prev;
bool disposed;
@ -244,7 +243,7 @@ public:
}
size_t returnPos = _memoryPosition;
_memoryPosition += size;
return ((char *)_memoryBuffer) + returnPos;
return ((byte *)_memoryBuffer) + returnPos;
}
void reset() {
@ -300,8 +299,8 @@ struct GLContext {
int texture_2d_enabled;
int texture_mag_filter;
int texture_min_filter;
unsigned int texture_wrap_s;
unsigned int texture_wrap_t;
uint texture_wrap_s;
uint texture_wrap_t;
Common::Array<struct tglColorAssociation> colorAssociationList;
// shared state
@ -340,14 +339,14 @@ struct GLContext {
// selection
int render_mode;
unsigned int *select_buffer;
uint *select_buffer;
int select_size;
unsigned int *select_ptr, *select_hit;
uint *select_ptr, *select_hit;
int select_overflow;
int select_hits;
// names
unsigned int name_stack[MAX_NAME_STACK_DEPTH];
uint name_stack[MAX_NAME_STACK_DEPTH];
int name_stack_size;
// clear
@ -457,7 +456,7 @@ public:
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_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_enable_disable_light(int light, int v);
void gl_shade_vertex(GLVertex *v);

View file

@ -31,7 +31,7 @@
namespace TinyGL {
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)
putPixel<kDepthWrite, true>(pixelOffset, color, x, y, z);
else
@ -39,18 +39,18 @@ FORCEINLINE void FrameBuffer::putPixel(unsigned int pixelOffset, int color, int
}
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)) {
return;
}
unsigned int *pz = _zbuf + pixelOffset;
uint *pz = _zbuf + pixelOffset;
if (compareDepth(z, *pz)) {
writePixel<true, true, kDepthWrite>(pixelOffset, color, z);
}
}
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)) {
return;
}
@ -142,9 +142,9 @@ void FrameBuffer::drawLine(const ZBufferPoint *p1, const ZBufferPoint *p2) {
}
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 unsigned int z = p->z;
const uint z = p->z;
if (_depthWrite && _depthTestEnabled)
putPixel<true>(pixelOffset, col, p->x, p->y, z);
else

View file

@ -71,7 +71,7 @@ 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>
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,
int x, int y, uint &z, int &t, int &s,
uint &r, uint &g, uint &b, uint &a,
@ -152,7 +152,7 @@ template <bool kInterpRGB, bool kInterpZ, bool kInterpST, bool kInterpSTZ, int k
bool kDepthWrite, bool kAlphaTestEnabled, bool kEnableScissor, bool kBlendingEnabled,
bool kStencilEnabled, bool kDepthTestEnabled>
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;
ZBufferPoint *tp, *pr1 = 0, *pr2 = 0, *l1 = 0, *l2 = 0;