static void setMatrix(const Vector3i *Position, const Vector3i *Rotation, int scale) { pie_PerspectiveBegin(); pie_MatBegin(); pie_TRANSLATE(Position->x, Position->y, Position->z); pie_MatRotX(DEG(Rotation->x)); pie_MatRotY(DEG(Rotation->y)); pie_MatRotZ(DEG(Rotation->z)); pie_MatScale(scale / 100.f); }
static void setMatrix(Vector3i *Position, Vector3i *Rotation, bool RotXYZ) { pie_PerspectiveBegin(); pie_MatBegin(); pie_TRANSLATE(Position->x,Position->y,Position->z); if(RotXYZ) { pie_MatRotX(DEG(Rotation->x)); pie_MatRotY(DEG(Rotation->y)); pie_MatRotZ(DEG(Rotation->z)); } else { pie_MatRotY(DEG(Rotation->y)); pie_MatRotX(DEG(Rotation->x)); pie_MatRotZ(DEG(Rotation->z)); } }
static void pie_DrawShadows(void) { const float width = pie_GetVideoBufferWidth(); const float height = pie_GetVideoBufferHeight(); pie_SetTexturePage(TEXPAGE_NONE); glPushMatrix(); pie_SetAlphaTest(false); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glDepthFunc(GL_LESS); glDepthMask(GL_FALSE); glEnable(GL_STENCIL_TEST); ShadowStencilFunc(); pie_SetRendMode(REND_ALPHA); glEnable(GL_CULL_FACE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilMask(~0); glStencilFunc(GL_LESS, 0, ~0); glColor4f(0, 0, 0, 0.5); pie_PerspectiveEnd(); glLoadIdentity(); glDisable(GL_DEPTH_TEST); glBegin(GL_TRIANGLE_STRIP); glVertex2f(0, 0); glVertex2f(width, 0); glVertex2f(0, height); glVertex2f(width, height); glEnd(); pie_PerspectiveBegin(); pie_SetRendMode(REND_OPAQUE); glDisable(GL_STENCIL_TEST); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glPopMatrix(); scshapes.clear(); }
static void pie_DrawShadows(void) { const float width = pie_GetVideoBufferWidth(); const float height = pie_GetVideoBufferHeight(); GLenum op_depth_pass_front = GL_INCR, op_depth_pass_back = GL_DECR; pie_SetTexturePage(TEXPAGE_NONE); glPushMatrix(); pie_SetAlphaTest(false); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glDepthFunc(GL_LESS); glDepthMask(GL_FALSE); glEnable(GL_STENCIL_TEST); // Check if we have the required extensions if (GLEE_EXT_stencil_wrap) { op_depth_pass_front = GL_INCR_WRAP_EXT; op_depth_pass_back = GL_DECR_WRAP_EXT; } // generic 1-pass version if (GLEE_EXT_stencil_two_side) { glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT); glDisable(GL_CULL_FACE); glStencilMask(~0); glActiveStencilFaceEXT(GL_BACK); glStencilOp(GL_KEEP, GL_KEEP, op_depth_pass_back); glStencilFunc(GL_ALWAYS, 0, ~0); glActiveStencilFaceEXT(GL_FRONT); glStencilOp(GL_KEEP, GL_KEEP, op_depth_pass_front); glStencilFunc(GL_ALWAYS, 0, ~0); pie_ShadowDrawLoop(); glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT); } // check for ATI-specific 1-pass version else if (GLEE_ATI_separate_stencil) { glDisable(GL_CULL_FACE); glStencilMask(~0); glStencilOpSeparateATI(GL_BACK, GL_KEEP, GL_KEEP, op_depth_pass_back); glStencilOpSeparateATI(GL_FRONT, GL_KEEP, GL_KEEP, op_depth_pass_front); glStencilFunc(GL_ALWAYS, 0, ~0); pie_ShadowDrawLoop(); } // fall back to default 2-pass version else { glStencilMask(~0); glStencilFunc(GL_ALWAYS, 0, ~0); glEnable(GL_CULL_FACE); // Setup stencil for front-facing polygons glCullFace(GL_BACK); glStencilOp(GL_KEEP, GL_KEEP, op_depth_pass_front); pie_ShadowDrawLoop(); // Setup stencil for back-facing polygons glCullFace(GL_FRONT); glStencilOp(GL_KEEP, GL_KEEP, op_depth_pass_back); pie_ShadowDrawLoop(); } pie_SetRendMode(REND_ALPHA); glEnable(GL_CULL_FACE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilMask(~0); glStencilFunc(GL_LESS, 0, ~0); glColor4f(0, 0, 0, 0.5); pie_PerspectiveEnd(); glLoadIdentity(); glDisable(GL_DEPTH_TEST); glBegin(GL_TRIANGLE_STRIP); glVertex2f(0, 0); glVertex2f(width, 0); glVertex2f(0, height); glVertex2f(width, height); glEnd(); pie_PerspectiveBegin(); pie_SetRendMode(REND_OPAQUE); glDisable(GL_STENCIL_TEST); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glPopMatrix(); nb_scshapes = 0; }