Skip to content

Commit

Permalink
clear updated
Browse files Browse the repository at this point in the history
  • Loading branch information
lindemeier committed Jun 13, 2024
1 parent 7b788af commit 38ec492
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion prgl/FrameBufferObject.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FrameBufferObject final {
const std::shared_ptr<Texture2d>& getTarget() const;
const std::shared_ptr<Texture2d>& getDepth() const;

void clear(const std::array<float, 4UL>& clearColor, double clearDepth);
void clear(const std::array<float, 4UL>& clearColor);

private:
FrameBufferObject(const FrameBufferObject&) = delete;
Expand Down
10 changes: 10 additions & 0 deletions src/ContextImplementation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 3 additions & 15 deletions src/FrameBufferObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,9 @@ const std::shared_ptr<Texture2d>& FrameBufferObject::getDepth() const {
return mDepth;
}

void FrameBufferObject::clear(const std::array<float, 4UL>& 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<float, 4UL>& 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 {
Expand Down

0 comments on commit 38ec492

Please sign in to comment.