Merge pull request #182 from toolness/cfg-debug-assertions

Define ck() based on cfg(debug_assertions)
This commit is contained in:
Patrick Walton 2019-06-05 18:32:51 -07:00 committed by GitHub
commit 412d35ae57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 4 deletions

View File

@ -901,17 +901,28 @@ impl GLVersion {
// Error checking // Error checking
#[cfg(debug)] #[cfg(debug_assertions)]
fn ck() { fn ck() {
unsafe { 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(); let err = gl::GetError();
if err != 0 { if err != gl::NO_ERROR {
panic!("GL error: 0x{:x}", err); 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() {} fn ck() {}
// Shader preprocessing // Shader preprocessing