sync
This commit is contained in:
parent
5c338b18fa
commit
129732cd7e
@ -152,7 +152,7 @@ impl Component for MonitorModel {
|
||||
});
|
||||
}
|
||||
MonitorInputMsg::QueueDraw => {
|
||||
widgets.renderer.queue_draw();
|
||||
widgets.renderer.queue_render();
|
||||
}
|
||||
|
||||
// MonitorInputMsg::KeyPress(key) => {
|
||||
|
||||
@ -129,6 +129,7 @@ impl ObjectImpl for Render {
|
||||
impl WidgetImpl for Render {
|
||||
fn realize(&self) {
|
||||
self.parent_realize();
|
||||
self.ensure_canvas();
|
||||
}
|
||||
fn unrealize(&self) {
|
||||
self.obj().make_current();
|
||||
@ -157,7 +158,6 @@ impl GLAreaImpl for Render {
|
||||
}
|
||||
|
||||
fn render(&self, context: >k::gdk::GLContext) -> glib::Propagation {
|
||||
self.ensure_canvas();
|
||||
let viewport = self.viewport.borrow();
|
||||
let viewport = viewport.as_ref().unwrap();
|
||||
|
||||
@ -169,8 +169,6 @@ impl GLAreaImpl for Render {
|
||||
gl.clear_color(0.0, 0.0, 0.0, 1.0);
|
||||
gl.clear(glow::COLOR_BUFFER_BIT | glow::DEPTH_BUFFER_BIT);
|
||||
gl.enable(glow::DEPTH_TEST);
|
||||
// gl.enable(glow::BLEND);
|
||||
// gl.blend_func(glow::SRC_ALPHA, glow::ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
if let Some(gi) = gi.as_mut() {
|
||||
@ -197,6 +195,7 @@ impl Render {
|
||||
fn ensure_canvas(&self) {
|
||||
use gi::{App as GI, Helper, GL};
|
||||
let widget = self.obj();
|
||||
widget.make_current();
|
||||
widget.attach_buffers();
|
||||
if self.gi.borrow().is_none() {
|
||||
info!("Creating canvas");
|
||||
@ -208,26 +207,7 @@ impl Render {
|
||||
|
||||
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);
|
||||
enable_opengl_debugging(&mut ctx);
|
||||
|
||||
let id =
|
||||
NonZeroU32::new(ctx.get_parameter_i32(glow::DRAW_FRAMEBUFFER_BINDING) as u32)
|
||||
@ -319,15 +299,21 @@ fn gl_debug_output(
|
||||
}
|
||||
}
|
||||
|
||||
fn enable_opengl_debugging(gl: &mut glow::Context) {
|
||||
fn enable_opengl_debugging(ctx: &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
|
||||
);
|
||||
});
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user