12 |
#include <vector> |
#include <vector> |
13 |
using std::vector; |
using std::vector; |
14 |
|
|
|
// Should include nvidia's gl.h... |
|
|
//extern "C" void glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); |
|
|
|
|
15 |
namespace CallGL { |
namespace CallGL { |
16 |
DBGVAR(dbg, "CallGL.general"); |
DBGVAR(dbg, "CallGL.general"); |
17 |
|
|
487 |
#endif |
#endif |
488 |
|
|
489 |
#ifdef GL_VERTEX_PROGRAM_NV |
#ifdef GL_VERTEX_PROGRAM_NV |
490 |
|
} else if (checkfunc(v, "BindProgram", 2)) { |
491 |
|
glBindProgramARB(getToken(v[1]), (GLuint)getToken(v[2])); |
492 |
} else if (checkfunc(v, "BindProgramNV", 2)) { |
} else if (checkfunc(v, "BindProgramNV", 2)) { |
493 |
glBindProgramNV(getToken(v[1]), (GLuint)getToken(v[2])); |
glBindProgramNV(getToken(v[1]), (GLuint)getToken(v[2])); |
494 |
} else if (checkfunc(v, "TrackMatrixNV", 4)) { |
} else if (checkfunc(v, "TrackMatrixNV", 4)) { |
615 |
return (const char *)glGetString(getTokenValue(name)); |
return (const char *)glGetString(getTokenValue(name)); |
616 |
} |
} |
617 |
|
|
618 |
template<class C>const vector<float> getFloat_impl(const char *name, C &c) { |
template<class T, class C>const vector<float> getFloat_impl(const char *name, C &c) { |
619 |
static float vec0[100]; |
static T vec0[100]; |
620 |
static float vec1[100]; |
static T vec1[100]; |
621 |
static int init; |
static int init; |
622 |
if (!init) { |
if (!init) { |
623 |
for (int i = 0; i < 100; i++) { |
for (int i = 0; i < 100; i++) { |
656 |
} |
} |
657 |
|
|
658 |
const vector<float> getFloat(const char *name) { |
const vector<float> getFloat(const char *name) { |
659 |
return getFloat_impl(name, glGetFloatv); |
return getFloat_impl<float>(name, glGetFloatv); |
660 |
} |
} |
661 |
|
|
662 |
struct X0 { GLuint target; |
struct X0 { GLuint target; |
669 |
glBindTexture(e, tex); |
glBindTexture(e, tex); |
670 |
X0 x; |
X0 x; |
671 |
x.target = e; |
x.target = e; |
672 |
vector<float> res = getFloat_impl(name, x); |
vector<float> res = getFloat_impl<float>(name, x); |
673 |
glBindTexture(e, 0); |
glBindTexture(e, 0); |
674 |
return res; |
return res; |
675 |
} |
} |
685 |
X1 x; |
X1 x; |
686 |
x.target = e; |
x.target = e; |
687 |
x.level = level; |
x.level = level; |
688 |
vector<float> res = getFloat_impl(name, x); |
vector<float> res = getFloat_impl<float>(name, x); |
689 |
glBindTexture(e, 0); |
glBindTexture(e, 0); |
690 |
return res; |
return res; |
691 |
} |
} |
692 |
|
|
693 |
|
struct X2 { GLuint target; |
694 |
|
void operator()(GLenum e, int *vec) { |
695 |
|
glGetProgramivARB(target, e,vec); |
696 |
|
} |
697 |
|
} ; |
698 |
|
|
699 |
|
const vector<float> getProgram(const char *target, const char *name) { |
700 |
|
X2 x; |
701 |
|
x.target = getTokenValue(target); |
702 |
|
return getFloat_impl<int>(name, x); |
703 |
|
} |
704 |
|
|
705 |
bool loadProgram(GLuint id, const string source) { |
bool loadProgram(GLuint id, const string source) { |
706 |
#ifdef GL_VERTEX_PROGRAM_NV |
#ifdef GL_VERTEX_PROGRAM_NV |
770 |
<< getTokenString(TARGET) |
<< getTokenString(TARGET) |
771 |
<< " program\n"; |
<< " program\n"; |
772 |
|
|
773 |
#if 0 // XXX: disabled until we have glwrapper support |
#ifdef GL_PROGRAM_ERROR_STRING_ARB // XXX: how to test support? |
|
//#ifdef GL_PROGRAM_ERROR_STRING_ARB // XXX: how to test support? |
|
774 |
glBindProgramARB(TARGET, id); |
glBindProgramARB(TARGET, id); |
775 |
glProgramStringARB(TARGET, GL_PROGRAM_FORMAT_ASCII_ARB, |
glProgramStringARB(TARGET, GL_PROGRAM_FORMAT_ASCII_ARB, |
776 |
source.length(), (GLubyte*)source.data()); |
source.length(), (GLubyte*)source.data()); |