4 Copyright 2008-2012 Michel Pollet <buserror@gmail.com>
6 This file is part of libc3.
8 libc3 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.
13 libc3 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.
18 You should have received a copy of the GNU General Public License
19 along with libc3. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef __C3CONTEXT_H___
24 #define __C3CONTEXT_H___
26 #include "c3algebra.h"
27 #include "c3geometry.h"
29 #include "c3program.h"
33 C3_CONTEXT_VIEW_EYE = 0,
37 typedef struct c3context_view_t {
38 int type : 4, // C3_CONTEXT_VIEW_EYE...
40 c3vec2 size; // in pixels. for fbo/textures/window
43 c3geometry_array_t projected;
47 } c3context_view_t, *c3context_view_p;
49 DECLARE_C_ARRAY(c3context_view_t, c3context_view_array, 4);
51 //! c3context_t is a container for a 'scene' to be drawn
53 * A c3context_t holds a root object, a list of already cached projected
54 * version of the geometry, and a driver that can be customized to draw it.
56 * This is a wrapper around a "top level object", the list of projected
57 * geometries is kept, purged and resorted if the root object becomes
59 * TODO: Add the camera/eye/arcball control there
61 typedef struct c3context_t {
63 c3context_view_array_t views;
65 struct c3object_t * root; // root object
67 c3pixels_array_t pixels; // pixels, textures...
68 c3program_array_t programs; // fragment, vertex, geometry shaders
70 const struct c3driver_context_t ** driver;
71 } c3context_t, *c3context_p;
73 //! Allocates a new context of size w=width, h=height
79 //! Initializes a new context 'c' of size w=width, h=height
86 //! Disposes the context, and everything underneath
91 //! Reproject geometry for dirty objects
100 IMPLEMENT_C_ARRAY(c3context_view_array);
103 * Set and get the current view, this is done
104 * before projecting and drawing
106 static inline c3context_view_p
110 return &c->views.e[c->current];
113 static inline c3context_view_p
114 c3context_view_get_at(
118 if (view < c->views.count)
119 return &c->views.e[view];
128 if (view < c->views.count)
133 #endif /* __C3CONTEXT_H___ */