From f5da7b5188a7da935650effd58000cfa348696aa Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Thu, 16 Dec 2021 23:57:05 +0000 Subject: [PATCH] :rotating_light: clean up a few lint errors and start building a new game --- src/bin/platformer.rs | 28 ++++++++++++++++++++++++++++ src/bin/terrain.rs | 35 +---------------------------------- src/lib.rs | 2 +- src/prelude.rs | 35 +++++++++++++++++++++++++++++++++++ src/quinn_common.rs | 2 +- 5 files changed, 66 insertions(+), 36 deletions(-) create mode 100644 src/bin/platformer.rs create mode 100644 src/prelude.rs diff --git a/src/bin/platformer.rs b/src/bin/platformer.rs new file mode 100644 index 0000000..754f08c --- /dev/null +++ b/src/bin/platformer.rs @@ -0,0 +1,28 @@ +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 (()) +} diff --git a/src/bin/terrain.rs b/src/bin/terrain.rs index f329627..c15524f 100644 --- a/src/bin/terrain.rs +++ b/src/bin/terrain.rs @@ -1,37 +1,4 @@ -use std::{ - convert::TryInto, - ffi::{ - CString, - c_void, - }, - time::Duration, -}; - -use anyhow::{ - anyhow, - Context, -}; -use glam::{ - Mat4, - Vec3, -}; -use sdl2::{ - event::Event, - keyboard::{Keycode, Scancode}, -}; -use tracing::{ - debug, - instrument, -}; - -use opengl_rust::{ - glezz, - gpu_buffers, - network_protocol::*, - quinn_common::make_client_endpoint, - shader, - timestep::TimeStep, -}; +use opengl_rust::prelude::*; struct GameState { logic_frames: u64, diff --git a/src/lib.rs b/src/lib.rs index 9713385..ebffafd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,3 @@ -#[macro_use] extern crate iota; #[macro_use] @@ -10,6 +9,7 @@ pub mod gl_state; pub mod gpu_buffers; pub mod network_protocol; pub mod physics; +pub mod prelude; pub mod quinn_common; pub mod renderable_model; pub mod shader; diff --git a/src/prelude.rs b/src/prelude.rs new file mode 100644 index 0000000..9160d44 --- /dev/null +++ b/src/prelude.rs @@ -0,0 +1,35 @@ +pub use std::{ + convert::TryInto, + ffi::{ + CString, + c_void, + }, + time::Duration, +}; + +pub use anyhow::{ + anyhow, + bail, + Context, +}; +pub use glam::{ + Mat4, + Vec3, +}; +pub use sdl2::{ + event::Event, + keyboard::{Keycode, Scancode}, +}; +pub use tracing::{ + debug, + instrument, +}; + +pub use crate::{ + glezz, + gpu_buffers, + network_protocol::*, + quinn_common::make_client_endpoint, + shader, + timestep::TimeStep, +}; diff --git a/src/quinn_common.rs b/src/quinn_common.rs index 1f64fc1..ff8ff70 100644 --- a/src/quinn_common.rs +++ b/src/quinn_common.rs @@ -2,7 +2,7 @@ use quinn::{ Certificate, CertificateChain, ClientConfig, ClientConfigBuilder, Endpoint, Incoming, PrivateKey, ServerConfig, ServerConfigBuilder, TransportConfig, }; -use std::{error::Error, net::SocketAddr, sync::Arc}; +use std::{net::SocketAddr, sync::Arc}; /// Constructs a QUIC endpoint configured for use a client only. ///