2021-32-bit-holiday-jam/src/bin/platformer.rs

29 lines
833 B
Rust

use opengl_rust::prelude::*;
use anyhow::Result;
#[tokio::main]
async fn main () -> Result <()> {
let sdl_context = sdl2::init ().map_err (|e| anyhow! ("Can't init SDL: {}", e))?;
let video_subsystem = sdl_context.video ().map_err (|e| anyhow! ("Can't get SDL video subsystem: {}", e))?;
let window = video_subsystem.window ("3D platformer", 1280, 720)
.position_centered ()
.opengl ()
.build ()
?;
gl::load_with (|s| {
video_subsystem.gl_get_proc_address (s) as *const _
});
if ! gl::ClearColor::is_loaded () {
bail! ("gl::ClearColor didn't load, something is wrong with OpenGL");
}
let gl_ctx = window.gl_create_context ().map_err (|e| anyhow! ("Can't create OpenGL context: {}", e))?;
window.gl_make_current (&gl_ctx).map_err (|e| anyhow! ("Can't make OpenGL context current: {}", e))?;
Ok (())
}