33 lines
804 B
C++
33 lines
804 B
C++
#pragma once
|
|
|
|
#include <SDL3/SDL_rect.h>
|
|
#include <SDL3/SDL_render.h>
|
|
#include <SDL3/SDL_video.h>
|
|
#include <format>
|
|
#include <stdexcept>
|
|
#include <string_view>
|
|
|
|
class Graphics {
|
|
public:
|
|
Graphics(std::string_view title){
|
|
// TODO Don't hardcode resolution
|
|
if (!SDL_CreateWindowAndRenderer(title.data(), 2560, 1440, SDL_WINDOW_FULLSCREEN, &window, &renderer)) {
|
|
throw std::runtime_error(std::format("Couldn't create window and renderer: {}", SDL_GetError()));
|
|
}
|
|
}
|
|
|
|
void drawRect(SDL_FRect const& rect, SDL_Color const& color) {
|
|
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);
|
|
SDL_RenderFillRect(renderer, &rect);
|
|
}
|
|
|
|
void show() {
|
|
SDL_RenderPresent(renderer);
|
|
}
|
|
|
|
private:
|
|
SDL_Renderer *renderer = nullptr;
|
|
SDL_Window *window = nullptr;
|
|
};
|
|
|