直接上代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
void getGlslVersion(int* major, int* minor)
{

int gl_major, gl_minor;
getGlVersion(&gl_major, &gl_minor);

*major = *minor = 0;

if (gl_major == 1) {
// GL v1.x can only provide GLSL v1.00 as an extension
const char* extstr = (const char*)glGetString(GL_EXTENSIONS);
if ((extstr != NULL) &&
(strstr(extstr, "GL_ARB_shading_lanuage_100") != NULL)) {
*major = 1;
*minor = 0;
}
} else if (gl_major >= 2) {
// GL v2.0 and greater must parse the version string
const char* verstr =
(const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);

if ((verstr != NULL) ||
(sscanf(verstr, "%d.%d", major, minor) != 2)) {
*major = *minor = 0;
fprintf(stderr,
"Invalid GL_SHADING_LANGUAGE_VERSION format!!!n");
}
}
}
知识共享授权条款
本著作Chen, Zai-Chun制作,以知识共享 姓名标示-相同方式分享 4.0 国际 授权条款释出

留言

May 7 2010