gl: fix hello triangle

This commit is contained in:
chyyran 2022-11-24 02:08:00 -05:00
parent dadfb6ba33
commit f6a862339c

View file

@ -12,7 +12,7 @@ use crate::framebuffer::{Framebuffer, GlImage, Viewport};
const WIDTH: u32 = 900;
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 {
let vertex_shader = unsafe { gl::CreateShader(gl::VERTEX_SHADER) };
@ -459,11 +459,8 @@ void main()
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 (vp_width, vp_height) = window.get_size();
let output = Framebuffer::new_from_raw(
output_texture,
@ -473,6 +470,7 @@ void main()
1,
);
while !window.should_close() {
glfw.poll_events();
for (_, event) in glfw::flush_messages(&events) {
glfw_handle_event(&mut window, event);
@ -521,19 +519,19 @@ void main()
filter.frame(framecount, &viewport, &rendered, false)
.unwrap();
//
// unsafe {
// // texture is done now.
// // draw quad to screen
// gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
// gl::UseProgram(quad_programid);
//
// gl::ActiveTexture(gl::TEXTURE0);
// gl::BindTexture(gl::TEXTURE_2D, output_texture);
//
// gl::BindVertexArray(quad_vao);
// gl::DrawArrays(gl::TRIANGLE_STRIP, 0, 4);
// }
unsafe {
// texture is done now.
// draw quad to screen
gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
gl::UseProgram(quad_programid);
gl::ActiveTexture(gl::TEXTURE0);
gl::BindTexture(gl::TEXTURE_2D, output_texture);
gl::BindVertexArray(quad_vao);
gl::DrawArrays(gl::TRIANGLE_STRIP, 0, 4);
}
framecount += 1;
window.swap_buffers();