Loading...
Searching...
No Matches
view.c
Go to the documentation of this file.
#include "arc/graphics/view.h"
#include "arc/std/errno.h"
#include <SDL.h>
#include <stdlib.h>
void ARC_View_Create(ARC_View **view, ARC_Renderer *renderer, ARC_Rect bounds){
*view = (ARC_View *)malloc(sizeof(ARC_View));
(*view)->renderer = renderer;
(*view)->bounds = bounds;
}
void ARC_View_Destroy(ARC_View *view){
free(view);
}
void ARC_View_Render(ARC_View *view, ARC_View_RenderFn renderFn, void *data){
int err = SDL_RenderSetViewport((SDL_Renderer *)view->renderer, (const SDL_Rect *)&(view->bounds));
if(err){
ARC_DEBUG_LOG(ARC_ERRNO_DATA, "in src/graphics/sdl/view.c ARC_View_Render(view, renderFn), SDL_RenderSetViewport(...) returned: %d", err);
return;
}
renderFn(data);
err = SDL_RenderSetViewport((SDL_Renderer *)view->renderer, NULL);
if(err){
ARC_DEBUG_LOG(ARC_ERRNO_DATA, "in src/graphics/sdl/view.c ARC_View_Render(view, NULL), SDL_RenderSetViewport(...) returned: %d", err);
return;
}
}
ARC_Rect ARC_View_GetBounds(ARC_View *view){
return view->bounds;
}
errno.h
ARC_ERRNO_DATA
#define ARC_ERRNO_DATA
Definition errno.h:7
ARC_View_GetBounds
ARC_Rect ARC_View_GetBounds(ARC_View *view)
gets bounds from ARC_View type
Definition view.c:33
ARC_View_Render
void ARC_View_Render(ARC_View *view, ARC_View_RenderFn renderFn, void *data)
renders callbacks contents within an ARC_View
Definition view.c:17
ARC_View_Destroy
void ARC_View_Destroy(ARC_View *view)
destroys ARC_View type
Definition view.c:13
ARC_View_Create
void ARC_View_Create(ARC_View **view, ARC_Renderer *renderer, ARC_Rect bounds)
creates ARC_View type
Definition view.c:7
view.h
ARC_View_RenderFn
void(* ARC_View_RenderFn)(void *data)
a function for ARC_View where contents of the function will be rendered within a view
Definition view.h:21
ARC_Renderer
struct ARC_RendererType ARC_Renderer
Definition renderer.h:16
ARC_Rect
Definition rectangle.h:12
ARC_View
Definition view.h:11
ARC_View::renderer
ARC_Renderer * renderer
Definition view.h:12
ARC_View::bounds
ARC_Rect bounds
Definition view.h:13