Trace Engine
A Raycaster Engine in C
Loading...
Searching...
No Matches
window_manager.c File Reference
#include "window_manager.h"
#include "log.h"
#include "pop_up_windows.h"
#include "graphics.h"
#include <stdbool.h>
#include "SDL.h"
#include "glad/glad.h"

Macros

#define SDL_MAIN_HANDLED
 
#define V_SYNC_OFF   0 /** Immediate update from frame to frame */
 
#define V_SYNC_ON   1 /** Updates synchronized with the vertical retrace */
 
#define V_SYNC_ADAPT   -1 /** Adaptive V-sync */
 
#define SDL_INIT_ENGINE   (SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_EVENTS)
 

Functions

bool init_GL (int window_width, int window_height)
 
void init_glad (SDL_Window *window)
 
void init_SLD (void)
 
void create_window (const char *title, const int width, const int height)
 
void update_window (void)
 
void swap_window_buffers (void)
 
void destroy_window (void)
 

Variables

SDL_Window * engine_window
 

Macro Definition Documentation

◆ SDL_INIT_ENGINE

#define SDL_INIT_ENGINE   (SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_EVENTS)

◆ SDL_MAIN_HANDLED

#define SDL_MAIN_HANDLED

◆ V_SYNC_ADAPT

#define V_SYNC_ADAPT   -1 /** Adaptive V-sync */

◆ V_SYNC_OFF

#define V_SYNC_OFF   0 /** Immediate update from frame to frame */

V-sync modes

◆ V_SYNC_ON

#define V_SYNC_ON   1 /** Updates synchronized with the vertical retrace */

Function Documentation

◆ create_window()

void create_window ( const char *  title,
const int  width,
const int  height 
)

Creates the window and the context for OpenGL

Parameters
titleThe title of the window, it'll show up in the upper section of the window
widthThe window width in pixels
heightThe window height in pixels

◆ destroy_window()

void destroy_window ( void  )

Calls every deleter function for the graphical stuff

◆ init_GL()

bool init_GL ( int  window_width,
int  window_height 
)

◆ init_glad()

void init_glad ( SDL_Window *  window)

◆ init_SLD()

void init_SLD ( void  )

◆ swap_window_buffers()

void swap_window_buffers ( void  )

Swaps the current frame with the one rendered, call it every time at the end of the main loop (when everything has been drawn)

◆ update_window()

void update_window ( void  )

Clears the previous frame and renders the next frame

Variable Documentation

◆ engine_window

SDL_Window* engine_window