Use OpenGL functions under extension names, if not present under regular names.

master
Cyp 2012-06-16 23:09:00 +02:00
parent 174c56190d
commit 96272ebf50
5 changed files with 36 additions and 7 deletions

Binary file not shown.

View File

@ -204,12 +204,19 @@ void screenShutDown(void)
}
// Make OpenGL's VBO functions available under the core names for drivers that support OpenGL 1.4 only but have the VBO extension
void screen_EnableVBO()
void screen_EnableMissingFunctions()
{
// no need if there is OpenGL 1.5 available
if (!GLEW_VERSION_1_3 && GLEW_ARB_multitexture)
{
debug(LOG_WARNING, "Pre-OpenGL 1.3: Fixing ARB_multitexture extension function names.");
__glewActiveTexture = __glewActiveTextureARB;
__glewMultiTexCoord2fv = __glewMultiTexCoord2fvARB;
}
if (!GLEW_VERSION_1_5 && GLEW_ARB_vertex_buffer_object)
{
debug(LOG_WARNING, "OpenGL 1.4+: Using VBO extension functions under the core names.");
debug(LOG_WARNING, "Pre-OpenGL 1.5: Fixing ARB_vertex_buffer_object extension function names.");
__glewBindBuffer = __glewBindBufferARB;
__glewBufferData = __glewBufferDataARB;
@ -223,6 +230,27 @@ void screen_EnableVBO()
__glewMapBuffer = __glewMapBufferARB;
__glewUnmapBuffer = __glewUnmapBufferARB;
}
if (!GLEW_VERSION_2_0 && GLEW_ARB_shader_objects)
{
debug(LOG_WARNING, "Pre-OpenGL 2.0: Fixing ARB_shader_objects extension function names.");
__glewGetUniformLocation = __glewGetUniformLocationARB;
__glewAttachShader = __glewAttachObjectARB;
__glewCompileShader = __glewCompileShaderARB;
__glewCreateProgram = __glewCreateProgramObjectARB;
__glewCreateShader = __glewCreateShaderObjectARB;
__glewGetProgramInfoLog = __glewGetInfoLogARB;
__glewGetShaderInfoLog = __glewGetInfoLogARB; // Same as previous.
__glewGetProgramiv = __glewGetObjectParameterivARB;
__glewUseProgram = __glewUseProgramObjectARB;
__glewGetShaderiv = __glewGetObjectParameterivARB;
__glewLinkProgram = __glewLinkProgramARB;
__glewShaderSource = __glewShaderSourceARB;
__glewUniform1f = __glewUniform1fARB;
__glewUniform1i = __glewUniform1iARB;
__glewUniform4fv = __glewUniform4fvARB;
}
}
void screen_SetBackDropFromFile(const char* filename)

View File

@ -63,8 +63,8 @@ extern void screenDoDumpToDiskIfRequired(void);
void screen_enableMapPreview(char *name, int width, int height, Vector2i *playerpositions);
void screen_disableMapPreview(void);
bool screen_getMapPreview(void);
void screen_EnableMissingFunctions();
void screen_EnableVBO();
struct OPENGL_DATA
{
char vendor[256];

View File

@ -35,6 +35,7 @@
#include "lib/framework/wzapp.h"
#include "lib/ivis_opengl/piemode.h"
#include "lib/ivis_opengl/piestate.h"
#include "lib/ivis_opengl/screen.h"
#include "lib/ivis_opengl/tex.h"
#include "lib/ivis_opengl/ivi.h"
#include "lib/netplay/netplay.h"
@ -520,6 +521,9 @@ bool systemInitialise(void)
// Initialize the iVis text rendering module
iV_TextInit();
// Fix badly named OpenGL functions. Must be done after iV_TextInit, to avoid the renames being clobbered by an extra glewInit() call.
screen_EnableMissingFunctions();
iV_Reset(); // Reset the IV library.
readAIs();

View File

@ -711,9 +711,6 @@ bool initTerrain(void)
int decalSize;
int maxSectorSizeIndices, maxSectorSizeVertices;
bool decreasedSize = false;
// call VBO support hack before using it
screen_EnableVBO();
// this information is useful to prevent crashes with buggy opengl implementations
glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &GLmaxElementsVertices);