FreeWRL/FreeX3D  3.0.0
OpenGL_Utils.h
1 /*
2 
3 
4 Screen snapshot.
5 
6 */
7 
8 /****************************************************************************
9  This file is part of the FreeWRL/FreeX3D Distribution.
10 
11  Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
12 
13  FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
14  it under the terms of the GNU Lesser Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  FreeWRL/FreeX3D is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  GNU General Public License for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
25 ****************************************************************************/
26 
27 
28 #ifndef __FREEWRL_OPENGL_UTILS_H__
29 #define __FREEWRL_OPENGL_UTILS_H__
30 
31 // number of Shader nodes available per invocation
32 #define MAX_USER_DEFINED_SHADERS 40 //Sept 2016, changed from 4 to 40. In theory could do 2^32 - we have an int32 now just for user shaders
33 
34 int getNextFreeUserDefinedShaderSlot();
35 void kill_userDefinedShaders();
36 void sendShaderTextToEngine(int ste, int partsN, char ** vertSource, char ** fragSource);
37 
38 typedef enum vertexShaderResources {
39  vertexGLSLVersion,
40 
41  vertexPrecisionDeclare,
42  vertMaxLightsDeclare,
43 
44  vertexLightDefines,
45  vertexTCGTDefines,
46 
47  vertexNormalDeclare,
48  vertexPositionDeclare,
49  vertexSimpleColourDeclare,
50  vertexTextureMatrixDeclare,
51  vertexOneMaterialDeclare,
52  vertexBackMaterialDeclare,
53  vertFrontColourDeclare,
54  vertexTexCoordInputDeclare,
55  vertexTexCoordOutputDeclare,
56  vertexHatchPositionDeclare,
57  vertexPointSizeDeclare,
58 
59  vertexNormPosOutput,
60 
61  vertexLightingEquation,
62 
63  vertexMainStart,
64 
65  vertexPointSizeAssign,
66  vertexPositionCalculation,
67 
68  vertexOneMaterialCalculation,
69  vertexNormPosCalculation,
70  vertexSingleTextureCalculation,
71  vertexADSLCalculation,
72  vertexSimpleColourCalculation,
73  vertexHatchPositionCalculation,
74 
75  vertexUserDefinedInput,
76 
77  vertexMainEnd,
78  vertexEndMarker
79 } vertexShaderResources_t;
80 
81 typedef enum fragmenShaderResources {
82  fragmentGLSLVersion,
83  fragmentPrecisionDeclare,
84  fragMaxLightsDeclare,
85 
86  fragmentMultiTexDefines,
87  fragmentLightDefines,
88  fragmentFillPropDefines,
89 
90  fragmentNormalColorDefs,
91 
92  fragmentTexCoordDeclare,
93  fragmentTex0Declare,
94  fragmentMultiTexDeclare,
95  fragmentSimpleColourDeclare,
96  fragmentOneColourDeclare,
97  fragmentBackColourDeclare,
98  fragmentNormPosDeclare,
99  fragmentHatchPositionDeclare,
100  fragmentADSLLightModel,
101  fragmentMultiTexModel,
102  fragmentFillPropModel,
103 
104  fragmentMainStart,
105 
106  fragmentUserDefinedInput,
107 
108  fragmentSimpleColourAssign,
109  fragmentOneColourAssign,
110  fragmentADSLAssign,
111  fragmentTextureAssign,
112  fragmentFillPropAssign,
113 
114  fragmentMainEnd,
115  fragmentEndMarker
116 } fragmentShaderResources_t;
117 
118 
119 #ifdef OLDCODE
120 OLDCODE /* Ian moved this from iglobal.h so that OpenGL_Utils.c could use it
121 OLDCODE * since OpenGL_Utils.c cannot #include <iglobal.h> due to recursion */
122 OLDCODE struct multiTexParams {
123 OLDCODE int multitex_mode[2];
124 OLDCODE int multitex_source[2];
125 OLDCODE int multitex_function;
126 OLDCODE };
127 #endif //OLDCODE
128 
129 
130 void do_textureTransform (struct X3D_Node *textureNode, int ttnum);
131 void markForDispose(struct X3D_Node *node, int recursive);
132 
133 //s_shader_capabilities_t *getMyShaders(shaderflagsstruct ); //moved to component_shape.h where shaderflagsstruct defined
134 s_shader_capabilities_t *getMyShader(unsigned int);
135 
136 void sendMatriciesToShader(s_shader_capabilities_t *me);
137 void sendMaterialsToShader(s_shader_capabilities_t *me);
138 
139 void
140 BackEndClearBuffer(int);
141 
142 void
143 BackEndLightsOff(void);
144 
145 #ifdef DEBUGGING_CODE
146 void drawBBOX(struct X3D_Node *node);
147 #endif //DEBUGGING_CODE
148 
149 
150 void fw_glMatrixMode(GLint mode);
151 void fw_glLoadIdentity(void);
152 void fw_glPushMatrix(void);
153 void fw_glPopMatrix(void);
154 void fw_glTranslated(GLDOUBLE a, GLDOUBLE b, GLDOUBLE c);
155 void fw_glTranslatef(float a, float b, float c);
156 void fw_glRotateRad (GLDOUBLE a, GLDOUBLE b, GLDOUBLE c, GLDOUBLE d);
157 void fw_glRotated (GLDOUBLE a, GLDOUBLE b, GLDOUBLE c, GLDOUBLE d);
158 void fw_glRotatef (float a, float b, float c, float d);
159 void fw_glScaled (GLDOUBLE a, GLDOUBLE b, GLDOUBLE c);
160 void fw_glScalef (float a, float b, float c);
161 void fw_glGetDoublev (int ty, GLDOUBLE *mat);
162 void fw_glSetDoublev (int ty, GLDOUBLE *mat);
163 
164 /* OpenGL-ES specifics for Materials and Vertices */
165 void fw_iphone_enableClientState(GLenum aaa);
166 void fw_iphone_disableClientState(GLenum aaa);
167 void fw_iphone_vertexPointer(GLint aaa,GLenum bbb,GLsizei ccc,const GLvoid *ddd);
168 void fw_iphone_normalPointer(GLenum aaa,GLsizei bbb, const GLvoid *ccc);
169 void fw_iphone_texcoordPointer(GLint aaa, GLenum bbb ,GLsizei ccc,const GLvoid *ddd);
170 void fw_iphone_colorPointer(GLint aaa, GLenum bbb,GLsizei ccc,const GLvoid *ddd);
171 void fw_gluPerspective(GLDOUBLE fovy, GLDOUBLE aspect, GLDOUBLE zNear, GLDOUBLE zFar);
172 void fw_gluPickMatrix(GLDOUBLE xx, GLDOUBLE yy, GLDOUBLE width, GLDOUBLE height, GLint *vp);
173 void fw_Frustum(GLDOUBLE left, GLDOUBLE right, GLDOUBLE bottom, GLDOUBLE top, GLDOUBLE nearZ, GLDOUBLE farZ);
174 void fw_Ortho(GLDOUBLE left, GLDOUBLE right, GLDOUBLE bottom, GLDOUBLE top, GLDOUBLE nearZ, GLDOUBLE farZ);
175 void fw_gluProject( GLDOUBLE objX,
176  GLDOUBLE objY,
177  GLDOUBLE objZ,
178  const GLDOUBLE *model,
179  const GLDOUBLE *proj,
180  const GLint *view,
181  GLDOUBLE* winX,
182  GLDOUBLE* winY,
183  GLDOUBLE* winZ );
184 void fw_gluUnProject( GLDOUBLE winX,
185  GLDOUBLE winY,
186  GLDOUBLE winZ,
187  const GLDOUBLE *model,
188  const GLDOUBLE *proj,
189  const GLint *view,
190  GLDOUBLE* objX,
191  GLDOUBLE* objY,
192  GLDOUBLE* objZ );
193 
194 void fw_gluPickMatrix(GLDOUBLE x, GLDOUBLE y, GLDOUBLE deltax, GLDOUBLE deltay,
195  GLint viewport[4]);
196 
197 void printMaxStackUsed();
198 GLDOUBLE *getPickrayMatrix(int index);
199 void setPickrayMatrix(int index, GLDOUBLE *mat);
200 void freeMallocedNodeFields(struct X3D_Node* node);
201 void unRegisterX3DNode(struct X3D_Node * tmp);
202 
203 
204 #endif /* __FREEWRL_OPENGL_UTILS_H__ */