TINYGL: added tglAlphaTest stubs
This commit is contained in:
parent
2bf63a5f52
commit
b4962f645e
11 changed files with 61 additions and 7 deletions
|
@ -862,10 +862,10 @@ void GfxTinyGL::drawSprite(const Sprite *sprite) {
|
||||||
tglDisable(TGL_LIGHTING);
|
tglDisable(TGL_LIGHTING);
|
||||||
|
|
||||||
if (sprite->_alphaTest) {
|
if (sprite->_alphaTest) {
|
||||||
//tglEnable(TGL_ALPHA_TEST);
|
tglEnable(TGL_ALPHA_TEST);
|
||||||
//tglAlphaFunc(TGL_GEQUAL, g_grim->getGameType() == GType_MONKEY4 ? 0.1f : 0.5f);
|
tglAlphaFunc(TGL_GEQUAL, g_grim->getGameType() == GType_MONKEY4 ? 0.1f : 0.5f);
|
||||||
} else {
|
} else {
|
||||||
//tglDisable(TGL_ALPHA_TEST);
|
tglDisable(TGL_ALPHA_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sprite->_writeDepth) {
|
if (sprite->_writeDepth) {
|
||||||
|
|
|
@ -25,5 +25,6 @@ The changes made from the original version of TinyGL 0.4 are:
|
||||||
* Heavily refactored the triangle and line drawing routines
|
* Heavily refactored the triangle and line drawing routines
|
||||||
* Renamed ZBuffer into FrameBuffer and moved all the external C functions as member functions.
|
* Renamed ZBuffer into FrameBuffer and moved all the external C functions as member functions.
|
||||||
* Added implementation of glBlendFunc and support for 8-bit alpha.
|
* Added implementation of glBlendFunc and support for 8-bit alpha.
|
||||||
|
* Added implementation of glAlphaTestFunc.
|
||||||
|
|
||||||
For more information refer to log changes in github: https://github.com/residualvm/residualvm
|
For more information refer to log changes in github: https://github.com/residualvm/residualvm
|
||||||
|
|
|
@ -185,6 +185,16 @@ void tglBlendFunc(TGLenum sfactor, TGLenum dfactor) {
|
||||||
TinyGL::gl_add_op(p);
|
TinyGL::gl_add_op(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tglAlphaFunc(TGLenum func, float ref) {
|
||||||
|
TinyGL::GLParam p[3];
|
||||||
|
|
||||||
|
p[0].op = TinyGL::OP_AlphaFunc;
|
||||||
|
p[1].i = func;
|
||||||
|
p[2].f = ref;
|
||||||
|
|
||||||
|
TinyGL::gl_add_op(p);
|
||||||
|
}
|
||||||
|
|
||||||
void tglPolygonMode(int face, int mode) {
|
void tglPolygonMode(int face, int mode) {
|
||||||
TinyGL::GLParam p[3];
|
TinyGL::GLParam p[3];
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,11 @@ void tglGetIntegerv(int pname, int *params) {
|
||||||
case TGL_BLEND:
|
case TGL_BLEND:
|
||||||
*params = c->enableBlend;
|
*params = c->enableBlend;
|
||||||
break;
|
break;
|
||||||
|
case TGL_ALPHA_TEST:
|
||||||
|
*params = c->_alphaTestEnabled;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
error("glGet: option not implemented");
|
error("tglGet: option not implemented");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -798,6 +798,7 @@ void tglFrontFace(int mode);
|
||||||
void tglColorMask(TGLboolean r, TGLboolean g, TGLboolean b, TGLboolean a);
|
void tglColorMask(TGLboolean r, TGLboolean g, TGLboolean b, TGLboolean a);
|
||||||
void tglDepthMask(int enableWrite);
|
void tglDepthMask(int enableWrite);
|
||||||
void tglBlendFunc(TGLenum sfactor, TGLenum dfactor);
|
void tglBlendFunc(TGLenum sfactor, TGLenum dfactor);
|
||||||
|
void tglAlphaFunc(TGLenum func, float ref);
|
||||||
|
|
||||||
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);
|
||||||
|
|
|
@ -126,8 +126,13 @@ void glInit(void *zbuffer1) {
|
||||||
c->render_mode = TGL_RENDER;
|
c->render_mode = TGL_RENDER;
|
||||||
c->select_buffer = NULL;
|
c->select_buffer = NULL;
|
||||||
c->name_stack_size = 0;
|
c->name_stack_size = 0;
|
||||||
|
|
||||||
|
// blending
|
||||||
c->enableBlend = false;
|
c->enableBlend = false;
|
||||||
|
|
||||||
|
// alpha test
|
||||||
|
c->_alphaTestEnabled = false;
|
||||||
|
|
||||||
// matrix
|
// matrix
|
||||||
c->matrix_mode = 0;
|
c->matrix_mode = 0;
|
||||||
|
|
||||||
|
@ -146,8 +151,11 @@ void glInit(void *zbuffer1) {
|
||||||
tglLoadIdentity();
|
tglLoadIdentity();
|
||||||
tglMatrixMode(TGL_MODELVIEW);
|
tglMatrixMode(TGL_MODELVIEW);
|
||||||
tglLoadIdentity();
|
tglLoadIdentity();
|
||||||
|
|
||||||
tglBlendFunc(TGL_SRC_ALPHA, TGL_ONE_MINUS_SRC_ALPHA);
|
tglBlendFunc(TGL_SRC_ALPHA, TGL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
tglAlphaFunc(TGL_ALWAYS, 0.f);
|
||||||
|
|
||||||
c->matrix_model_projection_updated = 1;
|
c->matrix_model_projection_updated = 1;
|
||||||
|
|
||||||
// opengl 1.1 arrays
|
// opengl 1.1 arrays
|
||||||
|
|
|
@ -61,6 +61,10 @@ void glopEnableDisable(GLContext *c, GLParam *p) {
|
||||||
case TGL_DEPTH_TEST:
|
case TGL_DEPTH_TEST:
|
||||||
c->depth_test = v;
|
c->depth_test = v;
|
||||||
break;
|
break;
|
||||||
|
case TGL_ALPHA_TEST:
|
||||||
|
c->_alphaTestEnabled = v;
|
||||||
|
c->fb->enableAlphaTest(v);
|
||||||
|
break;
|
||||||
case TGL_BLEND:
|
case TGL_BLEND:
|
||||||
c->enableBlend = v;
|
c->enableBlend = v;
|
||||||
c->fb->enableBlending(v);
|
c->fb->enableBlending(v);
|
||||||
|
@ -111,6 +115,12 @@ void glopBlendFunc(GLContext *c, GLParam *p) {
|
||||||
c->fb->setBlendingFactors(sfactor, dfactor);
|
c->fb->setBlendingFactors(sfactor, dfactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void glopAlphaFunc(GLContext *c, GLParam *p) {
|
||||||
|
TGLenum func = p[1].i;
|
||||||
|
float ref = p[2].i;
|
||||||
|
c->fb->setAlphaTestFunc(func, ref);
|
||||||
|
}
|
||||||
|
|
||||||
void glopShadeModel(GLContext *c, GLParam *p) {
|
void glopShadeModel(GLContext *c, GLParam *p) {
|
||||||
int code = p[1].i;
|
int code = p[1].i;
|
||||||
c->current_shade_model = code;
|
c->current_shade_model = code;
|
||||||
|
|
|
@ -52,6 +52,7 @@ ADD_OP(PolygonMode, 2, "%C %C")
|
||||||
ADD_OP(ColorMask, 1, "%08x")
|
ADD_OP(ColorMask, 1, "%08x")
|
||||||
ADD_OP(DepthMask, 1, "%d")
|
ADD_OP(DepthMask, 1, "%d")
|
||||||
ADD_OP(BlendFunc, 2, "%d %d")
|
ADD_OP(BlendFunc, 2, "%d %d")
|
||||||
|
ADD_OP(AlphaFunc, 2, "%d %f")
|
||||||
|
|
||||||
ADD_OP(CallList, 1, "%d")
|
ADD_OP(CallList, 1, "%d")
|
||||||
ADD_OP(Hint, 2, "%C %C")
|
ADD_OP(Hint, 2, "%C %C")
|
||||||
|
|
|
@ -86,6 +86,7 @@ FrameBuffer::FrameBuffer(int width, int height, const Graphics::PixelBuffer &fra
|
||||||
this->buffer.pbuf = this->pbuf.getRawBuffer();
|
this->buffer.pbuf = this->pbuf.getRawBuffer();
|
||||||
this->buffer.zbuf = this->zbuf;
|
this->buffer.zbuf = this->zbuf;
|
||||||
_blendingEnabled = false;
|
_blendingEnabled = false;
|
||||||
|
_alphaTestEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameBuffer::~FrameBuffer() {
|
FrameBuffer::~FrameBuffer() {
|
||||||
|
@ -171,4 +172,13 @@ void FrameBuffer::enableBlending(bool enable) {
|
||||||
_blendingEnabled = enable;
|
_blendingEnabled = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FrameBuffer::setAlphaTestFunc(int func, float ref) {
|
||||||
|
_alphaTestFunc = func;
|
||||||
|
_alphaTestRefVal = (int)(ref * 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameBuffer::enableAlphaTest(bool enable) {
|
||||||
|
_alphaTestEnabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
} // end of namespace TinyGL
|
} // end of namespace TinyGL
|
||||||
|
|
|
@ -199,8 +199,10 @@ struct FrameBuffer {
|
||||||
pbuf.copyBuffer(0, xsize * ysize, buf);
|
pbuf.copyBuffer(0, xsize * ysize, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableBlending(bool enableBlending);
|
void enableBlending(bool enable);
|
||||||
void setBlendingFactors(int sfactor, int dfactor);
|
void setBlendingFactors(int sfactor, int dfactor);
|
||||||
|
void enableAlphaTest(bool enable);
|
||||||
|
void setAlphaTestFunc(int func, float ref);
|
||||||
void enableDepthWrite(bool enable) {
|
void enableDepthWrite(bool enable) {
|
||||||
this->_depthWrite = enable;
|
this->_depthWrite = enable;
|
||||||
}
|
}
|
||||||
|
@ -261,6 +263,9 @@ private:
|
||||||
bool _blendingEnabled;
|
bool _blendingEnabled;
|
||||||
int _sourceBlendingFactor;
|
int _sourceBlendingFactor;
|
||||||
int _destinationBlendingFactor;
|
int _destinationBlendingFactor;
|
||||||
|
bool _alphaTestEnabled;
|
||||||
|
int _alphaTestFunc;
|
||||||
|
int _alphaTestRefVal;
|
||||||
};
|
};
|
||||||
|
|
||||||
// memory.c
|
// memory.c
|
||||||
|
|
|
@ -210,7 +210,6 @@ struct GLContext {
|
||||||
gl_draw_triangle_func draw_triangle_front, draw_triangle_back;
|
gl_draw_triangle_func draw_triangle_front, draw_triangle_back;
|
||||||
|
|
||||||
// selection
|
// selection
|
||||||
bool enableBlend;
|
|
||||||
int render_mode;
|
int render_mode;
|
||||||
unsigned int *select_buffer;
|
unsigned int *select_buffer;
|
||||||
int select_size;
|
int select_size;
|
||||||
|
@ -275,6 +274,12 @@ struct GLContext {
|
||||||
// depth test
|
// depth test
|
||||||
int depth_test;
|
int depth_test;
|
||||||
int color_mask;
|
int color_mask;
|
||||||
|
|
||||||
|
// alpha test
|
||||||
|
bool _alphaTestEnabled;
|
||||||
|
|
||||||
|
// blending
|
||||||
|
bool enableBlend;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern GLContext *gl_ctx;
|
extern GLContext *gl_ctx;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue