Skip to content

Commit

Permalink
Merge pull request rust-windowing#182 from toolness/cfg-debug-assertions
Browse files Browse the repository at this point in the history
Define ck() based on cfg(debug_assertions)
  • Loading branch information
pcwalton authored Jun 6, 2019
2 parents 1897cc5 + 7563e95 commit 412d35a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions gl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,17 +901,28 @@ impl GLVersion {

// Error checking

#[cfg(debug)]
#[cfg(debug_assertions)]
fn ck() {
unsafe {
// Note that ideally we should be calling gl::GetError() in a loop until it
// returns gl::NO_ERROR, but for now we'll just report the first one we find.
let err = gl::GetError();
if err != 0 {
panic!("GL error: 0x{:x}", err);
if err != gl::NO_ERROR {
panic!("GL error: 0x{:x} ({})", err, match err {
gl::INVALID_ENUM => "INVALID_ENUM",
gl::INVALID_VALUE => "INVALID_VALUE",
gl::INVALID_OPERATION => "INVALID_OPERATION",
gl::INVALID_FRAMEBUFFER_OPERATION => "INVALID_FRAMEBUFFER_OPERATION",
gl::OUT_OF_MEMORY => "OUT_OF_MEMORY",
gl::STACK_UNDERFLOW => "STACK_UNDERFLOW",
gl::STACK_OVERFLOW => "STACK_OVERFLOW",
_ => "Unknown"
});
}
}
}

#[cfg(not(debug))]
#[cfg(not(debug_assertions))]
fn ck() {}

// Shader preprocessing

0 comments on commit 412d35a

Please sign in to comment.