GL3: Use glClearBuffer

--HG--
branch : opengl3
hg/feature/opengl3
kaetemi 11 years ago
parent 7e565518ec
commit 44102b2034

@ -297,7 +297,7 @@ public:
virtual bool clearZBuffer(float zval=1) = 0; virtual bool clearZBuffer(float zval=1) = 0;
/// Clear the current target surface stencil buffer. The function ignores the viewport settings but uses the scissor. /// 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 /// Set the color mask filter through where the operation done will pass
virtual void setColorMask(bool bRed, bool bGreen, bool bBlue, bool bAlpha) = 0; virtual void setColorMask(bool bRed, bool bGreen, bool bBlue, bool bAlpha) = 0;

@ -1952,7 +1952,7 @@ bool CDriverD3D::clearZBuffer(float zval)
// *************************************************************************** // ***************************************************************************
bool CDriverD3D::clearStencilBuffer(float stencilval) bool CDriverD3D::clearStencilBuffer(sint stencilval)
{ {
H_AUTO_D3D(CDriverD3D_clearStencilBuffer); H_AUTO_D3D(CDriverD3D_clearStencilBuffer);
nlassert (_DeviceInterface); nlassert (_DeviceInterface);

@ -916,7 +916,7 @@ public:
// Buffer // Buffer
virtual bool clear2D(CRGBA rgba); virtual bool clear2D(CRGBA rgba);
virtual bool clearZBuffer(float zval=1); 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 setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha);
virtual bool swapBuffers(); virtual bool swapBuffers();
virtual void getBuffer (CBitmap &bitmap); // Only 32 bits back buffer supported virtual void getBuffer (CBitmap &bitmap); // Only 32 bits back buffer supported

@ -833,10 +833,10 @@ bool CDriverGL::clearZBuffer(float zval)
} }
// -------------------------------------------------- // --------------------------------------------------
bool CDriverGL::clearStencilBuffer(float stencilval) bool CDriverGL::clearStencilBuffer(sint stencilval)
{ {
H_AUTO_OGL(CDriverGL_clearStencilBuffer) H_AUTO_OGL(CDriverGL_clearStencilBuffer)
glClearStencil((int)stencilval); glClearStencil(stencilval);
glClear(GL_STENCIL_BUFFER_BIT); glClear(GL_STENCIL_BUFFER_BIT);

@ -354,7 +354,7 @@ public:
virtual bool clear2D(CRGBA rgba); virtual bool clear2D(CRGBA rgba);
virtual bool clearZBuffer(float zval=1); 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 setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha);
virtual void setDepthRange(float znear, float zfar); virtual void setDepthRange(float znear, float zfar);
virtual void getDepthRange(float &znear, float &zfar) const; virtual void getDepthRange(float &znear, float &zfar) const;

@ -534,9 +534,10 @@ bool CDriverGL3::isTextureExist(const ITexture&tex)
bool CDriverGL3::clear2D(CRGBA rgba) bool CDriverGL3::clear2D(CRGBA rgba)
{ {
H_AUTO_OGL(CDriverGL3_clear2D) 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; return true;
} }
@ -546,21 +547,18 @@ bool CDriverGL3::clearZBuffer(float zval)
{ {
H_AUTO_OGL(CDriverGL3_clearZBuffer); H_AUTO_OGL(CDriverGL3_clearZBuffer);
glClearDepth(zval);
_DriverGLStates.enableZWrite(true); _DriverGLStates.enableZWrite(true);
glClear(GL_DEPTH_BUFFER_BIT); nglClearBufferfv(GL_DEPTH, 0, &zval);
return true; return true;
} }
// -------------------------------------------------- // --------------------------------------------------
bool CDriverGL3::clearStencilBuffer(float stencilval) bool CDriverGL3::clearStencilBuffer(sint stencilval)
{ {
H_AUTO_OGL(CDriverGL3_clearStencilBuffer) H_AUTO_OGL(CDriverGL3_clearStencilBuffer)
glClearStencil((int)stencilval);
glClear(GL_STENCIL_BUFFER_BIT); nglClearBufferiv(GL_STENCIL, 0, &stencilval);
return true; return true;
} }

@ -333,7 +333,7 @@ public:
virtual bool clear2D(CRGBA rgba); virtual bool clear2D(CRGBA rgba);
virtual bool clearZBuffer(float zval=1); 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 setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha);
virtual void setDepthRange(float znear, float zfar); virtual void setDepthRange(float znear, float zfar);
virtual void getDepthRange(float &znear, float &zfar) const; virtual void getDepthRange(float &znear, float &zfar) const;

