Declare OpenGL 2.0 dynamically-loaded functions for internal use
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1220 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
1dae162bb0
commit
63ca031e62
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -83,6 +83,8 @@ freeglut/freeglut/src/fg_font.c svn_keywords=Author+Date+Id+Revision
|
|||||||
freeglut/freeglut/src/fg_font_data.c svn_keywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/fg_font_data.c svn_keywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/fg_gamemode.c svn_keywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/fg_gamemode.c svn_keywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/fg_geometry.c svn_keywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/fg_geometry.c svn_keywords=Author+Date+Id+Revision
|
||||||
|
freeglut/freeglut/src/fg_gl2.c -text
|
||||||
|
freeglut/freeglut/src/fg_gl2.h -text
|
||||||
freeglut/freeglut/src/fg_init.c svn_keywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/fg_init.c svn_keywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/fg_input_devices.c svn_keywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/fg_input_devices.c svn_keywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/fg_internal.h svn_keywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/fg_internal.h svn_keywords=Author+Date+Id+Revision
|
||||||
|
@ -43,6 +43,8 @@ SET(FREEGLUT_SRCS
|
|||||||
src/fg_ext.c
|
src/fg_ext.c
|
||||||
src/fg_font_data.c
|
src/fg_font_data.c
|
||||||
src/fg_gamemode.c
|
src/fg_gamemode.c
|
||||||
|
src/fg_gl2.c
|
||||||
|
src/fg_gl2.h
|
||||||
src/fg_init.c
|
src/fg_init.c
|
||||||
src/fg_internal.h
|
src/fg_internal.h
|
||||||
src/fg_input_devices.c
|
src/fg_input_devices.c
|
||||||
|
58
freeglut/freeglut/src/fg_gl2.c
Normal file
58
freeglut/freeglut/src/fg_gl2.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* fg_gl2.c
|
||||||
|
*
|
||||||
|
* Load OpenGL (ES) 2.0 functions used by fg_geometry
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Sylvain Beucler
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <GL/freeglut.h>
|
||||||
|
#include "fg_internal.h"
|
||||||
|
#include "fg_gl2.h"
|
||||||
|
|
||||||
|
typedef void (APIENTRY *PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
|
||||||
|
typedef void (APIENTRY *PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
|
||||||
|
typedef void (APIENTRY *PFNGLBUFFERDATAPROC) (GLenum target, fghGLsizeiptr size, const GLvoid *data, GLenum usage);
|
||||||
|
typedef void (APIENTRY *PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers);
|
||||||
|
typedef void (APIENTRY *PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
|
||||||
|
typedef void (APIENTRY *PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint);
|
||||||
|
typedef void (APIENTRY *PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
|
||||||
|
|
||||||
|
PFNGLGENBUFFERSPROC fghGenBuffers = NULL;
|
||||||
|
PFNGLDELETEBUFFERSPROC fghDeleteBuffers = NULL;
|
||||||
|
PFNGLBINDBUFFERPROC fghBindBuffer = NULL;
|
||||||
|
PFNGLBUFFERDATAPROC fghBufferData = NULL;
|
||||||
|
PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray = NULL;
|
||||||
|
PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray = NULL;
|
||||||
|
PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer = NULL;
|
||||||
|
|
||||||
|
void fgInitGL2() {
|
||||||
|
fgState.HasOpenGL20 = 0;
|
||||||
|
#define CHECK(func, a) if ((a) == NULL) { fgWarning("fgInitGL2: " func " is NULL"); return; }
|
||||||
|
CHECK("fghGenBuffers", fghGenBuffers = (PFNGLGENBUFFERSPROC) glutGetProcAddress ("glGenBuffers"));
|
||||||
|
CHECK("fghDeleteBuffers", fghDeleteBuffers = (PFNGLDELETEBUFFERSPROC) glutGetProcAddress ("glDeleteBuffers"));
|
||||||
|
CHECK("fghBindBuffer", fghBindBuffer = (PFNGLBINDBUFFERPROC) glutGetProcAddress ("glBindBuffer"));
|
||||||
|
CHECK("fghBufferData", fghBufferData = (PFNGLBUFFERDATAPROC) glutGetProcAddress ("glBufferData"));
|
||||||
|
CHECK("fghVertexAttribPointer", fghVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) glutGetProcAddress ("glVertexAttribPointer"));
|
||||||
|
CHECK("fghEnableVertexAttribArray", fghEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) glutGetProcAddress ("glEnableVertexAttribArray"));
|
||||||
|
CHECK("fghDisableVertexAttribArray", fghDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) glutGetProcAddress ("glDisnableVertexAttribArray"));
|
||||||
|
#undef CHECK
|
||||||
|
fgState.HasOpenGL20 = 1;
|
||||||
|
}
|
49
freeglut/freeglut/src/fg_gl2.h
Normal file
49
freeglut/freeglut/src/fg_gl2.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* fg_gl2.c
|
||||||
|
*
|
||||||
|
* Load OpenGL (ES) 2.0 functions used by fg_geometry
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Sylvain Beucler
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FG_GL2_H
|
||||||
|
#define FG_GL2_H
|
||||||
|
|
||||||
|
#ifndef APIENTRY
|
||||||
|
# define APIENTRY
|
||||||
|
#endif
|
||||||
|
typedef ptrdiff_t fghGLsizeiptr;
|
||||||
|
typedef void (APIENTRY *PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
|
||||||
|
typedef void (APIENTRY *PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
|
||||||
|
typedef void (APIENTRY *PFNGLBUFFERDATAPROC) (GLenum target, fghGLsizeiptr size, const GLvoid *data, GLenum usage);
|
||||||
|
typedef void (APIENTRY *PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers);
|
||||||
|
typedef void (APIENTRY *PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
|
||||||
|
typedef void (APIENTRY *PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint);
|
||||||
|
typedef void (APIENTRY *PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
|
||||||
|
|
||||||
|
PFNGLGENBUFFERSPROC fghGenBuffers;
|
||||||
|
PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
|
||||||
|
PFNGLBINDBUFFERPROC fghBindBuffer;
|
||||||
|
PFNGLBUFFERDATAPROC fghBufferData;
|
||||||
|
PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
|
||||||
|
PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
|
||||||
|
PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
|
||||||
|
|
||||||
|
#endif
|
@ -90,6 +90,7 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */
|
|||||||
0, /* OpenGL context MinorVersion */
|
0, /* OpenGL context MinorVersion */
|
||||||
0, /* OpenGL ContextFlags */
|
0, /* OpenGL ContextFlags */
|
||||||
0, /* OpenGL ContextProfile */
|
0, /* OpenGL ContextProfile */
|
||||||
|
0, /* HasOpenGL20 */
|
||||||
NULL, /* ErrorFunc */
|
NULL, /* ErrorFunc */
|
||||||
NULL /* WarningFunc */
|
NULL /* WarningFunc */
|
||||||
};
|
};
|
||||||
@ -380,6 +381,8 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
|
|||||||
if( (mask & (XValue|YValue)) == (XValue|YValue) )
|
if( (mask & (XValue|YValue)) == (XValue|YValue) )
|
||||||
fgState.Position.Use = GL_TRUE;
|
fgState.Position.Use = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fgInitGL2();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -319,6 +319,7 @@ struct tagSFG_State
|
|||||||
int MajorVersion; /* Major OpenGL context version */
|
int MajorVersion; /* Major OpenGL context version */
|
||||||
int MinorVersion; /* Minor OpenGL context version */
|
int MinorVersion; /* Minor OpenGL context version */
|
||||||
int ContextFlags; /* OpenGL context flags */
|
int ContextFlags; /* OpenGL context flags */
|
||||||
|
int HasOpenGL20; /* fgInitGL2 could find all OpenGL 2.0 functions */
|
||||||
int ContextProfile; /* OpenGL context profile */
|
int ContextProfile; /* OpenGL context profile */
|
||||||
FGError ErrorFunc; /* User defined error handler */
|
FGError ErrorFunc; /* User defined error handler */
|
||||||
FGWarning WarningFunc; /* User defined warning handler */
|
FGWarning WarningFunc; /* User defined warning handler */
|
||||||
|
Reference in New Issue
Block a user