-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphics.cpp
More file actions
37 lines (29 loc) · 884 Bytes
/
Copy pathGraphics.cpp
File metadata and controls
37 lines (29 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <SDL.h>
#include <SDL_image.h>
#include "Graphics.h"
#include "Globals.h"
Graphics::Graphics() {
SDL_CreateWindowAndRenderer(globals::SCREEN_WIDTH, globals::SCREEN_HEIGHT, 0, &_window, &_renderer);
SDL_SetWindowTitle(_window, "Cavestory");
}
Graphics::~Graphics() {
SDL_DestroyWindow(_window);
}
SDL_Surface* Graphics::loadImage(const std::string& filePath) {
if (_spriteSheets.count(filePath) == 0) {
_spriteSheets[filePath] = IMG_Load(filePath.c_str());
}
return _spriteSheets[filePath];
}
void Graphics::blitSurface(SDL_Texture* texture, SDL_Rect* sourceRectangle, SDL_Rect* destinationRectangle) {
SDL_RenderCopy(_renderer, texture, sourceRectangle, destinationRectangle);
}
void Graphics::flip() {
SDL_RenderPresent(_renderer);
}
void Graphics::clear() {
SDL_RenderClear(_renderer);
}
SDL_Renderer* Graphics::getRenderer() const {
return _renderer;
}