When -mno-cygwin is used, we get ancient GL headers, so be a bit more conservative.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@787 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
5cd0ad0211
commit
49526044d2
@ -66,6 +66,10 @@ void checkError(const char *functionName)
|
|||||||
#define GL_STATIC_DRAW 0x88E4
|
#define GL_STATIC_DRAW 0x88E4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef GL_FRAGMENT_SHADER
|
||||||
|
#define GL_FRAGMENT_SHADER 0x8B30
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef GL_VERTEX_SHADER
|
#ifndef GL_VERTEX_SHADER
|
||||||
#define GL_VERTEX_SHADER 0x8B31
|
#define GL_VERTEX_SHADER 0x8B31
|
||||||
#endif
|
#endif
|
||||||
@ -86,13 +90,16 @@ void checkError(const char *functionName)
|
|||||||
#define GL_INFO_LOG_LENGTH 0x8B84
|
#define GL_INFO_LOG_LENGTH 0x8B84
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef ptrdiff_t ourGLsizeiptr;
|
||||||
|
typedef char ourGLchar;
|
||||||
|
|
||||||
typedef void (*PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
|
typedef void (*PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
|
||||||
PFNGLGENBUFFERSPROC gl_GenBuffers;
|
PFNGLGENBUFFERSPROC gl_GenBuffers;
|
||||||
|
|
||||||
typedef void (*PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
|
typedef void (*PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
|
||||||
PFNGLBINDBUFFERPROC gl_BindBuffer;
|
PFNGLBINDBUFFERPROC gl_BindBuffer;
|
||||||
|
|
||||||
typedef void (*PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size,
|
typedef void (*PFNGLBUFFERDATAPROC) (GLenum target, ourGLsizeiptr size,
|
||||||
const GLvoid *data, GLenum usage);
|
const GLvoid *data, GLenum usage);
|
||||||
PFNGLBUFFERDATAPROC gl_BufferData;
|
PFNGLBUFFERDATAPROC gl_BufferData;
|
||||||
|
|
||||||
@ -100,7 +107,7 @@ typedef GLuint (*PFNGLCREATESHADERPROC) (GLenum type);
|
|||||||
PFNGLCREATESHADERPROC gl_CreateShader;
|
PFNGLCREATESHADERPROC gl_CreateShader;
|
||||||
|
|
||||||
typedef void (*PFNGLSHADERSOURCEPROC)
|
typedef void (*PFNGLSHADERSOURCEPROC)
|
||||||
(GLuint shader, GLsizei count, const GLchar **string, const GLint *length);
|
(GLuint shader, GLsizei count, const ourGLchar **string, const GLint *length);
|
||||||
PFNGLSHADERSOURCEPROC gl_ShaderSource;
|
PFNGLSHADERSOURCEPROC gl_ShaderSource;
|
||||||
|
|
||||||
typedef void (*PFNGLCOMPILESHADERPROC) (GLuint shader);
|
typedef void (*PFNGLCOMPILESHADERPROC) (GLuint shader);
|
||||||
@ -122,17 +129,17 @@ typedef void (*PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params
|
|||||||
PFNGLGETSHADERIVPROC gl_GetShaderiv;
|
PFNGLGETSHADERIVPROC gl_GetShaderiv;
|
||||||
|
|
||||||
typedef void (*PFNGLGETSHADERINFOLOGPROC)
|
typedef void (*PFNGLGETSHADERINFOLOGPROC)
|
||||||
(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
(GLuint shader, GLsizei bufSize, GLsizei *length, ourGLchar *infoLog);
|
||||||
PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog;
|
PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog;
|
||||||
|
|
||||||
typedef void (*PFNGLGETPROGRAMIVPROC) (GLenum target, GLenum pname, GLint *params);
|
typedef void (*PFNGLGETPROGRAMIVPROC) (GLenum target, GLenum pname, GLint *params);
|
||||||
PFNGLGETPROGRAMIVPROC gl_GetProgramiv;
|
PFNGLGETPROGRAMIVPROC gl_GetProgramiv;
|
||||||
|
|
||||||
typedef void (*PFNGLGETPROGRAMINFOLOGPROC)
|
typedef void (*PFNGLGETPROGRAMINFOLOGPROC)
|
||||||
(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
(GLuint program, GLsizei bufSize, GLsizei *length, ourGLchar *infoLog);
|
||||||
PFNGLGETPROGRAMINFOLOGPROC gl_GetProgramInfoLog;
|
PFNGLGETPROGRAMINFOLOGPROC gl_GetProgramInfoLog;
|
||||||
|
|
||||||
typedef GLint (*PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
|
typedef GLint (*PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const ourGLchar *name);
|
||||||
PFNGLGETATTRIBLOCATIONPROC gl_GetAttribLocation;
|
PFNGLGETATTRIBLOCATIONPROC gl_GetAttribLocation;
|
||||||
|
|
||||||
typedef void (*PFNGLVERTEXATTRIBPOINTERPROC)
|
typedef void (*PFNGLVERTEXATTRIBPOINTERPROC)
|
||||||
@ -143,7 +150,7 @@ PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer;
|
|||||||
typedef void (*PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
|
typedef void (*PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
|
||||||
PFNGLENABLEVERTEXATTRIBARRAYPROC gl_EnableVertexAttribArray;
|
PFNGLENABLEVERTEXATTRIBARRAYPROC gl_EnableVertexAttribArray;
|
||||||
|
|
||||||
typedef GLint (*PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
|
typedef GLint (*PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const ourGLchar *name);
|
||||||
PFNGLGETUNIFORMLOCATIONPROC gl_GetUniformLocation;
|
PFNGLGETUNIFORMLOCATIONPROC gl_GetUniformLocation;
|
||||||
|
|
||||||
typedef void (*PFNGLUNIFORMMATRIX4FVPROC)
|
typedef void (*PFNGLUNIFORMMATRIX4FVPROC)
|
||||||
@ -205,7 +212,7 @@ void initBuffer(void)
|
|||||||
checkError ("initBuffer");
|
checkError ("initBuffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
const GLchar *vertexShaderSource[] = {
|
const ourGLchar *vertexShaderSource[] = {
|
||||||
"#version 130\n",
|
"#version 130\n",
|
||||||
"uniform mat4 fg_ProjectionMatrix;\n",
|
"uniform mat4 fg_ProjectionMatrix;\n",
|
||||||
"in vec4 fg_Color;\n",
|
"in vec4 fg_Color;\n",
|
||||||
@ -217,7 +224,7 @@ const GLchar *vertexShaderSource[] = {
|
|||||||
"}\n"
|
"}\n"
|
||||||
};
|
};
|
||||||
|
|
||||||
const GLchar *fragmentShaderSource[] = {
|
const ourGLchar *fragmentShaderSource[] = {
|
||||||
"#version 130\n",
|
"#version 130\n",
|
||||||
"out vec4 fg_FragColor;\n",
|
"out vec4 fg_FragColor;\n",
|
||||||
"void main(void)\n",
|
"void main(void)\n",
|
||||||
@ -233,16 +240,16 @@ void compileAndCheck(GLuint shader)
|
|||||||
gl_GetShaderiv (shader, GL_COMPILE_STATUS, &status);
|
gl_GetShaderiv (shader, GL_COMPILE_STATUS, &status);
|
||||||
if (status == GL_FALSE) {
|
if (status == GL_FALSE) {
|
||||||
GLint infoLogLength;
|
GLint infoLogLength;
|
||||||
GLchar *infoLog;
|
ourGLchar *infoLog;
|
||||||
gl_GetShaderiv (shader, GL_INFO_LOG_LENGTH, &infoLogLength);
|
gl_GetShaderiv (shader, GL_INFO_LOG_LENGTH, &infoLogLength);
|
||||||
infoLog = (GLchar*) malloc (infoLogLength);
|
infoLog = (ourGLchar*) malloc (infoLogLength);
|
||||||
gl_GetShaderInfoLog (shader, infoLogLength, NULL, infoLog);
|
gl_GetShaderInfoLog (shader, infoLogLength, NULL, infoLog);
|
||||||
fprintf (stderr, "compile log: %s\n", infoLog);
|
fprintf (stderr, "compile log: %s\n", infoLog);
|
||||||
free (infoLog);
|
free (infoLog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint compileShaderSource(GLenum type, GLsizei count, const GLchar **string)
|
GLuint compileShaderSource(GLenum type, GLsizei count, const ourGLchar **string)
|
||||||
{
|
{
|
||||||
GLuint shader = gl_CreateShader (type);
|
GLuint shader = gl_CreateShader (type);
|
||||||
gl_ShaderSource (shader, count, string, NULL);
|
gl_ShaderSource (shader, count, string, NULL);
|
||||||
@ -257,9 +264,9 @@ void linkAndCheck(GLuint program)
|
|||||||
gl_GetProgramiv (program, GL_LINK_STATUS, &status);
|
gl_GetProgramiv (program, GL_LINK_STATUS, &status);
|
||||||
if (status == GL_FALSE) {
|
if (status == GL_FALSE) {
|
||||||
GLint infoLogLength;
|
GLint infoLogLength;
|
||||||
GLchar *infoLog;
|
ourGLchar *infoLog;
|
||||||
gl_GetProgramiv (program, GL_INFO_LOG_LENGTH, &infoLogLength);
|
gl_GetProgramiv (program, GL_INFO_LOG_LENGTH, &infoLogLength);
|
||||||
infoLog = (GLchar*) malloc (infoLogLength);
|
infoLog = (ourGLchar*) malloc (infoLogLength);
|
||||||
gl_GetProgramInfoLog (program, infoLogLength, NULL, infoLog);
|
gl_GetProgramInfoLog (program, infoLogLength, NULL, infoLog);
|
||||||
fprintf (stderr, "link log: %s\n", infoLog);
|
fprintf (stderr, "link log: %s\n", infoLog);
|
||||||
free (infoLog);
|
free (infoLog);
|
||||||
@ -285,11 +292,11 @@ GLuint fgVertexIndex;
|
|||||||
|
|
||||||
void initShader(void)
|
void initShader(void)
|
||||||
{
|
{
|
||||||
const GLsizei vertexShaderLines = sizeof(vertexShaderSource) / sizeof(GLchar*);
|
const GLsizei vertexShaderLines = sizeof(vertexShaderSource) / sizeof(ourGLchar*);
|
||||||
GLuint vertexShader =
|
GLuint vertexShader =
|
||||||
compileShaderSource (GL_VERTEX_SHADER, vertexShaderLines, vertexShaderSource);
|
compileShaderSource (GL_VERTEX_SHADER, vertexShaderLines, vertexShaderSource);
|
||||||
|
|
||||||
const GLsizei fragmentShaderLines = sizeof(fragmentShaderSource) / sizeof(GLchar*);
|
const GLsizei fragmentShaderLines = sizeof(fragmentShaderSource) / sizeof(ourGLchar*);
|
||||||
GLuint fragmentShader =
|
GLuint fragmentShader =
|
||||||
compileShaderSource (GL_FRAGMENT_SHADER, fragmentShaderLines, fragmentShaderSource);
|
compileShaderSource (GL_FRAGMENT_SHADER, fragmentShaderLines, fragmentShaderSource);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user