diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 3eb5823ca..f118cca84 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -297,7 +297,7 @@ public: virtual bool clearZBuffer(float zval=1) = 0; /// Clear the current target surface stencil buffer. The function ignores the viewport settings but uses the scissor. - virtual bool clearStencilBuffer(float stencilval=0) = 0; + virtual bool clearStencilBuffer(sint stencilval=0) = 0; /// Set the color mask filter through where the operation done will pass virtual void setColorMask(bool bRed, bool bGreen, bool bBlue, bool bAlpha) = 0; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index 864406205..cb92c5fb3 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -1952,7 +1952,7 @@ bool CDriverD3D::clearZBuffer(float zval) // *************************************************************************** -bool CDriverD3D::clearStencilBuffer(float stencilval) +bool CDriverD3D::clearStencilBuffer(sint stencilval) { H_AUTO_D3D(CDriverD3D_clearStencilBuffer); nlassert (_DeviceInterface); diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h index 1055e105c..f5fca15da 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -916,7 +916,7 @@ public: // Buffer virtual bool clear2D(CRGBA rgba); virtual bool clearZBuffer(float zval=1); - virtual bool clearStencilBuffer(float stencilval=0); + virtual bool clearStencilBuffer(sint stencilval=0); virtual void setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha); virtual bool swapBuffers(); virtual void getBuffer (CBitmap &bitmap); // Only 32 bits back buffer supported diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 474750d2c..5740b1d79 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -833,10 +833,10 @@ bool CDriverGL::clearZBuffer(float zval) } // -------------------------------------------------- -bool CDriverGL::clearStencilBuffer(float stencilval) +bool CDriverGL::clearStencilBuffer(sint stencilval) { H_AUTO_OGL(CDriverGL_clearStencilBuffer) - glClearStencil((int)stencilval); + glClearStencil(stencilval); glClear(GL_STENCIL_BUFFER_BIT); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 57f73b0b6..a1609c1a0 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -354,7 +354,7 @@ public: virtual bool clear2D(CRGBA rgba); virtual bool clearZBuffer(float zval=1); - virtual bool clearStencilBuffer(float stencilval=0); + virtual bool clearStencilBuffer(sint stencilval=0); virtual void setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha); virtual void setDepthRange(float znear, float zfar); virtual void getDepthRange(float &znear, float &zfar) const; diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl.cpp index 0fae4cf17..09ef3f687 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl.cpp @@ -534,9 +534,10 @@ bool CDriverGL3::isTextureExist(const ITexture&tex) bool CDriverGL3::clear2D(CRGBA rgba) { H_AUTO_OGL(CDriverGL3_clear2D) - glClearColor((float)rgba.R/255.0f,(float)rgba.G/255.0f,(float)rgba.B/255.0f,(float)rgba.A/255.0f); - glClear(GL_COLOR_BUFFER_BIT); + NLMISC::CRGBAF rgbaf(rgba); + GLfloat fv[] = { rgbaf.R, rgbaf.G, rgbaf.B, rgbaf.A }; + nglClearBufferfv(GL_COLOR, 0, fv); return true; } @@ -546,21 +547,18 @@ bool CDriverGL3::clearZBuffer(float zval) { H_AUTO_OGL(CDriverGL3_clearZBuffer); - glClearDepth(zval); - _DriverGLStates.enableZWrite(true); - glClear(GL_DEPTH_BUFFER_BIT); + nglClearBufferfv(GL_DEPTH, 0, &zval); return true; } // -------------------------------------------------- -bool CDriverGL3::clearStencilBuffer(float stencilval) +bool CDriverGL3::clearStencilBuffer(sint stencilval) { H_AUTO_OGL(CDriverGL3_clearStencilBuffer) - glClearStencil((int)stencilval); - glClear(GL_STENCIL_BUFFER_BIT); + nglClearBufferiv(GL_STENCIL, 0, &stencilval); return true; } diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl.h b/code/nel/src/3d/driver/opengl3/driver_opengl.h index 99cb352e8..f1a0f96e9 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl3/driver_opengl.h @@ -333,7 +333,7 @@ public: virtual bool clear2D(CRGBA rgba); virtual bool clearZBuffer(float zval=1); - virtual bool clearStencilBuffer(float stencilval=0); + virtual bool clearStencilBuffer(sint stencilval=0); virtual void setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha); virtual void setDepthRange(float znear, float zfar); virtual void getDepthRange(float &znear, float &zfar) const; diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_extension.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_extension.cpp index be5b36a00..5e6f26e22 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_extension.cpp @@ -66,6 +66,11 @@ void (*nglGetProcAddress(const char *procName))() // Core 3.30 PFNGLGETSTRINGIPROC nglGetStringi; +PFNGLCLEARBUFFERIVPROC nglClearBufferiv; +PFNGLCLEARBUFFERUIVPROC nglClearBufferuiv; +PFNGLCLEARBUFFERFVPROC nglClearBufferfv; +PFNGLCLEARBUFFERFIPROC nglClearBufferfi; + PFNGLATTACHSHADERPROC nglAttachShader; PFNGLCOMPILESHADERPROC nglCompileShader; PFNGLCREATEPROGRAMPROC nglCreateProgram; @@ -356,6 +361,11 @@ static bool setupEXTTextureFilterAnisotropic(std::vector &glext) static bool setupGLCore(std::vector &glext) { + CHECK_ADDRESS(PFNGLCLEARBUFFERIVPROC, glClearBufferiv); + CHECK_ADDRESS(PFNGLCLEARBUFFERUIVPROC, glClearBufferuiv); + CHECK_ADDRESS(PFNGLCLEARBUFFERFVPROC, glClearBufferfv); + CHECK_ADDRESS(PFNGLCLEARBUFFERFIPROC, glClearBufferfi); + CHECK_ADDRESS(PFNGLATTACHSHADERPROC, glAttachShader); CHECK_ADDRESS(PFNGLCOMPILESHADERPROC, glCompileShader); CHECK_ADDRESS(PFNGLCREATEPROGRAMPROC, glCreateProgram); diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_extension.h b/code/nel/src/3d/driver/opengl3/driver_opengl_extension.h index 615398b17..64b634cb8 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_extension.h +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_extension.h @@ -153,6 +153,11 @@ bool registerGlExtensions(CGlExtensions &ext); // Core 3.30 extern PFNGLGETSTRINGIPROC nglGetStringi; +extern PFNGLCLEARBUFFERIVPROC nglClearBufferiv; +extern PFNGLCLEARBUFFERUIVPROC nglClearBufferuiv; +extern PFNGLCLEARBUFFERFVPROC nglClearBufferfv; +extern PFNGLCLEARBUFFERFIPROC nglClearBufferfi; + extern PFNGLATTACHSHADERPROC nglAttachShader; extern PFNGLCOMPILESHADERPROC nglCompileShader; extern PFNGLCREATEPROGRAMPROC nglCreateProgram;