Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clear updated #19

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading