libc3: remerged
[simavr] / examples / shared / libc3 / src / c3program.h
1 /*
2         c3program.h
3
4         Copyright 2008-2012 Michel Pollet <buserror@gmail.com>
5
6         This file is part of libc3.
7
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.
12
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.
17
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/>.
20  */
21
22
23 #ifndef __C3PROGRAM_H___
24 #define __C3PROGRAM_H___
25
26 #include "c3types.h"
27 #include "c_utils.h"
28
29 typedef struct c3shader_t {
30         c3apiobject_t sid;      // shader id
31         uint32_t type;
32         str_p   name;
33         str_p   shader;
34 } c3shader_t, *c3shader_p;
35
36 DECLARE_C_ARRAY(c3shader_t, c3shader_array, 4);
37
38 typedef struct c3program_param_t {
39         struct c3program_t * program;
40         c3apiobject_t pid;      // parameter id
41         str_p   type;
42         str_p   name;
43 } c3program_param_t, *c3program_param_p;
44
45 DECLARE_C_ARRAY(c3program_param_t, c3program_param_array, 4);
46
47 typedef struct c3program_t {
48         c3apiobject_t pid;      // program id
49         int                                             verbose : 1;
50         str_p name;
51         c3shader_array_t        shaders;
52         c3program_param_array_t params;
53         str_p                                   log;    // if an error occurs
54 } c3program_t, *c3program_p;
55
56 DECLARE_C_ARRAY(c3program_p, c3program_array, 4);
57
58 //! Allocates a new, empty program
59 c3program_p
60 c3program_new(
61                 const char * name);
62
63 //! disposes of a c3program memory
64 void
65 c3program_dispose(
66                 c3program_p p);
67
68 //! purge deletes the shader storage, but keep the program and parameters
69 void
70 c3program_purge(
71                 c3program_p p);
72
73 enum {
74         C3_PROGRAM_LOAD_UNIFORM = (1 << 0),
75 };
76
77 int
78 c3program_load_shader(
79                 c3program_p p,
80                 uint32_t        type,
81                 const char * header,
82                 const char * filename,
83                 uint16_t flags);
84
85 c3program_param_p
86 c3program_locate_param(
87                 c3program_p p,
88                 const char * name );
89
90 IMPLEMENT_C_ARRAY(c3program_param_array);
91 IMPLEMENT_C_ARRAY(c3shader_array);
92 IMPLEMENT_C_ARRAY(c3program_array);
93
94 #endif /* __C3PROGRAM_H___ */