From acb4179118018f406a18aecb55ddfe22ebd4c89b Mon Sep 17 00:00:00 2001 From: Thomas Lindemeier Date: Thu, 13 Jun 2024 14:12:58 +0200 Subject: [PATCH] clear updated (#19) --- prgl/FrameBufferObject.hxx | 2 +- src/ContextImplementation.cxx | 10 ++++++++++ src/FrameBufferObject.cxx | 18 +++--------------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/prgl/FrameBufferObject.hxx b/prgl/FrameBufferObject.hxx index 1d67c07..d9091a5 100644 --- a/prgl/FrameBufferObject.hxx +++ b/prgl/FrameBufferObject.hxx @@ -31,7 +31,7 @@ class FrameBufferObject final { const std::shared_ptr& getTarget() const; const std::shared_ptr& getDepth() const; - void clear(const std::array& clearColor, double clearDepth); + void clear(const std::array& clearColor); private: FrameBufferObject(const FrameBufferObject&) = delete; diff --git a/src/ContextImplementation.cxx b/src/ContextImplementation.cxx index b003ea5..0b02101 100644 --- a/src/ContextImplementation.cxx +++ b/src/ContextImplementation.cxx @@ -48,8 +48,14 @@ void checkGLError(const char* file, const char* function, int line) { } } +// if clang is used, the following pragma is needed to suppress the warning +#ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-function" +#elif defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" +#endif // http://blog.nobel-joergensen.com/2013/02/17/debugging-opengl-part-2-using-gldebugmessagecallback/ static void APIENTRY openGlDebugCallback(GLenum /*unused*/, GLenum type, GLuint id, GLenum severity, @@ -111,7 +117,11 @@ static void APIENTRY openGlDebugCallback(GLenum /*unused*/, GLenum type, << std::endl; std::cerr << std::endl; } +#ifdef __clang__ #pragma clang diagnostic pop +#elif defined(__GNUC__) +#pragma GCC diagnostic pop +#endif ContextImplementation::ContextImplementation() : ContextImplementation(640, 480, "", 8, 8, 8, 8, 8, 8, 4, false, false, diff --git a/src/FrameBufferObject.cxx b/src/FrameBufferObject.cxx index 0fe353d..f12784e 100644 --- a/src/FrameBufferObject.cxx +++ b/src/FrameBufferObject.cxx @@ -69,21 +69,9 @@ const std::shared_ptr& FrameBufferObject::getDepth() const { return mDepth; } -void FrameBufferObject::clear(const std::array& clearColor, - double clearDepth) { - if (mTarget != nullptr) { - mTarget->bind(true); - glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); - glClear(GL_COLOR_BUFFER_BIT); - mTarget->bind(false); - } - - if (mDepth != nullptr) { - mDepth->bind(true); - glClearDepth(clearDepth); - glClear(GL_DEPTH_BUFFER_BIT); - mDepth->bind(false); - } +void FrameBufferObject::clear(const std::array& clearColor) { + glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } bool FrameBufferObject::checkStatus() const {