gl: fix hello triangle
This commit is contained in:
parent
dadfb6ba33
commit
f6a862339c
|
@ -12,7 +12,7 @@ use crate::framebuffer::{Framebuffer, GlImage, Viewport};
|
||||||
|
|
||||||
const WIDTH: u32 = 900;
|
const WIDTH: u32 = 900;
|
||||||
const HEIGHT: u32 = 700;
|
const HEIGHT: u32 = 700;
|
||||||
const TITLE: &str = "librashader OpenGL";
|
const TITLE: &str = "Hello From OpenGL World!";
|
||||||
|
|
||||||
pub fn compile_program(vertex: &str, fragment: &str) -> GLuint {
|
pub fn compile_program(vertex: &str, fragment: &str) -> GLuint {
|
||||||
let vertex_shader = unsafe { gl::CreateShader(gl::VERTEX_SHADER) };
|
let vertex_shader = unsafe { gl::CreateShader(gl::VERTEX_SHADER) };
|
||||||
|
@ -459,20 +459,18 @@ void main()
|
||||||
gl::GenVertexArrays(1, &mut quad_vao);
|
gl::GenVertexArrays(1, &mut quad_vao);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let (fb_width, fb_height) = window.get_framebuffer_size();
|
||||||
|
let (vp_width, vp_height) = window.get_size();
|
||||||
|
|
||||||
|
let output = Framebuffer::new_from_raw(
|
||||||
|
output_texture,
|
||||||
|
output_framebuffer_handle,
|
||||||
|
gl::RGBA8,
|
||||||
|
Size::new(vp_width as u32, vp_height as u32),
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
|
||||||
while !window.should_close() {
|
while !window.should_close() {
|
||||||
let (vp_width, vp_height) = window.get_size();
|
|
||||||
let (fb_width, fb_height) = window.get_framebuffer_size();
|
|
||||||
|
|
||||||
let output = Framebuffer::new_from_raw(
|
|
||||||
output_texture,
|
|
||||||
output_framebuffer_handle,
|
|
||||||
gl::RGBA8,
|
|
||||||
Size::new(vp_width as u32, vp_height as u32),
|
|
||||||
1,
|
|
||||||
);
|
|
||||||
|
|
||||||
glfw.poll_events();
|
glfw.poll_events();
|
||||||
for (_, event) in glfw::flush_messages(&events) {
|
for (_, event) in glfw::flush_messages(&events) {
|
||||||
glfw_handle_event(&mut window, event);
|
glfw_handle_event(&mut window, event);
|
||||||
|
@ -521,19 +519,19 @@ void main()
|
||||||
|
|
||||||
filter.frame(framecount, &viewport, &rendered, false)
|
filter.frame(framecount, &viewport, &rendered, false)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
//
|
|
||||||
// unsafe {
|
unsafe {
|
||||||
// // texture is done now.
|
// texture is done now.
|
||||||
// // draw quad to screen
|
// draw quad to screen
|
||||||
// gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
|
gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
|
||||||
// gl::UseProgram(quad_programid);
|
gl::UseProgram(quad_programid);
|
||||||
//
|
|
||||||
// gl::ActiveTexture(gl::TEXTURE0);
|
gl::ActiveTexture(gl::TEXTURE0);
|
||||||
// gl::BindTexture(gl::TEXTURE_2D, output_texture);
|
gl::BindTexture(gl::TEXTURE_2D, output_texture);
|
||||||
//
|
|
||||||
// gl::BindVertexArray(quad_vao);
|
gl::BindVertexArray(quad_vao);
|
||||||
// gl::DrawArrays(gl::TRIANGLE_STRIP, 0, 4);
|
gl::DrawArrays(gl::TRIANGLE_STRIP, 0, 4);
|
||||||
// }
|
}
|
||||||
|
|
||||||
framecount += 1;
|
framecount += 1;
|
||||||
window.swap_buffers();
|
window.swap_buffers();
|
||||||
|
@ -564,4 +562,4 @@ fn glfw_handle_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
|
||||||
Event::Size(width, height) => window.set_size(width, height),
|
Event::Size(width, height) => window.set_size(width, height),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue