-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenderer.h
45 lines (39 loc) · 1.4 KB
/
renderer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef __RENDERER_H__
#define __RENDERER_H__
#include "color.h"
#include <cairo.h>
// the different face directions
enum FaceOrientation{
FACE_LEFT,
FACE_RIGHT,
FACE_TOP
};
typedef struct Renderer Renderer;
struct Renderer{
// width of the image
unsigned int image_width;
// height of the image
unsigned int image_height;
// stride (number of pixels in each row
unsigned int stride;
// number of faces
unsigned int num_faces;
// number of voxels
unsigned int num_voxels;
// temporary storage of pixels
Color *pixels;
// cairo surface
cairo_surface_t *surface;
// face indexo of each pixel
unsigned int *face_map;
};
Renderer *renderer_create();
int renderer_save(Renderer *renderer, Settings *settings);
void renderer_free(Renderer *renderer);
void renderer_render(Renderer *renderer, Settings *settings, VoxelGrid *voxelgrid);
void draw_vertical_line(int x, int y, Settings *settings, Renderer *renderer, Color color ,unsigned int face_id);
void draw_diagonal_line(int x, int y, int direction, Settings *settings, Renderer *renderer, Color color, unsigned int face_id);
void draw_face(int x, int y, enum FaceOrientation orientation, unsigned int face_id, Settings *settings, Renderer *renderer);
void draw_numbers(Renderer *renderer, Settings *settings);
void draw_number(Renderer *renderer, unsigned int x, unsigned int y, unsigned int number);
#endif