Loading...
Searching...
No Matches
renderer.c
Go to the documentation of this file.
#include "arc/graphics/renderer.h"
#include "renderer.h"
#include <SDL.h>
#include <stdlib.h>
#include "arc/engine/engine.h"
#include "arc/graphics/window.h"
#include "arc/std/errno.h"
void ARC_Renderer_CreateWithEngineData(ARC_Renderer **renderer, ARC_EngineData *data){
if(!data){
arc_errno = ARC_ERRNO_NULL;
ARC_DEBUG_LOG_ERROR("ARC_Renderer_CreateWithEngineData(**renderer, NULL)");
return;
}
*renderer = (ARC_Renderer *)SDL_CreateRenderer((SDL_Window *)(data->window), -1, SDL_RENDERER_ACCELERATED);
if(!*renderer){
arc_errno = ARC_ERRNO_NULL;
ARC_DEBUG_LOG_ERROR_WITH_VARIABLES("SDL_CreateRenderer(%p, %d, %u);", data->window, -1, SDL_RENDERER_ACCELERATED);
free(renderer);
}
SDL_SetRenderDrawBlendMode((SDL_Renderer *)*renderer, SDL_BLENDMODE_BLEND);
}
void ARC_Renderer_Destroy(ARC_Renderer *renderer){
SDL_DestroyRenderer((SDL_Renderer *) renderer);
}
void ARC_Renderer_Clear(ARC_Renderer *renderer){
//TODO: changed for school, also need to add the ability to change render draw color
//SDL_SetRenderDrawColor((SDL_Renderer *)renderer, 0x1c, 0x2c, 0x3c, 0x00);
SDL_SetRenderDrawColor((SDL_Renderer *)renderer, 0x15, 0x2a, 0x26, 0x00);
SDL_RenderClear((SDL_Renderer *)renderer);
}
void ARC_Renderer_Render(ARC_Renderer *renderer){
SDL_RenderPresent((SDL_Renderer *)renderer);
}
engine.h
errno.h
arc_errno
int32_t arc_errno
Definition errno.c:5
ARC_DEBUG_LOG_ERROR_WITH_VARIABLES
#define ARC_DEBUG_LOG_ERROR_WITH_VARIABLES(STR,...)
Definition errno.h:40
ARC_ERRNO_NULL
#define ARC_ERRNO_NULL
Definition errno.h:6
ARC_DEBUG_LOG_ERROR
#define ARC_DEBUG_LOG_ERROR(STR)
Definition errno.h:39
renderer.h
ARC_Renderer
struct ARC_RendererType ARC_Renderer
Definition renderer.h:16
ARC_Renderer_CreateWithEngineData
void ARC_Renderer_CreateWithEngineData(ARC_Renderer **renderer, ARC_EngineData *data)
creates ARC_Renderer type with ARC_EngineData
Definition renderer.c:10
ARC_Renderer_Clear
void ARC_Renderer_Clear(ARC_Renderer *renderer)
Definition renderer.c:32
ARC_Renderer_Destroy
void ARC_Renderer_Destroy(ARC_Renderer *renderer)
destroys ARC_Renderer type
Definition renderer.c:28
ARC_Renderer_Render
void ARC_Renderer_Render(ARC_Renderer *renderer)
renders the renderer
Definition renderer.c:39
window.h
renderer.h
ARC_EngineData
Definition engine.h:17
ARC_EngineData::window
ARC_Window * window
Definition engine.h:18