added window class, may implement in future

This commit is contained in:
Solomon W. 2020-05-28 15:27:57 -04:00
parent 540d4d3448
commit 0b3e1c4be0
2 changed files with 44 additions and 0 deletions

30
src/Window.cpp Normal file
View File

@ -0,0 +1,30 @@
#include "Window.h"
int Window::setClearColor(Color c) {
clearColor = &c;
}
int Window::setClearColor(uint8_t r,Uint8 g,Uint8 b,Uint8 a) {
clearColor[0].r = r;
clearColor[0].g = g;
clearColor[0].b = b;
clearColor[0].a = a;
}
int Window::initUI() {
if(SDL_Init(SDL_INIT_EVERYTHING) != 0) {
fprintf(stderr,"\033[92m[ ERROR ] Could not initialize SDL:\n%s\n", SDL_GetError());
}
win = SDL_CreateWindow("Simple Rigid Sim",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
500,
500,
0
);
rend = SDL_CreateRenderer(win,
-1,
SDL_RENDERER_ACCELERATED
);
}

14
src/Window.h Normal file
View File

@ -0,0 +1,14 @@
#include <SDL2/SDL.h>
#include <SDL2/SDL_timer.h>
#include "Color.h"
class Window {
public:
Color *clearColor = new Color(BLACK);
SDL_Window *win;
SDL_Renderer *rend;
virtual int update() {};
int initUI() {};
int setClearColor(Color c) {};
int setClearColor(Uint8 r,Uint8 g,Uint8 b,Uint8 a) {};
};