-#include <GL/glxew.h>
-#include <GL/glut.h>
+#include "engine/engine.h"
-#include "engine/logger.h"
-#include "engine/performance.h"
-#include "engine/render.h"
-#include "engine/ui.h"
+#include "game/game.h"
-#include "game/input.h"
-#include "game/level.h"
-#include "game/player.h"
+int main(/*int argc, char** argv*/) {
+ EngineConfig cfg = { .windowWidth = 1280,
+ .windowHeight = 720,
+ .windowTitle = newString("shadowclad"),
+ .swapInterval = 1 };
-int main(int argc, char** argv) {
- glutInit(&argc, argv);
- // glutInitContextVersion(4,5); TODO establish correct context
-
- glutInitWindowSize(1280, 720);
-
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
- glutCreateWindow("shadowclad");
-
- logInfo("OpenGL %s", (const char*) glGetString(GL_VERSION));
- logInfo("GLSL %s", (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION));
- logInfo("%s", (const char*) glGetString(GL_RENDERER));
-
- GLenum glewInitStatus = glewInit();
- if (glewInitStatus != GLEW_OK) {
- logError("GLEW init failed: %s", (const char*) glewGetErrorString(glewInitStatus));
- return 1;
- }
- logInfo("GLEW %s", (const char*) glewGetString(GLEW_VERSION));
-
- if (GLXEW_EXT_swap_control) {
- Display* display = glXGetCurrentDisplay();
- GLXDrawable drawable = glXGetCurrentDrawable();
- if (drawable) {
- glXSwapIntervalEXT(display, drawable, 1);
- }
- else {
- logWarning("Drawable is not here ¯\\_(ツ)_/¯");
- logWarning("Could not enable vsync (GLX_EXT_swap_control)");
- }
- }
- else if (GLXEW_MESA_swap_control) {
- glXSwapIntervalMESA(1);
- logDebug("Vsync enabled with GLX_MESA_swap_control, swap interval %d", glXGetSwapIntervalMESA());
- }
- else {
- logWarning("Could not enable vsync (extensions not supported)");
- }
-
- glutDisplayFunc(renderFrame);
- glutReshapeFunc(resizeStage);
- glutKeyboardFunc(onKeyPressed);
- //glutMouseFunc(mouse_button_event);
- //glutMotionFunc(mouse_motion_event);
-
- initRender();
- //initPerformanceMetering();
- initLevel();
- initPlayer();
- startLevel();
-
- glutMainLoop();
+ // Engine startup
+ init(cfg);
+
+ initGame();
+
+ // Main update loop
+ run(update);
+
+ // Shutdown
+ terminate();
return 0;
}