This commit is contained in:
2025-07-12 02:12:46 +01:00
parent 233cfdc356
commit ce44dfc950
10 changed files with 421 additions and 170 deletions

45
include/graphics.hpp Normal file
View File

@@ -0,0 +1,45 @@
#ifndef GRAPHICS_HPP
#define GRAPHICS_HPP
#define GL_GLEXT_PROTOTYPES
// Includes
#include "imgui.h"
#include "imgui_impl_sdl3.h"
#include "imgui_impl_opengl3.h"
#include <SDL3/SDL_opengl.h>
#include "window.hpp"
// Constants
const int open_gl_major_version = 3;
const int open_gl_minor_version = 3;
const int enable_vsync = 1;
// Variables
extern Uint32 last_time;
extern Uint32 current_time;
extern float frame_time;
extern float fps;
extern float frame_time_graph[100];
extern SDL_GLContext gl_context;
extern ImGuiIO& io;
extern ImGuiStyle& style;
// Functions
int initialize_opengl();
void cleanup_opengl();
// ImGui
int initialize_imgui();
void cleanup_imgui();
void new_frame_imgui();
void frame_time_ui();
// Frame time calculation
void calc_frame_time();
// Shader management
unsigned int compile_shader(const char* shader_source, GLenum shader_type);
unsigned int create_program(unsigned int vertex_shader, unsigned int fragment_shader);
#endif

View File

@@ -1,44 +1,16 @@
#ifndef MAIN_HPP
#define MAIN_HPP
// ImGui
#include "imgui.h"
#include "imgui_impl_sdl3.h"
#include "imgui_impl_opengl3.h"
// SDL3 and OpenGL
#include <SDL3/SDL.h>
#include <SDL3/SDL_opengl.h>
// C++ Standard Library
// Includes
#include <iostream>
#include <string>
#include <vector>
// Structs
#include "window.hpp"
#include "graphics.hpp"
#include "utils.hpp"
// Variables
int window_width = 1920;
int window_height = 1080;
float main_scale;
SDL_WindowFlags window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
SDL_Window* window;
bool running;
SDL_Event event;
Uint32 last_time;
Uint32 current_time;
float frame_time;
float fps;
float frame_time_graph[100] = {0.0f};
extern bool running;
// Functions
int main(int argc, char* argv[]);
int initialize();
void cleanup();
#endif

11
include/utils.hpp Normal file
View File

@@ -0,0 +1,11 @@
#ifndef UTILS_HPP
#define UTILS_HPP
// Includes
#include <fstream>
#include <iostream>
// Function
char* read_file(const char* file_path);
#endif

22
include/window.hpp Normal file
View File

@@ -0,0 +1,22 @@
#ifndef WINDOW_HPP
#define WINDOW_HPP
// Includes
#include "iostream"
#include <SDL3/SDL.h>
// Constants
const int window_width = 800;
const int window_height = 600;
// Variables
const SDL_WindowFlags window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
extern float main_scale;
extern SDL_Window* window;
extern SDL_Event event;
// Functions
int initialize_sdl();
void cleanup_sdl();
#endif