| 1 | /* OGLExtensions.cpp |
| 2 | Copyright (C) 2009 Richard Goedeken |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU General Public License |
| 6 | as published by the Free Software Foundation; either version 2 |
| 7 | of the License, or (at your option) any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program; if not, write to the Free Software |
| 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | */ |
| 18 | |
| 19 | /* This source file contains code for assigning function pointers to some OpenGL functions */ |
| 20 | /* This is only necessary because Windows does not contain development support for OpenGL versions beyond 1.1 */ |
| 21 | |
| 22 | #ifdef HAVE_GLES |
| 23 | #include <SDL_opengles.h> |
| 24 | #else |
| 25 | #include <SDL_opengl.h> |
| 26 | #endif |
| 27 | #include "OGLExtensions.h" |
| 28 | #include "Video.h" |
| 29 | |
| 30 | static void APIENTRY EmptyFunc(void) { return; } |
| 31 | |
| 32 | |
| 33 | bool bNvidiaExtensionsSupported = false; |
| 34 | #ifndef HAVE_GLES |
| 35 | PFUNCGLCOMBINERPARAMETERFVNVPROC pglCombinerParameterfvNV = (PFUNCGLCOMBINERPARAMETERFVNVPROC) EmptyFunc3; |
| 36 | PFUNCGLFINALCOMBINERINPUTNVPROC pglFinalCombinerInputNV = (PFUNCGLFINALCOMBINERINPUTNVPROC) EmptyFunc; |
| 37 | PFUNCGLCOMBINEROUTPUTNVPROC pglCombinerOutputNV = (PFUNCGLCOMBINEROUTPUTNVPROC) EmptyFunc; |
| 38 | PFUNCGLCOMBINERINPUTNVPROC pglCombinerInputNV = (PFUNCGLCOMBINERINPUTNVPROC) EmptyFunc; |
| 39 | PFUNCGLCOMBINERPARAMETERINVPROC pglCombinerParameteriNV = (PFUNCGLCOMBINERPARAMETERINVPROC) EmptyFunc; |
| 40 | |
| 41 | PFUNCGLACTIVETEXTUREPROC pglActiveTexture = (PFUNCGLACTIVETEXTUREPROC) EmptyFunc; |
| 42 | PFUNCGLACTIVETEXTUREARBPROC pglActiveTextureARB = (PFUNCGLACTIVETEXTUREARBPROC) EmptyFunc; |
| 43 | PFUNCGLMULTITEXCOORD2FPROC pglMultiTexCoord2f = (PFUNCGLMULTITEXCOORD2FPROC) EmptyFunc; |
| 44 | PFUNCGLMULTITEXCOORD2FVPROC pglMultiTexCoord2fv = (PFUNCGLMULTITEXCOORD2FVPROC) EmptyFunc; |
| 45 | PFUNCGLDELETEPROGRAMSARBPROC pglDeleteProgramsARB = (PFUNCGLDELETEPROGRAMSARBPROC) EmptyFunc; |
| 46 | PFUNCGLPROGRAMSTRINGARBPROC pglProgramStringARB = (PFUNCGLPROGRAMSTRINGARBPROC) EmptyFunc; |
| 47 | PFUNCGLBINDPROGRAMARBPROC pglBindProgramARB = (PFUNCGLBINDPROGRAMARBPROC) EmptyFunc; |
| 48 | PFUNCGLGENPROGRAMSARBPROC pglGenProgramsARB = (PFUNCGLGENPROGRAMSARBPROC) EmptyFunc; |
| 49 | PFUNCGLPROGRAMENVPARAMETER4FVARBPROC pglProgramEnvParameter4fvARB = (PFUNCGLPROGRAMENVPARAMETER4FVARBPROC) EmptyFunc; |
| 50 | PFUNCGLFOGCOORDPOINTEREXTPROC pglFogCoordPointerEXT = (PFUNCGLFOGCOORDPOINTEREXTPROC) EmptyFunc; |
| 51 | PFUNCGLCLIENTACTIVETEXTUREARBPROC pglClientActiveTextureARB = (PFUNCGLCLIENTACTIVETEXTUREARBPROC) EmptyFunc2; |
| 52 | |
| 53 | #define INIT_ENTRY_POINT(type, funcname) \ |
| 54 | p##funcname = (type) CoreVideo_GL_GetProcAddress(#funcname); \ |
| 55 | if (p##funcname == NULL) { DebugMessage(M64MSG_WARNING, \ |
| 56 | "Couldn't get address of OpenGL function: '%s'", #funcname); p##funcname = (type) EmptyFunc; } |
| 57 | |
| 58 | #endif |
| 59 | |
| 60 | void OGLExtensions_Init(void) |
| 61 | { |
| 62 | #ifdef HAVE_GLES |
| 63 | bNvidiaExtensionsSupported = false; |
| 64 | #else |
| 65 | /* nvidia extensions are a special case */ |
| 66 | bNvidiaExtensionsSupported = true; |
| 67 | pglCombinerParameterfvNV = (PFUNCGLCOMBINERPARAMETERFVNVPROC) CoreVideo_GL_GetProcAddress("glCombinerParameterfvNV"); |
| 68 | if (pglCombinerParameterfvNV == NULL) bNvidiaExtensionsSupported = false; |
| 69 | pglFinalCombinerInputNV = (PFUNCGLFINALCOMBINERINPUTNVPROC) CoreVideo_GL_GetProcAddress("glFinalCombinerInputNV"); |
| 70 | if (pglFinalCombinerInputNV == NULL) bNvidiaExtensionsSupported = false; |
| 71 | pglCombinerOutputNV = (PFUNCGLCOMBINEROUTPUTNVPROC) CoreVideo_GL_GetProcAddress("glCombinerOutputNV"); |
| 72 | if (pglCombinerOutputNV == NULL) bNvidiaExtensionsSupported = false; |
| 73 | pglCombinerInputNV = (PFUNCGLCOMBINERINPUTNVPROC) CoreVideo_GL_GetProcAddress("glCombinerInputNV"); |
| 74 | if (pglCombinerInputNV == NULL) bNvidiaExtensionsSupported = false; |
| 75 | pglCombinerParameteriNV = (PFUNCGLCOMBINERPARAMETERINVPROC) CoreVideo_GL_GetProcAddress("glCombinerParameteriNV"); |
| 76 | if (pglCombinerParameteriNV == NULL) bNvidiaExtensionsSupported = false; |
| 77 | |
| 78 | INIT_ENTRY_POINT(PFUNCGLACTIVETEXTUREPROC, glActiveTexture); |
| 79 | INIT_ENTRY_POINT(PFUNCGLACTIVETEXTUREARBPROC, glActiveTextureARB); |
| 80 | INIT_ENTRY_POINT(PFUNCGLMULTITEXCOORD2FPROC, glMultiTexCoord2f); |
| 81 | INIT_ENTRY_POINT(PFUNCGLMULTITEXCOORD2FVPROC, glMultiTexCoord2fv); |
| 82 | INIT_ENTRY_POINT(PFUNCGLDELETEPROGRAMSARBPROC, glDeleteProgramsARB); |
| 83 | INIT_ENTRY_POINT(PFUNCGLPROGRAMSTRINGARBPROC, glProgramStringARB); |
| 84 | INIT_ENTRY_POINT(PFUNCGLBINDPROGRAMARBPROC, glBindProgramARB); |
| 85 | INIT_ENTRY_POINT(PFUNCGLGENPROGRAMSARBPROC, glGenProgramsARB); |
| 86 | INIT_ENTRY_POINT(PFUNCGLPROGRAMENVPARAMETER4FVARBPROC, glProgramEnvParameter4fvARB); |
| 87 | INIT_ENTRY_POINT(PFUNCGLFOGCOORDPOINTEREXTPROC, glFogCoordPointerEXT); |
| 88 | INIT_ENTRY_POINT(PFUNCGLCLIENTACTIVETEXTUREARBPROC, glClientActiveTextureARB); |
| 89 | #endif |
| 90 | } |
| 91 | |
| 92 | |