add debug layer
This commit is contained in:
parent
71ac338c1d
commit
5c338b18fa
@ -15,6 +15,7 @@ use gtk::subclass::prelude::*;
|
|||||||
use slippy_map_tiles::Tile;
|
use slippy_map_tiles::Tile;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::ffi::CStr;
|
||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
@ -203,7 +204,30 @@ impl Render {
|
|||||||
static LOAD_FN: fn(&str) -> *const std::ffi::c_void =
|
static LOAD_FN: fn(&str) -> *const std::ffi::c_void =
|
||||||
|s| epoxy::get_proc_addr(s) as *const _;
|
|s| epoxy::get_proc_addr(s) as *const _;
|
||||||
use femtovg::renderer::OpenGl;
|
use femtovg::renderer::OpenGl;
|
||||||
let ctx = glow::Context::from_loader_function(LOAD_FN);
|
let mut ctx = glow::Context::from_loader_function(LOAD_FN);
|
||||||
|
|
||||||
|
let version = unsafe { ctx.get_parameter_string(glow::VERSION) };
|
||||||
|
info!("OpenGL Version: {}", version);
|
||||||
|
|
||||||
|
if ctx.supported_extensions().contains("GL_ARB_debug_output") {
|
||||||
|
unsafe {
|
||||||
|
ctx.debug_message_callback(|source, _type, id, severity, message| {
|
||||||
|
println!(
|
||||||
|
"GL ARB Debug Message: Source: {:?}, ID: {}, Severity: {:?}, Message: {}",
|
||||||
|
source,
|
||||||
|
id,
|
||||||
|
severity,
|
||||||
|
message
|
||||||
|
);
|
||||||
|
});
|
||||||
|
ctx.enable(glow::DEBUG_OUTPUT);
|
||||||
|
ctx.enable(glow::DEBUG_OUTPUT_SYNCHRONOUS);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
info!("GL_ARB_debug_output not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
// enable_opengl_debugging(&mut ctx);
|
||||||
|
|
||||||
let id =
|
let id =
|
||||||
NonZeroU32::new(ctx.get_parameter_i32(glow::DRAW_FRAMEBUFFER_BINDING) as u32)
|
NonZeroU32::new(ctx.get_parameter_i32(glow::DRAW_FRAMEBUFFER_BINDING) as u32)
|
||||||
@ -273,3 +297,37 @@ impl Render {
|
|||||||
(x, h as f32 - y)
|
(x, h as f32 - y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn gl_debug_output(
|
||||||
|
source: u32,
|
||||||
|
_type: u32,
|
||||||
|
id: u32,
|
||||||
|
severity: u32,
|
||||||
|
_length: i32,
|
||||||
|
message: *const i8,
|
||||||
|
_user_param: *mut std::ffi::c_void,
|
||||||
|
) {
|
||||||
|
unsafe {
|
||||||
|
let message = CStr::from_ptr(message);
|
||||||
|
println!(
|
||||||
|
"GL Debug Message: Source: {:?}, ID: {}, Severity: {:?}, Message: {}",
|
||||||
|
source,
|
||||||
|
id,
|
||||||
|
severity,
|
||||||
|
message.to_string_lossy()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn enable_opengl_debugging(gl: &mut glow::Context) {
|
||||||
|
unsafe {
|
||||||
|
gl.enable(glow::DEBUG_OUTPUT);
|
||||||
|
gl.enable(glow::DEBUG_OUTPUT_SYNCHRONOUS); // 确保错误信息立即显示
|
||||||
|
gl.debug_message_callback(|source, _type, id, severity, message| {
|
||||||
|
println!(
|
||||||
|
"GL Debug Message: Source: {:?}, ID: {}, Severity: {:?}, Message: {}",
|
||||||
|
source, id, severity, message
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user