aboutsummaryrefslogtreecommitdiff
path: root/graphics/graphics.h
diff options
context:
space:
mode:
authorjacopograndi <jak.sk8@hotmail.it>2021-08-19 18:46:51 +0200
committerjacopograndi <jak.sk8@hotmail.it>2021-08-19 18:46:51 +0200
commita8bcacc95045102e67f2feabbdddf79535837554 (patch)
tree5781dd4cb2fe66b67deab84ff4641b7e21b9c174 /graphics/graphics.h
forgot to make repo until now
Diffstat (limited to 'graphics/graphics.h')
-rw-r--r--graphics/graphics.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/graphics/graphics.h b/graphics/graphics.h
new file mode 100644
index 0000000..6b36cbd
--- /dev/null
+++ b/graphics/graphics.h
@@ -0,0 +1,70 @@
+#ifndef GRAPHICS_H
+#define GRAPHICS_H
+
+#include <vector>
+#include <string>
+
+#define SDL_MAIN_HANDLED
+#include <SDL2/SDL.h>
+
+#include "../game/gst.h"
+#include "../game/view.h"
+#include "cam.h"
+
+#include <string>
+
+
+class Graphics_sdl_text {
+ public:
+ Graphics_sdl_text();
+ int get_text_width (char str[]);
+ void render_text (std::string str, vec2 off);
+ SDL_Renderer* gRenderer;
+ SDL_Texture *tex;
+ int char_width[128];
+};
+
+class Graphics_sdl {
+ public:
+ Graphics_sdl (int resx, int resy);
+ ~Graphics_sdl ();
+ SDL_Renderer* get_renderer ();
+ void load_sheet ();
+ void present ();
+ void render_sprite (
+ int x, int y, int w, int h,
+ int u, int v, int s, int t);
+ void render_rect (
+ int r, int g, int b, int a,
+ int x, int y, int w, int h);
+ void render_sprite (
+ int x, int y, int w, int h,
+ int u, int v, int s, int t,
+ int r, int g, int b);
+
+ Graphics_sdl_text txt;
+
+ private:
+ SDL_Window* window = NULL;
+ SDL_Surface* screenSurface = NULL;
+ SDL_Renderer* rend = NULL;
+ SDL_Texture* txsprites = NULL;
+};
+
+
+class Graphics {
+ public:
+ Graphics (int resx, int resy)
+ : resx(resx), resy(resy), backend(resx, resy) {}
+ ~Graphics ();
+
+ Graphics_sdl backend;
+
+ int resx, resy;
+ Cam cam;
+
+ void render (Gst &gst, View &view);
+ void present ();
+};
+
+#endif \ No newline at end of file