Connected the AssetManager to the GameEngine and added function in the

GameEngine API to allow for loading and removing assets as well as rendering
textures using their AssetID
This commit is contained in:
abdelrahman committed 2022-09-23 04:39:17 +01:00
1 parent c4f1775392
commit 3f71cf0f3f
11 files changed
+156 -33

No files matched your search

+20 -1
View File
@@ -1,5 +1,7 @@
#include "Renderer.h"
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_rect.h"
#include "SDL_render.h"
#include "engine_build_config.h"
#include <stdbool.h>
@@ -35,12 +37,25 @@ void render_clear(const Renderer *renderer, SDL_Color color) {
return;
}
SDL_SetRenderDrawColor(renderer->SDL_base_renderer, color.r, color.r, color.b,
SDL_SetRenderDrawColor(renderer->SDL_base_renderer, color.r, color.g, color.b,
color.a);
SDL_RenderClear(renderer->SDL_base_renderer);
}
void render_texture(const Renderer *renderer, SDL_Texture *texture, float x,
float y, float w, float h) {
if (!renderer || !texture) {
return;
}
SDL_FRect dest = {x, y, w, h};
// TODO (Abdelrahman): Look into using the SDL_RenderCopyExF instead to
// support rotating the texture
SDL_RenderCopyF(renderer->SDL_base_renderer, texture, NULL, &dest);
}
void swap_buffers(const Renderer *renderer) {
if (!renderer || !(renderer->SDL_base_renderer)) {
return;
@@ -49,6 +64,10 @@ void swap_buffers(const Renderer *renderer) {
SDL_RenderPresent(renderer->SDL_base_renderer);
}
SDL_Texture *load_texture(const Renderer *renderer, const char *path) {
return IMG_LoadTexture(renderer->SDL_base_renderer, path);
}
void destroy_renderer(Renderer *renderer) {
if (renderer) {
if (renderer->SDL_base_renderer) {