FreeWRL / FreeX3D 4.3.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(AQUA) || 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
62const char *libFreeWRL_get_version();
63const char *freewrl_get_version();
64
65/* for front ends to get the versions */
66const char *fwl_libFreeWRL_get_version(); /* library version */
67const char *fwl_freewrl_get_version(); /* UI version */
68
72typedef struct freewrl_params {
73 /* Put here global parameters, parsed in main program
74 and needed to initialize libFreeWRL
75 example: width, height, fullscreen, multithreading, eai...
76 */
77 int width;
78 int height;
79 int xpos;
80 int ypos;
81 long int winToEmbedInto;
82 bool fullscreen;
83 bool multithreading;
84 bool enableEAI;
85 bool verbose;
86 //int collision; /* do collision detection? moved to x3d_viewer struct july 7, 2012*/
87 bool frontend_handles_display_thread;
88 //for multiple-context applications such as 2+ fw instances on a web page,
89 //or a window app with 2+ fw windows - swapbuffers needs to know which one
90 void *display;
91 void *context;
92
93 // generic place holder for current surface
94 // on Linux, Window {aka long unsigned int} but Window definition is not used
95 // everywhere this file is, so we store it as a pointer and just cast it.
96
97 void *surface;
98
100
101
102/* FreeWRL parameters */
103/*
104 * These have been subject to abuse when then were all fw_params
105 * At at Fri Apr 29 09:38:26 BST 2011 I expect lots of compiler messages.
106 */
107/* extern freewrl_params_t fv_params; */
108/* extern freewrl_params_t OSX_params; */
109void *fwl_init_instance();
110void fwl_initParams( freewrl_params_t *params) ;
111
112bool fwl_initFreeWRL(freewrl_params_t *params);
113void closeFreeWRL();
114void terminateFreeWRL();
115
116int fwl_parse_geometry_string(const char *geometry, int *out_width, int *out_height,
117 int *out_xpos, int *out_ypos);
118
122int ConsoleMessage(const char *fmt, ...); /* This does not belong here!! */
123//#endif
124
125/* void Anchor_ReplaceWorld(char *name); */
126bool Anchor_ReplaceWorld();
127
128#define VIEWER_NONE 0 /* would have conflicted with another NONE definition */
129#define VIEWER_EXAMINE 1
130#define VIEWER_WALK 2
131#define VIEWER_EXFLY 3
132#define VIEWER_FLY 4
133#define VIEWER_SPHERICAL 5
134#define VIEWER_FLY2 6
135#define VIEWER_TILT 7
136#define VIEWER_TPLANE 8
137#define VIEWER_RPLANE 9
138#define VIEWER_TURNTABLE 10
139#define VIEWER_LOOKAT 11
140#define VIEWER_EXPLORE 12
141#define VIEWER_YAWZ 13
142#define VIEWER_XY 14
143#define VIEWER_YAWPITCH 15
144#define VIEWER_ROLL 16
145#define VIEWER_DIST 17
146
147#define CHORD_YAWZ 0
148#define CHORD_YAWPITCH 1
149#define CHORD_ROLL 2
150#define CHORD_XY 3
151
152void setStereoBufferStyle(int);
153
154
159#define INT_ID_UNDEFINED -1
160
161
162#define RUNNINGASPLUGIN (isBrowserPlugin)
163
164extern char *BrowserFullPath;
165
166extern int _fw_pipe, _fw_FD;
167extern int _fw_browser_plugin;
168extern int isBrowserPlugin;
169#include <stdint.h>
170extern uintptr_t _fw_instance;
171//extern char *keypress_string;
172
173#ifdef HAVE_LIBCURL
174extern int with_libcurl;
175#endif
176
177#endif /* COMPILING_IPHONE_FRONT_END */
178
179/* ** NEW DJ ** */
180
181void fwl_set_strictParsing(bool flag);
182void fwl_set_plugin_print(bool flag);
183void fwl_set_occlusion_disable(bool flag);
184void fwl_set_print_opengl_errors(bool flag);
185void fwl_set_trace_threads(bool flag);
186void fwl_set_texture_size(unsigned int texture_size);
187unsigned int fwl_get_texture_size();
188void fwl_set_glClearColor (float red , float green , float blue , float alpha);
189void fwl_thread_dump(void);
190int fwg_get_unread_message_count(void);
191char *fwg_get_last_message();
192void fwl_set_logfile(char *);
193void fwl_set_nameTest(char *);
194void fwl_set_testPath(char *);
195void fwl_set_jsengine(char *);
196
197#if defined(_ANDROID)
198int DROIDDEBUG( const char*pFmtStr, ...);
199void PRINTF_ALL( const char*pFmtStr, ...);
200#endif
201
202
203/* ** REPLACE DJ ** */
204/* Try to replace the compile-time options in ConsoleMessage with run-time options */
205// OLD_IPHONE_AQUA #ifdef AQUA
206// OLD_IPHONE_AQUA #define MC_DEF_AQUA 1
207// OLD_IPHONE_AQUA #else
208// OLD_IPHONE_AQUA #define MC_DEF_AQUA 0
209// OLD_IPHONE_AQUA #endif
210
211// OLD_IPHONE_AQUA #ifdef TARGET_AQUA
212// OLD_IPHONE_AQUA #define MC_TARGET_AQUA 1
213// OLD_IPHONE_AQUA #else
214// OLD_IPHONE_AQUA #define MC_TARGET_AQUA 0
215// OLD_IPHONE_AQUA #endif
216
217#ifdef OLDCODE
218OLDCODE#ifdef HAVE_MOTIF
219OLDCODE #define MC_HAVE_MOTIF 1
220OLDCODE#else
221OLDCODE #define MC_HAVE_MOTIF 0
222OLDCODE#endif
223OLDCODE
224OLDCODE#ifdef TARGET_MOTIF
225OLDCODE #define MC_TARGET_MOTIF 1
226OLDCODE#else
227OLDCODE #define MC_TARGET_MOTIF 0
228OLDCODE#endif
229OLDCODE
230OLDCODE#ifdef _MSC_VER
231OLDCODE #define MC_MSC_HAVE_VER 1
232OLDCODE#else
233OLDCODE #define MC_MSC_HAVE_VER 0
234OLDCODE#endif
235#endif // OLDCODE
236
237
238
239int fwl_StringConsoleMessage(char* message);
240
241void fwl_init_SnapGif(void);
242void fwl_set_SnapFile(const char* file);
243void fwl_set_SnapTmp(const char* file);
244void fwl_set_LineWidth(float lwidth);
245void fwl_set_KeyString(const char *str);
246void fwl_setCurXY(int x, int y);
247void fwl_do_keyPress(char kp, int type);
248void fwl_doQuit(char *, int);
249void fwl_doQuitInstance(void *instance);
250void fwl_updateScreenDim(int wi, int he);
251void fwl_doQuitAndWait();
252void fwl_set_viewer_type(const int type);
253
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 */
274int fwlio_RxTx_control(int channel, int action);
275char * fwlio_RxTx_getbuffer(int channel) ;
276void fwlio_RxTx_sendbuffer(char *fromFile, int fromLine, int channel, char *str);
277char * fwlio_RxTx_waitfor(int channel, char *str);
278
279void fwl_init_EaiVerbose();
280char * fwl_EAI_handleBuffer(char *tempEAIdata);
281int fwl_EAI_allDone();
282char * fwl_EAI_handleRest();
283//OLDCODE char * fwl_MIDI_handleBuffer(char *tempEAIdata);
284
285void fwl_set_ScreenDist(const char *optArg);
286void fwl_init_StereoDefaults(void); //don't need to call now March 2012
287void fwl_set_EyeDist(const char *optArg);
288void fwl_init_Shutter(void);
289void fwl_init_SideBySide(void);
290
291void fwl_init_UpDown(void);
292void fwl_set_AnaglyphParameter(const char *optArg);
293void fwl_set_StereoParameter(const char *optArg);
294void fwl_setDrawBoundingBoxes(int drawbb);
295void fwl_setJsEngine(char *optarg);
296// JAS obsolete void fwl_askForRefreshOK();
297
298/* DISPLAY THREAD */
299void fwl_initializeDisplayThread();
300bool checkNetworkFile(const char *fn);
301#define fwl_checkNetworkFile(a) checkNetworkFile(a)
302
303/* PARSER THREAD */
304void fwl_initialize_parser();
305void fwl_initializeInputParseThread();
306int fwl_isinputThreadParsing();
307int fwl_isInputThreadInitialized();
308
309/* TEXTURE THREAD */
310void fwl_initializeTextureThread();
311int fwl_isTextureinitialized();
312
313/* PARSER THREAD */
314int fwl_isTextureParsing();
315
316void fwl_Next_ViewPoint(void);
317void fwl_Prev_ViewPoint(void);
318void fwl_First_ViewPoint(void);
319void fwl_Last_ViewPoint(void);
320void fwl_gotoViewpoint (char *findThisOne);
321
322void fwl_startFreeWRL(const char *url);
323/* distinguish instances from window event handler using the window handle */
324int fwl_setCurrentHandle(void *handle, char*, int);
325void fwl_clearCurrentHandle();
326void *fwl_getCurrentHandle(char *, int);
327
328void fwl_resource_push_single_request(const char *request);
329void fwl_OSX_initializeParameters(const char* initialURL);
330void fwl_resource_push_single_request_IE_main_scene(const char *request);
331
332void fwg_frontEndReturningData(char* fileData,int length,int width,int height,bool hasAlpha);
333
334/* from main/ConsoleMessage.c */
335void fwg_setConsoleParam_maxLines(int);
336void fwg_setConsoleParam_maxLineLength(int);
337void fwg_setConsoleParam_replaceTabs(int);
338
339void fwg_setFrontEndOnX3DFileLoadedListener(void (*frontEndOnX3DFileLoadedListener)(char *));
340
341
342void fwg_frontEndReturningLocalFile(char *localfile, int iret);
343void fwl_RenderSceneUpdateScene(void);
344void fwl_gotoCurrentViewPoint();
345void fwl_setScreenDim(int wi, int he);
346void fwl_setScreenDim0(int wi, int he);
347void fwl_setDensityFactor(float density_factor);
348float fwl_getDensityFactor();
349int fwl_hwnd_to_windex(void *hWnd);
350void fwl_setScreenDim1(int wi, int he, int windex);
351bool fwl_initialize_GL(void);
352//void fwl_setLastMouseEvent(int etype);
353int fwl_handle_aqua(const int mev, const unsigned int button, int x, int y);
354//APPLE int fwl_handle_aqua1(const int mev, const unsigned int button, int x, int y, int windex);
355int fwl_handle_mouse(int mev, int button, int x, int y, int windex);
356int fwl_handle_touch(int mev, unsigned int ID, int x, int y, int windex);
357void fwl_handle_gyro(float rx, float ry, float rz);
358void fwl_handle_accelerometer(float ax, float ay, float az);
359void fwl_handle_magnetic(float azimuth, float pitch, float roll);
360
361
362/* JAS - moving OSX front end into 2011 code workings - these may change. */
363void fwl_replaceWorldNeeded(char* str);
364int fwl_pollPromptForURL(); /* poll from front end / UI in loop */
365int fwl_pollPromptForFile();
366void fwl_setPromptForURL(int state);
367void fwl_setPromptForFile(int state);
368
369char *fwg_frontEndWantsFileName(void);
370int fv_display_initialize(void);
371void fwl_initializeRenderSceneUpdateScene(void);
372void fwl_setButDown(int button, int value);
373
374
375/* IS - moving from main/headers.h to here for use in front-ends (bin/main.c calls some of these) */
376int fwl_get_headlight();
377char* fwl_getNavModeStr();
378int fwl_getNavMode();
379int fwl_getLookatMode();
380int fwl_getCollision();
381void fwl_setCollision(int state);
382int fwl_getAnaglyphSide(int whichSide);
383int fwl_draw(); //use when frontend_handles_display_thread
384void fwl_tmpFileLocation(char *tmpFileLocation);
385void fwl_fontFileLocation(char *fontFileLocation);
386int fwl_set_ui_colorscheme(char *colorschemename);
387void fwl_set_ui_colors(char *fourhtmlcolors);
388void fwl_get_ui_color(char *use, float *rgb);
389char *fwl_get_ui_colorschemename();
390void fwl_next_ui_colorscheme();
391int fwl_get_ui_color_changed();
392int fwl_set_sbh_pin_option(char *optarg);
393int fwl_set_sbh_want_option(char *optarg);
394void fwl_setShadingStyle(int style);
395void fwl_set_sbh_pin(int sb, int mb);
396void fwl_get_sbh_pin(int *sb, int *mb);
397void fwl_set_target_fps(int target_fps);
398int fwl_get_target_fps();
399void fwl_set_sbh_wantMenubar(int want);
400int fwl_get_sbh_wantMenubar();
401void fwl_set_sbh_wantStatusbar(int want);
402int fwl_get_sbh_wantStatusbar();
403void fwl_set_modulation(int modulation);
404int fwl_get_modulation();
405
406
407int fwl_commandline(char *cmdline);
408int fwl_getShift();
409void fwl_setShift(int ishift);
410int fwl_getHover();
411void fwl_setHover(int hover);
412int fwl_getPedal();
413void fwl_setPedal(int pedal);
414int fwl_getCtrl();
415void fwl_set_emulate_multitouch(int ion);
416int fwl_get_emulate_multitouch();
417
418// a few function prototypes from around libfreewrl
419void fwl_setConsole_writePrimitive(int ibool);
420void statusbar_set_window_size(int width, int height);
421int statusbar_handle_mouse(int mev, int butnum, int mouseX, int mouseY);
422int getCursorStyle();
423void *fwl_frontenditem_dequeue();
424char* fwl_resitem_getURL(void *res);
425char* fwl_resitem_getTempDir(void *res);
426void fwl_resitem_setActualFile(void *res, char *fname);
427int fwl_resitem_getStatus(void *res);
428void fwl_resitem_setStatus(void *resp, int status);
429int fwl_resitem_getType(void *res);
430int fwl_resitem_getMediaType(void *res);
431void fwl_resitem_enqueuNextMulti(void *res);
432void fwl_resitem_setLocalPath(void *res, char* path);
433void fwl_resitem_enqueue(void *res);
434void fwl_resitem_setDownloadThread(void *res, void *thread);
435void *fwl_resitem_getDownloadThread(void *res);
436void *fwl_resitem_getGlobal(void *res);
437
438void fwl_init_DIS();
439int fwl_get_allow_DIS();
440void fwl_set_allow_DIS(int allow);
441
442
443int file2blob(void *res);
444#ifdef SSR_SERVER
445//SSR (Server-side rendering)
446void SSRserver_enqueue_request_and_wait(void *fwctx, void *request);
447#endif //SSR_SERVER
448
449#endif /* __LIBFREEWRL_API_H__ */
Initialization.
Definition libFreeWRL.h:72