12 |
#include <vector> |
#include <vector> |
13 |
using std::vector; |
using std::vector; |
14 |
|
|
15 |
|
#include <map> |
16 |
|
|
17 |
// Should include nvidia's gl.h... |
// Should include nvidia's gl.h... |
18 |
//extern "C" void glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); |
//extern "C" void glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); |
19 |
|
|
22 |
|
|
23 |
using std::string; |
using std::string; |
24 |
using std::vector; |
using std::vector; |
25 |
|
using std::map; |
26 |
|
|
27 |
using std::cerr; |
using std::cerr; |
28 |
using std::cout; |
using std::cout; |
29 |
|
|
30 |
|
map<string, void (*)()> extended_calls; |
31 |
|
ExtCallsCheckList ext_check; |
32 |
|
|
33 |
static bool Begin = false; |
static bool Begin = false; |
34 |
|
|
35 |
int getToken(string tok); |
int getToken(string tok); |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
/* vector<string> v = split(" asdf # asdffoo fasdf # fadasfd "); |
/* vector<string> v = split(" foo # bar "); |
75 |
* 0: asdf |
* 0: foo |
76 |
* 1: # |
* 1: # |
77 |
* 2: asdffoo |
* 2: bar |
|
* 3: fasdf |
|
|
* 4: # |
|
|
* 5: fadasfd |
|
78 |
*/ |
*/ |
79 |
vector<string> split(string str) { |
vector<string> split(string str) { |
80 |
string tmp; |
string tmp; |
129 |
bool callGLop(string s) { |
bool callGLop(string s) { |
130 |
DBG(dbg) << "callGLop(\"" << s << "\")\n"; |
DBG(dbg) << "callGLop(\"" << s << "\")\n"; |
131 |
|
|
132 |
|
// Substring comment out -- if '#' found |
133 |
string::size_type position = s.find('#'); |
string::size_type position = s.find('#'); |
134 |
if (position != string::npos) s = s.substr(0, position); |
if (position != string::npos) s = s.substr(0, position); |
135 |
|
|
137 |
|
|
138 |
if (v.size() < 1) return true; |
if (v.size() < 1) return true; |
139 |
|
|
|
// Ignore lines where the first splitted "word" starts with a '#' |
|
|
//if (v[0][0] == '#') return true; |
|
|
|
|
140 |
if (checkfunc(v, "Enable", 1)) { |
if (checkfunc(v, "Enable", 1)) { |
141 |
glEnable(getToken(v[1])); |
glEnable(getToken(v[1])); |
142 |
} else if (checkfunc(v, "Disable", 1)) { |
} else if (checkfunc(v, "Disable", 1)) { |
427 |
|
|
428 |
#endif |
#endif |
429 |
|
|
430 |
|
// XXX |
431 |
|
//#define USE_GL_EXTENSION_CALLS |
432 |
|
#ifdef USE_GL_EXTENSION_CALLS |
433 |
|
|
434 |
|
} else if (checkfunc(v, "GetProcAddress", 1)) { |
435 |
|
if (ext_check.isCallNameFound(v[1])) { |
436 |
|
|
437 |
|
void (* addr)() = Os::getExtendedProcAddress(v[1]); |
438 |
|
|
439 |
|
if (addr == NULL) { |
440 |
|
cerr << v[1] << " not supported by your gl-driver.\n"; |
441 |
|
return false; |
442 |
|
} |
443 |
|
extended_calls[v[1]] = addr; |
444 |
|
|
445 |
|
} else { |
446 |
|
cerr << v[1] << " not found from extended calls list.\n"; |
447 |
|
return false; |
448 |
|
} |
449 |
|
} else { |
450 |
|
if (ext_check.isCallNameFound(v[0])) { |
451 |
|
ExtCall ext_c = ext_check.getCallObj(v[0]); |
452 |
|
|
453 |
|
void (* addr)() = extended_calls[v[0]]; |
454 |
|
|
455 |
|
if (addr == NULL) { |
456 |
|
cerr << v[0] << " is extension function but "<< |
457 |
|
"it haven't been initialized with \"GetProcAddress\".\n"; |
458 |
|
return false; |
459 |
|
} |
460 |
|
switch (ext_c.getType()) { |
461 |
|
case EXT_ERROR: |
462 |
|
cerr << "something very broken in extended call.\n"; |
463 |
|
return false; |
464 |
|
case FLOAT3: { if (v.size() != 4) goto error_args_count; |
465 |
|
void (* a)(float,float,float); |
466 |
|
a = (void (*)( float, float,float))(addr); |
467 |
|
(* a)( atof(v[1].c_str()), atof(v[2].c_str()), |
468 |
|
atof(v[3].c_str())); |
469 |
|
break; |
470 |
|
} |
471 |
|
case FLOAT4: { |
472 |
|
if (v.size() != 5) goto error_args_count; |
473 |
|
void (* a)(float,float,float,float); |
474 |
|
a = (void (*)( float, float,float,float))(addr); |
475 |
|
(* a)( atof(v[1].c_str()), atof(v[2].c_str()), |
476 |
|
atof(v[3].c_str()), atof(v[4].c_str())); |
477 |
|
break; |
478 |
|
} |
479 |
|
/* //probably just put ints to map<string> or something |
480 |
|
case ENUM1: { |
481 |
|
if (v.size() != 2) goto error_args_count; |
482 |
|
void (* a)(enum); |
483 |
|
a = (void (*)(enum))(addr); |
484 |
|
|
485 |
|
//(* a)( ); |
486 |
|
break; |
487 |
|
} |
488 |
|
*/ |
489 |
|
} // end of switch |
490 |
|
|
491 |
|
} else { |
492 |
|
error_args_count: |
493 |
|
cerr << "Unknown function \"" << v[0] << "\" with " |
494 |
|
<< v.size() - 1 << " arguments\n"; |
495 |
|
return false; |
496 |
|
} |
497 |
|
} |
498 |
|
|
499 |
|
#else /* with no extension calls.. */ |
500 |
} else { |
} else { |
501 |
cerr << "Unknown function \"" << v[0] << "\" with " |
cerr << "Unknown function \"" << v[0] << "\" with " |
502 |
<< v.size() - 1 << " arguments\n"; |
<< v.size() - 1 << " arguments\n"; |
503 |
return false; |
return false; |
504 |
} |
} |
505 |
|
#endif /* USE_GL_EXTENSION_CALLS */ |
506 |
|
|
507 |
|
|
508 |
if (!Begin) { |
if (!Begin) { |
509 |
int er = glGetError(); |
int er = glGetError(); |