Exemplo n.º 1
0
void glDrawVolume(DrawVolumeFunc drawFunc, const void* data)
{
    glDepthMask(GL_FALSE);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_DEPTH_CLAMP_NV);

    glEnable(GL_STENCIL_TEST);

    glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

    // using zfail method to avoid doing the inside check
    if (GLEW_EXT_stencil_two_side && GL_EXT_stencil_wrap) {
        glDisable(GL_CULL_FACE);
        glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
        glActiveStencilFaceEXT(GL_BACK);
        glStencilMask(~0);
        glStencilOp(GL_KEEP, GL_DECR_WRAP, GL_KEEP);
        glStencilFunc(GL_ALWAYS, 0, ~0);
        glActiveStencilFaceEXT(GL_FRONT);
        glStencilMask(~0);
        glStencilOp(GL_KEEP, GL_INCR_WRAP, GL_KEEP);
        glStencilFunc(GL_ALWAYS, 0, ~0);
        drawFunc(data); // draw
        glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
    } else {
        glEnable(GL_CULL_FACE);
        glStencilMask(~0);
        glStencilFunc(GL_ALWAYS, 0, ~0);
        glCullFace(GL_FRONT);
        glStencilOp(GL_KEEP, GL_INCR, GL_KEEP);
        drawFunc(data); // draw
        glCullFace(GL_BACK);
        glStencilOp(GL_KEEP, GL_DECR, GL_KEEP);
        drawFunc(data); // draw
        glDisable(GL_CULL_FACE);
    }

    glDisable(GL_DEPTH_TEST);

    glStencilFunc(GL_NOTEQUAL, 0, ~0);
    glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO); // clear as we go

    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

    drawFunc(data);   // draw

    glDisable(GL_DEPTH_CLAMP_NV);

    glDisable(GL_STENCIL_TEST);

    glEnable(GL_DEPTH_TEST);
}
Exemplo n.º 2
0
// generic 1-pass version
static void ss_EXT_1pass()
{
	glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
	glDisable(GL_CULL_FACE);
	glStencilMask(~0);
	glActiveStencilFaceEXT(GL_BACK);
	glStencilOp(GL_KEEP, GL_KEEP, ss_op_depth_pass_back);
	glStencilFunc(GL_ALWAYS, 0, ~0);
	glActiveStencilFaceEXT(GL_FRONT);
	glStencilOp(GL_KEEP, GL_KEEP, ss_op_depth_pass_front);
	glStencilFunc(GL_ALWAYS, 0, ~0);

	pie_ShadowDrawLoop();

	glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
}
Exemplo n.º 3
0
void e_endpass(e_device_t* device,unsigned int pass)
{
	glPopAttrib();

	switch(pass)
	{
		case E_RENDER_MESHES:
			glDisable(GL_VERTEX_PROGRAM_ARB);
			glDisable(GL_FRAGMENT_PROGRAM_ARB);
			break;
		case E_RENDER_SHADOWS:
			//Disable those extensions manually
			glDisable(GL_VERTEX_PROGRAM_ARB);
			if(glActiveStencilFaceEXT)
			{
				glActiveStencilFaceEXT(GL_FRONT_AND_BACK);
				glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
			}

			glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
			glDepthMask(GL_TRUE);
			break;
		case E_RENDER_SHADING:
			glDisable(GL_VERTEX_PROGRAM_ARB);
			glDisable(GL_FRAGMENT_PROGRAM_ARB);
			glDepthFunc(GL_LESS);
			break;
		case E_RENDER_OUTLINES:
			glColor3ub(255,255,255);
			glLineWidth(1.0f);
			break;
	}
}
Exemplo n.º 4
0
static void render_shadow(asset_t a, renderer_t r, light_t l)
{
#if 1
	glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
	glDepthMask(GL_FALSE);
	if ( GLEW_EXT_stencil_two_side ) {
		glDisable(GL_CULL_FACE);
		glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
	}else{
		glEnable(GL_CULL_FACE);
	}
	glEnable(GL_STENCIL_TEST);
	glEnable(GL_POLYGON_OFFSET_FILL);
	glPolygonOffset(0.0f, 100.0f);

	if ( GLEW_EXT_stencil_two_side ) {
		glActiveStencilFaceEXT(GL_BACK);
		glStencilFunc(GL_ALWAYS, 0, ~0);
		glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);
	}else{
		glCullFace(GL_BACK);
		glStencilFunc(GL_ALWAYS, 0x0, ~0);
		glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);
		render_vol(a);
	}

	if ( GLEW_EXT_stencil_two_side ) {
		glActiveStencilFaceEXT(GL_FRONT);
		glStencilFunc(GL_ALWAYS, 0, ~0);
		glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);
	}else{
		glCullFace(GL_FRONT);
		glStencilFunc(GL_ALWAYS, 0x0, ~0);
		glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);
	}
