2025-01-05 01:30:18 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <SDL2/SDL.h>
|
2025-01-06 18:32:22 +00:00
|
|
|
#include <string>
|
2025-01-05 02:41:40 +00:00
|
|
|
// Include the OpenGL headers (these may vary by system)
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
#include <OpenGL/gl3.h> // On macOS, <OpenGL/gl3.h> is often used
|
|
|
|
#else
|
|
|
|
#include <GL/glew.h> // or <glad/glad.h> if using GLAD
|
|
|
|
#endif
|
|
|
|
|
2025-01-06 18:32:22 +00:00
|
|
|
//#include <iostream>
|
2025-01-06 20:01:22 +00:00
|
|
|
#include <fstream>
|
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
2025-01-05 01:30:18 +00:00
|
|
|
|
|
|
|
// Forward declaration of classes and structs if needed
|
|
|
|
// class SomethingElse;
|
|
|
|
|
|
|
|
class SdlWindow {
|
|
|
|
public:
|
2025-01-06 18:32:22 +00:00
|
|
|
// Constructor
|
|
|
|
SdlWindow(const char* title, int width, int height);
|
2025-01-05 01:30:18 +00:00
|
|
|
|
2025-01-06 18:32:22 +00:00
|
|
|
// Destructor
|
|
|
|
~SdlWindow();
|
2025-01-05 01:30:18 +00:00
|
|
|
|
2025-01-06 18:32:22 +00:00
|
|
|
// Run the main loop
|
|
|
|
void run();
|
|
|
|
unsigned int compileShader(unsigned int type, const std::string& source);
|
|
|
|
unsigned int createShader(const std::string& vetexShader, const std::string& fragmentShader);
|
2025-01-06 20:01:22 +00:00
|
|
|
// for spliting our shaders
|
|
|
|
//struct ShaderProgramSource {
|
|
|
|
// std::string VetexSource, FragmentSource;
|
|
|
|
struct ShaderProgramSource {
|
|
|
|
std::string VertexSource;
|
|
|
|
std::string FragmentSource;
|
|
|
|
};
|
|
|
|
ShaderProgramSource parseShader(const std::string& filepath);
|
2025-01-05 01:30:18 +00:00
|
|
|
|
2025-01-06 18:32:22 +00:00
|
|
|
void setFullscreen(bool fullscreen);
|
2025-01-07 23:34:46 +00:00
|
|
|
void GLClearError();
|
|
|
|
bool GLLogCall();
|
|
|
|
|
2025-01-05 01:30:18 +00:00
|
|
|
|
|
|
|
private:
|
2025-01-06 18:32:22 +00:00
|
|
|
// Private data members
|
|
|
|
SDL_Window* m_window;
|
|
|
|
SDL_Renderer* m_renderer;
|
|
|
|
bool m_isRunning;
|
|
|
|
bool m_isFullscreen;
|
|
|
|
int m_width;
|
|
|
|
int m_height;
|
|
|
|
int m_windowedWidth; // stored width before fullscreen
|
|
|
|
int m_windowedHeight; // stored height before fullscreen
|
|
|
|
SDL_GLContext m_glContext;
|
|
|
|
// temp shader stuff
|
|
|
|
std::string vetexShader;
|
|
|
|
std::string fragmentShader;
|
|
|
|
unsigned int shader;
|
|
|
|
|
|
|
|
|
|
|
|
// Private methods
|
|
|
|
void processEvents();
|
|
|
|
void update();
|
|
|
|
void render();
|
2025-01-05 01:30:18 +00:00
|
|
|
};
|
|
|
|
|