// Copyright (c) 2021 Dominic Msters
// 
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT

#pragma once
#include <glad/gl.h>
#include <GLFW/glfw3.h>
#include <libs.h>
#include <display/render.h>
#include <game/game.h>
#include <input/input.h>

#define WINDOW_WIDTH_DEFAULT 1280
#define WINDOW_HEIGHT_DEFAULT WINDOW_WIDTH_DEFAULT/16*9

#define GLFW_PLATFORM_INPUT_MOUSE_X (inputsource_t)0xFF
#define GLFW_PLATFORM_INPUT_MOUSE_Y (inputsource_t)0xFE

/** The current running game state. */
extern game_t *GAME_STATE;

/** The GLFW Window Context Pointer */
extern GLFWwindow *window;

/**
 * Entry of the program
 * @return 0 if success, anything else for failure.
 */
int32_t main();

/**
 * Resize callbacks.
 * 
 * @param window Window that was resized.
 * @param width New window width.
 * @param height New window height.
 */
void glfwOnResize(GLFWwindow *window, int32_t width, int32_t height);

/**
 * Keyboard Input callbacks.
 * 
 * @param window Window that was resized.
 */
void glfwOnKey(GLFWwindow *window,
  int32_t key, int32_t scancode, int32_t action, int32_t mods
);


void glfwOnError(int error, const char* description);
void glfwOnCursor(GLFWwindow *window, double x, double y);


/**
 * Get the game engine specific input source for a given GLFW Key code.
 * 
 * @param key Key to get the input source for.
 * @return The input source. 
 */
inputsource_t glfwGetInputSourceForKey(int32_t key);