engine/asset.c \
engine/engine.c \
engine/geometry.c \
+ engine/input.c \
engine/logger.c \
engine/performance.c \
engine/render.c \
-#ifndef ASSET_H_
-#define ASSET_H_
+#ifndef ENGINE_ASSET_H_
+#define ENGINE_ASSET_H_
#include <stddef.h>
#include <GL/gl.h>
const Solid* importSolid(const char* path);
-#endif // ASSET_H_
+#endif // ENGINE_ASSET_H_
#include <GL/glxew.h>
#include <GLFW/glfw3.h>
+#include "input.h"
#include "logger.h"
#include "performance.h"
#include "render.h"
resizeStage(window, width, height);
glfwSetFramebufferSizeCallback(window, resizeStage);
+ glfwSetKeyCallback(window, onKeyboardEvent);
initRender();
//initPerformanceMetering();
glfwTerminate();
}
-void setKeyboardEventCallback(void (*keyboardEventCallback) (GLFWwindow*, int, int, int, int)) {
- glfwSetKeyCallback(window, keyboardEventCallback);
-}
-
static void onGlfwError(int error, const char* description) {
logError("GLFW error: %s", description);
}
-#ifndef ENGINE_H_
-#define ENGINE_H_
-
-typedef struct GLFWwindow GLFWwindow;
+#ifndef ENGINE_ENGINE_H_
+#define ENGINE_ENGINE_H_
void init();
void run(void (*updateFn) (float));
void terminate();
-void setKeyboardEventCallback(void (*) (GLFWwindow*, int, int, int, int));
-#endif // ENGINE_H_
+#endif // ENGINE_ENGINE_H_
-#ifndef GEOMETRY_H_
-#define GEOMETRY_H_
+#ifndef ENGINE_GEOMETRY_H_
+#define ENGINE_GEOMETRY_H_
#include <GL/gl.h>
Vector3D translationOf(Transform transform);
Vector3D normalized(Vector3D vec);
-#endif // GEOMETRY_H_
+#endif // ENGINE_GEOMETRY_H_
--- /dev/null
+#include "input.h"
+
+#include <stdbool.h>
+
+static void (*keyboardInputCallback) (int, int, int, int);
+
+
+
+void onKeyboardEvent(GLFWwindow* window, int key, int scancode, int action, int mods) {
+ bool handled = false;
+
+ if (!handled && keyboardInputCallback) {
+ keyboardInputCallback(key, scancode, action, mods);
+ }
+}
+
+void setKeyboardInputCallback(void (*callback) (int, int, int, int)) {
+ keyboardInputCallback = callback;
+}
--- /dev/null
+#ifndef ENGINE_INPUT_H
+#define ENGINE_INPUT_H
+
+#include <GLFW/glfw3.h>
+
+void onKeyboardEvent(GLFWwindow* window, int key, int scancode, int action, int mods);
+void setKeyboardInputCallback(void (*) (int, int, int, int));
+
+#endif // ENGINE_INPUT_H
-#ifndef LOGGER_H_
-#define LOGGER_H_
+#ifndef ENGINE_LOGGER_H_
+#define ENGINE_LOGGER_H_
typedef enum {
LOGLEVEL_ERROR,
void logMessage(LogLevel msgLevel, const char* func, const char* message, ...);
-#endif // LOGGER_H_
+#endif // ENGINE_LOGGER_H_
-#ifndef PERFORMANCE_H_
-#define PERFORMANCE_H_
+#ifndef ENGINE_PERFORMANCE_H_
+#define ENGINE_PERFORMANCE_H_
void initPerformanceMetering();
void frameRendered();
-#endif // PERFORMANCE_H_
+#endif // ENGINE_PERFORMANCE_H_
-#ifndef RENDER_H_
-#define RENDER_H_
+#ifndef ENGINE_RENDER_H_
+#define ENGINE_RENDER_H_
#include <GLFW/glfw3.h>
void initRender();
void renderFrame(GLFWwindow* window);
-#endif // RENDER_H_
+#endif // ENGINE_RENDER_H_
-#ifndef SCENE_H_
-#define SCENE_H_
+#ifndef ENGINE_SCENE_H_
+#define ENGINE_SCENE_H_
#include "asset.h"
void reparentScene(Scene* scene, Scene* newParent);
Transform worldTransform(const Scene* scene);
-#endif // SCENE_H_
+#endif // ENGINE_SCENE_H_
-#ifndef STRING_H_
-#define STRING_H_
+#ifndef ENGINE_STRING_H_
+#define ENGINE_STRING_H_
#include <assimp/types.h>
String stringFromAiString(const struct aiString aistr);
void dropString(String str);
-#endif // STRING_H_
+#endif // ENGINE_STRING_H_
-#ifndef TGA_H_
-#define TGA_H_
+#ifndef ENGINE_TGA_H_
+#define ENGINE_TGA_H_
#include <GL/gl.h>
TgaImage* readTga(const char* path);
-#endif // TGA_H_
+#endif // ENGINE_TGA_H_
-#ifndef UI_H_
-#define UI_H_
+#ifndef ENGINE_UI_H_
+#define ENGINE_UI_H_
#include <GL/gl.h>
void resizeStage(GLFWwindow* window, int width, int height);
-#endif // UI_H_
+#endif // ENGINE_UI_H_
#include "game.h"
-#include "engine/engine.h"
+#include "engine/input.h"
#include "input.h"
#include "level.h"
initPlayer();
startLevel();
- setKeyboardEventCallback(onKeyboardEvent);
+ setKeyboardInputCallback(keyboardInput);
}
void update(float delta) {
#include "input.h"
+#include <GLFW/glfw3.h>
+
#include "player.h"
-void onKeyboardEvent(GLFWwindow* window, int key, int scancode, int action, int mods) {
+void keyboardInput(int key, int scancode, int action, int mods) {
switch (key) {
case GLFW_KEY_W:
if (action == GLFW_PRESS) {
#ifndef INPUT_H_
#define INPUT_H_
-#include <GLFW/glfw3.h>
-
-void onKeyboardEvent(GLFWwindow* window, int key, int scancode, int action, int mods);
+void keyboardInput(int key, int scancode, int action, int mods);
#endif // INPUT_H_