🚨 clean up a few lint errors and start building a new game

main
_ 2021-12-16 23:57:05 +00:00
parent 06c173e6da
commit f5da7b5188
5 changed files with 66 additions and 36 deletions

28
src/bin/platformer.rs Normal file
View File

@ -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 (())
}

View File

@ -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,

View File

@ -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;

35
src/prelude.rs Normal file
View File

@ -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,
};

View File

@ -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.
///