Skip to content
Snippets Groups Projects
Commit 6f64a0fd authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

make glfw use the same pseudo-module approach

parent bf3e5186
No related branches found
No related tags found
No related merge requests found
Pipeline #3039 failed
......@@ -6,6 +6,8 @@
#include <fggl/gfx/window.hpp>
#include <fggl/gfx/camera.hpp>
#include <fggl/gfx/compat.hpp>
#include <fggl/gfx/ogl/compat.hpp>
#include <fggl/data/procedural.hpp>
......@@ -170,16 +172,16 @@ void process_freecam(fggl::gfx::Window& window, fggl::ecs::ECS& ecs, fggl::gfx::
}
int main(int argc, char* argv[]) {
fggl::gfx::Context ctx;
// setup ECS
fggl::ecs::ECS ecs;
// build our main window
auto glfwModule = fggl::gfx::ecsInitGlfw(ecs);
fggl::gfx::Window win( fggl::gfx::Input::instance() );
win.title("FGGL Demo");
win.fullscreen( true );
// setup ECS
fggl::ecs::ECS ecs;
// storage API
fggl::data::Storage storage;
discover( storage.resolvePath(fggl::data::Data, "res") );
......@@ -260,7 +262,7 @@ int main(int argc, char* argv[]) {
while( !win.closeRequested() ) {
input.frame();
ctx.pollEvents();
glfwModule->context.pollEvents();
debug.frameStart();
// update step
......
#ifndef FGGL_GFX_GLFW_COMPAT_H
#define FGGL_GFX_GLFW_COMPAT_H
/**
* Window management Calls.
*
* This shouldn't be exposed to the demo app, but the ECS we're using isn't smart enouph to allow us to
* abstract this yet. It's next thing on the list, but this branch is about cleaning up OpenGL not about
* extending our ECS.
*
* Should be removed when the engine has suitable abstractions in place.
*/
#include <memory>
#include <fggl/gfx/window.hpp>
#include <fggl/ecs/ecs.hpp>
namespace fggl::gfx {
//
// fake module support - allows us to still RAII
//
struct ecsGlfwModule {
GlfwContext context;
inline ecsGlfwModule() : context() {
}
};
using GlfwModule = std::shared_ptr<ecsGlfwModule>;
//
// fake module/callbacks - our ECS doesn't have module/callback support yet.
//
inline GlfwModule ecsInitGlfw(ecs::ECS& ecs) {
auto mod = std::make_shared<ecsGlfwModule>();
return mod;
}
}
#endif
......@@ -91,7 +91,7 @@ static void fggl_joystick(int jid, int state) {
}
}
Context::Context() {
GlfwContext::GlfwContext() {
glfwInitHint(GLFW_JOYSTICK_HAT_BUTTONS, GLFW_FALSE);
int state = glfwInit();
......@@ -106,11 +106,11 @@ Context::Context() {
glfwSetJoystickCallback(fggl_joystick);
}
Context::~Context() {
GlfwContext::~GlfwContext() {
glfwTerminate();
}
void Context::pollEvents() {
void GlfwContext::pollEvents() {
glfwPollEvents();
fggl_joystick_poll();
}
......
......@@ -10,10 +10,10 @@
namespace fggl::gfx {
class Context {
class GlfwContext {
public:
Context();
~Context();
GlfwContext();
~GlfwContext();
void pollEvents();
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment