smoothgl3 and shapes demos, now checking if glutGetProcAddress calls give us valid function pointers
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1500 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
05a9a7c907
commit
f79dae9865
@ -93,11 +93,6 @@ typedef char ourGLchar;
|
||||
#define APIENTRY
|
||||
#endif
|
||||
|
||||
#ifndef GL_VERSION_1_5
|
||||
typedef void (APIENTRY *PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
|
||||
typedef void (APIENTRY *PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
|
||||
typedef void (APIENTRY *PFNGLBUFFERDATAPROC) (GLenum target, ourGLsizeiptr size, const GLvoid *data, GLenum usage);
|
||||
#endif
|
||||
#ifndef GL_VERSION_2_0
|
||||
typedef GLuint (APIENTRY *PFNGLCREATESHADERPROC) (GLenum type);
|
||||
typedef void (APIENTRY *PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const ourGLchar **string, const GLint *length);
|
||||
@ -149,6 +144,11 @@ void initExtensionEntries(void)
|
||||
gl_GetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) glutGetProcAddress ("glGetUniformLocation");
|
||||
gl_UniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) glutGetProcAddress ("glUniformMatrix4fv");
|
||||
gl_UniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) glutGetProcAddress ("glUniformMatrix3fv");
|
||||
if (!gl_CreateShader || !gl_ShaderSource || !gl_CompileShader || !gl_CreateProgram || !gl_AttachShader || !gl_LinkProgram || !gl_UseProgram || !gl_GetShaderiv || !gl_GetShaderInfoLog || !gl_GetProgramiv || !gl_GetProgramInfoLog || !gl_GetAttribLocation || !gl_GetUniformLocation || !gl_UniformMatrix4fv || !gl_UniformMatrix3fv)
|
||||
{
|
||||
fprintf (stderr, "glCreateShader, glShaderSource, glCompileShader, glCreateProgram, glAttachShader, glLinkProgram, glUseProgram, glGetShaderiv, glGetShaderInfoLog, glGetProgramiv, glGetProgramInfoLog, glGetAttribLocation, glGetUniformLocation, glUniformMatrix4fv or gl_UniformMatrix3fv not found");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
const ourGLchar *vertexShaderSource[] = {
|
||||
|
@ -153,9 +153,19 @@ void initExtensionEntries(void)
|
||||
{
|
||||
gl_GenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) glutGetProcAddress ("glGenVertexArrays");
|
||||
gl_BindVertexArray = (PFNGLBINDVERTEXARRAYPROC) glutGetProcAddress ("glBindVertexArray");
|
||||
if (!gl_GenVertexArrays || !gl_BindVertexArray)
|
||||
{
|
||||
fprintf (stderr, "glGenVertexArrays or glBindVertexArray not found");
|
||||
exit(1);
|
||||
}
|
||||
gl_GenBuffers = (PFNGLGENBUFFERSPROC) glutGetProcAddress ("glGenBuffers");
|
||||
gl_BindBuffer = (PFNGLBINDBUFFERPROC) glutGetProcAddress ("glBindBuffer");
|
||||
gl_BufferData = (PFNGLBUFFERDATAPROC) glutGetProcAddress ("glBufferData");
|
||||
if (!gl_GenBuffers || !gl_BindBuffer || !gl_BufferData)
|
||||
{
|
||||
fprintf (stderr, "glGenBuffers, glBindBuffer or glBufferData not found");
|
||||
exit(1);
|
||||
}
|
||||
gl_CreateShader = (PFNGLCREATESHADERPROC) glutGetProcAddress ("glCreateShader");
|
||||
gl_ShaderSource = (PFNGLSHADERSOURCEPROC) glutGetProcAddress ("glShaderSource");
|
||||
gl_CompileShader = (PFNGLCOMPILESHADERPROC) glutGetProcAddress ("glCompileShader");
|
||||
@ -172,6 +182,11 @@ void initExtensionEntries(void)
|
||||
gl_EnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) glutGetProcAddress ("glEnableVertexAttribArray");
|
||||
gl_GetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) glutGetProcAddress ("glGetUniformLocation");
|
||||
gl_UniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) glutGetProcAddress ("glUniformMatrix4fv");
|
||||
if (!gl_CreateShader || !gl_ShaderSource || !gl_CompileShader || !gl_CreateProgram || !gl_AttachShader || !gl_LinkProgram || !gl_UseProgram || !gl_GetShaderiv || !gl_GetShaderInfoLog || !gl_GetProgramiv || !gl_GetProgramInfoLog || !gl_GetAttribLocation || !gl_VertexAttribPointer || !gl_EnableVertexAttribArray || !gl_GetUniformLocation || !gl_UniformMatrix4fv)
|
||||
{
|
||||
fprintf (stderr, "glCreateShader, glShaderSource, glCompileShader, glCreateProgram, glAttachShader, glLinkProgram, glUseProgram, glGetShaderiv, glGetShaderInfoLog, glGetProgramiv, glGetProgramInfoLog, glGetAttribLocation, glVertexAttribPointer, glEnableVertexAttribArray, glGetUniformLocation or glUniformMatrix4fv not found");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* vertex array data for a colored 2D triangle, consisting of RGB color values
|
||||
|
Reference in New Issue
Block a user