1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | #ifndef GLXX_INT_ATTRIB_H |
29 | #define GLXX_INT_ATTRIB_H |
30 | |
31 | #include "interface/khronos/include/GLES/gl.h" |
32 | #include "interface/khronos/include/GLES2/gl2.h" |
33 | #include "interface/khronos/glxx/gl11_int_config.h" |
34 | #include "interface/khronos/glxx/glxx_int_config.h" |
35 | |
36 | #include <stddef.h> |
37 | |
38 | typedef struct { |
39 | GLboolean enabled; |
40 | |
41 | GLint size; |
42 | GLenum type; |
43 | GLboolean normalized; |
44 | GLsizei stride; |
45 | |
46 | const GLvoid *pointer; |
47 | |
48 | GLuint buffer; |
49 | |
50 | GLfloat value[4]; |
51 | } GLXX_ATTRIB_T; |
52 | |
53 | |
54 | /* GL 1.1 specific For indexing into arrays of handles/pointers */ |
55 | #define GL11_IX_COLOR 1//0 |
56 | #define GL11_IX_NORMAL 2//1 |
57 | #define GL11_IX_VERTEX 0//2 |
58 | #define GL11_IX_TEXTURE_COORD 3 |
59 | #define GL11_IX_POINT_SIZE 7 |
60 | #define GL11_IX_MATRIX_WEIGHT 8 |
61 | #define GL11_IX_MATRIX_INDEX 9 |
62 | #define GL11_IX_MAX_ATTRIBS 10 |
63 | |
64 | /* Special values passed to glintAttrib etc. instead of indices */ |
65 | #define GL11_IX_CLIENT_ACTIVE_TEXTURE 0x80000000 |
66 | |
67 | static INLINE void gl20_attrib_init(GLXX_ATTRIB_T *attrib) |
68 | { |
69 | uint32_t i; |
70 | for (i = 0; i < GLXX_CONFIG_MAX_VERTEX_ATTRIBS; i++) |
71 | { |
72 | attrib[i].enabled = GL_FALSE; |
73 | attrib[i].size = 4; |
74 | attrib[i].type = GL_FLOAT; |
75 | attrib[i].normalized = GL_FALSE; |
76 | attrib[i].stride = 0; |
77 | attrib[i].pointer = NULL; |
78 | attrib[i].buffer = 0; |
79 | attrib[i].value[0] = 0.0f; |
80 | attrib[i].value[1] = 0.0f; |
81 | attrib[i].value[2] = 0.0f; |
82 | attrib[i].value[3] = 1.0f; |
83 | } |
84 | } |
85 | |
86 | static INLINE void gl11_attrib_init(GLXX_ATTRIB_T *attrib) |
87 | { |
88 | int32_t i, indx; |
89 | |
90 | gl20_attrib_init(attrib); |
91 | |
92 | //vertex |
93 | attrib[GL11_IX_VERTEX].size = 4; |
94 | attrib[GL11_IX_VERTEX].normalized = GL_FALSE; |
95 | attrib[GL11_IX_VERTEX].value[0] = 0.0f; |
96 | attrib[GL11_IX_VERTEX].value[1] = 0.0f; |
97 | attrib[GL11_IX_VERTEX].value[2] = 0.0f; |
98 | attrib[GL11_IX_VERTEX].value[3] = 1.0f; |
99 | |
100 | //color |
101 | attrib[GL11_IX_COLOR].size = 4; |
102 | attrib[GL11_IX_COLOR].normalized = GL_TRUE; |
103 | attrib[GL11_IX_COLOR].value[0] = 1.0f; |
104 | attrib[GL11_IX_COLOR].value[1] = 1.0f; |
105 | attrib[GL11_IX_COLOR].value[2] = 1.0f; |
106 | attrib[GL11_IX_COLOR].value[3] = 1.0f; |
107 | |
108 | //normal |
109 | attrib[GL11_IX_NORMAL].size = 3; |
110 | attrib[GL11_IX_NORMAL].normalized = GL_TRUE; |
111 | attrib[GL11_IX_NORMAL].value[0] = 0.0f; |
112 | attrib[GL11_IX_NORMAL].value[1] = 0.0f; |
113 | attrib[GL11_IX_NORMAL].value[2] = 1.0f; |
114 | |
115 | for (i = 0; i < GL11_CONFIG_MAX_TEXTURE_UNITS; i++) { |
116 | indx = GL11_IX_TEXTURE_COORD + i; |
117 | attrib[indx].size = 4; |
118 | attrib[indx].normalized = GL_FALSE; |
119 | attrib[indx].value[0] = 0.0f; |
120 | attrib[indx].value[1] = 0.0f; |
121 | attrib[indx].value[2] = 0.0f; |
122 | attrib[indx].value[3] = 1.0f; |
123 | } |
124 | |
125 | //point size |
126 | attrib[GL11_IX_POINT_SIZE].size = 1; |
127 | attrib[GL11_IX_POINT_SIZE].normalized = GL_FALSE; |
128 | attrib[GL11_IX_POINT_SIZE].value[0] = 1.0f; |
129 | } |
130 | |
131 | typedef struct |
132 | { |
133 | uint32_t cache_offset; /* How far into the cache this attrib starts */ |
134 | uint32_t has_interlock; /* (Boolean) Whether there is an interlock immediately before this attrib. */ |
135 | } GLXX_CACHE_INFO_ENTRY_T; |
136 | |
137 | typedef struct |
138 | { |
139 | uint32_t send_any; /* True if we're sending any vertices. If false, remainder of structure is invalid. */ |
140 | GLXX_CACHE_INFO_ENTRY_T entries[GLXX_CONFIG_MAX_VERTEX_ATTRIBS]; |
141 | } GLXX_CACHE_INFO_T; |
142 | |
143 | #endif |
144 | |