Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let sdlsys = match sdl2::init() {
- Ok(s) => s,
- Err(e) => return Err(format!("Could not initialize SDL. {}", e))
- };
- let videosys: sdl2::VideoSubsystem = match sdlsys.video() {
- Ok(s) => s,
- Err(e) => return Err(format!("Could not initialize video. {}", e))
- };
- let windowsys: Window = match videosys.window(title, w, h).position_centered().opengl().build() {
- Ok(s) => s,
- Err(e) => return Err(format!("Could not create window. {}", e))
- };
- let attr = videosys.gl_attr();
- attr.set_context_profile(GLProfile::Core);
- attr.set_context_version(3, 3);
- attr.set_double_buffer(true);
- attr.set_context_flags().debug().set();
- let context = match windowsys.gl_create_context() {
- Ok(s) => s,
- Err(e) => return Err(format!("Could not create OpenGL context. {}", e))
- };
- windowsys.gl_make_current(&context);
- gl::load_with(|s| videosys.gl_get_proc_address(s) as *const _);
- let evt = match sdlsys.event_pump() {
- Ok(s) => s,
- Err(e) => return Err(format!("Could not create Event handler. {}", e))
- };
- unsafe {
- println!("GL_VERSION: {}", CStr::from_ptr(gl::GetString(gl::VERSION) as *const i8).to_string_lossy().into_owned());
- println!("GL_VENDOR: {}", CStr::from_ptr(gl::GetString(gl::VENDOR) as *const i8).to_string_lossy().into_owned());
- println!("GL_RENDERER: {}", CStr::from_ptr(gl::GetString(gl::RENDERER) as *const i8).to_string_lossy().into_owned());
- }
- Ok(Display {
- _window: windowsys,
- _evt: evt,
- width: w,
- height: h
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement