sdl and opengl contexts
This commit is contained in:
28
inc/engine/opengl.hpp
Normal file
28
inc/engine/opengl.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef OPENGL_HPP
|
||||
#define OPENGL_HPP
|
||||
|
||||
// Includes
|
||||
#include <SDL3/SDL_opengl.h>
|
||||
#include "engine/sdl.hpp"
|
||||
|
||||
// OpenGL Context Class
|
||||
class OpenGLContext {
|
||||
public:
|
||||
OpenGLContext(SDLWindow& window);
|
||||
~OpenGLContext();
|
||||
|
||||
bool isInitialized() const;
|
||||
void makeCurrent();
|
||||
void swapBuffers();
|
||||
float getFrameTime();
|
||||
|
||||
private:
|
||||
SDLWindow& window;
|
||||
SDL_GLContext glContext;
|
||||
|
||||
Uint32 lastTime;
|
||||
float frameTime;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
28
inc/engine/sdl.hpp
Normal file
28
inc/engine/sdl.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef SDL_HPP
|
||||
#define SDL_HPP
|
||||
|
||||
// Includes
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
// Classes
|
||||
class SDLWindow {
|
||||
public:
|
||||
SDLWindow(const char* title, int width, int height, SDL_WindowFlags flags = SDL_WINDOW_OPENGL | SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_HIDDEN);
|
||||
~SDLWindow();
|
||||
|
||||
void setEventCallback(void (*callback)(const SDL_Event&));
|
||||
void pollEvents();
|
||||
bool isRunning() const;
|
||||
void showWindow();
|
||||
void hideWindow();
|
||||
void setPosition(int x, int y);
|
||||
SDL_Window* getSDLWindow() const;
|
||||
|
||||
private:
|
||||
SDL_Window* window;
|
||||
SDL_Event event;
|
||||
bool running;
|
||||
void (*eventCallback)(const SDL_Event&) = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user