randomPoison / gunship-rs

An experimental game engine written in Rust.
MIT License
27 stars 3 forks source link

Gunship Cannot Start Without debug_draw.glsl #54

Closed randomPoison closed 8 years ago

randomPoison commented 8 years ago

Gunship is hard-coded to look for shaders/debug_draw.glsl on startup, so if that file doesn't exist then the game crashes with a rather unhelpful warning message about unwrapping an Err value. debug_draw.glsl is distributed with the Gunship source code, however the resource loader uses relative paths so it still won't find the file unless the developer copies it to their local shaders directory.

While there are a bunch of changes that need to be made to the resource manager and the way Gunship handles resource files in general, I think the solution here is to have the shader code hard-coded insude debug_draw.rs the same way that the debug wireframe meshes are. To do this will require the following:

  1. Copy the contents of debug_draw.glsl into a raw string in debug_draw.rs.
  2. In DebugDraw::new() remove the call to call to resource_manager.get_shader().
  3. Split up ResourceManager::get_shader() into two functions: get_shader() and compile_shader() where get_shader() loads the contents of the file into a string and then passes it to compile_shader() which parses and those contents and has the renderer compile them.
  4. Have DebugDraw::new() call resource_manager.comiple_shader() passing in the hard-coded shader string.
randomPoison commented 8 years ago

This issue has been invalidated for the time being due to the async refactor. If the issue crops up again we can re-open the issue.