FreeWRL / FreeX3D 4.3.0
iglobal.h
1/*
2The globals have 'private' and 'public' facilities
31. if the variables are used only in one source file, they go
4 in a ppFileName struct in Filename.c
52. if the variables are used in other source files (via extern) then either:
62a. add getter and setter functions and keep private, or
72b. add directly to iiglobal struct in iglobal.h, in the struct tFileName sub-struct
82bi. in this case if its a pointer to a complex type, put as void* in iglobal and
9 add casting to the code (so iglobal.h doesn't have to #include a bunch of headers)
10
11Variable initialization:
121. for private: in a //private section in FileName_init(..) p->variable = const value
132. for public: in a //public section in FileName_init(..) t->variable = const value
14
15Variable use:
161. for private: ppFileName p = (ppFileName)gglobal()->FileName.prv;
17-- p->variable = ...
182. for public: gglobal()->FileName.variable = ...
19
20*/
21
22#ifndef INSTANCEGLOBAL
23//#include "display.h" //for opengl_utils.h which is for rdr_caps
24//#include "opengl/OpenGL_Utils.h" //for rdr_caps
25#include "list.h"
26#ifdef DISABLER
27#include "dbl_list.h"
28#endif
29#include <system.h>
30//#include <libFreeWRL.h>
31#include <pthread.h>
32#include <threads.h> //for threads
33//#define GLenum int
34//#define GLuint unsigned int
35//#include "vrml_parser/Structs.h" //for SFColor
36//#include "x3d_parser/X3DParser.h" //for PARENTSTACKSIZE
37//#include "ui/common.h" // for ppcommon
38
39
40#define IBOOL int
41
42typedef struct iiglobal //InstanceGlobal
43{
44
45
46 struct tdisplay{
47 void *params; //freewrl_params_t
48 int _global_gl_err; //GLenum
49 IBOOL display_initialized;// = FALSE;
50 int screenWidth;// = 0; /* screen */
51 int screenHeight;// = 0;
52 char *window_title;// = NULL;
53 int shutterGlasses;// = 0; /* stereo shutter glasses */
54 void *rdr_caps; //s_renderer_capabilities_t
55 void *prv;
56 }display;
57 struct tinternalc {
58 IBOOL global_strictParsing;// = FALSE;
59 IBOOL global_plugin_print;// = FALSE;
60 IBOOL global_occlusion_disable;// = FALSE;
61 unsigned user_request_texture_size;// = 0;
62 IBOOL global_print_opengl_errors;// = FALSE;
63 IBOOL global_trace_threads;// = FALSE;
64 void *prv;
65 } internalc;
66 //struct tio_http {
67 // void *prv;
68 //} io_http;
69 struct tresources {
70 //resource_item_t *root_res; // = NULL;
71 void *root_res;
72 void *prv;
73 } resources;
74 struct tthreads {
75 pthread_t disposeThread;
76 pthread_t mainThread; /* main (default) thread */
77 pthread_t DispThrd; /*DEF_THREAD(DispThrd); display thread */
78 pthread_t PCthread; /* DEF_THREAD(PCthread)parser thread */
79 pthread_t loadThread; /* DEF_THREAD(pthread_t loadThread)texture thread */
80 /* Synchronize / exclusion root_res and below */
81 pthread_mutex_t mutex_resource_tree; // = PTHREAD_MUTEX_INITIALIZER;
82
83 /* Synchronize / exclusion : resource queue for parser */
84 pthread_mutex_t mutex_resource_list; // = PTHREAD_MUTEX_INITIALIZER;
85 pthread_cond_t resource_list_condition; // = PTHREAD_COND_INITIALIZER;
86
87 pthread_mutex_t mutex_frontend_list; // = PTHREAD_MUTEX_INITIALIZER;
88
89 /* Synchronize / exclusion (main<=>texture) */
90 pthread_mutex_t mutex_texture_list; // = PTHREAD_MUTEX_INITIALIZER;
91 pthread_cond_t texture_list_condition; // = PTHREAD_COND_INITIALIZER;
92
93 IBOOL ResourceThreadRunning;
94 IBOOL TextureThreadRunning;
95 IBOOL ResourceThreadWaiting;
96 IBOOL TextureThreadWaiting;
97 IBOOL flushing;
98 int MainLoopQuit;
99 void *prv;
100 } threads;
101
102 struct tSnapshot {
103 IBOOL doSnapshot;
104 IBOOL doPrintshot;
105 int snapGoodCount;
106 void *prv;
107 } Snapshot;
109 int eaiverbose;// = FALSE;
110 void *prv;
111 } EAI_C_CommonFunctions;
113 void *prv;
114 } EAIEventsIn;
116 char *outBuffer;
117 int outBufferLen;
118 void *prv;
119 } EAIHelpers;
120 struct tEAICore{
121 /* EAI input buffer */
122 char *EAIbuffer;
123 int EAIbufcount; /* pointer into buffer*/
124 int EAIbufpos;
125 int EAIbufsize; /* current size in bytes of input buffer*/
126 void *prv;
127 } EAICore;
129 void *prv;
130 } SensInterps;
132 int consMsgCount;
133 int Console_writeToHud;
134 void *prv;
135 } ConsoleMessage;
136 struct tMainloop{
137 float gl_linewidth;
138 /* what kind of file was just parsed? */
139 int currentFileVersion;
140 double TickTime;
141 double lastTime;
142 double BrowserFPS;// = 100.0; /* calculated FPS */
143 double BrowserSpeed;// = 0.0; /* calculated movement speed */
144 const char *BrowserDescription;
145 int HaveSensitive;// = FALSE;
146 int AllowNavDrag;
147 int trisThisLoop;
148 unsigned int iframe;
149 int clipPlane;// = 0;
150 int SHIFT; //state of shift key up = 0, down = 1
151 int CTRL; //state of ctrl key up = 0, down = 1
152 //int currentX[20], currentY[20]; /* current mouse position.*/
153 void *prv;
154 char *tmpFileLocation;
155 char *url;
156 char *scene_name; //null or take from url
157 char *scene_suff; //null or wrl or x3d
158 int scene_profile; //from parser (or capabilities handler) used in js scene.profile
159 int *scene_components;
160 char *replaceWorldRequest;
161 void *replaceWorldRequestMulti; //will be struct multi-string
162 void *_vportstack; //Stack for viewports
163 void *_stagestack; //stack for stage ID
164 void *_framebufferstack; //stack for backbuffers, usually GL_BACK, or can be FBO
165 int screenOrientation2;
166 int pickray_x;
167 int pickray_y;
168 float fieldOfView; //set in setup_projection, used in volumeRendering
169 } Mainloop;
170 struct tProdCon{
171 struct Vector *viewpointNodes;// = NULL;
172 int currboundvpno;//=0;
173 /* bind nodes in display loop, NOT in parsing threadthread */
174 struct X3D_Node *setViewpointBindInRender;// = NULL;
175 struct X3D_Node *setFogBindInRender;// = NULL;
176 struct X3D_Node *setBackgroundBindInRender;// = NULL;
177 struct X3D_Node *setNavigationBindInRender;// = NULL;
178 void *savedParser; //struct VRMLParser* savedParser;
179 void *prv;
180 } ProdCon;
181 #if defined (INCLUDE_NON_WEB3D_FORMATS)
182 struct tColladaParser{
183 void *prv;
184 }ColladaParser;
185 #endif //INCLUDE_NON_WEB3D_FORMATS
186
187 #if defined (INCLUDE_STL_FILES)
188 struct tSTLHandler {
189 void *prv;
190 }STLHandler;
191 #endif // INCLUDE_STL_FILES
192
193
194 struct tFrustum{
195 int OccFailed;//. = FALSE;
196 void *prv;
197 } Frustum;
199 /* is the texture thread up and running yet? */
200 //int TextureThreadInitialized;// = FALSE;
201 void *prv;
202 }LoadTextures;
204 /* is this 24 bit depth? 16? 8?? Assume 24, unless set on opening */
205 int displayDepth;// = 24;
206 //static float cc_red = 0.0f, cc_green = 0.0f, cc_blue = 0.0f, cc_alpha = 1.0f;
207 int cc_changed;// = FALSE;
208 void *prv;
209 }OpenGL_Utils;
210
211#ifdef HAVE_OPENCL
212 struct tOpenCL_Utils{
213 IBOOL OpenCL_Initialized; // = FALSE;
214 IBOOL OpenCL_OK; // = FALSE
215 void *prv;
216 }OpenCL_Utils;
217#endif //HAVE_OPENCL
218
219#ifdef STATUSBAR_STD
220 struct tRasterFont{
221 void *prv;
222 }RasterFont;
223#endif
225 //struct multiTexParams textureParameterStack[MAX_MULTITEXTURE];
226 void *textureParameterStack;
227 void *prv;
228 }RenderTextures;
229 struct tTextures{
230 /* for texture remapping in TextureCoordinate nodes */
231 //GLuint *global_tcin;
232 unsigned int *global_tcin;
233 int global_tcin_count;
234 void *global_tcin_lastParent;
235 //GLuint defaultBlankTexture;
236 unsigned int defaultBlankTexture;
237 void *prv;
238 }Textures;
240 /*
241 GLint _projTexGenMatCam0_Location;
242 GLint _MultiprojTexGenMatCam_Location[4];
243 GLint _projTexCoord_Location;
244 GLint _projViewMat_Location;
245 GLint _projMap_forCam1_Location;
246 //struct projective_Texdata data[4];
247 */
248 //void *data;
249 //bool ProjActive;
250 int globalProjector;
251 void *prv;
252 }Component_TextureProjector;
254 void *prv;
255 }PluginSocket;
257 void *prv;
258 }pluginUtils;
260 void *prv;
261 }collision;
263 void *prv;
264 }Component_CubeMapTexturing;
266 void* prv;
267 }Component_Lighting;
269 void *prv;
270 }Component_EnvironSensor;
272 void *prv;
273 }Component_Geometry3D;
275 void *prv;
276 }Component_Geospatial;
278 void *prv;
279 }Component_HAnim;
281 void *prv;
282 }Component_Layering;
284 void *prv;
285 }Component_Layout;
287 void *prv;
288 }Component_NURBS;
290 void *prv;
291 }Component_ParticleSystems;
293 void *prv;
294 }Component_ProgrammableShaders;
296 void *prv;
297 }Component_RigidBodyPhysics;
299 void *prv;
300 }Component_Followers;
302 void *prv;
303 }Component_KeyDevice;
304
305#ifdef OLDCODE
306iOLDCODE struct tComponent_Networking{
307iOLDCODE void *ReWireNamenames;
308iOLDCODE int ReWireNametableSize;
309iOLDCODE void *ReWireDevices;
310iOLDCODE int ReWireDevicetableSize;
311iOLDCODE void *prv;
312iOLDCODE }Component_Networking;
313#endif // OLDCODE
314
316 void *prv;
317 }Component_Picking;
319 void *prv;
320 }Component_Rendering;
322 void *prv;
323 }Component_Shape;
325 int sound_from_audioclip;// = 0;
326 /* is the sound engine started yet? */
327 int SoundEngineStarted;// = FALSE;
328 void *prv;
329 }Component_Sound;
331 void *prv;
332 }Component_Text;
334 void *prv;
335 }Component_VRML1;
337 void *prv;
338 }Component_VolumeRendering;
340 void* prv;
341 }Component_MIDI;
343 void *prv;
344 }Component_Grouping;
346 #ifdef OLDCODE
347 OLDCODE char *OSX_last_world_url_for_reload;
348 OLDCODE char *OSX_replace_world_from_console;
349 #endif //OLDCODE
350
351 /* Any action for the Browser to do? */
352 int BrowserAction;// = FALSE;
353 double hitPointDist; /* distance in ray: 0 = r1, 1 = r2, 2 = 2*r2-r1... */
354 /* used to save rayhit and hyperhit for later use by C functions */
355 //struct SFColor hyp_save_posn, hyp_save_norm, ray_save_posn;
356 float hyp_save_posn[3];
357 float hyp_save_norm[3];
358 float ray_save_posn[3]; //getRayHit() > last intersection of pickray/bearing with geometry, transformed into the coordinates of the geometry
359 int touchID;
360 float camera_axis[3];
361 void *hypersensitive;//= 0;
362 int hyperhit;// = 0;
363 //struct point_XYZ hp;
364 void *hp;
365 void *rayHit;
366 //void *rayHitHyper;
367 //struct point_XYZ t_r1,t_r2,t_r3; /* transformed ray */
368 //void *t_r123; /* transformed ray */
369 int lightingOn; /* do we need to restore lighting in Shape? */
370 int have_transparency;//=FALSE;/* did any Shape have transparent material? */
371 /* material node usage depends on texture depth; if rgb (depth1) we blend color field
372 and diffusecolor with texture, else, we dont bother with material colors */
373 int last_texture_type;// = NOTEXTURE;
374 /* texture stuff - see code. Need array because of MultiTextures */
375 //GLuint boundTextureStack[10];//MAX_MULTITEXTURE];
376 unsigned int boundTextureStack[10];//MAX_MULTITEXTURE];
377 int textureStackTop;
378 void *texturenode;
379 void *shapenode;
380 void *prv;
381 }RenderFuncs;
383 void *prv;
384 }StreamPoly;
385 struct tTess{
386 int *global_IFS_Coords;
387 int global_IFS_Coord_count;//=0;
388 //GLUtriangulatorObj *global_tessobj;
389 void *global_tessobj;
390 int *text_IFS_Coords;
391 int text_IFS_Coord_count;//=0;
392 //GLUtriangulatorObj *global_tessobj;
393 void *text_tessobj;
394 void *prv;
395 }Tess;
396 struct tViewer{
397 int stereotype;
398 void *prv;
399 }Viewer;
401 void *prv;
402 }statusbar;
403 struct tCParse{
404 void* globalParser;
405 void *prv;
406 }CParse;
408 void *prv;
409 }CParseParser;
410 struct tCRoutes{
411 /* EAI needs the extra parameter, so we put it globally when a RegisteredListener is clicked. */
412 void *CRoutesExtra;// = 0;
413 //jsval JSglobal_return_val;
414 void *JSSFpointer;
415 int max_script_found;// = -1; /* the maximum script number found */
416 int max_script_found_and_initialized;// = -1; /* the maximum script number found */
417 int jsnameindex; //= -1;
418 int MAXJSparamNames;// = 0;
419
420 void *prv;
421 }CRoutes;
422 struct tCScripts{
423 void *prv;
424 }CScripts;
425#ifdef JAVASCRIPT_SM
426 struct tJScript{
427 void * JSglobal_return_val;
428 void *prv;
429 }JScript;
430 struct tjsUtils{
431 void *prv;
432 }jsUtils;
433 struct tjsVRMLBrowser{
434 /* for setting field values to the output of a CreateVrml style of call */
435 /* it is kept at zero, unless it has been used. Then it is reset to zero */
436 void * JSCreate_global_return_val;
437 void *prv;
438 }jsVRMLBrowser;
439 struct tjsVRMLClasses{
440 void *prv;
441 }jsVRMLClasses;
442#endif
443#ifdef JAVASCRIPT_DUK
444 struct tJScript_duk{
445 void * JSglobal_return_val;
446 void *prv;
447 }JScript_duk;
448#endif
449 struct tBindable{
450 //struct sNaviInfo naviinfo;
451 // struct Vector *background_stack;
452 // struct Vector *viewpoint_stack;
453 // struct Vector *navigation_stack;
454 // struct Vector *fog_stack;
455 void *naviinfo;
456 //void *background_stack;
457 //void *viewpoint_stack;
458 //void *navigation_stack;
459 //void *fog_stack;
460 int activeLayer;
461 void *bstacks;
462 void *prv;
463 }Bindable;
465 int parentIndex;// = -1;
466 //struct X3D_Node *parentStack[PARENTSTACKSIZE];
467 char *CDATA_Text;// = NULL;
468 int CDATA_Text_curlen;// = 0;
469 void *prv;
470 }X3DParser;
472 void *prv;
473 }gltf_loader;
474 struct tcommon{
475 void *prv;
476 }common;
478 void *prv;
479 }CursorDraw;
480#ifdef DISABLER
481#if defined(WRAP_MALLOC) || defined(DEBUG_MALLOC)
482 pthread_mutex_t __memTableGlobalLock;
483 IBOOL __memTable_CheckInit;
484 IBOOL __memTable_ShouldRegisterAllocation;
485 dbl_list_t *__memTable;
486#endif
487#endif
488} * ttglobal;
489#define INSTANCEGLOBAL 1
490#endif
491ttglobal iglobal_constructor();
492void iglobal_destructor(ttglobal);
493//void set_thread2global(ttglobal fwl, pthread_t any , char *desc);
494void resetGGlobal();
495ttglobal gglobal(); //gets based on threadID, errors out if no threadID
496//ppcommon gglobal_common(); // lets the front end get the myMenuStatus without hassle. dug9 Mar2014: poll for the values with get_status, get_... in common.c
497ttglobal gglobal0(); //will return null if thread not yet initialized
498//ttglobal gglobalH(void *handle); //use window handle
499//ttglobal gglobalH0(void *handle); //test if window handle is in thetable yet