Skip to content

Instantly share code, notes, and snippets.

@freedmo
Created May 21, 2015 20:44
Show Gist options
  • Save freedmo/4f6d2e8f35a03489e668 to your computer and use it in GitHub Desktop.
Save freedmo/4f6d2e8f35a03489e668 to your computer and use it in GitHub Desktop.
#ifndef APPLICATION_H
#define APPLICATION_H
#include <iostream>
#include <cstdlib>
#include <GLFW/glfw3.h>
using namespace std;
class Application
{
private:
int argc;
char *argv[];
//GLFW Variables
GLFWwindow* WINDOW;
char* TITLE;
int HEIGHT, WIDTH;
float RATIO;
bool FULLSCREEN;
//Draw Pointer
void ( *PTR_Draw ) ( int, int, float );
//Input Pointer
void ( *PTR_Mousebutton ) ( GLFWwindow*, int , int , int );
void ( *PTR_Cursor ) ( GLFWwindow* , double , double );
void ( *PTR_Focus ) ( GLFWwindow * , int );
void ( *PTR_Scroll ) ( GLFWwindow* , double , double );
void ( *PTR_Key ) ( GLFWwindow* , int , int , int , int );
void ( *PTR_Key_Unicode ) ( GLFWwindow* , unsigned int );
//Error Pointer
void ( *PTR_ERROR ) ( int, const char* );
//Routine Pointer
void ( *PTR_Position ) ( GLFWwindow* , int , int );
void ( *PTR_Resize ) ( GLFWwindow*, int , int );
void ( *PTR_WindowClose ) ( GLFWwindow* );
void ( *PTR_Refresh ) ( GLFWwindow* );
void ( *PTR_FocusW ) ( GLFWwindow* , int );
void ( *PTR_Iconify ) ( GLFWwindow* , int );
void ( *PTR_Framebuffer ) ( GLFWwindow* , int, int );
public:
Application();
Application ( char*, int, int, bool );
void Init();
bool ToggleFullscreen();
void Loop();
virtual ~Application();
//Mouse Stuff
void MouseCoordinates(double* x, double* y){
glfwGetCursorPos(WINDOW, x, y);
};
//Draw PTR
inline void Draw ( void ( *F ) ( int, int, float ) ){
PTR_Draw = F;
};
//Input Callbacks
inline void Callback_Mousebutton ( void ( *F ) ( GLFWwindow*, int, int, int ) )
{
PTR_Mousebutton = F;
};
inline void Callback_Cursor ( void ( *F ) ( GLFWwindow*, double, double ) )
{
PTR_Cursor = F;
};
inline void Callback_Focus ( void ( *F ) ( GLFWwindow *, int ) )
{
PTR_Focus = F;
};
inline void Callback_Scroll ( void ( *F ) ( GLFWwindow*, double, double ) )
{
PTR_Scroll = F;
};
inline void Callback_Key ( void ( *F ) ( GLFWwindow*, int, int, int, int ) )
{
PTR_Key = F;
};
inline void Callback_Key_Unicode ( void ( *F ) ( GLFWwindow*, unsigned int ) )
{
PTR_Key_Unicode = F;
};
//Error Callback
inline void Callback_Error ( void ( *F ) ( int, const char* ) )
{
PTR_ERROR = F;
};
//Routine Callbacks
inline void Window_Framebuffer ( void ( *F ) ( GLFWwindow*, int, int ) )
{
PTR_Framebuffer = F;
};
inline void Window_WindowClose ( void ( *F ) ( GLFWwindow* ) )
{
PTR_WindowClose = F;
};
inline void Window_Focus ( void ( *F ) ( GLFWwindow*, int ) )
{
PTR_FocusW = F;
};
inline void Window_Iconify ( void ( *F ) ( GLFWwindow*, int ) )
{
PTR_Iconify = F;
};
inline void Window_Position ( void ( *F ) ( GLFWwindow*, int, int ) )
{
PTR_Position = F;
};
inline void Window_Refresh ( void ( *F ) ( GLFWwindow* ) )
{
PTR_Refresh = F;
};
inline void Window_Resize ( void ( *F ) ( GLFWwindow*, int, int ) )
{
PTR_Resize = F;
};
protected:
};
#endif // APPLICATION_H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment