31 #include <system_threads.h>
35 #include <libFreeWRL.h>
39 #include <libFreeWRL.h>
41 #include "vrml_parser/Structs.h"
42 #include "main/ProdCon.h"
43 #include "input/InputFunctions.h"
45 #include "ui/common.h"
47 char consoleBuffer[200];
56 void fwl_OSX_initializeParameters(
const char* initialURL) {
67 if ((tg->threads.loadThread == 0 ) || (tg->threads.PCthread == 0 )) {
71 myParams.height = 400;
74 myParams.winToEmbedInto = INT_ID_UNDEFINED;
75 myParams.fullscreen = FALSE;
76 myParams.multithreading = TRUE;
77 myParams.enableEAI = FALSE;
78 myParams.verbose = FALSE;
82 OLDCODE fwl_setp_height(400);
83 OLDCODE fwl_setp_eai(FALSE);
84 OLDCODE fwl_setp_fullscreen(FALSE);
87 ConsoleMessage(
"forcing EAI");
88 myParams.enableEAI = TRUE;
93 if (!fwl_initFreeWRL(&myParams)) {
94 ERROR_MSG(
"main: aborting during initialization.\n");
99 res = resource_create_single(initialURL);
103 send_resource_to_parser_async(res);
105 while ((!res->complete) && (res->status != ress_failed)
106 && (res->status != ress_not_loaded)) {
111 if (res->status == ress_not_loaded) {
112 sprintf(consoleBuffer,
"FreeWRL: Problem loading file \"%s\"",
114 fwl_StringConsoleMessage(consoleBuffer);
117 if (res->status == ress_failed) {
118 printf(
"load failed %s\n", initialURL);
119 sprintf(consoleBuffer,
"FreeWRL: unknown data on command line: \"%s\"",
121 fwl_StringConsoleMessage(consoleBuffer);
125 if (res->afterPoundCharacters != NULL) {
126 fwl_gotoViewpoint(res->afterPoundCharacters);
133 if (tg->ProdCon._frontEndOnX3DFileLoadedListener) {
134 char *URLRequest = STRDUP(res->URLrequest);
135 tg->ProdCon._frontEndOnX3DFileLoadedListener(URLRequest);
145 void setInstance(uintptr_t instance) {
147 _fw_instance = instance;
151 void setFullPath(
const char* file) {
160 file = stripLocalFileName((
char *) file);
161 FREE_IF_NZ(BrowserFullPath);
162 BrowserFullPath = STRDUP((
char *) file);
169 char *strForeslash2back(
char *str) {
172 for( jj=0;jj<(int)strlen(str);jj++)
173 if(str[jj] ==
'/' ) str[jj] =
'\\';
181 With Doug Sanden (correctly) moving FreeWRL to multi-invocation, the global parameter "fwl_params"
182 is now local, and options are set within this.
184 OLDCODEvoid fwl_setp_width (
int foo) { fwl_params.width = foo; }
185 OLDCODEvoid fwl_setp_height (
int foo) { fwl_params.height = foo; }
186 OLDCODEvoid fwl_setp_winToEmbedInto (
void* foo) { fwl_params.winToEmbedInto = foo; }
187 OLDCODEvoid fwl_setp_fullscreen (
bool foo) { fwl_params.fullscreen = foo; }
188 OLDCODEvoid fwl_setp_multithreading (
bool foo) { fwl_params.multithreading = foo; }
189 OLDCODEvoid fwl_setp_eai (
bool foo) { fwl_params.enableEAI = foo; }
190 OLDCODEvoid fwl_setp_verbose (
bool foo) { fwl_params.verbose = foo; }
193 OLDCODEint fwl_getp_width (
void) {
return fwl_params.width; }
194 OLDCODEint fwl_getp_height (
void) {
return fwl_params.height; }
195 OLDCODElong
int fwl_getp_winToEmbedInto (
void) {
return fwl_params.winToEmbedInto; }
196 OLDCODEbool fwl_getp_fullscreen (
void) {
return fwl_params.fullscreen; }
197 OLDCODEbool fwl_getp_multithreading (
void) {
return fwl_params.multithreading; }
198 OLDCODEbool fwl_getp_eai (
void) {
return fwl_params.enableEAI; }
199 OLDCODEbool fwl_getp_verbose (
void) {
return fwl_params.verbose; }
205 void* fwl_init_instance() {
209 fwl_setCurrentHandle(NULL, __FILE__, __LINE__);
220 tg = iglobal_constructor();
222 fwl_setCurrentHandle(tg, __FILE__, __LINE__);
228 tg = (
ttglobal) fwl_getCurrentHandle(__FILE__, __LINE__);
232 tg = fwl_init_instance();
233 TRACE_MSG(
"FreeWRL: initializing...\n");
237 tg->threads.mainThread = pthread_self();
249 #if !defined(_ANDROID)
257 DEBUG_MSG(
"copying application supplied params...\n");
265 #if !defined(EXCLUDE_EAI)
267 if (params->enableEAI) {
268 fwlio_RxTx_control(CHANNEL_EAI, RxTx_START);
275 fwl_initialize_parser();
276 fwl_initializeInputParseThread();
277 fwl_initializeTextureThread();
289 void splitpath_local_suffix(
const char *url,
char **local_name,
char **suff) {
297 len = (int) strlen(url);
299 for (i = len - 1; i >= 0; i--) {
302 localname = (
char*) &url[i];
305 *local_name = STRDUP(localname);
306 localname = *local_name;
307 len = (int) strlen(localname);
309 for (i = len - 1; i >= 0; i--) {
310 if (localname[i] ==
'.') {
312 *suff = STRDUP(&localname[i+1]);
320 int checkExitRequest();
326 void closeFreeWRL() {