529 |
string s(str); |
string s(str); |
530 |
return getToken(s); |
return getToken(s); |
531 |
} |
} |
532 |
|
const char *getTokenString(GLenum value) { |
533 |
|
for(int i=0; tokenarr[i].name != NULL; i++) { |
534 |
|
if(tokenarr[i].value == value) |
535 |
|
return tokenarr[i].name; |
536 |
|
} |
537 |
|
return "unknown"; |
538 |
|
} |
539 |
|
|
540 |
double getTokenf(string tok) { |
double getTokenf(string tok) { |
541 |
const char *str = tok.c_str(); |
const char *str = tok.c_str(); |
579 |
return (const char *)glGetString(getTokenValue(name)); |
return (const char *)glGetString(getTokenValue(name)); |
580 |
} |
} |
581 |
|
|
582 |
const vector<float> getFloat(const char *name) { |
template<class C>const vector<float> getFloat_impl(const char *name, C &c) { |
583 |
static float vec0[100]; |
static float vec0[100]; |
584 |
static float vec1[100]; |
static float vec1[100]; |
585 |
static int init; |
static int init; |
600 |
|
|
601 |
int n = 0; |
int n = 0; |
602 |
vector<float> r; |
vector<float> r; |
603 |
glGetFloatv(e, vec0); |
c(e, vec0); |
604 |
glGetFloatv(e, vec1); |
c(e, vec1); |
605 |
|
|
606 |
er = glGetError(); |
er = glGetError(); |
607 |
if (er != GL_NO_ERROR) { |
if (er != GL_NO_ERROR) { |
619 |
return r; |
return r; |
620 |
} |
} |
621 |
|
|
622 |
|
const vector<float> getFloat(const char *name) { |
623 |
|
return getFloat_impl(name, glGetFloatv); |
624 |
|
} |
625 |
|
|
626 |
|
struct X0 { GLuint target; |
627 |
|
void operator()(GLenum e, float *vec) { |
628 |
|
glGetTexParameterfv(target, e,vec); |
629 |
|
} |
630 |
|
} ; |
631 |
|
const vector<float> getTexParameterFloat(const char *target, GLuint tex, const char *name) { |
632 |
|
GLenum e = getTokenValue(target); |
633 |
|
glBindTexture(e, tex); |
634 |
|
X0 x; |
635 |
|
x.target = e; |
636 |
|
vector<float> res = getFloat_impl(name, x); |
637 |
|
glBindTexture(e, 0); |
638 |
|
return res; |
639 |
|
} |
640 |
|
|
641 |
|
struct X1 { GLuint target; GLuint level; |
642 |
|
void operator()(GLenum e, float *vec) { |
643 |
|
glGetTexLevelParameterfv(target, level, e, vec); |
644 |
|
} |
645 |
|
} ; |
646 |
|
const vector<float> getTexLevelParameterFloat(const char *target, GLuint tex, GLuint level, const char *name) { |
647 |
|
GLenum e = getTokenValue(target); |
648 |
|
glBindTexture(e, tex); |
649 |
|
X1 x; |
650 |
|
x.target = e; |
651 |
|
x.level = level; |
652 |
|
vector<float> res = getFloat_impl(name, x); |
653 |
|
glBindTexture(e, 0); |
654 |
|
return res; |
655 |
|
} |
656 |
|
|
657 |
|
|
658 |
void VPCode::compile() { |
void VPCode::compile() { |
659 |
vpid = shared_ptr<VPid>(new VPid); |
vpid = shared_ptr<VPid>(new VPid); |