diff --git a/demo/data/packs/rollball/scene.yml b/demo/data/packs/rollball/scene.yml deleted file mode 100644 index 774694713b135484cdd1b0d8b30c66cb56e837a8..0000000000000000000000000000000000000000 --- a/demo/data/packs/rollball/scene.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- -# This currently isn't functional, it's an experiment in how this -# might be defined in a user-friendly(ish) way. - -prefabs: - wallX: - transform: - staticMesh: - pipeline: phong - shape: # TODO - rigidBody: - type: static - shape: - type: box - extents: [0.5, 2.5, 20.5] - wallZ: - transform: - staticMesh: - pipeline: phong - rigidBody: - type: static - shape: - type: box - extents: [39.0, 2.5, 0.5] - floor: - transform: - staticMesh: - pipeline: phong - shape: # TODO - rigidBody: - type: static - shape: box - extents: [20, 0.5, 20.0] - player: - transform: - rigidBody: - mass: 1 - shape: - type: sphere - extents: [0.5, 0.5, 0.5] - dynamics: - staticMesh: - pipeline: phong - shape: # TODO - collectable: - transform: - staticMesh: - shader: phong - shape: # TODO - callbacks: -scene: - entities: - - prefab: wallX - transform: - origin: [20, 0, 0] - - prefab: wallX - transform: - origin: [-20, 0, 0] - - prefab: wallZ - transform: [0, 0, -20] - - prefab: wallZ - transform: [0, 0, 20] - - prefab: floor - transform: [0, -2.5, 0] - - prefab: player \ No newline at end of file diff --git a/fggl/gfx/ogl/renderer.cpp b/fggl/gfx/ogl/renderer.cpp index 8a9b1fe2fbfcd998e4d0d9013a8d8ef373bf9ea4..d1d024c42021ff316a537fcae6fe05fe73569811 100644 --- a/fggl/gfx/ogl/renderer.cpp +++ b/fggl/gfx/ogl/renderer.cpp @@ -92,7 +92,7 @@ PRAGMA_DIAGNOSTIC_PUSH constexpr const char *OGL_LOG_FMT{"[GL] {}, {}: [{}]: {}"}; -void static GLAPIENTRY fggl_ogl_to_spdlog(GLenum source, +void static GLAPIENTRY fggl_ogl_log(GLenum source, GLenum type, unsigned int msgId, GLenum severity, @@ -139,13 +139,14 @@ namespace fggl::gfx { using data::Mesh2D; using data::Vertex2D; - OpenGL4Backend::OpenGL4Backend(data::Storage *storage, gui::FontLibrary *fonts, assets::AssetManager *assets) + OpenGL4Backend::OpenGL4Backend(data::Storage *storage, gui::FontLibrary *fonts, assets::AssetManager *assets, GlFunctionLoader loader) : fggl::gfx::Graphics(), m_canvasPipeline(nullptr), m_storage(storage) { - // initialise GLEW, or fail - // FIXME this binds the graphics stack to GLFW :'( - int version = gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); + + // load OpenGL context, or fail. + int version = gladLoadGLLoader(loader); if (version == 0) { - printf("Failed to initialize OpenGL context\n"); + debug::error("Failed to initialize OpenGL context\n"); + return; } // OpenGL debug Support @@ -155,7 +156,7 @@ namespace fggl::gfx { debug::info("enabling OpenGL debug output"); glEnable(GL_DEBUG_OUTPUT); glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); - glDebugMessageCallback(fggl_ogl_to_spdlog, nullptr); + glDebugMessageCallback(fggl_ogl_log, nullptr); glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE); } diff --git a/fggl/gfx/ogl4/setup.cpp b/fggl/gfx/ogl4/setup.cpp index ba1a9483e44b16907367b2de833fbb3b547e9a14..85fbde7baf509164d8b086954c5735ecd42ec014 100644 --- a/fggl/gfx/ogl4/setup.cpp +++ b/fggl/gfx/ogl4/setup.cpp @@ -21,7 +21,7 @@ namespace fggl::gfx::ogl4 { Graphics *WindowGraphics::create(display::Window &window) { - return new OpenGL4Backend(m_storage, m_fonts, m_assets); + return new OpenGL4Backend(m_storage, m_fonts, m_assets, (GlFunctionLoader)glfwGetProcAddress); } } \ No newline at end of file diff --git a/include/fggl/gfx/ogl/renderer.hpp b/include/fggl/gfx/ogl/renderer.hpp index fd88e2dad3dd140796b233be440892d4aa1f3074..c0d8d06a1ed44c610adf64c32f5f431d9f824fd1 100644 --- a/include/fggl/gfx/ogl/renderer.hpp +++ b/include/fggl/gfx/ogl/renderer.hpp @@ -30,6 +30,8 @@ namespace fggl::gfx { + using GlFunctionLoader = GLADloadproc; + enum GlRenderType { triangles = GL_TRIANGLES, triangle_strip = GL_TRIANGLE_STRIP @@ -55,7 +57,7 @@ namespace fggl::gfx { */ class OpenGL4Backend : public Graphics { public: - explicit OpenGL4Backend(data::Storage *storage, gui::FontLibrary *fonts, assets::AssetManager *assets); + explicit OpenGL4Backend(data::Storage *storage, gui::FontLibrary *fonts, assets::AssetManager *assets, GlFunctionLoader loader); ~OpenGL4Backend() override = default; // copy bad @@ -96,7 +98,7 @@ namespace fggl::gfx { /** * Get the 2D canvas bounds. * - * @return + * @return the canvas bounds */ inline Bounds canvasBounds() override { return m_canvasRenderer->bounds();