From 0d0ae391c5c7740c8cdd359d2fb826c65b40112d Mon Sep 17 00:00:00 2001 From: Dreamy Cecil <21009796+DreamyCecil@users.noreply.github.com> Date: Sat, 11 Nov 2023 19:45:31 +0300 Subject: [PATCH] Replace gl_eCurrentAPI usage with GetCurrentAPI() in most places. --- Sources/Engine/Graphics/Benchmark.cpp | 11 ++- Sources/Engine/Graphics/DepthCheck.cpp | 2 +- Sources/Engine/Graphics/DrawPort.cpp | 48 +++++----- .../Engine/Graphics/DrawPort_RenderScene.cpp | 2 +- Sources/Engine/Graphics/GfxLibrary.cpp | 71 ++++++++------ Sources/Engine/Graphics/Gfx_wrapper.cpp | 28 +++--- .../Engine/Graphics/Gfx_wrapper_Direct3D.cpp | 94 +++++++++---------- .../Engine/Graphics/Gfx_wrapper_OpenGL.cpp | 92 +++++++++--------- Sources/Engine/Graphics/Texture.cpp | 6 +- Sources/Engine/Graphics/ViewPort.cpp | 20 ++-- Sources/Engine/Models/RenderModel.cpp | 2 +- Sources/Engine/Models/RenderModel_View.cpp | 2 +- Sources/Engine/Rendering/Render.cpp | 14 ++- Sources/SeriousSam/GLSettings.cpp | 2 +- Sources/SeriousSam/SeriousSam.cpp | 9 +- 15 files changed, 206 insertions(+), 197 deletions(-) diff --git a/Sources/Engine/Graphics/Benchmark.cpp b/Sources/Engine/Graphics/Benchmark.cpp index 2783da2e6..65f21289f 100644 --- a/Sources/Engine/Graphics/Benchmark.cpp +++ b/Sources/Engine/Graphics/Benchmark.cpp @@ -353,10 +353,13 @@ void CGfxLibrary::Benchmark(CViewPort *pvp, CDrawPort *pdp) _pixSizeJ = pdp->GetHeight(); CTString strAPI = ""; - if( _pGfx->gl_eCurrentAPI==GAT_OGL) strAPI = "OpenGL"; -#ifdef SE1_D3D - else if( _pGfx->gl_eCurrentAPI==GAT_D3D) strAPI = "Direct3D"; -#endif // SE1_D3D + + if (_pGfx->GetCurrentAPI() == GAT_OGL) { + strAPI = "OpenGL"; + } else if (_pGfx->GetCurrentAPI()==GAT_D3D) { + strAPI = "Direct3D"; + } + CPrintF("=====================================\n"); CPrintF("%s performance testing ...\n", strAPI); diff --git a/Sources/Engine/Graphics/DepthCheck.cpp b/Sources/Engine/Graphics/DepthCheck.cpp index 85d44e275..e4667807c 100644 --- a/Sources/Engine/Graphics/DepthCheck.cpp +++ b/Sources/Engine/Graphics/DepthCheck.cpp @@ -54,7 +54,7 @@ CStaticStackArray _acolDelayed; static void UpdateDepthPointsVisibility( const CDrawPort *pdp, const INDEX iMirrorLevel, DepthInfo *pdi, const INDEX ctCount) { - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D diff --git a/Sources/Engine/Graphics/DrawPort.cpp b/Sources/Engine/Graphics/DrawPort.cpp index 05f904141..173d52cf6 100644 --- a/Sources/Engine/Graphics/DrawPort.cpp +++ b/Sources/Engine/Graphics/DrawPort.cpp @@ -308,11 +308,10 @@ void CDrawPort::SetOrtho(void) const // finish all pending render-operations (if required) ogl_iFinish = Clamp( ogl_iFinish, 0L, 3L); d3d_iFinish = Clamp( d3d_iFinish, 0L, 3L); - if( (ogl_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_OGL) -#ifdef SE1_D3D - || (d3d_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_D3D) -#endif // SE1_D3D - ) gfxFinish(); + if ((ogl_iFinish == 3 && _pGfx->GetCurrentAPI() == GAT_OGL) + || (d3d_iFinish == 3 && _pGfx->GetCurrentAPI() == GAT_D3D)) { + gfxFinish(); + } // prepare ortho dimensions const PIX pixMinI = dp_MinI; @@ -339,11 +338,10 @@ void CDrawPort::SetProjection(CAnyProjection3D &apr) const // finish all pending render-operations (if required) ogl_iFinish = Clamp( ogl_iFinish, 0L, 3L); d3d_iFinish = Clamp( d3d_iFinish, 0L, 3L); - if( (ogl_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_OGL) -#ifdef SE1_D3D - || (d3d_iFinish==3 && _pGfx->gl_eCurrentAPI==GAT_D3D) -#endif // SE1_D3D - ) gfxFinish(); + if ((ogl_iFinish == 3 && _pGfx->GetCurrentAPI() == GAT_OGL) + || (d3d_iFinish == 3 && _pGfx->GetCurrentAPI() == GAT_D3D)) { + gfxFinish(); + } // if isometric projection if( apr.IsIsometric()) { @@ -437,7 +435,7 @@ BOOL CDrawPort::Lock(void) void CDrawPort::DrawPoint( PIX pixI, PIX pixJ, COLOR col, PIX pixRadius/*=1*/) const { // check API and radius - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); #else // SE1_D3D @@ -491,7 +489,7 @@ void CDrawPort::DrawPoint( PIX pixI, PIX pixJ, COLOR col, PIX pixRadius/*=1*/) c void CDrawPort::DrawPoint3D( FLOAT3D v, COLOR col, FLOAT fRadius/*=1.0f*/) const { // check API and radius - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -540,7 +538,7 @@ void CDrawPort::DrawPoint3D( FLOAT3D v, COLOR col, FLOAT fRadius/*=1.0f*/) const void CDrawPort::DrawLine( PIX pixI0, PIX pixJ0, PIX pixI1, PIX pixJ1, COLOR col, ULONG typ/*=_FULL*/) const { // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -609,7 +607,7 @@ void CDrawPort::DrawLine( PIX pixI0, PIX pixJ0, PIX pixI1, PIX pixJ1, COLOR col, void CDrawPort::DrawLine3D( FLOAT3D v0, FLOAT3D v1, COLOR col) const { // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -655,7 +653,7 @@ void CDrawPort::DrawLine3D( FLOAT3D v0, FLOAT3D v1, COLOR col) const void CDrawPort::DrawBorder( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, COLOR col, ULONG typ/*=_FULL_*/) const { // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -745,7 +743,7 @@ void CDrawPort::Fill( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, COLOR col col = AdjustColor( col, _slTexHueShift, _slTexSaturation); // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -796,7 +794,7 @@ void CDrawPort::Fill( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, if( !bInside) return; // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -866,7 +864,7 @@ void CDrawPort::Fill( COLOR col) const col = AdjustColor( col, _slTexHueShift, _slTexSaturation); // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -898,7 +896,7 @@ void CDrawPort::Fill( COLOR col) const void CDrawPort::FillZBuffer( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, FLOAT zval) const { // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -939,7 +937,7 @@ void CDrawPort::FillZBuffer( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, FL void CDrawPort::FillZBuffer( FLOAT zval) const { // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -970,7 +968,7 @@ void CDrawPort::FillZBuffer( FLOAT zval) const void CDrawPort::GrabScreen( class CImageInfo &iiGrabbedImage, INDEX iGrabZBuffer/*=0*/) const { // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -1072,7 +1070,7 @@ BOOL CDrawPort::IsPointVisible( PIX pixI, PIX pixJ, FLOAT fOoK, INDEX iID, INDEX if( pixI<1 || pixI>dp_Width-2 || pixJ<1 || pixJ>dp_Height-2) return FALSE; // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -1089,7 +1087,7 @@ void CDrawPort::RenderLensFlare( CTextureObject *pto, FLOAT fI, FLOAT fJ, FLOAT fSizeI, FLOAT fSizeJ, ANGLE aRotation, COLOR colLight) const { // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -1220,7 +1218,7 @@ ULONG CDrawPort::GetTextWidth( const CTString &strText) const void CDrawPort::PutText( const CTString &strText, PIX pixX0, PIX pixY0, const COLOR colBlend) const { // check API and adjust position for D3D by half pixel - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -1512,7 +1510,7 @@ void CDrawPort::PutTexture( class CTextureObject *pTO, } // check API and adjust position for D3D by half pixel - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D diff --git a/Sources/Engine/Graphics/DrawPort_RenderScene.cpp b/Sources/Engine/Graphics/DrawPort_RenderScene.cpp index 9005e5e01..7ca0da3a7 100644 --- a/Sources/Engine/Graphics/DrawPort_RenderScene.cpp +++ b/Sources/Engine/Graphics/DrawPort_RenderScene.cpp @@ -1709,7 +1709,7 @@ void RenderScene( CDrawPort *pDP, ScenePolygon *pspoFirst, CAnyProjection3D &prP COLOR colSelection, BOOL bTranslucent) { // check API - eAPI = _pGfx->gl_eCurrentAPI; + eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); #else // SE1_D3D diff --git a/Sources/Engine/Graphics/GfxLibrary.cpp b/Sources/Engine/Graphics/GfxLibrary.cpp index 67c18af53..77c88fd9c 100644 --- a/Sources/Engine/Graphics/GfxLibrary.cpp +++ b/Sources/Engine/Graphics/GfxLibrary.cpp @@ -479,7 +479,7 @@ extern CTString ReformatExtensionsString( CTString strUnformatted) static void GAPInfo(void) { // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); #else // SE1_D3D @@ -735,14 +735,22 @@ extern void UpdateGfxSysCVars(void) if( _pGfx->gl_ulFlags & GLF_ADJUSTABLEGAMMA) sys_bHasAdjustableGamma = 1; if( _pGfx->gl_ulFlags & GLF_32BITTEXTURES) sys_bHas32bitTextures = 1; if( _pGfx->gl_ulFlags & GLF_VSYNC) sys_bHasSwapInterval = 1; - if( _pGfx->gl_eCurrentAPI==GAT_OGL && !(_pGfx->gl_ulFlags&GLF_EXT_COMPILEDVERTEXARRAY)) sys_bHasCVAs = 0; -#ifdef SE1_D3D - if( _pGfx->gl_eCurrentAPI==GAT_D3D && !(_pGfx->gl_ulFlags&GLF_D3D_HASHWTNL)) sys_bHasHardwareTnL = 0; -#endif // SE1_D3D - if( _pGfx->gl_eCurrentAPI==GAT_OGL) sys_bUsingOpenGL = 1; -#ifdef SE1_D3D - if( _pGfx->gl_eCurrentAPI==GAT_D3D) sys_bUsingDirect3D = 1; -#endif // SE1_D3D + + if (_pGfx->GetCurrentAPI() == GAT_OGL) { + if (!(_pGfx->gl_ulFlags & GLF_EXT_COMPILEDVERTEXARRAY)) { + sys_bHasCVAs = 0; + } + + sys_bUsingOpenGL = 1; + } + + if (_pGfx->GetCurrentAPI() == GAT_D3D) { + if (!(_pGfx->gl_ulFlags & GLF_D3D_HASHWTNL)) { + sys_bHasHardwareTnL = 0; + } + + sys_bUsingDirect3D = 1; + } } @@ -1248,7 +1256,7 @@ BOOL CGfxLibrary::SetDisplayMode( enum GfxAPIType eAPI, INDEX iAdapter, PIX pixS // determine new API GfxAPIType eNewAPI = eAPI; - if( eNewAPI==GAT_CURRENT) eNewAPI = gl_eCurrentAPI; + if (eNewAPI == GAT_CURRENT) eNewAPI = GetCurrentAPI(); // shutdown old and startup new API, and mode and ... stuff, you know! StopDisplayMode(); @@ -1256,14 +1264,14 @@ BOOL CGfxLibrary::SetDisplayMode( enum GfxAPIType eAPI, INDEX iAdapter, PIX pixS if( !bRet) return FALSE; // didn't make it? // update some info - gl_iCurrentAdapter = gl_gaAPI[gl_eCurrentAPI].ga_iCurrentAdapter = iAdapter; + gl_iCurrentAdapter = gl_gaAPI[GetCurrentAPI()].ga_iCurrentAdapter = iAdapter; gl_dmCurrentDisplayMode.dm_pixSizeI = pixSizeI; gl_dmCurrentDisplayMode.dm_pixSizeJ = pixSizeJ; gl_dmCurrentDisplayMode.dm_ddDepth = eColorDepth; // prepare texture formats for this display mode extern void DetermineSupportedTextureFormats( GfxAPIType eAPI); - DetermineSupportedTextureFormats(gl_eCurrentAPI); + DetermineSupportedTextureFormats(GetCurrentAPI()); // made it! (eventually disable windows system keys) if( gfx_bDisableWindowsKeys) DisableWindowsKeys(); @@ -1277,7 +1285,7 @@ BOOL CGfxLibrary::ResetDisplayMode( enum GfxAPIType eAPI/*=GAT_CURRENT*/) { // determine new API GfxAPIType eNewAPI = eAPI; - if( eNewAPI==GAT_CURRENT) eNewAPI = gl_eCurrentAPI; + if (eNewAPI == GAT_CURRENT) eNewAPI = GetCurrentAPI(); // shutdown old and startup new API, and mode and ... stuff, you know! StopDisplayMode(); @@ -1292,7 +1300,7 @@ BOOL CGfxLibrary::ResetDisplayMode( enum GfxAPIType eAPI/*=GAT_CURRENT*/) // prepare texture formats for this display mode extern void DetermineSupportedTextureFormats( GfxAPIType eAPI); - DetermineSupportedTextureFormats(gl_eCurrentAPI); + DetermineSupportedTextureFormats(GetCurrentAPI()); // made it! EnableWindowsKeys(); @@ -1382,7 +1390,7 @@ BOOL CGfxLibrary::StartDisplayMode( enum GfxAPIType eAPI, INDEX iAdapter, PIX pi gl_fTextureLODBias = 0.0f; // set function pointers - GFX_SetFunctionPointers( (INDEX)gl_eCurrentAPI); + GFX_SetFunctionPointers(GetCurrentAPI()); // all done return TRUE; @@ -1399,14 +1407,14 @@ void CGfxLibrary::StopDisplayMode(void) UncacheShadows(); // shutdown API - if( gl_eCurrentAPI==GAT_OGL) + if (GetCurrentAPI() == GAT_OGL) { // OpenGL EndDriver_OGL(); MonitorsOn(); // re-enable multimonitor support if disabled CDS_ResetMode(); } #ifdef SE1_D3D - else if( gl_eCurrentAPI==GAT_D3D) + else if (GetCurrentAPI() == GAT_D3D) { // Direct3D EndDriver_D3D(); MonitorsOn(); @@ -1414,7 +1422,7 @@ void CGfxLibrary::StopDisplayMode(void) #endif // SE1_D3D else { // none - ASSERT( gl_eCurrentAPI==GAT_NONE); + ASSERT(GetCurrentAPI() == GAT_NONE); } // free driver DLL @@ -1436,12 +1444,13 @@ void CGfxLibrary::StopDisplayMode(void) // prepare current viewport for rendering BOOL CGfxLibrary::SetCurrentViewport(CViewPort *pvp) { - if( gl_eCurrentAPI==GAT_OGL) return SetCurrentViewport_OGL(pvp); + const GfxAPIType eAPI = GetCurrentAPI(); + if (eAPI == GAT_OGL) return SetCurrentViewport_OGL(pvp); #ifdef SE1_D3D - if( gl_eCurrentAPI==GAT_D3D) return SetCurrentViewport_D3D(pvp); + if (eAPI == GAT_D3D) return SetCurrentViewport_D3D(pvp); #endif // SE1_D3D - if( gl_eCurrentAPI==GAT_NONE) return TRUE; - ASSERTALWAYS( "SetCurrenViewport: Wrong API!"); + if (eAPI == GAT_NONE) return TRUE; + ASSERTALWAYS("SetCurrenViewport: Wrong API!"); return FALSE; } @@ -1468,7 +1477,7 @@ BOOL CGfxLibrary::LockDrawPort( CDrawPort *pdpToLock) } // OpenGL ... - if( gl_eCurrentAPI==GAT_OGL) + if (GetCurrentAPI() == GAT_OGL) { // pass drawport dimensions to OpenGL const PIX pixMinSI = pdpToLock->dp_ScissorMinI; @@ -1481,7 +1490,7 @@ BOOL CGfxLibrary::LockDrawPort( CDrawPort *pdpToLock) } // Direct3D ... #ifdef SE1_D3D - else if( gl_eCurrentAPI==GAT_D3D) + else if (GetCurrentAPI() == GAT_D3D) { // set viewport const PIX pixMinSI = pdpToLock->dp_ScissorMinI; @@ -1745,7 +1754,7 @@ void CGfxLibrary::SwapBuffers(CViewPort *pvp) d3d_iFinish = Clamp( d3d_iFinish, 0L, 3L); // OpenGL - if( gl_eCurrentAPI==GAT_OGL) + if (GetCurrentAPI() == GAT_OGL) { // force finishing of all rendering operations (if required) if( ogl_iFinish==2) gfxFinish(); @@ -1770,7 +1779,7 @@ void CGfxLibrary::SwapBuffers(CViewPort *pvp) // Direct3D #ifdef SE1_D3D - else if( gl_eCurrentAPI==GAT_D3D) + else if (GetCurrentAPI() == GAT_D3D) { // force finishing of all rendering operations (if required) if( d3d_iFinish==2) gfxFinish(); @@ -1873,12 +1882,12 @@ void CGfxLibrary::SwapBuffers(CViewPort *pvp) // ... and required const BOOL bTableSet = GenerateGammaTable(); if( bTableSet) { - if( gl_eCurrentAPI==GAT_OGL) { + if (GetCurrentAPI() == GAT_OGL) { CTempDC tdc(pvp->vp_hWnd); SetDeviceGammaRamp( tdc.hdc, &_auwGammaTable[0]); } #ifdef SE1_D3D - else if( gl_eCurrentAPI==GAT_D3D) { + else if (GetCurrentAPI() == GAT_D3D) { gl_pd3dDevice->SetGammaRamp( D3DSGR_NO_CALIBRATION, (D3DGAMMARAMP*)&_auwGammaTable[0]); } #endif // SE1_D3D @@ -1903,8 +1912,8 @@ void CGfxLibrary::SwapBuffers(CViewPort *pvp) // get array of all supported display modes CDisplayMode *CGfxLibrary::EnumDisplayModes( INDEX &ctModes, enum GfxAPIType eAPI/*=GAT_CURRENT*/, INDEX iAdapter/*=0*/) { - if( eAPI==GAT_CURRENT) eAPI = gl_eCurrentAPI; - if( iAdapter==0) iAdapter = gl_iCurrentAdapter; + if (eAPI == GAT_CURRENT) eAPI = GetCurrentAPI(); + if (iAdapter == 0) iAdapter = gl_iCurrentAdapter; CDisplayAdapter *pda = &gl_gaAPI[eAPI].ga_adaAdapter[iAdapter]; ctModes = pda->da_ctDisplayModes; return &pda->da_admDisplayModes[0]; @@ -1922,7 +1931,7 @@ BOOL CGfxLibrary::LockRaster( CRaster *praToLock) if( bRes) { // must signal to picky Direct3D #ifdef SE1_D3D - if( gl_eCurrentAPI==GAT_D3D && !GFX_bRenderingScene) { + if (GetCurrentAPI() == GAT_D3D && !GFX_bRenderingScene) { HRESULT hr = gl_pd3dDevice->BeginScene(); D3D_CHECKERROR(hr); bRes = (hr==D3D_OK); diff --git a/Sources/Engine/Graphics/Gfx_wrapper.cpp b/Sources/Engine/Graphics/Gfx_wrapper.cpp index c0c056084..ffc3aedb2 100644 --- a/Sources/Engine/Graphics/Gfx_wrapper.cpp +++ b/Sources/Engine/Graphics/Gfx_wrapper.cpp @@ -141,7 +141,7 @@ extern void (*gfxSetColorMask)( ULONG ulColorMask) = NULL; // dummy function (one size fits all:) static void none_void(void) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_NONE); + ASSERT(_pGfx->GetCurrentAPI() == GAT_NONE); } @@ -150,7 +150,7 @@ static void none_void(void) extern void OGL_CheckError(void) { #ifndef NDEBUG - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); if( eAPI==GAT_OGL) ASSERT( pglGetError()==GL_NO_ERROR); else ASSERT( eAPI==GAT_NONE); #endif @@ -160,7 +160,7 @@ extern void OGL_CheckError(void) extern void D3D_CheckError(HRESULT hr) { #ifndef NDEBUG - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); if( eAPI==GAT_D3D) ASSERT( hr==D3D_OK); else ASSERT( eAPI==GAT_NONE); #endif @@ -192,7 +192,7 @@ extern FLOAT _fCurrentLODBias = 0; // LOD bias adjuster extern void UpdateLODBias( const FLOAT fLODBias) { // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); #else // SE1_D3D @@ -263,7 +263,7 @@ extern void gfxSetTextureFiltering( INDEX &iFilterType, INDEX &iAnisotropyDegree // for OpenGL, that's about it #ifdef SE1_D3D - if( _pGfx->gl_eCurrentAPI!=GAT_D3D) return; + if (_pGfx->GetCurrentAPI() != GAT_D3D) return; _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -308,7 +308,7 @@ extern void gfxSetTextureBiasing( FLOAT &fLODBias) extern void gfxSetTextureUnit( INDEX iUnit) { // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); #else // SE1_D3D @@ -355,7 +355,7 @@ extern void gfxSetTexture( ULONG &ulTexObject, CTexParams &tpLocal) } // determine API and enable texturing - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -392,7 +392,7 @@ extern void gfxSetTexture( ULONG &ulTexObject, CTexParams &tpLocal) extern void gfxUploadTexture( ULONG *pulTexture, PIX pixWidth, PIX pixHeight, ULONG ulFormat, BOOL bNoDiscard) { // determine API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -428,7 +428,7 @@ extern SLONG gfxGetTextureSize( ULONG ulTexObject, BOOL bHasMipmaps/*=TRUE*/) if (ulTexObject == 0) return 0; // determine API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -488,7 +488,7 @@ extern SLONG gfxGetTextureSize( ULONG ulTexObject, BOOL bHasMipmaps/*=TRUE*/) extern INDEX gfxGetTexturePixRatio( ULONG ulTextureObject) { // determine API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -508,7 +508,7 @@ extern INDEX gfxGetTexturePixRatio( ULONG ulTextureObject) extern INDEX gfxGetFormatPixRatio( ULONG ulTextureFormat) { // determine API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D @@ -566,7 +566,7 @@ extern void gfxUnlockArrays(void) { // only if locked (OpenGL can lock 'em) if( !_bCVAReallyLocked) return; - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG INDEX glctRet; pglGetIntegerv( GL_ARRAY_ELEMENT_LOCK_COUNT_EXT, (GLint*)&glctRet); @@ -623,7 +623,7 @@ extern void gfxFlushQuads(void) if( ctElements<=0) return; // draw thru arrays (for OGL only) or elements? extern INDEX ogl_bAllowQuadArrays; - if( _pGfx->gl_eCurrentAPI==GAT_OGL && ogl_bAllowQuadArrays) FlushArrays( NULL, _avtxCommon.Count()); + if (_pGfx->GetCurrentAPI() == GAT_OGL && ogl_bAllowQuadArrays) FlushArrays(NULL, _avtxCommon.Count()); else { // make sure that enough quad elements has been initialized const INDEX ctQuads = _aiCommonQuads.Count(); @@ -657,7 +657,7 @@ extern void gfxSetTruform( INDEX iLevel, BOOL bLinearNormals) if( truform_iLevel==iLevel && !truform_bLinear==!bLinearNormals) return; // determine API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); #else // SE1_D3D diff --git a/Sources/Engine/Graphics/Gfx_wrapper_Direct3D.cpp b/Sources/Engine/Graphics/Gfx_wrapper_Direct3D.cpp index 57ea52384..7da7f2dbc 100644 --- a/Sources/Engine/Graphics/Gfx_wrapper_Direct3D.cpp +++ b/Sources/Engine/Graphics/Gfx_wrapper_Direct3D.cpp @@ -62,7 +62,7 @@ static void UpdateClipPlane_D3D(void) static void d3d_EnableTexture(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -90,7 +90,7 @@ static void d3d_EnableTexture(void) static void d3d_DisableTexture(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -117,7 +117,7 @@ static void d3d_DisableTexture(void) static void d3d_EnableDepthTest(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -142,7 +142,7 @@ static void d3d_EnableDepthTest(void) static void d3d_DisableDepthTest(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -168,7 +168,7 @@ static void d3d_DisableDepthTest(void) static void d3d_EnableDepthBias(void) { // only if supported - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); if( !(_pGfx->gl_ulFlags&GLF_D3D_ZBIAS)) return; _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -184,7 +184,7 @@ static void d3d_EnableDepthBias(void) static void d3d_DisableDepthBias(void) { // only if supported - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); if( !(_pGfx->gl_ulFlags&GLF_D3D_ZBIAS)) return; _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -200,7 +200,7 @@ static void d3d_DisableDepthBias(void) static void d3d_EnableDepthWrite(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -226,7 +226,7 @@ static void d3d_EnableDepthWrite(void) static void d3d_DisableDepthWrite(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -252,7 +252,7 @@ static void d3d_DisableDepthWrite(void) static void d3d_EnableDither(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -278,7 +278,7 @@ static void d3d_EnableDither(void) static void d3d_DisableDither(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -304,7 +304,7 @@ static void d3d_DisableDither(void) static void d3d_EnableAlphaTest(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -330,7 +330,7 @@ static void d3d_EnableAlphaTest(void) static void d3d_DisableAlphaTest(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -356,7 +356,7 @@ static void d3d_DisableAlphaTest(void) static void d3d_EnableBlend(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -385,7 +385,7 @@ static void d3d_EnableBlend(void) static void d3d_DisableBlend(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -415,7 +415,7 @@ static void d3d_DisableBlend(void) static void d3d_EnableClipping(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes = GFX_bClipping; @@ -445,7 +445,7 @@ static void d3d_DisableClipping(void) if( gap_iOptimizeClipping<2) return; // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -479,7 +479,7 @@ static void d3d_EnableClipPlane(void) if( !(_pGfx->gl_ulFlags&GLF_D3D_CLIPPLANE)) return; // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -516,7 +516,7 @@ static void d3d_DisableClipPlane(void) if( !(_pGfx->gl_ulFlags&GLF_D3D_CLIPPLANE)) return; // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes = GFX_bClipPlane; @@ -546,7 +546,7 @@ static void d3d_DisableClipPlane(void) static void d3d_EnableColorArray(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -574,7 +574,7 @@ static void d3d_EnableColorArray(void) static void d3d_DisableColorArray(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG BOOL bRes; @@ -604,7 +604,7 @@ static void d3d_EnableTruform(void) if( truform_iLevel<1) return; // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; FLOAT fSegments; #ifndef NDEBUG @@ -635,7 +635,7 @@ static void d3d_DisableTruform(void) if( truform_iLevel<1) return; // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; FLOAT fSegments; #ifndef NDEBUG @@ -695,7 +695,7 @@ __forceinline GfxBlend BlendFromD3D( _D3DBLEND d3dbFunc) { static void d3d_BlendFunc( GfxBlend eSrc, GfxBlend eDst) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG GfxBlend gfxSrc, gfxDst; @@ -732,7 +732,7 @@ static void d3d_SetColorMask( ULONG ulColorMask) { // only if supported _ulCurrentColorMask = ulColorMask; // keep for Get...() - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); if( !(_pGfx->gl_ulFlags&GLF_D3D_COLORWRITES)) { // emulate disabling of all channels if( ulColorMask==0) { @@ -793,7 +793,7 @@ __forceinline GfxComp CompFromD3D( _D3DCMPFUNC d3dcFunc) { static void d3d_DepthFunc( GfxComp eFunc) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; _D3DCMPFUNC d3dcFunc; #ifndef NDEBUG @@ -826,7 +826,7 @@ static void d3d_DepthRange( FLOAT fMin, FLOAT fMax) if( fMax<0.001f) fMax = 0.001f; // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; D3DVIEWPORT8 d3dViewport; #ifndef NDEBUG @@ -860,7 +860,7 @@ static void d3d_CullFace( GfxFace eFace) { // check consistency and face ASSERT( eFace==GFX_FRONT || eFace==GFX_BACK || eFace==GFX_NONE); - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; // must (re)assign faces for front-face emulation purposes @@ -891,7 +891,7 @@ static void d3d_FrontFace( GfxFace eFace) { // check consistency and face ASSERT( eFace==GFX_CW || eFace==GFX_CCW); - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); // cached? BOOL bFrontFace = (eFace==GFX_CCW); if( !bFrontFace==!GFX_bFrontFace && gap_bOptimizeStateChanges) return; @@ -907,7 +907,7 @@ static void d3d_FrontFace( GfxFace eFace) static void d3d_ClipPlane( const DOUBLE *pdViewPlane) { // check API and plane - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D && pdViewPlane!=NULL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D && pdViewPlane != NULL); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -926,7 +926,7 @@ static void d3d_ClipPlane( const DOUBLE *pdViewPlane) static void d3d_SetTextureMatrix( const FLOAT *pfMatrix/*=NULL*/) { // check API - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -951,7 +951,7 @@ static void d3d_SetTextureMatrix( const FLOAT *pfMatrix/*=NULL*/) static void d3d_SetViewMatrix( const FLOAT *pfMatrix/*=NULL*/) { // check API - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; // cached? (only identity matrix) @@ -983,7 +983,7 @@ static void d3d_SetOrtho( const FLOAT fLeft, const FLOAT fRight, const FLOAT f const BOOL bSubPixelAdjust/*=FALSE*/) { // check API and matrix type - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); // cached? if( GFX_fLastL==fLeft && GFX_fLastT==fTop && GFX_fLastN==fNear @@ -1015,7 +1015,7 @@ static void d3d_SetFrustum( const FLOAT fLeft, const FLOAT fRight, const FLOAT fNear, const FLOAT fFar) { // check API - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); // cached? if( GFX_fLastL==-fLeft && GFX_fLastT==-fTop && GFX_fLastN==-fNear @@ -1045,7 +1045,7 @@ static void d3d_SetFrustum( const FLOAT fLeft, const FLOAT fRight, static void d3d_PolygonMode( GfxPolyMode ePolyMode) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); _sfStats.StartTimer(CStatForm::STI_GFXAPI); HRESULT hr; @@ -1068,7 +1068,7 @@ static void d3d_PolygonMode( GfxPolyMode ePolyMode) static void d3d_SetTextureWrapping( enum GfxWrap eWrapU, enum GfxWrap eWrapV) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG // check wrapping consistency @@ -1107,7 +1107,7 @@ static void d3d_SetTextureWrapping( enum GfxWrap eWrapU, enum GfxWrap eWrapV) static void d3d_SetTextureModulation( INDEX iScale) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); HRESULT hr; #ifndef NDEBUG INDEX iRet; @@ -1138,7 +1138,7 @@ static void d3d_SetTextureModulation( INDEX iScale) static void d3d_GenerateTexture( ULONG &ulTexObject) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); _sfStats.StartTimer(CStatForm::STI_BINDTEXTURE); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -1155,7 +1155,7 @@ static void d3d_GenerateTexture( ULONG &ulTexObject) static void d3d_DeleteTexture( ULONG &ulTexObject) { // skip if already unbound - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); if( ulTexObject==NONE) return; _sfStats.StartTimer(CStatForm::STI_BINDTEXTURE); @@ -1176,7 +1176,7 @@ static void d3d_DeleteTexture( ULONG &ulTexObject) static void d3d_SetVertexArray( GFXVertex4 *pvtx, INDEX ctVtx) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); ASSERT( ctVtx>0 && pvtx!=NULL && GFX_iActiveTexUnit==0); GFX_ctVertices = ctVtx; _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -1190,7 +1190,7 @@ static void d3d_SetVertexArray( GFXVertex4 *pvtx, INDEX ctVtx) static void d3d_SetNormalArray( GFXNormal *pnor) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); ASSERT( pnor!=NULL); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -1203,7 +1203,7 @@ static void d3d_SetNormalArray( GFXNormal *pnor) static void d3d_SetColorArray( GFXColor *pcol) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); ASSERT( pcol!=NULL); d3d_EnableColorArray(); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -1217,7 +1217,7 @@ static void d3d_SetColorArray( GFXColor *pcol) static void d3d_SetTexCoordArray( GFXTexCoord *ptex, BOOL b4/*=FALSE*/) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); ASSERT( ptex!=NULL); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -1231,7 +1231,7 @@ static void d3d_SetTexCoordArray( GFXTexCoord *ptex, BOOL b4/*=FALSE*/) static void d3d_SetConstantColor( COLOR col) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); d3d_DisableColorArray(); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -1246,7 +1246,7 @@ static void d3d_SetConstantColor( COLOR col) static void d3d_DrawElements( INDEX ctElem, INDEX *pidx) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); #ifndef NDEBUG // check if all indices are inside lock count (or smaller than 65536) if( pidx!=NULL) for( INDEX i=0; igl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); _sfStats.StartTimer(CStatForm::STI_GFXAPI); // must "emulate" this by reading from back buffer :( @@ -1295,7 +1295,7 @@ static void d3d_Finish(void) static void d3d_LockArrays(void) { // only for OpenGL - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); ASSERT( GFX_ctVertices>0 && !_bCVAReallyLocked); } @@ -1306,7 +1306,7 @@ static void d3d_LockArrays(void) // set D3D vertex shader only if different than last time extern void d3dSetVertexShader( DWORD dwHandle) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_D3D); + ASSERT(_pGfx->GetCurrentAPI() == GAT_D3D); if( _pGfx->gl_dwVertexShader==dwHandle) return; HRESULT hr = _pGfx->gl_pd3dDevice->SetVertexShader(dwHandle); D3D_CHECKERROR(hr); diff --git a/Sources/Engine/Graphics/Gfx_wrapper_OpenGL.cpp b/Sources/Engine/Graphics/Gfx_wrapper_OpenGL.cpp index 12422dc86..8083cce84 100644 --- a/Sources/Engine/Graphics/Gfx_wrapper_OpenGL.cpp +++ b/Sources/Engine/Graphics/Gfx_wrapper_OpenGL.cpp @@ -21,7 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., static void ogl_EnableTexture(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_TEXTURE_2D); @@ -46,7 +46,7 @@ static void ogl_EnableTexture(void) static void ogl_DisableTexture(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_TEXTURE_2D); @@ -72,7 +72,7 @@ static void ogl_DisableTexture(void) static void ogl_EnableDepthTest(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_DEPTH_TEST); @@ -95,7 +95,7 @@ static void ogl_EnableDepthTest(void) static void ogl_DisableDepthTest(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_DEPTH_TEST); @@ -118,7 +118,7 @@ static void ogl_DisableDepthTest(void) static void ogl_EnableDepthBias(void) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglEnable( GL_POLYGON_OFFSET_POINT); @@ -133,7 +133,7 @@ static void ogl_EnableDepthBias(void) static void ogl_DisableDepthBias(void) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglDisable( GL_POLYGON_OFFSET_POINT); @@ -150,7 +150,7 @@ static void ogl_DisableDepthBias(void) static void ogl_EnableDepthWrite(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; pglGetIntegerv( GL_DEPTH_WRITEMASK, (GLint*)&bRes); @@ -175,7 +175,7 @@ static void ogl_EnableDepthWrite(void) static void ogl_DisableDepthWrite(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; pglGetIntegerv( GL_DEPTH_WRITEMASK, (GLint*)&bRes); @@ -200,7 +200,7 @@ static void ogl_DisableDepthWrite(void) static void ogl_EnableDither(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_DITHER); @@ -225,7 +225,7 @@ static void ogl_EnableDither(void) static void ogl_DisableDither(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_DITHER); @@ -250,7 +250,7 @@ static void ogl_DisableDither(void) static void ogl_EnableAlphaTest(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_ALPHA_TEST); @@ -275,7 +275,7 @@ static void ogl_EnableAlphaTest(void) static void ogl_DisableAlphaTest(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_ALPHA_TEST); @@ -300,7 +300,7 @@ static void ogl_DisableAlphaTest(void) static void ogl_EnableBlend(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_BLEND); @@ -328,7 +328,7 @@ static void ogl_EnableBlend(void) static void ogl_DisableBlend(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_BLEND); @@ -360,7 +360,7 @@ static void ogl_EnableClipping(void) if( !(_pGfx->gl_ulFlags&GLF_EXT_CLIPHINT)) return; // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; pglGetIntegerv( GL_CLIP_VOLUME_CLIPPING_HINT_EXT, (GLint*)&bRes); @@ -389,7 +389,7 @@ static void ogl_DisableClipping(void) if( gap_iOptimizeClipping<2 || !(_pGfx->gl_ulFlags&GLF_EXT_CLIPHINT)) return; // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; pglGetIntegerv( GL_CLIP_VOLUME_CLIPPING_HINT_EXT, (GLint*)&bRes); @@ -416,7 +416,7 @@ static void ogl_DisableClipping(void) static void ogl_EnableClipPlane(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_CLIP_PLANE0); @@ -440,7 +440,7 @@ static void ogl_EnableClipPlane(void) static void ogl_DisableClipPlane(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_CLIP_PLANE0); @@ -465,7 +465,7 @@ static void ogl_DisableClipPlane(void) static void ogl_EnableColorArray(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_COLOR_ARRAY); @@ -491,7 +491,7 @@ static void ogl_EnableColorArray(void) static void ogl_DisableColorArray(void) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_COLOR_ARRAY); @@ -520,7 +520,7 @@ static void ogl_EnableTruform(void) if( truform_iLevel<1) return; // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_PN_TRIANGLES_ATI); @@ -548,7 +548,7 @@ static void ogl_DisableTruform(void) if( truform_iLevel<1) return; // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_PN_TRIANGLES_ATI); @@ -603,7 +603,7 @@ __forceinline GfxBlend BlendFromOGL( GLenum gFunc) { static void ogl_BlendFunc( GfxBlend eSrc, GfxBlend eDst) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); GLenum gleSrc, gleDst; #ifndef NDEBUG GfxBlend gfxSrc, gfxDst; @@ -635,7 +635,7 @@ static void ogl_BlendFunc( GfxBlend eSrc, GfxBlend eDst) // color buffer writing enable static void ogl_SetColorMask( ULONG ulColorMask) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); _ulCurrentColorMask = ulColorMask; // keep for Get...() _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -686,7 +686,7 @@ __forceinline GfxComp CompFromOGL( GLenum gFunc) { static void ogl_DepthFunc( GfxComp eFunc) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); GLenum gleFunc; #ifndef NDEBUG GfxComp gfxFunc; @@ -714,7 +714,7 @@ static void ogl_DepthFunc( GfxComp eFunc) static void ogl_DepthRange( FLOAT fMin, FLOAT fMax) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG FLOAT fDepths[2]; pglGetFloatv( GL_DEPTH_RANGE,(GLfloat*)&fDepths); @@ -742,7 +742,7 @@ static void ogl_CullFace( GfxFace eFace) { // check consistency and face ASSERT( eFace==GFX_FRONT || eFace==GFX_BACK || eFace==GFX_NONE); - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG GLenum gleCull; BOOL bRes = pglIsEnabled(GL_CULL_FACE); @@ -779,7 +779,7 @@ static void ogl_FrontFace( GfxFace eFace) { // check consistency and face ASSERT( eFace==GFX_CW || eFace==GFX_CCW); - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG GLenum gleFace; pglGetIntegerv( GL_FRONT_FACE, (GLint*)&gleFace); @@ -810,7 +810,7 @@ static void ogl_FrontFace( GfxFace eFace) static void ogl_ClipPlane( const DOUBLE *pdViewPlane) { // check API and plane - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL && pdViewPlane!=NULL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL && pdViewPlane != NULL); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -826,7 +826,7 @@ static void ogl_ClipPlane( const DOUBLE *pdViewPlane) static void ogl_SetTextureMatrix( const FLOAT *pfMatrix/*=NULL*/) { // check API - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -846,7 +846,7 @@ static void ogl_SetTextureMatrix( const FLOAT *pfMatrix/*=NULL*/) static void ogl_SetViewMatrix( const FLOAT *pfMatrix/*=NULL*/) { // check API - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); // cached? (only identity matrix) if( pfMatrix==NULL && GFX_bViewMatrix==NONE && gap_bOptimizeStateChanges) return; @@ -871,7 +871,7 @@ static void ogl_SetOrtho( const FLOAT fLeft, const FLOAT fRight, const FLOAT f const BOOL bSubPixelAdjust/*=FALSE*/) { // check API and matrix type - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); // cached? if( GFX_fLastL==fLeft && GFX_fLastT==fTop && GFX_fLastN==fNear @@ -898,7 +898,7 @@ static void ogl_SetFrustum( const FLOAT fLeft, const FLOAT fRight, const FLOAT fNear, const FLOAT fFar) { // check API - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); // cached? if( GFX_fLastL==-fLeft && GFX_fLastT==-fTop && GFX_fLastN==-fNear @@ -922,7 +922,7 @@ static void ogl_SetFrustum( const FLOAT fLeft, const FLOAT fRight, // set polygon mode (point, line or fill) static void ogl_PolygonMode( GfxPolyMode ePolyMode) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); _sfStats.StartTimer(CStatForm::STI_GFXAPI); switch(ePolyMode) { @@ -945,7 +945,7 @@ static void ogl_PolygonMode( GfxPolyMode ePolyMode) // set texture wrapping mode static void ogl_SetTextureWrapping( enum GfxWrap eWrapU, enum GfxWrap eWrapV) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG // check texture unit consistency GLint gliRet; @@ -965,7 +965,7 @@ static void ogl_SetTextureWrapping( enum GfxWrap eWrapU, enum GfxWrap eWrapV) static void ogl_SetTextureModulation( INDEX iScale) { // check consistency - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG // check current modulation GLint iRet; @@ -998,7 +998,7 @@ static void ogl_SetTextureModulation( INDEX iScale) // generate texture for API static void ogl_GenerateTexture( ULONG &ulTexObject) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); _sfStats.StartTimer(CStatForm::STI_BINDTEXTURE); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -1015,7 +1015,7 @@ static void ogl_GenerateTexture( ULONG &ulTexObject) static void ogl_DeleteTexture( ULONG &ulTexObject) { // skip if already unbound - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); if( ulTexObject==NONE) return; _sfStats.StartTimer(CStatForm::STI_BINDTEXTURE); @@ -1036,7 +1036,7 @@ static void ogl_DeleteTexture( ULONG &ulTexObject) // prepare vertex array for API static void ogl_SetVertexArray( GFXVertex4 *pvtx, INDEX ctVtx) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); ASSERT( ctVtx>0 && pvtx!=NULL && GFX_iActiveTexUnit==0); GFX_ctVertices = ctVtx; _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -1060,7 +1060,7 @@ static void ogl_SetVertexArray( GFXVertex4 *pvtx, INDEX ctVtx) // prepare normal array for API static void ogl_SetNormalArray( GFXNormal *pnor) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); ASSERT( pnor!=NULL); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -1077,7 +1077,7 @@ static void ogl_SetNormalArray( GFXNormal *pnor) // prepare color array for API (and force rendering with color array!) static void ogl_SetColorArray( GFXColor *pcol) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); ASSERT( pcol!=NULL); ogl_EnableColorArray(); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -1093,7 +1093,7 @@ static void ogl_SetColorArray( GFXColor *pcol) // prepare texture coordinates array for API static void ogl_SetTexCoordArray( GFXTexCoord *ptex, BOOL b4/*=FALSE*/) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); ASSERT( ptex!=NULL); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -1110,7 +1110,7 @@ static void ogl_SetTexCoordArray( GFXTexCoord *ptex, BOOL b4/*=FALSE*/) // set constant color (and force rendering w/o color array!) static void ogl_SetConstantColor( COLOR col) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); ogl_DisableColorArray(); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -1125,7 +1125,7 @@ static void ogl_SetConstantColor( COLOR col) // draw prepared arrays static void ogl_DrawElements( INDEX ctElem, INDEX *pidx) { - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); #ifndef NDEBUG // check if all indices are inside lock count (or smaller than 65536) if( pidx!=NULL) for( INDEX i=0; igl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglFinish(); @@ -1163,7 +1163,7 @@ static void ogl_Finish(void) static void ogl_LockArrays(void) { // only if supported - ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); + ASSERT(_pGfx->GetCurrentAPI() == GAT_OGL); ASSERT( GFX_ctVertices>0 && !_bCVAReallyLocked); if( !(_pGfx->gl_ulFlags&GLF_EXT_COMPILEDVERTEXARRAY)) return; pglLockArraysEXT( 0, GFX_ctVertices); diff --git a/Sources/Engine/Graphics/Texture.cpp b/Sources/Engine/Graphics/Texture.cpp index e92511ef5..43d84ce1c 100644 --- a/Sources/Engine/Graphics/Texture.cpp +++ b/Sources/Engine/Graphics/Texture.cpp @@ -85,7 +85,7 @@ extern void DetermineSupportedTextureFormats( GfxAPIType eAPI) extern void UpdateTextureSettings(void) { // determine API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); #else @@ -683,7 +683,7 @@ void CTextureData::Read_t( CTStream *inFile) Clear(); // determine API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); #else // SE1_D3D @@ -1168,7 +1168,7 @@ void CTextureData::Force( ULONG ulTexFlags) void CTextureData::SetAsCurrent( INDEX iFrameNo/*=0*/, BOOL bForceUpload/*=FALSE*/) { // check API - const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; + const GfxAPIType eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); #else // SE1_D3D diff --git a/Sources/Engine/Graphics/ViewPort.cpp b/Sources/Engine/Graphics/ViewPort.cpp index e2b9edbcb..e5932ac69 100644 --- a/Sources/Engine/Graphics/ViewPort.cpp +++ b/Sources/Engine/Graphics/ViewPort.cpp @@ -189,7 +189,7 @@ void CViewPort::OpenCanvas(void) ASSERT( vp_hWnd!=NULL); #ifdef SE1_D3D // prepare new swap chain for D3D - if( _pGfx->gl_eCurrentAPI==GAT_D3D && !bFullScreen) CreateSwapChain_D3D( this, pixWinSizeI, pixWinSizeJ); + if (_pGfx->GetCurrentAPI() == GAT_D3D && !bFullScreen) CreateSwapChain_D3D(this, pixWinSizeI, pixWinSizeJ); #endif // SE1_D3D // resize raster @@ -197,7 +197,7 @@ void CViewPort::OpenCanvas(void) ShowWindow( vp_hWnd, SW_SHOW); #ifdef SE1_D3D // set as rendering target - if( _pGfx->gl_eCurrentAPI==GAT_D3D && vp_pSwapChain!=NULL) SetAsRenderTarget_D3D(this); + if (_pGfx->GetCurrentAPI() == GAT_D3D && vp_pSwapChain != NULL) SetAsRenderTarget_D3D(this); #endif // SE1_D3D } @@ -207,9 +207,9 @@ void CViewPort::CloseCanvas( BOOL bRelease/*=FALSE*/) { // release D3D swap chain if allocated #ifdef SE1_D3D - if( _pGfx->gl_eCurrentAPI==GAT_D3D && bRelease) { - if( vp_pSwapChain!=NULL) D3DRELEASE( vp_pSwapChain, TRUE); - if( vp_pSurfDepth!=NULL) D3DRELEASE( vp_pSurfDepth, TRUE); + if (_pGfx->GetCurrentAPI() == GAT_D3D && bRelease) { + if (vp_pSwapChain != NULL) D3DRELEASE(vp_pSwapChain, TRUE); + if (vp_pSurfDepth != NULL) D3DRELEASE(vp_pSurfDepth, TRUE); } #endif // SE1_D3D // destroy window @@ -246,13 +246,13 @@ void CViewPort::Resize(void) // "resize" D3D surface (if any) #ifdef SE1_D3D - if( _pGfx->gl_eCurrentAPI==GAT_D3D && vp_pSwapChain!=NULL) { + if (_pGfx->GetCurrentAPI() == GAT_D3D && vp_pSwapChain != NULL) { // release old surface - ASSERT( vp_pSurfDepth!=NULL); - D3DRELEASE( vp_pSwapChain, TRUE); - D3DRELEASE( vp_pSurfDepth, TRUE); + ASSERT(vp_pSurfDepth!=NULL); + D3DRELEASE(vp_pSwapChain, TRUE); + D3DRELEASE(vp_pSurfDepth, TRUE); // create a new one and set it as current - CreateSwapChain_D3D( this, pixNewWidth, pixNewHeight); + CreateSwapChain_D3D(this, pixNewWidth, pixNewHeight); SetAsRenderTarget_D3D(this); } #endif // SE1_D3D diff --git a/Sources/Engine/Models/RenderModel.cpp b/Sources/Engine/Models/RenderModel.cpp index c3b7ebfbb..130e58c07 100644 --- a/Sources/Engine/Models/RenderModel.cpp +++ b/Sources/Engine/Models/RenderModel.cpp @@ -413,7 +413,7 @@ static void PrepareView( CRenderModel &rm) static void RenderWireframeBox( FLOAT3D vMinVtx, FLOAT3D vMaxVtx, COLOR col) { // only for OpenGL (for now) - if( _pGfx->gl_eCurrentAPI!=GAT_OGL) return; + if (_pGfx->GetCurrentAPI() != GAT_OGL) return; // prepare wireframe OpenGL settings gfxDisableDepthTest(); diff --git a/Sources/Engine/Models/RenderModel_View.cpp b/Sources/Engine/Models/RenderModel_View.cpp index aafde9db7..ae484ad8d 100644 --- a/Sources/Engine/Models/RenderModel_View.cpp +++ b/Sources/Engine/Models/RenderModel_View.cpp @@ -1742,7 +1742,7 @@ static void UnpackFrame( CRenderModel &rm, BOOL bKeepNormals) void CModelObject::RenderModel_View( CRenderModel &rm) { // cache API - _eAPI = _pGfx->gl_eCurrentAPI; + _eAPI = _pGfx->GetCurrentAPI(); #ifdef SE1_D3D ASSERT( _eAPI==GAT_OGL || _eAPI==GAT_D3D || _eAPI==GAT_NONE); #else // SE1_D3D diff --git a/Sources/Engine/Rendering/Render.cpp b/Sources/Engine/Rendering/Render.cpp index c6b35ac65..eea4ec68b 100644 --- a/Sources/Engine/Rendering/Render.cpp +++ b/Sources/Engine/Rendering/Render.cpp @@ -712,18 +712,16 @@ void CRenderer::Render(void) ChangeStatsMode(CStatForm::STI_SWAPBUFFERS); extern INDEX ogl_iFinish; ogl_iFinish = Clamp( ogl_iFinish, 0L, 3L); extern INDEX d3d_iFinish; d3d_iFinish = Clamp( d3d_iFinish, 0L, 3L); - if( (ogl_iFinish==1 && _pGfx->gl_eCurrentAPI==GAT_OGL) -#ifdef SE1_D3D - || (d3d_iFinish==1 && _pGfx->gl_eCurrentAPI==GAT_D3D) -#endif // SE1_D3D - ) - gfxFinish(); + if ((ogl_iFinish == 1 && _pGfx->GetCurrentAPI() == GAT_OGL) + || (d3d_iFinish == 1 && _pGfx->GetCurrentAPI() == GAT_D3D)) { + gfxFinish(); + } // check any eventual delayed depth points outside the mirror (if API and time allows) if( !re_bRenderingShadows && re_iIndex==0) { // OpenGL allows us to check z-buffer from previous frame - cool deal! // Direct3D is, of course, totally different story. :( - if( _pGfx->gl_eCurrentAPI==GAT_OGL || d3d_bAlternateDepthReads) { + if (_pGfx->GetCurrentAPI() == GAT_OGL || d3d_bAlternateDepthReads) { ChangeStatsMode(CStatForm::STI_FLARESRENDERING); extern void CheckDelayedDepthPoints( const CDrawPort *pdp, INDEX iMirrorLevel=0); CheckDelayedDepthPoints(re_pdpDrawPort); @@ -889,7 +887,7 @@ void CRenderer::Render(void) // for D3D (or mirror) we have to check depth points now, because we need back (not depth!) buffer for it, // and D3D can't guarantee that it won't be discarded upon swapbuffers (especially if multisampling is on!) :( #ifdef SE1_D3D - if( !re_bRenderingShadows && ((_pGfx->gl_eCurrentAPI==GAT_D3D && !d3d_bAlternateDepthReads) || re_iIndex>0)) { + if (!re_bRenderingShadows && ((_pGfx->GetCurrentAPI() == GAT_D3D && !d3d_bAlternateDepthReads) || re_iIndex > 0)) { extern void CheckDelayedDepthPoints( const CDrawPort *pdp, INDEX iMirrorLevel=0); CheckDelayedDepthPoints( re_pdpDrawPort, re_iIndex); } diff --git a/Sources/SeriousSam/GLSettings.cpp b/Sources/SeriousSam/GLSettings.cpp index 75eb15a9b..c9d5338a2 100644 --- a/Sources/SeriousSam/GLSettings.cpp +++ b/Sources/SeriousSam/GLSettings.cpp @@ -121,7 +121,7 @@ CSettingsEntry *GetGLSettings( const CTString &strRenderer) extern void ApplyGLSettings(BOOL bForce) { CPrintF( TRANS("\nAutomatic 3D-board preferences adjustment...\n")); - CDisplayAdapter &da = _pGfx->gl_gaAPI[_pGfx->gl_eCurrentAPI].ga_adaAdapter[_pGfx->gl_iCurrentAdapter]; + CDisplayAdapter &da = _pGfx->gl_gaAPI[_pGfx->GetCurrentAPI()].ga_adaAdapter[_pGfx->gl_iCurrentAdapter]; CPrintF( TRANS("Detected: %s - %s - %s\n"), da.da_strVendor, da.da_strRenderer, da.da_strVersion); // get new settings diff --git a/Sources/SeriousSam/SeriousSam.cpp b/Sources/SeriousSam/SeriousSam.cpp index cbefcba23..59c73c37c 100644 --- a/Sources/SeriousSam/SeriousSam.cpp +++ b/Sources/SeriousSam/SeriousSam.cpp @@ -640,10 +640,11 @@ void PrintDisplayModeInfo(void) strRes.PrintF( "%dx%dx%s", slDPWidth, slDPHeight, _pGfx->gl_dmCurrentDisplayMode.DepthString()); if( dm.IsDualHead()) strRes += TRANS(" DualMonitor"); if( dm.IsWideScreen()) strRes += TRANS(" WideScreen"); - if( _pGfx->gl_eCurrentAPI==GAT_OGL) strRes += " (OpenGL)"; -#ifdef SE1_D3D - else if( _pGfx->gl_eCurrentAPI==GAT_D3D) strRes += " (Direct3D)"; -#endif // SE1_D3D + if (_pGfx->GetCurrentAPI() == GAT_OGL) { + strRes += " (OpenGL)"; + } else if (_pGfx->GetCurrentAPI() == GAT_D3D) { + strRes += " (Direct3D)"; + } CTString strDescr; strDescr.PrintF("\n%s (%s)\n", _strPreferencesDescription, RenderingPreferencesDescription(sam_iVideoSetup));