aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/build.sh7
-rw-r--r--src/crepe/SdlContext.cpp213
-rw-r--r--src/crepe/SdlContext.h43
-rw-r--r--src/crepe/Sound.cpp60
-rw-r--r--src/crepe/Sound.h82
-rw-r--r--src/crepe/SoundContext.cpp20
-rw-r--r--src/crepe/SoundContext.h26
-rw-r--r--src/crepe/api/AssetManager.cpp25
-rw-r--r--src/crepe/api/AssetManager.h57
-rw-r--r--src/crepe/api/AudioSource.cpp2
-rw-r--r--src/crepe/api/CMakeLists.txt1
-rw-r--r--src/crepe/api/Color.cpp53
-rw-r--r--src/crepe/api/Color.h34
-rw-r--r--src/crepe/api/Point.h14
-rw-r--r--src/crepe/api/Sprite.h28
-rw-r--r--src/crepe/api/Texture.cpp39
-rw-r--r--src/crepe/api/Texture.h31
-rw-r--r--src/crepe/api/Transform.h13
-rw-r--r--src/crepe/renderSystem.cpp37
-rw-r--r--src/crepe/renderSystem.h13
-rw-r--r--src/dummy_rendering.cpp19
-rw-r--r--src/dummy_resource_manager.cpp38
22 files changed, 665 insertions, 190 deletions
diff --git a/src/build.sh b/src/build.sh
new file mode 100755
index 0000000..e987bc1
--- /dev/null
+++ b/src/build.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+# creates the build dir and runs CMake with Ninja
+cmake -B build -G Ninja
+
+# build the project
+cmake --build build \ No newline at end of file
diff --git a/src/crepe/SdlContext.cpp b/src/crepe/SdlContext.cpp
new file mode 100644
index 0000000..44d1bdf
--- /dev/null
+++ b/src/crepe/SdlContext.cpp
@@ -0,0 +1,213 @@
+
+
+#include "SdlContext.h"
+#include "SDL_hints.h"
+#include "SDL_rect.h"
+#include "SDL_stdinc.h"
+#include "api/Sprite.h"
+#include "api/Transform.h"
+#include "facade/Texture.h"
+#include "util/log.h"
+#include <SDL2/SDL.h>
+#include <SDL2/SDL_image.h>
+#include <SDL2/SDL_render.h>
+#include <SDL2/SDL_surface.h>
+#include <SDL2/SDL_video.h>
+#include <cstddef>
+#include <iostream>
+#include <ostream>
+
+using namespace crepe;
+
+SdlContext & SdlContext::get_instance() {
+ static SdlContext instance;
+ return instance;
+}
+
+void SdlContext::handleEvents(bool & running) {
+ SDL_Event event;
+ while (SDL_PollEvent(&event)) {
+ if (event.type == SDL_QUIT) {
+ running = false;
+ }
+ }
+}
+void SdlContext::clearScreen() { SDL_RenderClear(this->m_game_renderer); }
+
+void SdlContext::presentScreen() { SDL_RenderPresent(this->m_game_renderer); }
+
+void SdlContext::draw(const api::Sprite & sprite,
+ const api::Transform & transform) {
+ static SDL_RendererFlip renderFlip
+ = (SDL_RendererFlip) ((SDL_FLIP_HORIZONTAL * sprite.flip.flipX)
+ | (SDL_FLIP_VERTICAL * sprite.flip.flipY));
+
+ // needs maybe camera for position
+ static SDL_Rect dstrect = {
+ .x = static_cast<int>(transform.position.x),
+ .y = static_cast<int>(transform.position.y),
+ .w
+ = static_cast<int>(sprite.sprite_image->get_rect().w * transform.scale),
+ .h
+ = static_cast<int>(sprite.sprite_image->get_rect().h * transform.scale),
+ };
+
+ SDL_RenderCopyEx(this->m_game_renderer, sprite.sprite_image->get_texture(),
+ &sprite.sprite_image->get_rect(), &dstrect, 0, NULL,
+ renderFlip);
+}
+
+SdlContext::SdlContext() {
+ if (SDL_Init(SDL_INIT_VIDEO) < 0) {
+ std::cerr << "SDL could not initialize! SDL_Error: " << SDL_GetError()
+ << std::endl;
+ return;
+ }
+
+ m_game_window = SDL_CreateWindow(
+ "Crepe Game Engine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
+ 1920, 1080, SDL_WINDOW_SHOWN);
+ if (!m_game_window) {
+ std::cerr << "Window could not be created! SDL_Error: "
+ << SDL_GetError() << std::endl;
+ }
+
+ m_game_renderer
+ = SDL_CreateRenderer(m_game_window, -1, SDL_RENDERER_ACCELERATED);
+ if (!m_game_renderer) {
+ std::cerr << "Renderer could not be created! SDL_Error: "
+ << SDL_GetError() << std::endl;
+ SDL_DestroyWindow(m_game_window);
+ return;
+ }
+ int imgFlags = IMG_INIT_PNG;
+ if (!(IMG_Init(imgFlags) & imgFlags)) {
+ std::cout << "SDL_image could not initialize! SDL_image Error: "
+ << IMG_GetError() << std::endl;
+ }
+
+ SDL_SetHint(SDL_HINT_RENDER_BATCHING, "1");
+ SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
+ //SDL_SetHint(SDL_HINT_RENDER_OPENGL_SHADERS, "1");
+ SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "X");
+
+
+
+
+ const char * hint = SDL_GetHint(SDL_HINT_RENDER_BATCHING);
+ if (hint != NULL) {
+ std::cout << "SDL_HINT_RENDER_BATCHING: " << hint << std::endl;
+ }
+
+ hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER);
+ if (hint != NULL) {
+ std::cout << "SDL_HINT_RENDER_DRIVER: " << hint << std::endl;
+ }
+
+ hint = SDL_GetHint(SDL_HINT_RENDER_OPENGL_SHADERS);
+ if (hint != NULL) {
+ std::cout << "SDL_HINT_RENDER_OPENGL_SHADERS: " << hint << std::endl;
+ }
+
+ hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
+ if (hint != NULL) {
+ std::cout << "SDL_HINT_RENDER_SCALE_QUALITY: " << hint << std::endl;
+ }
+
+ hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
+ if (hint != NULL) {
+ std::cout << "SDL_HINT_RENDER_VSYNC: " << hint << std::endl;
+ }
+
+ hint = SDL_GetHint(SDL_HINT_TIMER_RESOLUTION);
+ if (hint != NULL) {
+ std::cout << "SDL_HINT_TIMER_RESOLUTION: " << hint << std::endl;
+ }
+
+ hint = SDL_GetHint(SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT);
+ if (hint != NULL) {
+ std::cout << "SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT: " << hint
+ << std::endl;
+ }
+
+ hint = SDL_GetHint(SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN);
+ if (hint != NULL) {
+ std::cout << "SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN: "
+ << hint << std::endl;
+ }
+
+ hint = SDL_GetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE);
+ if (hint != NULL) {
+ std::cout << "SDL_HINT_RENDER_LOGICAL_SIZE_MODE: " << hint << std::endl;
+ }
+
+ hint = SDL_GetHint(SDL_HINT_VIDEO_DOUBLE_BUFFER);
+ if (hint != NULL) {
+ std::cout << "SDL_HINT_VIDEO_DOUBLE_BUFFER: " << hint << std::endl;
+ }
+
+ hint = SDL_GetHint(SDL_HINT_OPENGL_ES_DRIVER);
+ if (hint != NULL) {
+ std::cout << "SDL_HINT_OPENGL_ES_DRIVER: " << hint << std::endl;
+ }
+
+ hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
+ if (hint != NULL) {
+ std::cout << "SDL_HINT_FRAMEBUFFER_ACCELERATION: " << hint << std::endl;
+ }
+
+ std::cout << "HALLO " << std::endl;
+}
+
+SdlContext::~SdlContext() {
+ if (m_game_renderer) SDL_DestroyRenderer(m_game_renderer);
+
+ if (m_game_window) {
+ SDL_DestroyWindow(m_game_window);
+ }
+ IMG_Quit();
+ SDL_Quit();
+}
+
+SDL_Texture * SdlContext::setTextureFromPath(const char * path, SDL_Rect & clip,
+ const int row, const int col) {
+ dbg_trace();
+
+ SDL_Surface * tmp = IMG_Load(path);
+ if (!tmp) {
+ std::cerr << "Error surface " << IMG_GetError << std::endl;
+ }
+
+ clip.w = tmp->w / col;
+ clip.h = tmp->h / row;
+
+ SDL_Texture * CreatedTexture
+ = SDL_CreateTextureFromSurface(m_game_renderer, tmp);
+
+ if (!CreatedTexture) {
+ std::cerr << "Error could not create texture " << IMG_GetError
+ << std::endl;
+ }
+ SDL_FreeSurface(tmp);
+
+ return CreatedTexture;
+}
+
+SDL_Texture * SdlContext::setTextureFromPath(const char * path) {
+ dbg_trace();
+
+ SDL_Surface * tmp = IMG_Load(path);
+ if (!tmp) {
+ std::cerr << "Error surface " << IMG_GetError << std::endl;
+ }
+ SDL_Texture * CreatedTexture
+ = SDL_CreateTextureFromSurface(m_game_renderer, tmp);
+
+ if (!CreatedTexture) {
+ std::cerr << "Error could not create texture " << IMG_GetError
+ << std::endl;
+ }
+ SDL_FreeSurface(tmp);
+
+ return CreatedTexture;
+}
diff --git a/src/crepe/SdlContext.h b/src/crepe/SdlContext.h
new file mode 100644
index 0000000..c8f1304
--- /dev/null
+++ b/src/crepe/SdlContext.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#include "SDL_rect.h"
+#include "api/Sprite.h"
+#include "api/Transform.h"
+#include <SDL2/SDL_render.h>
+#include <SDL2/SDL_video.h>
+
+namespace crepe {
+
+
+class SdlContext {
+
+public:
+
+ void handleEvents(bool& running);
+ void clearScreen();
+ void presentScreen();
+ void draw(const api::Sprite&, const api::Transform&);
+
+ // singleton
+ static SdlContext & get_instance();
+ SDL_Texture* setTextureFromPath(const char*);
+ SDL_Texture* setTextureFromPath(const char*, SDL_Rect& clip, const int row, const int col);
+
+private:
+ SdlContext();
+ virtual ~SdlContext();
+
+ SdlContext(const SdlContext &) = delete;
+ SdlContext(SdlContext &&) = delete;
+ SdlContext & operator=(const SdlContext &) = delete;
+ SdlContext & operator=(SdlContext &&) = delete;
+
+
+private:
+
+ SDL_Window* m_game_window;
+ SDL_Renderer* m_game_renderer;
+};
+
+} //
+
diff --git a/src/crepe/Sound.cpp b/src/crepe/Sound.cpp
deleted file mode 100644
index 64fa281..0000000
--- a/src/crepe/Sound.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-#include "util/log.h"
-
-#include "Sound.h"
-#include "SoundContext.h"
-
-using namespace crepe;
-
-Sound::Sound(std::unique_ptr<Asset> res) {
- dbg_trace();
- this->load(std::move(res));
-}
-
-Sound::Sound(const char * src) {
- dbg_trace();
- this->load(std::make_unique<Asset>(src));
-}
-
-void Sound::load(std::unique_ptr<Asset> res) {
- this->sample.load(res->canonical());
-}
-
-void Sound::play() {
- SoundContext & ctx = SoundContext::get_instance();
- if (ctx.engine.getPause(this->handle)) {
- // resume if paused
- ctx.engine.setPause(this->handle, false);
- } else {
- // or start new sound
- this->handle = ctx.engine.play(this->sample, this->volume);
- ctx.engine.setLooping(this->handle, this->looping);
- }
-}
-
-void Sound::pause() {
- SoundContext & ctx = SoundContext::get_instance();
- if (ctx.engine.getPause(this->handle)) return;
- ctx.engine.setPause(this->handle, true);
-}
-
-void Sound::rewind() {
- SoundContext & ctx = SoundContext::get_instance();
- if (!ctx.engine.isValidVoiceHandle(this->handle)) return;
- ctx.engine.seek(this->handle, 0);
-}
-
-void Sound::set_volume(float volume) {
- this->volume = volume;
-
- SoundContext & ctx = SoundContext::get_instance();
- if (!ctx.engine.isValidVoiceHandle(this->handle)) return;
- ctx.engine.setVolume(this->handle, this->volume);
-}
-
-void Sound::set_looping(bool looping) {
- this->looping = looping;
-
- SoundContext & ctx = SoundContext::get_instance();
- if (!ctx.engine.isValidVoiceHandle(this->handle)) return;
- ctx.engine.setLooping(this->handle, this->looping);
-}
diff --git a/src/crepe/Sound.h b/src/crepe/Sound.h
deleted file mode 100644
index b7cfbb8..0000000
--- a/src/crepe/Sound.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#pragma once
-
-#include <soloud/soloud.h>
-#include <soloud/soloud_wav.h>
-
-#include <memory>
-
-#include "Asset.h"
-
-namespace crepe {
-
-class Sound {
-public:
- /**
- * \brief Pause this sample
- *
- * Pauses this sound if it is playing, or does nothing if it is already
- * paused. The playhead position is saved, such that calling \c play() after
- * this function makes the sound resume.
- */
- void pause();
- /**
- * \brief Play this sample
- *
- * Resume playback if this sound is paused, or start from the beginning of
- * the sample.
- *
- * \note This class only saves a reference to the most recent 'voice' of this
- * sound. Calling \c play() while the sound is already playing causes
- * multiple instances of the sample to play simultaniously. The sample
- * started last is the one that is controlled afterwards.
- */
- void play();
- /**
- * \brief Reset playhead position
- *
- * Resets the playhead position so that calling \c play() after this function
- * makes it play from the start of the sample. If the sound is not paused
- * before calling this function, this function will stop playback.
- */
- void rewind();
- /**
- * \brief Set playback volume / gain
- *
- * \param volume Volume (0 = muted, 1 = full volume)
- */
- void set_volume(float volume);
- /**
- * \brief Get playback volume / gain
- *
- * \return Volume
- */
- float get_volume() const { return this->volume; }
- /**
- * \brief Set looping behavior for this sample
- *
- * \param looping Looping behavior (false = one-shot, true = loop)
- */
- void set_looping(bool looping);
- /**
- * \brief Get looping behavior
- *
- * \return true if looping, false if one-shot
- */
- bool get_looping() const { return this->looping; }
-
-public:
- Sound(const char * src);
- Sound(std::unique_ptr<Asset> res);
-
-private:
- void load(std::unique_ptr<Asset> res);
-
-private:
- SoLoud::Wav sample;
- SoLoud::handle handle;
-
- float volume = 1.0f;
- bool looping = false;
-};
-
-} // namespace crepe
diff --git a/src/crepe/SoundContext.cpp b/src/crepe/SoundContext.cpp
deleted file mode 100644
index 72047d2..0000000
--- a/src/crepe/SoundContext.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "util/log.h"
-
-#include "SoundContext.h"
-
-using namespace crepe;
-
-SoundContext & SoundContext::get_instance() {
- static SoundContext instance;
- return instance;
-}
-
-SoundContext::SoundContext() {
- dbg_trace();
- engine.init();
-}
-
-SoundContext::~SoundContext() {
- dbg_trace();
- engine.deinit();
-}
diff --git a/src/crepe/SoundContext.h b/src/crepe/SoundContext.h
deleted file mode 100644
index d3123d2..0000000
--- a/src/crepe/SoundContext.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-
-#include <soloud/soloud.h>
-
-#include "Sound.h"
-
-namespace crepe {
-
-class SoundContext {
-private:
- SoundContext();
- virtual ~SoundContext();
-
- // singleton
- static SoundContext & get_instance();
- SoundContext(const SoundContext &) = delete;
- SoundContext(SoundContext &&) = delete;
- SoundContext & operator=(const SoundContext &) = delete;
- SoundContext & operator=(SoundContext &&) = delete;
-
-private:
- SoLoud::Soloud engine;
- friend class Sound;
-};
-
-} // namespace crepe
diff --git a/src/crepe/api/AssetManager.cpp b/src/crepe/api/AssetManager.cpp
new file mode 100644
index 0000000..0ecdae5
--- /dev/null
+++ b/src/crepe/api/AssetManager.cpp
@@ -0,0 +1,25 @@
+
+
+#include "resource_manager.h"
+#include <string>
+#include <unordered_map>
+
+using namespace crepe::api;
+
+ResourceManager& ResourceManager::get_instance(){
+ static ResourceManager instance;
+ return instance;
+}
+
+
+ResourceManager::~ResourceManager(){
+ m_resources.clear();
+}
+
+
+void ResourceManager::Unload(const std::string& file_path){
+ if(m_resources.find(file_path) != m_resources.end()){
+ m_resources.erase(file_path);
+ }
+}
+
diff --git a/src/crepe/api/AssetManager.h b/src/crepe/api/AssetManager.h
new file mode 100644
index 0000000..a646d95
--- /dev/null
+++ b/src/crepe/api/AssetManager.h
@@ -0,0 +1,57 @@
+#pragma once
+
+
+
+#include <memory>
+#include <string>
+#include <unordered_map>
+#include <utility>
+
+#include "api/baseResource.h"
+
+
+namespace crepe::api{
+
+class ResourceManager{
+
+
+private:
+
+ std::unordered_map< std::string, std::unique_ptr<BaseResource>> m_resources;
+
+
+protected:
+ ResourceManager() = default;
+ ~ResourceManager();
+
+public:
+ ResourceManager(const ResourceManager &) = delete;
+ ResourceManager(ResourceManager &&) = delete;
+ ResourceManager &operator=(const ResourceManager &) = delete;
+ ResourceManager &operator=(ResourceManager &&) = delete;
+
+ static ResourceManager& get_instance();
+
+
+
+public:
+ template<typename T>
+ T* Load(const std::string& file_path){
+
+ if (m_resources.find(file_path) != m_resources.end()) {
+ return static_cast<T*>(m_resources[file_path].get());
+ }
+
+ auto resource = std::make_unique<T>(file_path.c_str());
+ if (resource) {
+ m_resources[file_path] = std::move(resource);
+ return static_cast<T*>(m_resources[file_path].get() );
+ }
+
+ return nullptr;
+ }
+
+ void Unload(const std::string& file_path);
+
+};
+}
diff --git a/src/crepe/api/AudioSource.cpp b/src/crepe/api/AudioSource.cpp
index b512d27..a5b6d6a 100644
--- a/src/crepe/api/AudioSource.cpp
+++ b/src/crepe/api/AudioSource.cpp
@@ -1,6 +1,6 @@
#include "AudioSource.h"
-#include "../Sound.h"
+#include "facade/Sound.h"
#include <memory>
using namespace crepe::api;
diff --git a/src/crepe/api/CMakeLists.txt b/src/crepe/api/CMakeLists.txt
index 6b337be..9a02580 100644
--- a/src/crepe/api/CMakeLists.txt
+++ b/src/crepe/api/CMakeLists.txt
@@ -9,4 +9,3 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES
BehaviorScript.h
Script.h
)
-
diff --git a/src/crepe/api/Color.cpp b/src/crepe/api/Color.cpp
new file mode 100644
index 0000000..c73ce6c
--- /dev/null
+++ b/src/crepe/api/Color.cpp
@@ -0,0 +1,53 @@
+
+
+#include "Color.h"
+
+
+using namespace crepe::api;
+
+Color Color::white = Color(255,255,255,0);
+Color Color::red = Color(255,0,0,0);
+Color Color::green = Color(0,255,0,0);
+Color Color::blue = Color(0,0,255,0);
+Color Color::black = Color(0,0,0,0);
+Color Color::cyan = Color(0,255,255,0);
+Color Color::yellow = Color(255,255,0,0);
+Color Color::magenta= Color(255,0,255,0);
+
+Color::Color(double red, double green, double blue, double alpha){
+ this->a = alpha;
+ this->r = red;
+ this->g = green;
+ this->b = blue;
+};
+
+const Color& Color::get_white(){
+ return Color::white;
+};
+
+const Color& Color::get_red(){
+ return Color::red;
+};
+const Color& Color::get_green(){
+ return Color::green;
+};
+const Color& Color::get_blue(){
+ return Color::blue;
+};
+
+const Color& Color::get_black(){
+ return Color::black;
+};
+
+const Color& Color::get_cyan(){
+ return Color::cyan;
+};
+
+const Color& Color::get_yellow(){
+ return Color::yellow;
+};
+
+const Color& Color::get_magenta(){
+ return Color::magenta;
+};
+
diff --git a/src/crepe/api/Color.h b/src/crepe/api/Color.h
new file mode 100644
index 0000000..207434e
--- /dev/null
+++ b/src/crepe/api/Color.h
@@ -0,0 +1,34 @@
+#pragma once
+
+namespace crepe::api {
+
+class Color {
+
+public:
+ Color(double red, double green, double blue, double alpha);
+ static const Color & get_white();
+ static const Color & get_red();
+ static const Color & get_green();
+ static const Color & get_blue();
+ static const Color & get_cyan();
+ static const Color & get_magenta();
+ static const Color & get_yellow();
+ static const Color & get_black();
+
+private:
+ double r;
+ double g;
+ double b;
+ double a;
+
+ static Color white;
+ static Color red;
+ static Color green;
+ static Color blue;
+ static Color cyan;
+ static Color magenta;
+ static Color yellow;
+ static Color black;
+};
+
+} // namespace crepe::api
diff --git a/src/crepe/api/Point.h b/src/crepe/api/Point.h
new file mode 100644
index 0000000..463aa7c
--- /dev/null
+++ b/src/crepe/api/Point.h
@@ -0,0 +1,14 @@
+#pragma once
+
+
+
+namespace crepe::api {
+
+class Point {
+public:
+ double x;
+ double y;
+};
+
+
+}
diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h
new file mode 100644
index 0000000..84eeb83
--- /dev/null
+++ b/src/crepe/api/Sprite.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "Component.h"
+#include "api/Color.h"
+#include "facade/Texture.h"
+#include <cstdint>
+
+
+namespace crepe::api {
+
+struct flip_settings{
+ bool flipX : 1;
+ bool flipY : 1;
+};
+class Sprite : public Component {
+
+public:
+ Sprite(crepe::Texture& image, const Color& color, const flip_settings& flip ) : sprite_image(&image), color(color), flip(flip){}
+ crepe::Texture* sprite_image;
+ Color color;
+ flip_settings flip;
+ uint8_t sortingLayer;
+ uint8_t orderInLayer;
+
+
+};
+
+}
diff --git a/src/crepe/api/Texture.cpp b/src/crepe/api/Texture.cpp
new file mode 100644
index 0000000..b4e3aa8
--- /dev/null
+++ b/src/crepe/api/Texture.cpp
@@ -0,0 +1,39 @@
+
+
+#include "util/log.h"
+
+#include "Texture.h"
+#include "SdlContext.h"
+#include <SDL2/SDL_render.h>
+
+using namespace crepe;
+
+Texture::Texture(std::unique_ptr<api::Resource> res) {
+ dbg_trace();
+ this->load(std::move(res));
+}
+
+Texture::Texture(const char * src) {
+ dbg_trace();
+ this->load(std::make_unique<api::Resource>(src));
+}
+
+Texture::~Texture(){
+ dbg_trace();
+ if(this->m_texture){
+ SDL_DestroyTexture(m_texture);
+ }
+}
+void Texture::load(std::unique_ptr<api::Resource> res) {
+ dbg_trace();
+ SdlContext& ctx = SdlContext::get_instance();
+ m_texture = ctx.setTextureFromPath(res->canonical(), srcrect, 1, 1);
+}
+
+SDL_Texture* Texture::get_texture() const{
+ return m_texture;
+}
+
+SDL_Rect& Texture::get_rect() {
+ return srcrect;
+}
diff --git a/src/crepe/api/Texture.h b/src/crepe/api/Texture.h
new file mode 100644
index 0000000..db2f1f9
--- /dev/null
+++ b/src/crepe/api/Texture.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include "SDL_rect.h"
+#include "api/baseResource.h"
+#include "api/Resource.h"
+#include <SDL2/SDL_render.h>
+#include <memory>
+
+namespace crepe {
+
+
+
+class Texture : public api::BaseResource{
+
+public:
+ Texture(const char * src);
+ Texture(std::unique_ptr<api::Resource> res);
+ ~Texture();
+
+ SDL_Texture* get_texture() const;
+ SDL_Rect& get_rect() ;
+private:
+ void load(std::unique_ptr<api::Resource> res);
+
+private:
+ SDL_Texture* m_texture;
+ SDL_Rect srcrect;
+};
+
+} // namespace crepe
+
diff --git a/src/crepe/api/Transform.h b/src/crepe/api/Transform.h
new file mode 100644
index 0000000..d4dfafc
--- /dev/null
+++ b/src/crepe/api/Transform.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include "api/Component.h"
+#include "api/Point.h"
+namespace crepe::api {
+
+class Transform : public Component {
+public:
+ Point position; // Translation (shift)
+ double rotation; // Rotation, in radians
+ double scale; // Multiplication factoh
+};
+} // namespace crepe::api
diff --git a/src/crepe/renderSystem.cpp b/src/crepe/renderSystem.cpp
new file mode 100644
index 0000000..a06aeba
--- /dev/null
+++ b/src/crepe/renderSystem.cpp
@@ -0,0 +1,37 @@
+
+
+
+#include "renderSystem.h"
+#include <vector>
+
+#include "api/Color.h"
+#include "api/Sprite.h"
+#include "api/Transform.h"
+#include "facade/SdlContext.h"
+#include "facade/Texture.h"
+
+using namespace crepe::api;
+
+
+static crepe::Texture player("../asset/texture/img.png");
+
+
+void RenderSystem::render(){
+
+ Sprite sprite(player, Color::get_red(), {1,1});
+ Transform transform ={
+ .position = {0,0},
+ .rotation = 0,
+ .scale = 1,
+ };
+
+ // this will get changed to ecs getter of componets
+ crepe::SdlContext& ctx = crepe::SdlContext::get_instance();
+
+ ctx.draw(sprite, transform);
+ /*
+ for(const auto& S : test_objects){
+ ctx.draw(S, const api::Transform &)
+ }
+ */
+}
diff --git a/src/crepe/renderSystem.h b/src/crepe/renderSystem.h
new file mode 100644
index 0000000..9011b30
--- /dev/null
+++ b/src/crepe/renderSystem.h
@@ -0,0 +1,13 @@
+
+#pragma once
+
+
+
+class RenderSystem {
+
+public:
+ RenderSystem() = default;
+ ~RenderSystem() = default;
+
+ void render();
+};
diff --git a/src/dummy_rendering.cpp b/src/dummy_rendering.cpp
new file mode 100644
index 0000000..e00ab7f
--- /dev/null
+++ b/src/dummy_rendering.cpp
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+#include "api/game.h"
+#include <SDL2/SDL_hints.h>
+int main(){
+
+
+
+ Engine engine(800,600);
+
+ // engine.loop();
+
+}
diff --git a/src/dummy_resource_manager.cpp b/src/dummy_resource_manager.cpp
new file mode 100644
index 0000000..bb0b7af
--- /dev/null
+++ b/src/dummy_resource_manager.cpp
@@ -0,0 +1,38 @@
+
+
+
+
+#include "api/game.h"
+#include "api/resource_manager.h"
+#include "api/spritesheet.h"
+#include "facade/Texture.h"
+#include "util/log.h"
+#include <vector>
+
+using namespace crepe;
+
+int main(){
+
+
+ dbg_trace();
+
+ // get instance of resource manager
+ //api::ResourceManager& c_ResMan = api::ResourceManager::get_instance();
+
+
+ game engine;
+
+ api::ResourceManager& c_ResMan = api::ResourceManager::get_instance();
+
+ auto test = c_ResMan.Load<Texture>("../asset/texture/img.png");
+
+ auto img = Texture("../asset/texture/img.png");
+
+ auto SS = api::Spritesheet("../asset/spritesheet/spritesheet_test.png", 1 , 4);
+
+ std::vector<Texture*> t = {test};
+ std::vector<api::Spritesheet*> s = {&SS};
+
+ engine.render(t, s);
+
+}