more component stuff
This commit is contained in:
@@ -1,8 +1,32 @@
|
||||
#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(){}
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user