FreeWRL/FreeX3D  3.0.0
libFreeWRL.h
1 /*
2 
3  FreeWRL library API (public)
4 
5 */
6 
7 /****************************************************************************
8  This file is part of the FreeWRL/FreeX3D Distribution.
9 
10  Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
11 
12  FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
13  it under the terms of the GNU Lesser Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  FreeWRL/FreeX3D is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
24 ****************************************************************************/
25 
26 
27 #ifndef __LIBFREEWRL_API_H__
28 #define __LIBFREEWRL_API_H__
29 
30 
31 /* for front ends that do not have these X-11-based defines */
32 // OLD_IPHONE_AQUA #if defined(AQUA) || defined(_MSC_VER) || defined(_ANDROID)
33 
34 #if defined(_MSC_VER) || defined(_ANDROID)
35 #ifndef _MIMIC_X11_SCREEN_BUTTONS
36  #define _MIMIC_X11_SCREEN_BUTTONS
37  #define KeyPress 2
38  #define KeyRelease 3
39  #define ButtonPress 4
40  #define ButtonRelease 5
41  #define MotionNotify 6
42  #define MapNotify 19
43  #endif
44 #endif
45 
46 
47 
48 
49 #ifdef COMPILING_IPHONE_FRONT_END
50  /* Ok, ok, ok. I know. Another definition. But, Objective-C gives lots of
51  errors if the whole file is included, and also, we only need a couple of
52  definitions to keep the front end as separate from the library as possible... */
53 
54  void fwl_initializeRenderSceneUpdateScene(void);
55 
56 
57 #else /* COMPILING_IPHONE_FRONT_END */
58 
62 const char *libFreeWRL_get_version();
63 
64 /* for front ends to get the versions */
65 const char *fwl_libFreeWRL_get_version(); /* library version */
66 const char *fwl_freewrl_get_version(); /* UI version */
67 
71 typedef struct freewrl_params {
72  /* Put here global parameters, parsed in main program
73  and needed to initialize libFreeWRL
74  example: width, height, fullscreen, multithreading, eai...
75  */
76  int width;
77  int height;
78  int xpos;
79  int ypos;
80  long int winToEmbedInto;
81  bool fullscreen;
82  bool multithreading;
83  bool enableEAI;
84  bool verbose;
85  //int collision; /* do collision detection? moved to x3d_viewer struct july 7, 2012*/
86  bool frontend_handles_display_thread;
87  //for multiple-context applications such as 2+ fw instances on a web page,
88  //or a window app with 2+ fw windows - swapbuffers needs to know which one
89  void *display;
90  void *context;
91 
92  // generic place holder for current surface
93  // on Linux, Window {aka long unsigned int} but Window definition is not used
94  // everywhere this file is, so we store it as a pointer and just cast it.
95 
96  void *surface;
97 
99 
100 
101 /* FreeWRL parameters */
102 /*
103  * These have been subject to abuse when then were all fw_params
104  * At at Fri Apr 29 09:38:26 BST 2011 I expect lots of compiler messages.
105  */
106 /* extern freewrl_params_t fv_params; */
107 /* extern freewrl_params_t OSX_params; */
108 void *fwl_init_instance();
109 void fwl_initParams( freewrl_params_t *params) ;
110 
111 bool fwl_initFreeWRL(freewrl_params_t *params);
112 void closeFreeWRL();
113 void terminateFreeWRL();
114 
115 int fwl_parse_geometry_string(const char *geometry, int *out_width, int *out_height,
116  int *out_xpos, int *out_ypos);
117 
121 int ConsoleMessage(const char *fmt, ...); /* This does not belong here!! */
122 //#endif
123 
124 /* void Anchor_ReplaceWorld(char *name); */
125 bool Anchor_ReplaceWorld();
126 
127 #define VIEWER_NONE 0 /* would have conflicted with another NONE definition */
128 #define VIEWER_EXAMINE 1
129 #define VIEWER_WALK 2
130 #define VIEWER_EXFLY 3
131 #define VIEWER_FLY 4
132 #define VIEWER_SPHERICAL 5
133 #define VIEWER_FLY2 6
134 #define VIEWER_TILT 7
135 #define VIEWER_TPLANE 8
136 #define VIEWER_RPLANE 9
137 #define VIEWER_TURNTABLE 10
138 #define VIEWER_LOOKAT 11
139 #define VIEWER_EXPLORE 12
140 #define VIEWER_YAWZ 13
141 #define VIEWER_XY 14
142 #define VIEWER_YAWPITCH 15
143 #define VIEWER_ROLL 16
144 #define VIEWER_DIST 17
145 
146 #define CHORD_YAWZ 0
147 #define CHORD_YAWPITCH 1
148 #define CHORD_ROLL 2
149 #define CHORD_XY 3
150 
151 void setStereoBufferStyle(int);
152 
153 
158 #define INT_ID_UNDEFINED -1
159 
160 
161 #define RUNNINGASPLUGIN (isBrowserPlugin)
162 
163 extern char *BrowserFullPath;
164 
165 extern int _fw_pipe, _fw_FD;
166 extern int _fw_browser_plugin;
167 extern int isBrowserPlugin;
168 #include <stdint.h>
169 extern uintptr_t _fw_instance;
170 //extern char *keypress_string;
171 
172 #ifdef HAVE_LIBCURL
173 extern int with_libcurl;
174 #endif
175 
176 #endif /* COMPILING_IPHONE_FRONT_END */
177 
178 /* ** NEW DJ ** */
179 
180 void fwl_set_strictParsing(bool flag);
181 void fwl_set_plugin_print(bool flag);
182 void fwl_set_occlusion_disable(bool flag);
183 void fwl_set_print_opengl_errors(bool flag);
184 void fwl_set_trace_threads(bool flag);
185 void fwl_set_texture_size(unsigned int texture_size);
186 void fwl_set_glClearColor (float red , float green , float blue , float alpha);
187 void fwl_thread_dump(void);
188 int fwg_get_unread_message_count(void);
189 char *fwg_get_last_message();
190 void fwl_set_logfile(char *);
191 void fwl_set_nameTest(char *);
192 
193 #if defined(_ANDROID)
194 int DROIDDEBUG( const char*pFmtStr, ...);
195 void PRINTF_ALL( const char*pFmtStr, ...);
196 #endif
197 
198 
199 /* ** REPLACE DJ ** */
200 /* Try to replace the compile-time options in ConsoleMessage with run-time options */
201 // OLD_IPHONE_AQUA #ifdef AQUA
202 // OLD_IPHONE_AQUA #define MC_DEF_AQUA 1
203 // OLD_IPHONE_AQUA #else
204 // OLD_IPHONE_AQUA #define MC_DEF_AQUA 0
205 // OLD_IPHONE_AQUA #endif
206 
207 // OLD_IPHONE_AQUA #ifdef TARGET_AQUA
208 // OLD_IPHONE_AQUA #define MC_TARGET_AQUA 1
209 // OLD_IPHONE_AQUA #else
210 // OLD_IPHONE_AQUA #define MC_TARGET_AQUA 0
211 // OLD_IPHONE_AQUA #endif
212 
213 #ifdef OLDCODE
214 OLDCODE#ifdef HAVE_MOTIF
215 OLDCODE #define MC_HAVE_MOTIF 1
216 OLDCODE#else
217 OLDCODE #define MC_HAVE_MOTIF 0
218 OLDCODE#endif
219 OLDCODE
220 OLDCODE#ifdef TARGET_MOTIF
221 OLDCODE #define MC_TARGET_MOTIF 1
222 OLDCODE#else
223 OLDCODE #define MC_TARGET_MOTIF 0
224 OLDCODE#endif
225 OLDCODE
226 OLDCODE#ifdef _MSC_VER
227 OLDCODE #define MC_MSC_HAVE_VER 1
228 OLDCODE#else
229 OLDCODE #define MC_MSC_HAVE_VER 0
230 OLDCODE#endif
231 #endif // OLDCODE
232 
233 
234 
235 int fwl_StringConsoleMessage(char* message);
236 
237 void fwl_init_SnapGif(void);
238 void fwl_init_PrintShot();
239 void fwl_set_SnapFile(const char* file);
240 void fwl_set_SnapTmp(const char* file);
241 void fwl_init_SnapSeq(); /* Was in main/headers.h */
242 void fwl_toggleSnapshot();
243 void fwl_set_LineWidth(float lwidth);
244 void fwl_set_KeyString(const char *str);
245 void fwl_set_SeqFile(const char* file);
246 void fwl_set_MaxImages(int max);
247 void fwl_setCurXY(int x, int y);
248 void fwl_do_keyPress(char kp, int type);
249 void fwl_doQuit(char *, int);
250 void fwl_doQuitInstance(void *instance);
251 void fwl_updateScreenDim(int wi, int he);
252 void fwl_doQuitAndWait();
253 void fwl_set_viewer_type(const int type);
254 void fwl_set_modeRecord();
255 void fwl_set_modeFixture();
256 void fwl_set_modePlayback();
257 
258 #define CHANNEL_EAI 0
259 //OLDCODE #define CHANNEL_MIDI 1
260 
261 #define RxTx_STOP 0 /* Shutdown */
262 #define RxTx_START 1 /* Start */
263 #define RxTx_REFRESH 2 /* Read any pending input into PRIVATE buffer */
264 #define RxTx_EMPTY 4 /* Empty the private buffer */
265 #define RxTx_MOREVERBOSE 8
266 #define RxTx_SILENT 16
267 #define RxTx_SINK 32 /* Just throw away any future input */
268 #define RxTx_PENDING 64
269 #define RxTx_STOP_IF_DISCONNECT 128
270 #define RxTx_STATE 32768
271 #define RxTx_GET_VERBOSITY 65536
272 
273 /* The first few functions do I/O */
274 int fwlio_RxTx_control(int channel, int action);
275 char * fwlio_RxTx_getbuffer(int channel) ;
276 void fwlio_RxTx_sendbuffer(char *fromFile, int fromLine, int channel, char *str);
277 char * fwlio_RxTx_waitfor(int channel, char *str);
278 
279 void fwl_init_EaiVerbose();
280 char * fwl_EAI_handleBuffer(char *tempEAIdata);
281 int fwl_EAI_allDone();
282 char * fwl_EAI_handleRest();
283 //OLDCODE char * fwl_MIDI_handleBuffer(char *tempEAIdata);
284 
285 void fwl_set_ScreenDist(const char *optArg);
286 void fwl_init_StereoDefaults(void); //don't need to call now March 2012
287 void fwl_set_EyeDist(const char *optArg);
288 void fwl_init_Shutter(void);
289 void fwl_init_SideBySide(void);
290 void fwl_init_UpDown(void);
291 void fwl_set_AnaglyphParameter(const char *optArg);
292 void fwl_set_StereoParameter(const char *optArg);
293 
294 // JAS obsolete void fwl_askForRefreshOK();
295 
296 /* DISPLAY THREAD */
297 void fwl_initializeDisplayThread();
298 bool checkNetworkFile(const char *fn);
299 #define fwl_checkNetworkFile(a) checkNetworkFile(a)
300 
301 /* PARSER THREAD */
302 void fwl_initialize_parser();
303 void fwl_initializeInputParseThread();
304 int fwl_isinputThreadParsing();
305 int fwl_isInputThreadInitialized();
306 
307 /* TEXTURE THREAD */
308 void fwl_initializeTextureThread();
309 int fwl_isTextureinitialized();
310 
311 /* PARSER THREAD */
312 int fwl_isTextureParsing();
313 
314 void fwl_Next_ViewPoint(void);
315 void fwl_Prev_ViewPoint(void);
316 void fwl_First_ViewPoint(void);
317 void fwl_Last_ViewPoint(void);
318 void fwl_gotoViewpoint (char *findThisOne);
319 
320 void fwl_startFreeWRL(const char *url);
321 /* distinguish instances from window event handler using the window handle */
322 int fwl_setCurrentHandle(void *handle, char*, int);
323 void fwl_clearCurrentHandle();
324 void *fwl_getCurrentHandle(char *, int);
325 
326 void fwl_resource_push_single_request(const char *request);
327 void fwl_OSX_initializeParameters(const char* initialURL);
328 void fwl_resource_push_single_request_IE_main_scene(const char *request);
329 
330 void fwg_frontEndReturningData(char* fileData,int length,int width,int height,bool hasAlpha);
331 
332 /* from main/ConsoleMessage.c */
333 void fwg_setConsoleParam_maxLines(int);
334 void fwg_setConsoleParam_maxLineLength(int);
335 void fwg_setConsoleParam_replaceTabs(int);
336 
337 void fwg_setFrontEndOnX3DFileLoadedListener(void (*frontEndOnX3DFileLoadedListener)(char *));
338 
339 
340 void fwg_frontEndReturningLocalFile(char *localfile, int iret);
341 void fwl_RenderSceneUpdateScene(void);
342 void fwl_gotoCurrentViewPoint();
343 void fwl_setScreenDim(int wi, int he);
344 void fwl_setScreenDim0(int wi, int he);
345 void fwl_setDensityFactor(float density_factor);
346 float fwl_getDensityFactor();
347 int fwl_hwnd_to_windex(void *hWnd);
348 void fwl_setScreenDim1(int wi, int he, int windex);
349 bool fwl_initialize_GL(void);
350 //void fwl_setLastMouseEvent(int etype);
351 int fwl_handle_aqua(const int mev, const unsigned int button, int x, int y);
352 //APPLE int fwl_handle_aqua1(const int mev, const unsigned int button, int x, int y, int windex);
353 int fwl_handle_mouse(int mev, int button, int x, int y, int windex);
354 int fwl_handle_touch(int mev, unsigned int ID, int x, int y, int windex);
355 void fwl_handle_gyro(float rx, float ry, float rz);
356 void fwl_handle_accelerometer(float ax, float ay, float az);
357 void fwl_handle_magnetic(float azimuth, float pitch, float roll);
358 
359 
360 /* JAS - moving OSX front end into 2011 code workings - these may change. */
361 void fwl_replaceWorldNeeded(char* str);
362 int fwl_pollPromptForURL(); /* poll from front end / UI in loop */
363 int fwl_pollPromptForFile();
364 void fwl_setPromptForURL(int state);
365 void fwl_setPromptForFile(int state);
366 
367 char *fwg_frontEndWantsFileName(void);
368 int fv_display_initialize(void);
369 void fwl_initializeRenderSceneUpdateScene(void);
370 void fwl_setButDown(int button, int value);
371 
372 
373 /* IS - moving from main/headers.h to here for use in front-ends (bin/main.c calls some of these) */
374 int fwl_get_headlight();
375 char* fwl_getNavModeStr();
376 int fwl_getNavMode();
377 int fwl_getLookatMode();
378 int fwl_getCollision();
379 void fwl_setCollision(int state);
380 int fwl_getAnaglyphSide(int whichSide);
381 int fwl_draw(); //use when frontend_handles_display_thread
382 void fwl_tmpFileLocation(char *tmpFileLocation);
383 void fwl_fontFileLocation(char *fontFileLocation);
384 int fwl_set_ui_colorscheme(char *colorschemename);
385 void fwl_set_ui_colors(char *fourhtmlcolors);
386 void fwl_get_ui_color(char *use, float *rgb);
387 char *fwl_get_ui_colorschemename();
388 void fwl_next_ui_colorscheme();
389 int fwl_get_ui_color_changed();
390 int fwl_set_sbh_pin_option(char *optarg);
391 int fwl_set_sbh_want_option(char *optarg);
392 void fwl_setShadingStyle(int style);
393 void fwl_set_sbh_pin(int sb, int mb);
394 void fwl_get_sbh_pin(int *sb, int *mb);
395 void fwl_set_target_fps(int target_fps);
396 int fwl_get_target_fps();
397 void fwl_set_sbh_wantMenubar(int want);
398 int fwl_get_sbh_wantMenubar();
399 void fwl_set_sbh_wantStatusbar(int want);
400 int fwl_get_sbh_wantStatusbar();
401 
402 int fwl_commandline(char *cmdline);
403 int fwl_getShift();
404 void fwl_setShift(int ishift);
405 int fwl_getHover();
406 void fwl_setHover(int hover);
407 int fwl_getPedal();
408 void fwl_setPedal(int pedal);
409 int fwl_getCtrl();
410 void fwl_set_emulate_multitouch(int ion);
411 int fwl_get_emulate_multitouch();
412 
413 // a few function prototypes from around libfreewrl
414 void fwl_setConsole_writePrimitive(int ibool);
415 void statusbar_set_window_size(int width, int height);
416 int statusbar_handle_mouse(int mev, int butnum, int mouseX, int mouseY);
417 int getCursorStyle();
418 void *fwl_frontenditem_dequeue();
419 char* fwl_resitem_getURL(void *res);
420 char* fwl_resitem_getTempDir(void *res);
421 void fwl_resitem_setActualFile(void *res, char *fname);
422 int fwl_resitem_getStatus(void *res);
423 int fwl_resitem_getType(void *res);
424 int fwl_resitem_getMediaType(void *res);
425 void fwl_resitem_enqueuNextMulti(void *res);
426 void fwl_resitem_setLocalPath(void *res, char* path);
427 void fwl_resitem_enqueue(void *res);
428 void fwl_resitem_setDownloadThread(void *res, void *thread);
429 void *fwl_resitem_getDownloadThread(void *res);
430 void *fwl_resitem_getGlobal(void *res);
431 
432 int file2blob(void *res);
433 #ifdef SSR_SERVER
434 //SSR (Server-side rendering)
435 void SSRserver_enqueue_request_and_wait(void *fwctx, void *request);
436 #endif //SSR_SERVER
437 
438 #endif /* __LIBFREEWRL_API_H__ */
Initialization.
Definition: libFreeWRL.h:71