From: Jesse Date: Wed, 16 Jun 2021 02:44:59 +0000 (-0400) Subject: merge X-Git-Url: https://repo.jachan.dev/raytracer.git/commitdiff_plain/710ba2323f354dcdad0b2c25531c11edc953b288 merge --- 710ba2323f354dcdad0b2c25531c11edc953b288 diff --cc main.cpp index 1199ec4,a4e828f..a291648 --- a/main.cpp +++ b/main.cpp @@@ -6,7 -6,13 +6,8 @@@ #include "objects.h" #include "raytrace.h" #include "vector.h" + #include "stl.h" SDL_Event event; -struct rgb { - char r; - char g; - char b; -}; rgb colorC(const color c) { rgb colors; char * arr = (char*)&colors; diff --cc sdl_funcs.h index b0296bd,4c62820..ef29f56 --- a/sdl_funcs.h +++ b/sdl_funcs.h @@@ -8,27 -8,5 +8,28 @@@ void sdl_free() void sdl_frame(); char * sdl_pixels_lock(); void sdl_pixels_unlock(); + +struct rgb { + char r; + char g; + char b; +}; + +class frame{ + public: + size_t height; + size_t width; + rgb *framebuffer; + frame(size_t height_, size_t width_){ + framebuffer = (rgb*)sdl_pixels_lock(); + height = height_; + width = width_; + } + ~frame(){ + sdl_pixels_unlock(); + } + rgb* operator[](const size_t h) {return framebuffer+h*width; } + const rgb* operator[](const size_t h) const {return framebuffer+h*width; } +}; + void sdl_text(char * str); #endif //__SDL_FUNC_H__