//----------------------------------------------------------------------------// void OpenGLRenderer::beginRendering() { //save current attributes glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); glPushAttrib(GL_ALL_ATTRIB_BITS); // save current matrices glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); // do required set-up. yes, it really is this minimal ;) glEnable(GL_SCISSOR_TEST); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); // force set blending ops to get to a known state. setupRenderingBlendMode(BM_NORMAL, true); // enable arrays that we'll be using in the batches glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_SECONDARY_COLOR_ARRAY); glDisableClientState(GL_INDEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_FOG_COORDINATE_ARRAY); glDisableClientState(GL_EDGE_FLAG_ARRAY); // if enabled, restores a subset of the GL state back to default values. if (d_initExtraStates) setupExtraStates(); }
//----------------------------------------------------------------------------// void Direct3D9Renderer::beginRendering() { d_device->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); // no shaders initially d_device->SetVertexShader(0); d_device->SetPixelShader(0); // set device states d_device->SetRenderState(D3DRS_LIGHTING, FALSE); d_device->SetRenderState(D3DRS_FOGENABLE, FALSE); d_device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE); d_device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); d_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); d_device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); d_device->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE); d_device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE); // setup texture addressing settings d_device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); d_device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); // setup colour calculations d_device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); d_device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); d_device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); // setup alpha calculations d_device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); d_device->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); d_device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); // setup filtering d_device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); d_device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); // disable texture stages we do not need. d_device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); // setup scene alpha blending d_device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); // put alpha blend operations into a known state setupRenderingBlendMode(BM_NORMAL, true); // set view matrix back to identity. d_device->SetTransform(D3DTS_VIEW, &s_identityMatrix); }
//----------------------------------------------------------------------------// void OpenGL3Renderer::beginRendering() { // do required set-up. yes, it really is this minimal ;) glEnable(GL_SCISSOR_TEST); glEnable(GL_BLEND); // force set blending ops to get to a known state. setupRenderingBlendMode(BM_NORMAL, true); // if enabled, restores a subset of the GL state back to default values. if (d_initExtraStates) setupExtraStates(); d_shaderStandard->bind(); d_openGLStateChanger->reset(); }