From 30bb2c72d1f735c6d414110e9f1452a114e559d3 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 29 May 2010 18:12:27 +0200 Subject: [PATCH] Fixed: #946 Add a check for GL_ARB_texture_rectangle --- .../src/3d/driver/opengl/driver_opengl.cpp | 67 ++---------------- .../driver/opengl/driver_opengl_extension.cpp | 11 +++ .../driver/opengl/driver_opengl_extension.h | 2 + .../driver/opengl/driver_opengl_material.cpp | 69 ------------------- 4 files changed, 18 insertions(+), 131 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 1f7679823..70f009483 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -315,8 +315,6 @@ CDriverGL::CDriverGL() for(i=0;iupdateLostBuffers(); } - #ifdef NL_OS_WINDOWS SwapBuffers(_hDC); #else // NL_OS_WINDOWS glXSwapBuffers(dpy, win); - - #endif // NL_OS_WINDOWS - - // Activate the default texture environnments for all stages. //=========================================================== // This is not a requirement, but it ensure a more stable state each frame. @@ -2024,7 +1995,6 @@ bool CDriverGL::swapBuffers() forceActivateTexEnvColor(stage, env); } - // Activate the default material. //=========================================================== // Same reasoning as textures :) @@ -2032,8 +2002,6 @@ bool CDriverGL::swapBuffers() if (_NVTextureShaderEnabled) { glDisable(GL_TEXTURE_SHADER_NV); - - _NVTextureShaderEnabled = false; } _CurrentMaterial= NULL; @@ -2086,8 +2054,6 @@ bool CDriverGL::release() // Reset VertexArrayRange. resetVertexArrayRange(); - - // delete containers delete _AGPVertexArrayRange; delete _VRAMVertexArrayRange; @@ -2674,8 +2640,6 @@ bool CDriverGL::fillBuffer (CBitmap &bitmap) glPixelStorei(GL_UNPACK_ALIGNMENT,1); glDrawPixels (rect.Width, rect.Height, GL_RGBA, GL_UNSIGNED_BYTE, &(bitmap.getPixels()[0]) ); - - return true; } @@ -2747,8 +2711,6 @@ void CDriverGL::setPolygonMode (TPolygonMode mode) glPolygonMode (GL_FRONT_AND_BACK, GL_POINT); break; } - - } @@ -2798,8 +2760,6 @@ void CDriverGL::setupFog(float start, float end, CRGBA color) } _FogStart = start; _FogEnd = end; - - } @@ -2950,8 +2910,6 @@ void CDriverGL::setMatrix2DForTextureOffsetAddrMode(const uint stage, const floa nlassert(stage < inlGetNumTextStages() ); _DriverGLStates.activeTextureARB(stage); glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, mat); - - } @@ -2972,8 +2930,6 @@ void CDriverGL::enableNVTextureShader(bool enabled) glDisable(GL_TEXTURE_SHADER_NV); } _NVTextureShaderEnabled = enabled; - - } } @@ -3127,6 +3083,7 @@ bool CDriverGL::supportBlendConstantColor() const H_AUTO_OGL(CDriverGL_supportBlendConstantColor) return _Extensions.EXTBlendColor; } + // *************************************************************************** void CDriverGL::setBlendConstantColor(NLMISC::CRGBA col) { @@ -3140,9 +3097,8 @@ void CDriverGL::setBlendConstantColor(NLMISC::CRGBA col) return; static const float OO255= 1.0f/255; nglBlendColorEXT(col.R*OO255, col.G*OO255, col.B*OO255, col.A*OO255); - - } + // *************************************************************************** NLMISC::CRGBA CDriverGL::getBlendConstantColor() const { @@ -3169,11 +3125,8 @@ void CDriverGL::refreshProjMatrixFromGL() glGetFloatv(GL_PROJECTION_MATRIX, mat); _GLProjMat.set(mat); _ProjMatDirty = false; - - } - // *************************************************************************** bool CDriverGL::setMonitorColorProperties (const CMonitorColorProperties &properties) { @@ -3273,7 +3226,6 @@ void CDriverGL::initEMBM() { H_AUTO_OGL(CDriverGL_initEMBM) - if (supportEMBM()) { std::fill(_StageSupportEMBM, _StageSupportEMBM + IDRV_MAT_MAXTEXTURES, false); @@ -3741,7 +3693,6 @@ void CDriverGL::enablePolygonSmoothing(bool smooth) else glDisable(GL_POLYGON_SMOOTH); - _PolygonSmooth= smooth; } @@ -3756,7 +3707,6 @@ bool CDriverGL::isPolygonSmoothingEnabled() const // *************************************************************************** void CDriverGL::startProfileVBHardLock() { - if(_VBHardProfiling) return; @@ -3771,7 +3721,6 @@ void CDriverGL::startProfileVBHardLock() // *************************************************************************** void CDriverGL::endProfileVBHardLock(vector &result) { - if(!_VBHardProfiling) return; @@ -3810,7 +3759,6 @@ void CDriverGL::endProfileVBHardLock(vector &result) // *************************************************************************** void CDriverGL::appendVBHardLockProfile(NLMISC::TTicks time, CVertexBuffer *vb) { - // must allocate a new place? if(_CurVBHardLockCount>=_VBHardProfiles.size()) { @@ -3854,7 +3802,6 @@ void CDriverGL::profileIBAllocation(std::vector &/* result */) // *************************************************************************** void CDriverGL::profileVBHardAllocation(std::vector &result) { - result.clear(); result.reserve(1000); result.push_back(toString("Memory Allocated: %4d Ko in AGP / %4d Ko in VRAM", @@ -4074,7 +4021,6 @@ bool CDriverGL::activeShader(CShader * /* shd */) void CDriverGL::startBench (bool wantStandardDeviation, bool quick, bool reset) { - CHTimer::startBench (wantStandardDeviation, quick, reset); } @@ -4082,7 +4028,6 @@ void CDriverGL::startBench (bool wantStandardDeviation, bool quick, bool reset) void CDriverGL::endBench () { - CHTimer::endBench (); } @@ -4090,7 +4035,6 @@ void CDriverGL::endBench () void CDriverGL::displayBench (class NLMISC::CLog *log) { - // diplay CHTimer::displayHierarchicalByExecutionPathSorted(log, CHTimer::TotalTime, true, 48, 2); CHTimer::displayHierarchical(log, true, 48, 2); @@ -4113,7 +4057,7 @@ void CDriverGL::checkTextureOn() const // tmp for debug CDriverGLStates &dgs = const_cast(_DriverGLStates); uint currTexStage = dgs.getActiveTextureARB(); - for(uint k = 0; k < getNbTextureStages(); ++k) + for(uint k = 0; k < this->getNbTextureStages(); ++k) { dgs.activeTextureARB(k); GLboolean flag2D; @@ -4158,8 +4102,7 @@ bool CDriverGL::supportOcclusionQuery() const bool CDriverGL::supportTextureRectangle() const { H_AUTO_OGL(CDriverGL_supportTextureRectangle) - return (_Extensions.NVTextureRectangle || - _Extensions.EXTTextureRectangle); + return (_Extensions.NVTextureRectangle || _Extensions.EXTTextureRectangle || _Extensions.ARBTextureRectangle); } // *************************************************************************** diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp index fb6e33baa..006ac8e88 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp @@ -1151,6 +1151,14 @@ static bool setupEXTTextureRectangle(const char *glext) return true; } +// *************************************************************************** +static bool setupARBTextureRectangle(const char *glext) +{ + H_AUTO_OGL(setupARBTextureRectangle); + CHECK_EXT("GL_ARB_texture_rectangle"); + return true; +} + // *************************************************************************** static bool setupFrameBufferObject(const char *glext) { @@ -1322,6 +1330,9 @@ void registerGlExtensions(CGlExtensions &ext) // Check GL_EXT_texture_rectangle ext.EXTTextureRectangle = setupEXTTextureRectangle(glext); + // Check GL_ARB_texture_rectangle + ext.ARBTextureRectangle = setupARBTextureRectangle(glext); + // Check GL_EXT_framebuffer_object ext.FrameBufferObject = setupFrameBufferObject(glext); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.h b/code/nel/src/3d/driver/opengl/driver_opengl_extension.h index 676f43f41..c07fb34d2 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.h @@ -71,6 +71,7 @@ struct CGlExtensions bool NVOcclusionQuery; bool NVTextureRectangle; bool EXTTextureRectangle; + bool ARBTextureRectangle; bool FrameBufferObject; bool PackedDepthStencil; // true if NVVertexProgram and if we know that VP is emulated @@ -183,6 +184,7 @@ public: result += ATIEnvMapBumpMap ? "ATIEnvMapBumpMap " : ""; result += NVTextureRectangle ? "NVTextureRectangle " : ""; result += EXTTextureRectangle ? "EXTTextureRectangle " : ""; + result += ARBTextureRectangle ? "ARBTextureRectangle " : ""; result += ARBTextureNonPowerOfTwo ? "ARBTextureNonPowerOfTwo " : ""; result += "texture stages(*) = "; result += NLMISC::toString(NbTextureStages); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_material.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_material.cpp index f00c487ef..b5bdc2bec 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_material.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_material.cpp @@ -97,7 +97,6 @@ static inline void convTexAddr(ITexture *tex, CMaterial::TTexAddressingMode mode GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV, GL_DOT_PRODUCT_DEPTH_REPLACE_NV }; - if (!tex || !tex->isTextureCube()) { glenum = glTex2dAddrModesNV[(uint) mode]; @@ -165,7 +164,6 @@ void CDriverGL::setupUserTextureMatrix(uint numStages, CMaterial& mat) { glMatrixMode(GL_TEXTURE); - // for each stage, setup the texture matrix if needed uint newMask = (mat.getFlags() & IDRV_MAT_USER_TEX_MAT_ALL) >> IDRV_MAT_USER_TEX_FIRST_BIT; uint shiftMask = 1; @@ -176,7 +174,6 @@ void CDriverGL::setupUserTextureMatrix(uint numStages, CMaterial& mat) _DriverGLStates.activeTextureARB(k); glLoadMatrixf(mat.getUserTexMat(k).get()); - _UserTexMatEnabled |= shiftMask; } else @@ -189,15 +186,12 @@ void CDriverGL::setupUserTextureMatrix(uint numStages, CMaterial& mat) _DriverGLStates.activeTextureARB(k); glLoadIdentity(); - _UserTexMatEnabled &= ~shiftMask; } } shiftMask <<= 1; } glMatrixMode(GL_MODELVIEW); - - } } @@ -208,7 +202,6 @@ void CDriverGL::disableUserTextureMatrix() { glMatrixMode(GL_TEXTURE); - uint k = 0; do { @@ -217,16 +210,12 @@ void CDriverGL::disableUserTextureMatrix() _DriverGLStates.activeTextureARB(k); glLoadIdentity(); - _UserTexMatEnabled &= ~ (1 << k); - } ++k; } while (_UserTexMatEnabled != 0); glMatrixMode(GL_MODELVIEW); - - } } @@ -259,7 +248,6 @@ void CDriverGL::setTextureShaders(const uint8 *addressingModes, const CSmartPtr< convTexAddr(textures[stage], (CMaterial::TTexAddressingMode) addressingModes[stage], glAddrMode); if (glAddrMode != _CurrentTexAddrMode[stage]) // addressing mode different from the one in the device? - { _DriverGLStates.activeTextureARB(stage); glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, glAddrMode); @@ -404,7 +392,6 @@ bool CDriverGL::setupMaterial(CMaterial& mat) if (mat.getTexture(stage)) }*/ - // Activate the textures. // Do not do it for Lightmap and per pixel lighting , because done in multipass in a very special fashion. // This avoid the useless multiple change of texture states per lightmapped object. @@ -490,16 +477,13 @@ bool CDriverGL::setupMaterial(CMaterial& mat) } else { - // Color unlit part. CRGBA col= mat.getColor(); glColor4ub(col.R, col.G, col.B, col.A); - _DriverGLStates.setVertexColorLighted(false); } - // Fog Part. //================= @@ -745,7 +729,6 @@ void CDriverGL::setupLightMapPass(uint pass) static uint32 packedColorGrey= CRGBA(128,128,128,128).getPacked(); static GLfloat glcolGrey[4]= {0.5f,0.5f,0.5f,1.f}; - // No lightmap or all blacks??, just setup "black texture" for stage 0. if(_NLightMaps==0) { @@ -760,7 +743,6 @@ void CDriverGL::setupLightMapPass(uint pass) // setup color to 0 => blackness. in emissive cause texture can still be lighted by dynamic light _DriverGLStates.setEmissive(packedColorBlack, glcolBlack); - // Setup gen tex off _DriverGLStates.activeTextureARB(0); _DriverGLStates.setTexGenMode(0, 0); @@ -900,8 +882,6 @@ void CDriverGL::setupLightMapPass(uint pass) // Arg3. glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_ONE_MINUS_SRC_COLOR); - - } else { @@ -920,8 +900,6 @@ void CDriverGL::setupLightMapPass(uint pass) // Arg2. glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT ); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); - - } } } @@ -965,8 +943,6 @@ void CDriverGL::setupLightMapPass(uint pass) { // Multiply x 2 glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2); - - } } } @@ -988,8 +964,6 @@ void CDriverGL::setupLightMapPass(uint pass) { static GLfloat blackFog[4]= {0,0,0,0}; glFogfv(GL_FOG_COLOR, blackFog); - - } // Blend is different if the material is blended or not @@ -1051,8 +1025,6 @@ void CDriverGL::setupLightMapPass(uint pass) // no need to reset for pass after 1, since same than prec pass (black)! else if(pass==1) _DriverGLStates.setDiffuse(packedColorBlack, glcolBlack); - - } // *************************************************************************** void CDriverGL::endLightMapMultiPass() @@ -1081,8 +1053,6 @@ void CDriverGL::endLightMapMultiPass() { _DriverGLStates.activeTextureARB(i); glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1); - - } } } @@ -1180,8 +1150,6 @@ void CDriverGL::setupSpecularEnd() glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); - - } // *************************************************************************** @@ -1286,8 +1254,6 @@ void CDriverGL::setupSpecularPass(uint pass) // Arg3. glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_ALPHA_NV, GL_ZERO ); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_ALPHA_NV, GL_SRC_ALPHA); - - } } else if (_Extensions.ATITextureEnvCombine3) @@ -1340,8 +1306,6 @@ void CDriverGL::setupSpecularPass(uint pass) glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_ZERO ); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA); } - - } else { // We have to do it in 2 passes @@ -1390,8 +1354,6 @@ void CDriverGL::setupSpecularPass(uint pass) activateTexEnvMode(1, env); } } - - } // *************************************************************************** void CDriverGL::endSpecularMultiPass() @@ -1470,14 +1432,12 @@ CTextureCube *CDriverGL::getSpecularCubeMap(uint exp) _SpecularTextureCubes.resize(MaxExponent); } - NLMISC::clamp(exp, 1u, (MaxExponent - 1)); uint cubeMapIndex = expToCubeMap[exp]; nlassert(cubeMapIndex < numCubeMap); - if (_SpecularTextureCubes[cubeMapIndex] != NULL) // has the cube map already been cted ? { return _SpecularTextureCubes[cubeMapIndex]; @@ -1607,8 +1567,6 @@ void CDriverGL::setupPPLPass(uint pass) // Arg3 = White (= ~ Black) glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_ONE_MINUS_SRC_COLOR); - - } else // use ATI extension { @@ -1624,8 +1582,6 @@ void CDriverGL::setupPPLPass(uint pass) // Arg2 = Primary color (other light diffuse and glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); - - } } activateTexEnvColor(0, _PPLightDiffuseColor); @@ -1678,8 +1634,6 @@ void CDriverGL::setupPPLPass(uint pass) // Arg3 = 0 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_ALPHA_NV, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_ALPHA_NV, GL_SRC_COLOR); - - } else // ATI EnvCombine3 { @@ -1707,8 +1661,6 @@ void CDriverGL::setupPPLPass(uint pass) // Arg1 = 0 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_COLOR); - - } } activateTexEnvColor(2, _PPLightSpecularColor); @@ -1785,8 +1737,6 @@ void CDriverGL::setupPPLNoSpecPass(uint pass) // Arg3 = White (= ~ Black) glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_ONE_MINUS_SRC_COLOR); - - } else { @@ -1802,8 +1752,6 @@ void CDriverGL::setupPPLNoSpecPass(uint pass) // Arg1 = Primary color (other light diffuse and glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); - - } } activateTexEnvColor(0, _PPLightDiffuseColor); @@ -1860,7 +1808,6 @@ inline void CDriverGL::setupCausticsSecondTex(uint stage) // *************************************************************************** void CDriverGL::setupCausticsPass(const CMaterial &mat, uint pass) { - nlassert(mat.getShader() == CMaterial::Caustics); if (inlGetNumTextStages() == 1 || !_Extensions.ARBTextureCubeMap) @@ -1873,8 +1820,6 @@ void CDriverGL::setupCausticsPass(const CMaterial &mat, uint pass) nlassert(pass == 0); setupCausticsFirstTex(mat); - - } else if (inlGetNumTextStages() == 2) /// do in in 2 pass { @@ -1888,8 +1833,6 @@ void CDriverGL::setupCausticsPass(const CMaterial &mat, uint pass) /// setup additif blending _DriverGLStates.enableBlend(); _DriverGLStates.blendFunc(pShader->SrcBlend, pShader->DstBlend); - - } } } @@ -2002,8 +1945,6 @@ void CDriverGL::setupCloudPass (uint /* pass */) glEnable(GL_FRAGMENT_SHADER_ATI); float cst[4] = { 0.f, 0.f, 0.f, mat.getColor().A / 255.f }; nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst); - - /* _DriverGLStates.activeTextureARB(0); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); @@ -2188,7 +2129,6 @@ void CDriverGL::setupWaterPassARB(const CMaterial &mat) nglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ARBWaterShader[(_FogEnabled ? 1 : 0) | (mat.getTexture(3) != NULL ? 2 : 0)]); glEnable(GL_FRAGMENT_PROGRAM_ARB); - // setup the constant if (mat.getTexture(0) && mat.getTexture(0)->isBumpMap()) { @@ -2233,7 +2173,6 @@ void CDriverGL::setupWaterPassARB(const CMaterial &mat) } } } - } @@ -2291,14 +2230,10 @@ void CDriverGL::setupWaterPassNV20(const CMaterial &mat) float factor = tb->getNormalizationFactor(); float tsMatrix[4] = { 0.25f * factor, 0.f, 0.f, 0.25f * factor }; glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, tsMatrix); - - } else { glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, IdentityTexMat); - - } } tex = mat.getTexture(1); @@ -2314,14 +2249,10 @@ void CDriverGL::setupWaterPassNV20(const CMaterial &mat) float factor = tb->getNormalizationFactor(); float tsMatrix[4] = { factor, 0.f, 0.f, factor }; glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, tsMatrix); - - } else { glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, IdentityTexMat); - - } } tex = mat.getTexture(2);