#endif

	render_vol(a);

	glDisable(GL_POLYGON_OFFSET_FILL);
	glDisable(GL_CULL_FACE);
	glDisable(GL_STENCIL_TEST);
	glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
Exemplo n.º 5
0
void enable_shadow_stencil() {
	assert(have_EXT_stencil_wrap());
	if (have_EXT_stencil_two_side()) {
		glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);

		glActiveStencilFaceEXT(GL_BACK);
		glStencilFunc(GL_ALWAYS, 1, ~0U);
		glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP);

		glActiveStencilFaceEXT(GL_FRONT);
		glStencilFunc(GL_ALWAYS, 1, ~0U);
		glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP);
 	} else if (have_ATI_separate_stencil()) {
		glStencilFuncSeparateATI( GL_ALWAYS, GL_ALWAYS, 1, ~0U );
		glStencilOpSeparateATI( GL_BACK, GL_KEEP, GL_KEEP, GL_INCR_WRAP );
		glStencilOpSeparateATI( GL_FRONT, GL_KEEP, GL_KEEP, GL_DECR_WRAP );
	} else {
		assert(0);
	}

}
Exemplo n.º 6
0
std::string getOpenGLState(bool showDisabled) {
    {
        debugAssertGLOk();
        glGetInteger(GL_BLEND);
        debugAssertM(glGetError() != GL_INVALID_OPERATION, 
             "Can't call getOpenGLState between glBegin() and glEnd()");
    }

    // The implementation has to be careful not to disrupt any OpenGL state and
    // to produce output code that sets values that interact (e.g. lighting and modelview matrix) in an order
    // so they produce the same results as currently in memory.

    std::string result;

    result += "///////////////////////////////////////////////////////////////////\n";
    result += "//                         Matrices                              //\n\n";
    result += getMatrixState();


    result += "///////////////////////////////////////////////////////////////////\n";
    result += "//                         Lighting                              //\n\n";
    result += getLightingState(showDisabled);

    result += "///////////////////////////////////////////////////////////////////\n";
    result += "//                         Clipping                              //\n\n";
    result += getClippingState();

    result += "///////////////////////////////////////////////////////////////////\n";
    result += "//                         Textures                              //\n\n";

    result += getTextureState(showDisabled);

    result += "///////////////////////////////////////////////////////////////////\n";
    result += "//                          Other                                //\n\n";
    
    GLdouble d[4];
    GLboolean b[4];

    // Viewport
    glGetDoublev(GL_VIEWPORT, d);
    result += format("glViewport(%g, %g, %g, %g);\n\n", d[0], d[1], d[2], d[3]);

    //color
    result += enableEntry(GL_COLOR_ARRAY);
    result += enableEntry(GL_COLOR_LOGIC_OP);
    result += enableEntry(GL_COLOR_MATERIAL);

    glGetDoublev(GL_COLOR_CLEAR_VALUE, d);
    result += format("glClearColor(%g, %g, %g, %g);\n", d[0], d[1], d[2], d[3]);
    glGetDoublev(GL_CURRENT_COLOR, d);
    result += format("glColor4d(%g, %g, %g, %g);\n", d[0], d[1], d[2], d[3]);
    glGetBooleanv(GL_COLOR_WRITEMASK, b);
    result += format("glColorMask(%d, %d, %d, %d);\n", b[0], b[1], b[2], b[3]);

    result += format("\n");


    //blend
    result += enableEntry(GL_BLEND);

    if (showDisabled || glGetBoolean(GL_BLEND)) {
        result += format("glBlendFunc(%s, %s);\n", 
            GLenumToString(glGetInteger(GL_BLEND_DST)),
            GLenumToString(glGetInteger(GL_BLEND_SRC)));
        result += format("\n");
    }



    //alpha
    result += enableEntry(GL_ALPHA_TEST);

    if (showDisabled || glGetBoolean(GL_ALPHA_TEST)) {
        result += format("glAlphaFunc(%s, %g);\n", 
            GLenumToString(glGetInteger(GL_ALPHA_TEST_FUNC)),
            glGetDouble(GL_ALPHA_TEST_REF));
        result += format("\n");
    }


    //depth stuff
    result += "///////////////////////////////////////////////////////////////////\n";
    result += "//                      Depth Buffer                             //\n\n";
    result += enableEntry(GL_DEPTH_TEST);
    if (showDisabled || glGetBoolean(GL_DEPTH_TEST)) {
        result += format("glDepthFunc(%s);\n", 
            GLenumToString(glGetInteger(GL_DEPTH_FUNC)));
    }

    result += format("glClearDepth(%g);\n", glGetDouble(GL_DEPTH_CLEAR_VALUE));
    result += format("glDepthMask(%d);\n", glGetBoolean(GL_DEPTH_WRITEMASK));

    {
        Vector2 range = glGetVector2(GL_DEPTH_RANGE);
        result += format("glDepthRange(%g, %g);\n", range.x, range.y);
    }

    result += format("\n");


    //stencil stuff
    result += "///////////////////////////////////////////////////////////////////////\n";
    result += "// Stencil\n\n";

    result += enableEntry(GL_STENCIL_TEST);

    result += format("glClearStencil(0x%x);\n", glGetInteger(GL_STENCIL_CLEAR_VALUE));

    if (GLCaps::supports_GL_EXT_stencil_two_side()) {
        result += "glActiveStencilFaceEXT(GL_BACK);\n";
        glActiveStencilFaceEXT(GL_BACK);
    }

    if (showDisabled || glGetBoolean(GL_STENCIL_TEST)) 
        result += format(
            "glStencilFunc(%s, %d, %d);\n",
            GLenumToString(glGetInteger(GL_STENCIL_FUNC)),
            glGetInteger(GL_STENCIL_REF),
            glGetInteger(GL_STENCIL_VALUE_MASK));

    result += format(
        "glStencilOp(%s, %s, %s);\n",
        GLenumToString(glGetInteger(GL_STENCIL_FAIL)),
        GLenumToString(glGetInteger(GL_STENCIL_PASS_DEPTH_FAIL)),
        GLenumToString(glGetInteger(GL_STENCIL_PASS_DEPTH_PASS)));

    result += format("glStencilMask(0x%x);\n", glGetInteger(GL_STENCIL_WRITEMASK));

    if (GLCaps::supports_GL_EXT_stencil_two_side()) {
        result += "\nglActiveStencilFaceEXT(GL_FRONT);\n";
        glActiveStencilFaceEXT(GL_FRONT);

        if (showDisabled || glGetBoolean(GL_STENCIL_TEST)) 
            result += format(
                "glStencilFunc(%s, %d, %d);\n",
                GLenumToString(glGetInteger(GL_STENCIL_FUNC)),
                glGetInteger(GL_STENCIL_REF),
                glGetInteger(GL_STENCIL_VALUE_MASK));

        result += format(
            "glStencilOp(%s, %s, %s);\n",
            GLenumToString(glGetInteger(GL_STENCIL_FAIL)),
            GLenumToString(glGetInteger(GL_STENCIL_PASS_DEPTH_FAIL)),
            GLenumToString(glGetInteger(GL_STENCIL_PASS_DEPTH_PASS)));

        result += format("glStencilMask(0x%x);\n", glGetInteger(GL_STENCIL_WRITEMASK));
    }
    
    result += ("\n");

    //misc
    result += enableEntry(GL_NORMAL_ARRAY);
    result += enableEntry(GL_NORMALIZE);

    glGetDoublev(GL_CURRENT_NORMAL, d);
    result += format("glNormal3d(%g, %g, %g);\n", d[0], d[1], d[2]);

    result += ("\n");

    result += format("glPixelZoom(%g, %g);\n", glGetDouble(GL_ZOOM_X), 
        glGetDouble(GL_ZOOM_Y));

    result += format("glReadBuffer(%s);\n", 
        GLenumToString(glGetInteger(GL_READ_BUFFER)));

    result += enableEntry(GL_POLYGON_SMOOTH);
    result += enableEntry(GL_POLYGON_STIPPLE);
    result += enableEntry(GL_LINE_SMOOTH);
    result += enableEntry(GL_LINE_STIPPLE);
    result += enableEntry(GL_POINT_SMOOTH);

    result += enableEntry(GL_AUTO_NORMAL);
    result += enableEntry(GL_CULL_FACE);

    result += enableEntry(GL_POLYGON_OFFSET_FILL);
    result += enableEntry(GL_POLYGON_OFFSET_LINE);
    result += enableEntry(GL_POLYGON_OFFSET_POINT);

    result += ("\n");

    result += enableEntry(GL_DITHER);
    result += enableEntry(GL_FOG);

    result += enableEntry(GL_VERTEX_ARRAY);
    result += enableEntry(GL_INDEX_ARRAY);
    result += enableEntry(GL_INDEX_LOGIC_OP);

    result += format("\n");

    result += enableEntry(GL_MAP1_COLOR_4);
    result += enableEntry(GL_MAP1_INDEX);
    result += enableEntry(GL_MAP1_NORMAL);
    result += enableEntry(GL_MAP1_TEXTURE_COORD_1);
    result += enableEntry(GL_MAP1_TEXTURE_COORD_2);
    result += enableEntry(GL_MAP1_TEXTURE_COORD_3);
    result += enableEntry(GL_MAP1_TEXTURE_COORD_4);
    result += enableEntry(GL_MAP1_VERTEX_3);
    result += enableEntry(GL_MAP1_VERTEX_4);
    result += enableEntry(GL_MAP2_COLOR_4);
    result += enableEntry(GL_MAP2_INDEX);
    result += enableEntry(GL_MAP2_NORMAL);
    result += enableEntry(GL_MAP2_TEXTURE_COORD_1);
    result += enableEntry(GL_MAP2_TEXTURE_COORD_2);
    result += enableEntry(GL_MAP2_TEXTURE_COORD_3);
    result += enableEntry(GL_MAP2_TEXTURE_COORD_4);
    result += enableEntry(GL_MAP2_VERTEX_3);
    result += enableEntry(GL_MAP2_VERTEX_4);

    result += format("\n");

    result += enableEntry(GL_SCISSOR_TEST);

    return result;
}
Exemplo n.º 7
0
void OglStartFrame (int bFlat, int bResetColorBuf)
{
	GLint nError = glGetError ();

if (!gameStates.render.cameras.bActive)
	OglDrawBuffer (GL_BACK, 1);
#if SHADOWS
if (gameStates.render.nShadowPass) {
#if GL_INFINITY
	float	infProj [4][4];	//projection to infinity
#endif

	if (gameStates.render.nShadowPass == 1) {	//render unlit/final scene
		if (!gameStates.render.bShadowMaps) {
#if GL_INFINITY
			glMatrixMode (GL_PROJECTION);
			memset (infProj, 0, sizeof (infProj));
			infProj [1][1] = 1.0f / (float) tan (gameStates.render.glFOV);
			infProj [0][0] = infProj [1][1] / (float) gameStates.render.glAspect;
			infProj [3][2] = -0.02f;	// -2 * near
			infProj [2][2] =
			infProj [2][3] = -1.0f;
			glLoadMatrixf ((float *) infProj);
#endif
#if 0
			glMatrixMode (GL_MODELVIEW);
			glLoadIdentity ();
#endif
			glEnable (GL_DEPTH_TEST);
			glDisable (GL_STENCIL_TEST);
			glDepthFunc (GL_LESS);
			glEnable (GL_CULL_FACE);	
			glCullFace (GL_BACK);
			if (!FAST_SHADOWS)
				glColorMask (0,0,0,0);
			}
		}
	else if (gameStates.render.nShadowPass == 2) {	//render occluders / shadow maps
		if (gameStates.render.bShadowMaps) {
			glColorMask (0,0,0,0);
			glEnable (GL_POLYGON_OFFSET_FILL);
			glPolygonOffset (1.0f, 2.0f);
			}
		else {
#	if DBG_SHADOWS
			if (bShadowTest) {
				glColorMask (1,1,1,1);
				glDepthMask (0);
				glEnable (GL_BLEND);
				glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
				glDisable (GL_STENCIL_TEST);
				}
			else 
#	endif
				{
				glColorMask (0,0,0,0);
				glDepthMask (0);
				glEnable (GL_STENCIL_TEST);
				if (!glIsEnabled (GL_STENCIL_TEST))
					extraGameInfo [0].bShadows = 
					extraGameInfo [1].bShadows = 0;
				glClearStencil (0);
				glClear (GL_STENCIL_BUFFER_BIT);
#if 0
				if (!glActiveStencilFaceEXT)
#endif
					bSingleStencil = 1;
#	if DBG_SHADOWS
				if (bSingleStencil || bShadowTest) {
#	else
				if (bSingleStencil) {
#	endif
					glStencilMask (~0);
					glStencilFunc (GL_ALWAYS, 0, ~0);
					}
#if 0
				else {
					glEnable (GL_STENCIL_TEST_TWO_SIDE_EXT);
					glActiveStencilFaceEXT (GL_BACK);
					if (bZPass)
						glStencilOp (GL_KEEP, GL_KEEP, GL_DECR_WRAP);
					else
						glStencilOp (GL_KEEP, GL_DECR_WRAP, GL_KEEP);
					glStencilOp (GL_KEEP, GL_DECR_WRAP, GL_KEEP);
					glStencilMask (~0);
					glStencilFunc (GL_ALWAYS, 0, ~0);
					glActiveStencilFaceEXT (GL_FRONT);
					if (bZPass)
						glStencilOp (GL_KEEP, GL_KEEP, GL_INCR_WRAP);
					else
						glStencilOp (GL_KEEP, GL_INCR_WRAP, GL_KEEP);
					glStencilMask (~0);
					glStencilFunc (GL_ALWAYS, 0, ~0);
					}
#endif
#if 0
				glEnable (GL_POLYGON_OFFSET_FILL);
				glPolygonOffset (1.0f, 1.0f);
#endif
				}
			}
		}
	else if (gameStates.render.nShadowPass == 3) { //render final lit scene
		if (gameStates.render.bShadowMaps) {
			glDisable (GL_POLYGON_OFFSET_FILL);
			glDepthFunc (GL_LESS);
			}
		else {
#if 0
			glDisable (GL_POLYGON_OFFSET_FILL);
#endif
			if (gameStates.render.nShadowBlurPass == 2)
				glDisable (GL_STENCIL_TEST);
         else if (FAST_SHADOWS) {
				glStencilFunc (GL_NOTEQUAL, 0, ~0);
				glStencilOp (GL_REPLACE, GL_KEEP, GL_KEEP);	
				}
			else 
				{
				glStencilFunc (GL_EQUAL, 0, ~0);
#if 0
				glStencilOp (GL_KEEP, GL_KEEP, GL_INCR);	//problem: layered texturing fails
#else
				glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
#endif
				}
			glCullFace (GL_BACK);
			glDepthFunc (GL_LESS);
			glColorMask (1,1,1,1);
			}
		}
	else if (gameStates.render.nShadowPass == 4) {	//render unlit/final scene
		glEnable (GL_DEPTH_TEST);
		glDepthFunc (GL_LESS);
		glEnable (GL_CULL_FACE);	
		glCullFace (GL_BACK);
		}
#if GL_INFINITY
	glMatrixMode (GL_MODELVIEW);
	glLoadIdentity ();
#endif
	}
Exemplo n.º 8
0
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;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTStencilTwoSide_nglActiveStencilFaceEXT(JNIEnv *env, jclass clazz, jint face, jlong function_pointer) {
    glActiveStencilFaceEXTPROC glActiveStencilFaceEXT = (glActiveStencilFaceEXTPROC)((intptr_t)function_pointer);
    glActiveStencilFaceEXT(face);
}
Exemplo n.º 10
0
void e_beginpass(e_device_t* device,unsigned int pass)
{
	glPushAttrib(GL_ENABLE_BIT|GL_STENCIL_BUFFER_BIT|GL_POLYGON_BIT);
	switch(pass)
	{
		case E_RENDER_MESHES:
			glBindProgramARB(GL_VERTEX_PROGRAM_ARB,e_programids[E_PROGRAM_PASSTOFRAGMENT]);
			glEnable(GL_VERTEX_PROGRAM_ARB);
			glEnable(GL_FRAGMENT_PROGRAM_ARB);

			glEnable(GL_DEPTH_TEST);
			glEnable(GL_CULL_FACE);
			break;
		case E_RENDER_SHADOWS:
			//The support of this extension depends on the 3D card
			if(glActiveStencilFaceEXT)
			{
				glActiveStencilFaceEXT(GL_BACK);
				glStencilOp(GL_KEEP,GL_INCR_WRAP_EXT,GL_KEEP);
				glActiveStencilFaceEXT(GL_FRONT);
				glStencilOp(GL_KEEP,GL_DECR_WRAP_EXT,GL_KEEP);
				glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
			}
			else
				glEnable(GL_CULL_FACE);

			glBindProgramARB(GL_VERTEX_PROGRAM_ARB,e_programids[E_PROGRAM_SHADOW]);
			glEnable(GL_VERTEX_PROGRAM_ARB);

			glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
			glDepthMask(GL_FALSE);
			glEnable(GL_STENCIL_TEST);
			glStencilFunc(GL_ALWAYS,0,~0);
			glEnable(GL_DEPTH_TEST);
			break;
		case E_RENDER_SHADING:
			glBindProgramARB(GL_VERTEX_PROGRAM_ARB,e_programids[E_PROGRAM_PASSTOFRAGMENT]);
			glEnable(GL_VERTEX_PROGRAM_ARB);
			glEnable(GL_FRAGMENT_PROGRAM_ARB);

			glBlendFunc(GL_ONE,GL_ONE);
			glEnable(GL_BLEND);

			glEnable(GL_STENCIL_TEST);
			glStencilFunc(GL_EQUAL,0,~0);
			glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);
			glDepthFunc(GL_LEQUAL);

			glEnable(GL_CULL_FACE);
			glEnable(GL_DEPTH_TEST);
			break;
		case E_RENDER_OUTLINES:
			glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
#ifdef E_OUTLINES_SMOOTH
			glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
			glEnable(GL_LINE_SMOOTH);
			glEnable(GL_BLEND);
#endif
			glLineWidth(E_OUTLINES_WIDTH);
			glPolygonOffset(1.0f,1.0f);
			glEnable(GL_POLYGON_OFFSET_LINE);
			glColor3ub(0,0,0);
			glEnable(GL_CULL_FACE);
			glCullFace(GL_FRONT);
			glEnable(GL_DEPTH_TEST);
			break;
	}
}
Exemplo n.º 11
0
Arquivo: g_render.c Projeto: aosm/X11
void __glXDisp_ActiveStencilFaceEXT(GLbyte *pc)
{
	glActiveStencilFaceEXT(
		*(GLenum *)(pc + 0)
	);
}