diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 932bbff11..26d6436e2 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -264,7 +264,6 @@ static Bool WndProc(Display *d, XEvent *e, char *arg) */ #endif // NL_OS_UNIX - GLenum CDriverGL::NLCubeFaceToGLCubeFace[6] = { GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, @@ -279,9 +278,9 @@ GLenum CDriverGL::NLCubeFaceToGLCubeFace[6] = CDriverGL::CDriverGL() { H_AUTO_OGL(CDriverGL_CDriverGL) - _OffScreen = false; #ifdef NL_OS_WINDOWS + _PBuffer = NULL; _hWnd = NULL; _hRC = NULL; @@ -290,10 +289,13 @@ CDriverGL::CDriverGL() _Interval = 1; #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) + NL3D::MAC::ctor(); #elif defined (NL_OS_UNIX) cursor = None; + _win = 0; + _dpy = 0; # ifdef XF86VIDMODE // zero the old screen mode @@ -302,7 +304,8 @@ CDriverGL::CDriverGL() # endif //XF86VIDMODE #endif // NL_OS_UNIX - _FullScreen= false; + _OffScreen = false; + _FullScreen = false; _CurrentMaterial=NULL; _Initialized = false; @@ -347,7 +350,6 @@ CDriverGL::CDriverGL() _NVTextureShaderEnabled = false; - // Compute the Flag which say if one texture has been changed in CMaterial. _MaterialAllTextureTouchedFlag= 0; for(i=0; i < IDRV_MAT_MAXTEXTURES; i++) @@ -356,7 +358,6 @@ CDriverGL::CDriverGL() _CurrentTexAddrMode[i] = GL_NONE; } - _UserTexMatEnabled = 0; // Ligtmap preca. @@ -415,7 +416,6 @@ CDriverGL::CDriverGL() _TextureTargetUpload = false; } - // *************************************************************************** CDriverGL::~CDriverGL() { @@ -502,21 +502,18 @@ bool CDriverGL::stretchRect(ITexture * /* srcText */, NLMISC::CRect &/* srcRect } // *************************************************************************** - bool CDriverGL::supportBloomEffect() const { return (isVertexProgramSupported() && supportFrameBufferObject() && supportPackedDepthStencil() && supportTextureRectangle()); } // *************************************************************************** - bool CDriverGL::supportNonPowerOfTwoTextures() const { return _Extensions.ARBTextureNonPowerOfTwo; } // *************************************************************************** - bool CDriverGL::isTextureRectangle(ITexture * tex) const { return (supportTextureRectangle() && tex->isBloomTexture() && tex->mipMapOff() @@ -524,7 +521,6 @@ bool CDriverGL::isTextureRectangle(ITexture * tex) const } // *************************************************************************** - bool CDriverGL::activeFrameBufferObject(ITexture * tex) { if(supportFrameBufferObject()/* && supportPackedDepthStencil()*/) @@ -545,7 +541,6 @@ bool CDriverGL::activeFrameBufferObject(ITexture * tex) } // -------------------------------------------------- - void CDriverGL::disableHardwareVertexProgram() { H_AUTO_OGL(CDriverGL_disableHardwareVertexProgram) @@ -565,7 +560,6 @@ void CDriverGL::disableHardwareTextureShader() } // -------------------------------------------------- - bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool resizeable) throw(EBadDisplay) { H_AUTO_OGL(CDriverGL_setDisplay) @@ -677,8 +671,6 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re return false; } - - // Make the context current if (!wglMakeCurrent(tempHDC,tempGLRC)) { @@ -1190,7 +1182,6 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re nlwarning("Missing Important GL extension: GL_EXT_texture_env_combine => All envcombine are setup to GL_MODULATE!!!"); } - // Get num of light for this driver int numLight; glGetIntegerv (GL_MAX_LIGHTS, &numLight); @@ -1206,7 +1197,6 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re // init _DriverGLStates _DriverGLStates.init(_Extensions.ARBTextureCubeMap, (_Extensions.NVTextureRectangle || _Extensions.EXTTextureRectangle || _Extensions.ARBTextureRectangle), _MaxDriverLight); - // Init OpenGL/Driver defaults. //============================= glViewport(0,0,width,height); @@ -1248,7 +1238,6 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re _VertexProgramEnabled= false; _LastSetupGLArrayVertexProgram= false; - // Init VertexArrayRange according to supported extenstion. _SupportVBHard= false; _SlowUnlockVBHard= false; @@ -1297,7 +1286,8 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re _CurrentVertexBufferHard= NULL; _NVCurrentVARPtr= NULL; _NVCurrentVARSize= 0; - if(_SupportVBHard) + + if (_SupportVBHard) { // try to allocate 16Mo by default of AGP Ram. initVertexBufferHard(NL3D_DRV_VERTEXARRAY_AGP_INIT_SIZE, 0); @@ -1329,8 +1319,6 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re //=========================================================== initFragmentShaders(); - - // Activate the default texture environnments for all stages. //=========================================================== for(uint stage=0;stage0 && rect.Height>0; } - - void CDriverGL::getBufferPart (CBitmap &bitmap, NLMISC::CRect &rect) { H_AUTO_OGL(CDriverGL_getBufferPart ) @@ -2763,9 +2722,6 @@ bool CDriverGL::fillBuffer (CBitmap &bitmap) } // *************************************************************************** - - - void CDriverGL::copyFrameBufferToTexture(ITexture *tex, uint32 level, uint32 offsetx, @@ -2811,7 +2767,7 @@ void CDriverGL::copyFrameBufferToTexture(ITexture *tex, // gltext->activeFrameBufferObject(tex); } - +// *************************************************************************** void CDriverGL::setPolygonMode (TPolygonMode mode) { H_AUTO_OGL(CDriverGL_setPolygonMode ) @@ -2832,21 +2788,23 @@ void CDriverGL::setPolygonMode (TPolygonMode mode) } } - -bool CDriverGL::fogEnabled() +// *************************************************************************** +bool CDriverGL::fogEnabled() { H_AUTO_OGL(CDriverGL_fogEnabled) return _FogEnabled; } -void CDriverGL::enableFog(bool enable) +// *************************************************************************** +void CDriverGL::enableFog(bool enable) { H_AUTO_OGL(CDriverGL_enableFog) _DriverGLStates.enableFog(enable); _FogEnabled= enable; } -void CDriverGL::setupFog(float start, float end, CRGBA color) +// *************************************************************************** +void CDriverGL::setupFog(float start, float end, CRGBA color) { H_AUTO_OGL(CDriverGL_setupFog) glFogf(GL_FOG_MODE, GL_LINEAR); @@ -2881,23 +2839,22 @@ void CDriverGL::setupFog(float start, float end, CRGBA color) _FogEnd = end; } - // *************************************************************************** -float CDriverGL::getFogStart() const +float CDriverGL::getFogStart() const { H_AUTO_OGL(CDriverGL_getFogStart) return _FogStart; } // *************************************************************************** -float CDriverGL::getFogEnd() const +float CDriverGL::getFogEnd() const { H_AUTO_OGL(CDriverGL_getFogEnd) return _FogEnd; } // *************************************************************************** -CRGBA CDriverGL::getFogColor() const +CRGBA CDriverGL::getFogColor() const { H_AUTO_OGL(CDriverGL_getFogColor) CRGBA ret; @@ -3081,7 +3038,7 @@ bool CDriverGL::supportPerPixelLighting(bool specular) const } // *************************************************************************** -void CDriverGL::setPerPixelLightingLight(CRGBA diffuse, CRGBA specular, float shininess) +void CDriverGL::setPerPixelLightingLight(CRGBA diffuse, CRGBA specular, float shininess) { H_AUTO_OGL(CDriverGL_setPerPixelLightingLight) @@ -3091,7 +3048,7 @@ void CDriverGL::setPerPixelLightingLight(CRGBA diffuse, CRGBA specular, float sh } // *************************************************************************** -NLMISC::IMouseDevice *CDriverGL::enableLowLevelMouse(bool enable, bool exclusive) +NLMISC::IMouseDevice* CDriverGL::enableLowLevelMouse(bool enable, bool exclusive) { H_AUTO_OGL(CDriverGL_enableLowLevelMouse) @@ -3126,7 +3083,7 @@ NLMISC::IMouseDevice *CDriverGL::enableLowLevelMouse(bool enable, bool exclusive } // *************************************************************************** -NLMISC::IKeyboardDevice *CDriverGL::enableLowLevelKeyboard(bool enable) +NLMISC::IKeyboardDevice* CDriverGL::enableLowLevelKeyboard(bool enable) { H_AUTO_OGL(CDriverGL_enableLowLevelKeyboard) #ifdef NL_OS_WINDOWS @@ -3160,7 +3117,7 @@ NLMISC::IKeyboardDevice *CDriverGL::enableLowLevelKeyboard(bool enable) } // *************************************************************************** -NLMISC::IInputDeviceManager *CDriverGL::getLowLevelInputDeviceManager() +NLMISC::IInputDeviceManager* CDriverGL::getLowLevelInputDeviceManager() { H_AUTO_OGL(CDriverGL_getLowLevelInputDeviceManager) #ifdef NL_OS_WINDOWS @@ -3216,14 +3173,14 @@ uint CDriverGL::getDoubleClickDelay(bool hardwareMouse) } // *************************************************************************** -bool CDriverGL::supportBlendConstantColor() const +bool CDriverGL::supportBlendConstantColor() const { H_AUTO_OGL(CDriverGL_supportBlendConstantColor) return _Extensions.EXTBlendColor; } // *************************************************************************** -void CDriverGL::setBlendConstantColor(NLMISC::CRGBA col) +void CDriverGL::setBlendConstantColor(NLMISC::CRGBA col) { H_AUTO_OGL(CDriverGL_setBlendConstantColor) @@ -3238,7 +3195,7 @@ void CDriverGL::setBlendConstantColor(NLMISC::CRGBA col) } // *************************************************************************** -NLMISC::CRGBA CDriverGL::getBlendConstantColor() const +NLMISC::CRGBA CDriverGL::getBlendConstantColor() const { H_AUTO_OGL(CDriverGL_CDriverGL) @@ -3252,7 +3209,6 @@ uint CDriverGL::getNbTextureStages() const return inlGetNumTextStages(); } - // *************************************************************************** void CDriverGL::refreshProjMatrixFromGL() { @@ -3266,7 +3222,7 @@ void CDriverGL::refreshProjMatrixFromGL() } // *************************************************************************** -bool CDriverGL::setMonitorColorProperties (const CMonitorColorProperties &properties) +bool CDriverGL::setMonitorColorProperties (const CMonitorColorProperties &properties) { H_AUTO_OGL(CDriverGL_setMonitorColorProperties ) @@ -3419,9 +3375,6 @@ void CDriverGL::initEMBM() } } - - - // *************************************************************************** /** Water fragment program with extension ARB_fragment_program */ @@ -3483,8 +3436,6 @@ MAD_SAT tmpFog, fogValue.x, fogFactor.x, fogFactor.y; \n\ LRP oCol, tmpFog.x, envMap, fogColor; \n\ END "; - - // ************************************************************************************** /** Water fragment program with extension ARB_fragment_program and a diffuse map applied */ @@ -3556,7 +3507,6 @@ MUL diffuse, diffuse, envMap; \n\ LRP oCol, tmpFog.x, diffuse, fogColor; \n\ END "; - // *************************************************************************** /** Load a ARB_fragment_program_code, and ensure it is loaded natively */ @@ -3595,7 +3545,6 @@ uint loadARBFragmentProgramStringNative(const char *prog, bool forceNativeProgra return 0; } - // *************************************************************************** /** R200 Fragment Shader : * Send fragment shader to fetch a perturbed envmap from the addition of 2 bumpmap @@ -3627,6 +3576,7 @@ void CDriverGL::forceNativeFragmentPrograms(bool nativeOnly) _ForceNativeFragmentPrograms = nativeOnly; } +// *************************************************************************** void CDriverGL::initFragmentShaders() { H_AUTO_OGL(CDriverGL_initFragmentShaders) @@ -3781,7 +3731,6 @@ void CDriverGL::deleteFragmentShaders() } } - // *************************************************************************** void CDriverGL::finish() { @@ -4095,7 +4044,6 @@ void CDriverGL::retrieveATIDriverVersion() #endif } - // *************************************************************************** bool CDriverGL::supportMADOperator() const { @@ -4104,7 +4052,6 @@ bool CDriverGL::supportMADOperator() const return _Extensions.NVTextureEnvCombine4 || _Extensions.ATITextureEnvCombine3; } - // *************************************************************************** uint CDriverGL::getNumAdapter() const { @@ -4114,7 +4061,6 @@ uint CDriverGL::getNumAdapter() const } // *************************************************************************** - bool CDriverGL::getAdapter(uint adapter, CAdapter &desc) const { H_AUTO_OGL(CDriverGL_getAdapter) @@ -4137,7 +4083,6 @@ bool CDriverGL::getAdapter(uint adapter, CAdapter &desc) const } // *************************************************************************** - bool CDriverGL::setAdapter(uint adapter) { H_AUTO_OGL(CDriverGL_setAdapter) @@ -4146,7 +4091,6 @@ bool CDriverGL::setAdapter(uint adapter) } // *************************************************************************** - CVertexBuffer::TVertexColorType CDriverGL::getVertexColorFormat() const { H_AUTO_OGL(CDriverGL_CDriverGL) @@ -4155,7 +4099,6 @@ CVertexBuffer::TVertexColorType CDriverGL::getVertexColorFormat() const } // *************************************************************************** - bool CDriverGL::activeShader(CShader * /* shd */) { H_AUTO_OGL(CDriverGL_activeShader) @@ -4164,21 +4107,18 @@ bool CDriverGL::activeShader(CShader * /* shd */) } // *************************************************************************** - void CDriverGL::startBench (bool wantStandardDeviation, bool quick, bool reset) { CHTimer::startBench (wantStandardDeviation, quick, reset); } // *************************************************************************** - void CDriverGL::endBench () { CHTimer::endBench (); } // *************************************************************************** - void CDriverGL::displayBench (class NLMISC::CLog *log) { // diplay @@ -4360,7 +4300,6 @@ uint COcclusionQueryGL::getVisibleCount() return VisibleCount; } - // *************************************************************************** void CDriverGL::setDepthRange(float znear, float zfar) { @@ -4466,12 +4405,10 @@ void CDriverGL::stencilOp(TStencilOp fail, TStencilOp zfail, TStencilOp zpass) default: nlstop; } - _DriverGLStates.stencilOp(glFail, glZFail, glZPass); } // *************************************************************************** - void CDriverGL::stencilMask(uint mask) { H_AUTO_OGL(CDriverGL_CDriverGL) @@ -4498,6 +4435,7 @@ void CDriverGL::endDialogMode() } // NL3D +// *************************************************************************** void displayGLError(GLenum error) { switch(error)