Commit Graph

20 Commits

Author SHA1 Message Date
2a70da881b Update preview image 2026-10-28 22:17:06 +01:00
f416cd38ef Add Containers scene for testing specular maps; name scenes
- Add Scene::name and show it in the scene selector (falls back to
  "Scene N" when empty; ImGui IDs keep equal names apart)
- Add a Containers scene: container2 with its specular map, arranged
  on a floor as a pyramid, a stack, loose crates and one large crate.
  Lit by 8 point and 4 spot lights, with the directional light's
  diffuse and specular turned off
- create_textured_material() takes an optional specular map, loaded
  without the checkerboard fallback like in the OBJ loader
- Add create_floor() and use it for the Backpack scene too (same
  position as before)
2026-10-28 22:09:47 +01:00
a36ed3a902 Make GL state changes predictable and clean up main.cpp
Engine:
- Create, resize and update functions now restore the bindings they
  touch instead of leaving their own objects bound or resetting to 0
  (Texture, FrameBuffer, Mesh, UniformBuffer)
- Texture::bind/unbind switch back to texture unit 0 afterwards, so
  later texture binds can't replace a material's specular map
- Add gl_get_binding() helper to read the current binding
- Renderer remembers the wireframe mode (new is_wireframe());
  draw_debug_wireframes restores it instead of always disabling it,
  which fixes H having no effect while debug wireframes are shown

main.cpp (same behavior and UI):
- main() only sets up the window and renderer; all GL resources live
  in run() and are released before Renderer::shutdown()
- One function per scene and a shared create_textured_material()
- Split app state into AppState, CameraInput and PerformanceStats;
  drop the duplicate delta_time and static toggle variables
- Move the scene pass to render_scene() and the overlay to
  draw_overlay(); name the light box and overlay constants
- Clear the mouse callback before AppState is destroyed
2026-10-28 21:42:08 +01:00
d081108ea5 Add GL error handling, resource fallbacks and GPU timing; speed up lighting
Bug fixes:
- Release static GL objects (UBOs, logo texture) before the context is
  destroyed via new Renderer::shutdown()
- Fix max point/spot light warnings never firing
- Show frame time in ms instead of seconds
- Size the viewport framebuffer in physical pixels on HiDPI displays
- Stop double-flipping OBJ UVs; add flip_uvs option to load_obj for
  models with a top-left UV origin (backpack)

Build:
- Track header dependencies (-MMD -MP) so header edits trigger rebuilds
- Create build/ automatically

Error handling:
- Add gldebug module: KHR_debug output routed to the logger in debug
  builds, object labels, and error/status string helpers
- Validate inputs and check GL errors when creating textures, meshes,
  framebuffers, uniform buffers and shaders; FrameBuffer::resize() and
  Renderer::init() now report failure

Resources:
- Add ResourceCache: shares textures and shaders by path and substitutes
  fallbacks (magenta checkerboard texture, unlit shader, cube mesh) for
  assets that fail to load; specular maps are optional
- load_obj never fails, a broken model becomes a fallback cube
- Renderer draws submeshes with broken materials using the fallback
  material instead of skipping them
- Add Texture::create_from_pixels, Shader::create_from_source and
  Mesh::create_cube
- Cache uniform locations in Shader, looked up with string_view so
  hits don't allocate; missing uniforms warn once

Performance:
- Add CpuTimer and GpuTimer (GL_TIME_ELAPSED, non-blocking readback)
  and a Performance section in the UI with averaged overlay numbers
- Sample material textures once per fragment and apply material colors
  after accumulating lights
- Pass camera position through CameraBlock instead of inverting the
  view matrix per fragment
- Compute the normal matrix on the CPU instead of per vertex
- Skip spot light work for fragments outside the outer cone
2026-10-28 21:23:41 +01:00
642d29634a Implemented a custom logger 2026-10-01 03:04:17 +02:00
3972413594 Update README.md 2026-09-30 17:07:19 +02:00
72a895cfc1 Discard small alpha values in fragment shader 2026-09-28 06:19:50 +02:00
e34c284da9 Update unity header 2026-09-27 23:07:50 +02:00
5f65668168 Update preview.png 2026-09-27 22:48:26 +02:00
f3efa511b3 Fix UV mapping for logo image 2026-09-27 22:44:57 +02:00
e6016b4e8f Added Sponza scene. Updated README.md 2026-09-27 22:36:07 +02:00
b85e784d6f Edit example UI features 2026-09-27 21:14:33 +02:00
850a6f601b Implement Mesh partitioning 2026-09-27 17:48:22 +02:00
11426fe8fb Fix debug wireframe renderer 2026-09-27 06:21:29 +02:00
a9bda25031 Implemented uniform buffers. Optimized data upload to GPU 2026-09-27 05:33:36 +02:00
1703ead546 Define common limits for light sources count 2026-09-27 03:34:20 +02:00
60047d10e6 Rename header guard to match engine convention 2026-09-27 03:06:25 +02:00
4ccb1099d2 Rename thirdparty -> vendor 2026-09-27 01:53:32 +02:00
0c2c998033 Add preview image to README.md 2026-09-27 01:43:29 +02:00
3ac329a21b Initial commit 2026-09-27 01:33:35 +02:00