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,11 +459,8 @@ void main()
|
||||||
gl::GenVertexArrays(1, &mut quad_vao);
|
gl::GenVertexArrays(1, &mut quad_vao);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while !window.should_close() {
|
|
||||||
let (vp_width, vp_height) = window.get_size();
|
|
||||||
let (fb_width, fb_height) = window.get_framebuffer_size();
|
let (fb_width, fb_height) = window.get_framebuffer_size();
|
||||||
|
let (vp_width, vp_height) = window.get_size();
|
||||||
|
|
||||||
let output = Framebuffer::new_from_raw(
|
let output = Framebuffer::new_from_raw(
|
||||||
output_texture,
|
output_texture,
|
||||||
|
@ -473,6 +470,7 @@ void main()
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
while !window.should_close() {
|
||||||
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();
|
||||||
|
|
Loading…
Reference in a new issue