reprap: Compatibility with OSX
[simavr] / examples / shared / libc3 / src / c3context.h
1 /*
2         c3context.h
3
4         Copyright 2008-2012 Michel Pollet <buserror@gmail.com>
5
6         This file is part of simavr.
7
8         simavr is free software: you can redistribute it and/or modify
9         it under the terms of the GNU General Public License as published by
10         the Free Software Foundation, either version 3 of the License, or
11         (at your option) any later version.
12
13         simavr is distributed in the hope that it will be useful,
14         but WITHOUT ANY WARRANTY; without even the implied warranty of
15         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16         GNU General Public License for more details.
17
18         You should have received a copy of the GNU General Public License
19         along with simavr.  If not, see <http://www.gnu.org/licenses/>.
20  */
21
22
23 #ifndef __C3CONTEXT_H___
24 #define __C3CONTEXT_H___
25
26 #include "c3algebra.h"
27 #include "c3geometry.h"
28 #include "c3pixels.h"
29 #include "c3camera.h"
30
31 //! c3context_t is a container for a 'scene' to be drawn
32 /*!
33  * A c3context_t holds a root object, a list of already cached projected
34  * version of the geometry, and a driver that can be customized to draw it.
35  *
36  * This is a wrapper around a "top level object", the list of projected
37  * geometries is kept, purged and resorted if the root object becomes
38  * dirty
39  * TODO: Add the camera/eye/arcball control there
40  */
41 typedef struct c3context_t {
42         c3vec2          size;
43         c3cam           cam;
44
45         struct c3object_t * root;       // root object
46         c3pixels_array_t        pixels; // pixels, textures...
47
48         c3geometry_array_t      projected;
49
50         const struct c3driver_context_t ** driver;
51 } c3context_t, *c3context_p;
52
53 //! Allocates a new context of size w=width, h=height
54 c3context_p
55 c3context_new(
56                 int w,
57                 int h);
58
59 //! Initializes a new context 'c' of size w=width, h=height
60 c3context_p
61 c3context_init(
62                 c3context_p c,
63                 int w,
64                 int h);
65
66 //! Disposes the context, and everything underneath
67 void
68 c3context_dispose(
69                 c3context_p c);
70
71 //! Reproject geometry for dirty objects
72 void
73 c3context_project(
74                 c3context_p c);
75 //! Draws the context
76 void
77 c3context_draw(
78                 c3context_p c);
79
80 #endif /* __C3CONTEXT_H___ */