-
Notifications
You must be signed in to change notification settings - Fork 0
Window system
A simple window system.
You can have only 1 window.
- glad (c/c++, opengl 3.3, core profile, generate loader)
- glfw 3.2.1
automata_const.h
automata_input.h
The window system uses glad as OpenGL loader.
The window has an OpenGL context. The OpenGL version of this context is defined in automata_const.h
:
#define AUTOMATA_OPENGL_VERSION_MAJOR 3
#define AUTOMATA_OPENGL_VERSION_MINOR 3
All window structs and functions are defined in automata_window.h
.
struct AutomataWindow {
GLFWwindow *window;
unsigned int width;
unsigned int height;
const char *title;
AutomataWindowMode mode;
};
Internal use only.
The window structure.
window
: the GLFW window.
width
: the window width.
height
: the window height.
title
: the window title.
void automataWindowInit()
Initializes the window system.
void automataWindowCreate(unsigned int width, unsigned int height, const char *title)
Creates the window.
width
: the window width.
height
: the window height.
title
: the window title.
void automataWindowClose()
Closes the window.
void automataWindowTerminate();
Terminates the window system.
int automataWindowIsAlive()
Returns if the window is alive.
void automataWindowUpdate()
Updates the window.
unsigned int automataWindowGetWidth()
Returns the current window width.
unsigned int automataWindowGetHeight()
Returns the current window height.
const char *automataWindowGetTitle()
Returns the current window title.
AutomataWindowMode automataWindowGetMode()
Returns the window mode.
void automataWindowSetTitle(const char *title)
Changes the window title.
title
: the new window title
void automataWindowSetSize(unsigned int width, unsigned int height)
Resizes the window.
width
: the new window width.
height
: the new window height.
void automataWindowSetMode(AutomataWindowMode mode)
Sets the window mode.
mode
: the window mode. If it is an invalid value, it is set to AUTOMATA_WINDOW_MODE_UNKNOWN
.
void automataWindowCallbackResize(GLFWwindow* glfwWindow, int width, int height)
Internal use only. Called when a window is resized.
#include <stdio.h>
#include <stdlib.h>
#include "automata_const.h"
#include "automata_window.h"
int main() {
/* intialize application */
automataWindowInit();
automataWindowCreate(1280, 720, "Automata Engine");
/* application loop */
while (automataWindowIsAlive()) {
automataWindowUpdate();
}
/* terminate application */
automataWindowTerminate();
return EXIT_SUCCESS;
}
Creates and updates the window until it needs to close.