Ejemplo n.º 1
0
 void Graphics::ClearAllBuffers()
 {
     SetScissorTest();
     SetColorMask(true);
     SetDepthMask(true);
     SetStencilMask(~GLuint(0));
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
 }
Ejemplo n.º 2
0
    void Graphics::ResetCachedState()
    {
        Program::Clear();

        viewport_ = Recti(0);

        glGetIntegerv(GL_FRAMEBUFFER_BINDING, &systemFbo_); // On IOS default FBO is not zero

        // Set up texture data read/write alignment
        glPixelStorei(GL_PACK_ALIGNMENT, 1);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

        VertexArrayObj::Clear();
        lastMesh_ = nullptr;
        lastProgram_ = nullptr;
        activeMesh_ = nullptr;
        activeWindow_ = nullptr;

        CHECK_GL_STATUS();

        SetClearColor(Color(0, 0, 0, 1));
        SetClearDepth(1);
        SetClearStencil(0);
        SetFrameBuffer(nullptr);
        SetStencilTest(DEFAULT_STENCIL_ENABLE, DEFAULT_STENCIL_WRITEMASK, DEFAULT_STENCIL_SFAIL,
                       DEFAULT_STENCIL_DPFAIL, DEFAULT_STENCIL_DPPASS, DEFAULT_STENCIL_FUNC, DEFAULT_STENCIL_REF, DEFAULT_STENCIL_COMPAREMASK);
        SetScissorTest();

        CHECK_GL_STATUS();

        SetColorMask(DEFAULT_COLOR_MASK);
        SetDepthMask(DEFAULT_DEPTH_MASK);
        SetDepthFunc(DepthFunc::LESS);
        SetStencilMask(DEFAULT_STENCIL_MASK);
        SetBlendModeTest(DEFAULT_BLEND_MODE);
        EnableDepthTest(DEFAULT_DEPTH_TEST_ENABLE);
        EnableCullFace(DEFAULT_CULL_FACE_ENABLE);
        SetCullFace(CullFaceMode::DEFAULT);
        SetFrontFace(FrontFaceMode::DEFAULT);
        CHECK_GL_STATUS();

        UnboundTextures();
        SetVertexArrayObj(nullptr);
        SetVertexBuffer(nullptr);
        SetIndexBuffer(nullptr);
        SetProgram(nullptr);
        SetSlopeScaledBias(0);

        CHECK_GL_STATUS();
    }
Ejemplo n.º 3
0
    void Graphics::ClearBuffers(bool color, bool depth, bool stencil)
    {
        SetScissorTest();
        GLbitfield mask(0);
        if (color)
        {
            mask |= GL_COLOR_BUFFER_BIT;
            SetColorMask(true);
        }

        if (depth)
        {
            mask |= GL_DEPTH_BUFFER_BIT;
            SetDepthMask(true);
        }

        if (stencil)
        {
            mask |= GL_STENCIL_BUFFER_BIT;
            SetStencilMask(~GLuint(0));
        }

        glClear(mask);
    }
Ejemplo n.º 4
0
 void Graphics::ClearStencilBuffer(GLint value)
 {
     SetScissorTest();
     SetClearStencil(value);
     glClear(GL_STENCIL_BUFFER_BIT);
 }
Ejemplo n.º 5
0
void GlRasterStateInterface::BindRasterState( SRasterState const &newstate, bool bForce )
{
	bForce = true;
	
	bool bAlphaTestChanged =	(newstate.GetAlphaTest()	!=	mLastState.GetAlphaTest()		);
//	bool bTextureModeChanged =	(newstate.GetTextureMode()	!=	rLast.GetTextureMode()		);
//	bool bTextureActiveChanged =(newstate.GetTextureActive()!=	rLast.GetTextureActive()	);
	bool bBlendingChanged =		(newstate.GetBlending()		!=	mLastState.GetBlending()			);
	bool bDepthTestChanged =	(newstate.GetDepthTest()	!=	mLastState.GetDepthTest()		);
	//bool bStencilModeChanged =(newstate.GetStencilID()	!=	rLast.GetStencilID()		);
	bool bShadeModelChanged =	(newstate.GetShadeModel()	!=	mLastState.GetShadeModel()		);
	bool bCullTestChanged =		(newstate.GetCullTest()		!=	mLastState.GetCullTest()			);
	bool bScissorTestChanged =	(newstate.GetScissorTest()	!=	mLastState.GetScissorTest()		);
	
	GL_ERRORCHECK();

	if( bCullTestChanged || bForce )
	{
		SetCullTest( newstate.GetCullTest() );
	}

	/////////////////////////////////////////////////

	SetZWriteMask( newstate.GetZWriteMask() );
	SetRGBAWriteMask( newstate.GetRGBWriteMask(), newstate.GetAWriteMask() );

	/////////////////////////////////////////////////

	if( true )
	{
		glDisable( GL_STENCIL_TEST );
	}

	/////////////////////////////////////////////////
	//	Win32 GL Alpha
	
	if( false )
	{
	//	glDisable( GL_ALPHA_TEST );
	}
	else if( bAlphaTestChanged || bForce )
	{	
		static const F32 frecip = 1.0f / 15.0f;

		F32 fAlphaRef = frecip * (F32) newstate.muAlphaRef;

		switch( newstate.muAlphaTest )
		{	case EALPHATEST_OFF:
				//glDisable( GL_ALPHA_TEST );
				GL_ERRORCHECK();
				break;
			case EALPHATEST_GREATER:
				//glEnable( GL_ALPHA_TEST );
				//glAlphaFunc( GL_GREATER, fAlphaRef );
				GL_ERRORCHECK();
				break;
			case EALPHATEST_LESS:
				//glEnable( GL_ALPHA_TEST );
				//glAlphaFunc( GL_LESS, fAlphaRef );
				GL_ERRORCHECK();
				break;
		}
	}
		
	/////////////////////////////////////////////////
	//	Win32 GL Depth

	if(1)// bDepthTestChanged || bForce )
		SetDepthTest( newstate.GetDepthTest() );

	/////////////////////////////////////////////////

	if( bScissorTestChanged || bForce )
	{
		SetScissorTest( newstate.GetScissorTest() );
	}
	
	/////////////////////////////////////////////////

	if( bBlendingChanged || bForce )
	{
		SetBlending( newstate.GetBlending() );
	}
	
	GL_ERRORCHECK();
	
	if( false )
	{
		//glShadeModel( GL_FLAT );
	}
	else if( bShadeModelChanged || bForce )
	{
		switch( newstate.GetShadeModel() )
		{
			case ESHADEMODEL_FLAT:
				//glShadeModel( GL_FLAT );
				break;
			case ESHADEMODEL_SMOOTH:
				//glShadeModel( GL_SMOOTH );
				break;
			default:
				break;
		}
	}
	GL_ERRORCHECK();

}