Loading...
Searching...
No Matches
view.c File Reference
`#include "arc/graphics/view.h"`
`#include "arc/std/errno.h"`
`#include <SDL.h>`
`#include <stdlib.h>`

Go to the source code of this file.

## Functions

void | ARC_View_Create (ARC_View **view, ARC_Renderer *renderer, ARC_Rect bounds)
| creates ARC_View type
void | ARC_View_Destroy (ARC_View *view)
| destroys ARC_View type
void | ARC_View_Render (ARC_View *view, ARC_View_RenderFn renderFn, void *data)
| renders callbacks contents within an ARC_View
ARC_Rect | ARC_View_GetBounds (ARC_View *view)
| gets bounds from ARC_View type

## Function Documentation

## ARC_View_Create()

void ARC_View_Create | ( | ARC_View ** | view,
|  | ARC_Renderer * | renderer,
|  | ARC_Rect | bounds )

creates ARC_View type

Parameters

  view | ARC_View to initialize
  renderer | ARC_Renderer the view will render to
  bounds | ARC_Rect bounds of the view within the renderer

Definition at line 7 of file view.c.

{
*view = (ARC_View *)malloc(sizeof(ARC_View));
(*view)->renderer = renderer;
(*view)->bounds = bounds;
}
ARC_View
Definition view.h:11
ARC_View::renderer
ARC_Renderer * renderer
Definition view.h:12

References ARC_View::renderer.

## ARC_View_Destroy()

void ARC_View_Destroy | ( | ARC_View * | view | ) |

destroys ARC_View type

Definition at line 13 of file view.c.

{
free(view);
}

## ARC_View_GetBounds()

ARC_Rect ARC_View_GetBounds | ( | ARC_View * | view | ) |

gets bounds from ARC_View type

Parameters

  view | ARC_View to get bounds from

Returns
  bounds of the view

Definition at line 33 of file view.c.

{
return view->bounds;
}
ARC_View::bounds
ARC_Rect bounds
Definition view.h:13

References ARC_View::bounds.

## ARC_View_Render()

void ARC_View_Render | ( | ARC_View * | view,
|  | ARC_View_RenderFn | renderFn,
|  | void * | data )

renders callbacks contents within an ARC_View

Parameters

  view | ARC_View to be renedered to
  renderFn | function which contents will render to given ARC_View
  data | data to be used in renderFn

Definition at line 17 of file view.c.

{
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_ERRNO_DATA
#define ARC_ERRNO_DATA
Definition errno.h:7

References ARC_ERRNO_DATA, ARC_View::bounds, and ARC_View::renderer.