@ -66,6 +66,11 @@ void (*nglGetProcAddress(const char *procName))()
// Core 3.30 // Core 3.30
PFNGLGETSTRINGIPROC nglGetStringi; PFNGLGETSTRINGIPROC nglGetStringi;
PFNGLCLEARBUFFERIVPROC nglClearBufferiv;
PFNGLCLEARBUFFERUIVPROC nglClearBufferuiv;
PFNGLCLEARBUFFERFVPROC nglClearBufferfv;
PFNGLCLEARBUFFERFIPROC nglClearBufferfi;
PFNGLATTACHSHADERPROC nglAttachShader; PFNGLATTACHSHADERPROC nglAttachShader;
PFNGLCOMPILESHADERPROC nglCompileShader; PFNGLCOMPILESHADERPROC nglCompileShader;
PFNGLCREATEPROGRAMPROC nglCreateProgram; PFNGLCREATEPROGRAMPROC nglCreateProgram;
@ -356,6 +361,11 @@ static bool setupEXTTextureFilterAnisotropic(std::vector<const char *> &glext)
static bool setupGLCore(std::vector<const char *> &glext) static bool setupGLCore(std::vector<const char *> &glext)
{ {
CHECK_ADDRESS(PFNGLCLEARBUFFERIVPROC, glClearBufferiv);
CHECK_ADDRESS(PFNGLCLEARBUFFERUIVPROC, glClearBufferuiv);
CHECK_ADDRESS(PFNGLCLEARBUFFERFVPROC, glClearBufferfv);
CHECK_ADDRESS(PFNGLCLEARBUFFERFIPROC, glClearBufferfi);
CHECK_ADDRESS(PFNGLATTACHSHADERPROC, glAttachShader); CHECK_ADDRESS(PFNGLATTACHSHADERPROC, glAttachShader);
CHECK_ADDRESS(PFNGLCOMPILESHADERPROC, glCompileShader); CHECK_ADDRESS(PFNGLCOMPILESHADERPROC, glCompileShader);
CHECK_ADDRESS(PFNGLCREATEPROGRAMPROC, glCreateProgram); CHECK_ADDRESS(PFNGLCREATEPROGRAMPROC, glCreateProgram);

@ -153,6 +153,11 @@ bool registerGlExtensions(CGlExtensions &ext);
// Core 3.30 // Core 3.30
extern PFNGLGETSTRINGIPROC nglGetStringi; extern PFNGLGETSTRINGIPROC nglGetStringi;
extern PFNGLCLEARBUFFERIVPROC nglClearBufferiv;
extern PFNGLCLEARBUFFERUIVPROC nglClearBufferuiv;
extern PFNGLCLEARBUFFERFVPROC nglClearBufferfv;
extern PFNGLCLEARBUFFERFIPROC nglClearBufferfi;
extern PFNGLATTACHSHADERPROC nglAttachShader; extern PFNGLATTACHSHADERPROC nglAttachShader;
extern PFNGLCOMPILESHADERPROC nglCompileShader; extern PFNGLCOMPILESHADERPROC nglCompileShader;
extern PFNGLCREATEPROGRAMPROC nglCreateProgram; extern PFNGLCREATEPROGRAMPROC nglCreateProgram;

Loading…
Cancel
Save