Compiling shaders
@@ -28,7 +28,7 @@ fn main() {
.build()
.unwrap();
- let gl_context = window.gl_create_context().unwrap();
+ let _gl_context = window.gl_create_context().unwrap();
let _gl = gl::load_with(|s| video_ctx.gl_get_proc_address(s) as *const std::os::raw::c_void);
unsafe {
@@ -36,6 +36,21 @@ fn main() {
gl::ClearColor(0.3, 0.3, 0.5, 1.0);
}
+ use std::ffi::{CString};
+ let vert_shader = render_gl::Shader::from_vert_source(
+ &CString::new(include_str!("triangle.vert")).unwrap()
+ ).unwrap();
+
+ let frag_shader = render_gl::Shader::from_frag_source(
+ &CString::new(include_str!("triangle.frag")).unwrap()
+ ).unwrap();
+
+ let shader_program = render_gl::Program::from_shaders(
+ &[vert_shader, frag_shader]
+ ).unwrap();
+
+ shader_program.set_used();
+
let mut events = ctx.event_pump().unwrap();
let mut main_loop = || {
