Skip to content

Commit

Permalink
1. Don't throw warnings if the NVidia opengl extension functions are …
Browse files Browse the repository at this point in the history
…missing

2. If OpenGLRenderSetting is set to the nvidia combiner, but the extension functions are missing, then set to auto rather than crash
  • Loading branch information
richard42 committed Mar 7, 2012
1 parent 744c360 commit 420266b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/DeviceBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "OGLDebug.h"
#include "OGLFragmentShaders.h"
#include "OGLExtRender.h"
#include "OGLExtensions.h"
#include "OGLGraphicsContext.h"
#include "OGLTexture.h"

Expand Down Expand Up @@ -235,6 +236,11 @@ CColorCombiner * OGLDeviceBuilder::CreateColorCombiner(CRender *pRender)
else
{
m_deviceType = (SupportedDeviceType)options.OpenglRenderSetting;
if (m_deviceType == NVIDIA_OGL_DEVICE && !bNvidiaExtensionsSupported)
{
DebugMessage(M64MSG_WARNING, "Your video card does not support Nvidia OpenGL extensions. Falling back to auto device.");
m_deviceType = OGL_DEVICE;
}
if( m_deviceType == OGL_DEVICE ) // Best fit
{
GLint maxUnit = 2;
Expand Down
3 changes: 2 additions & 1 deletion src/OGLCombinerNV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ bool COGLColorCombinerNvidia::Initialize(void)
{
m_bNVSupported = true;
glEnable(GL_REGISTER_COMBINERS_NV);
return true;
}
else
{
DebugMessage(M64MSG_ERROR, "Your video card does not support Nvidia OpenGL extension combiner");
glDisable(GL_REGISTER_COMBINERS_NV);
return false;
}
return true;
}

glDisable(GL_REGISTER_COMBINERS_NV);
Expand Down
18 changes: 13 additions & 5 deletions src/OGLExtensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

static void APIENTRY EmptyFunc(void) { return; }

bool bNvidiaExtensionsSupported = false;
PFUNCGLCOMBINERPARAMETERFVNVPROC pglCombinerParameterfvNV = (PFUNCGLCOMBINERPARAMETERFVNVPROC) EmptyFunc;
PFUNCGLFINALCOMBINERINPUTNVPROC pglFinalCombinerInputNV = (PFUNCGLFINALCOMBINERINPUTNVPROC) EmptyFunc;
PFUNCGLCOMBINEROUTPUTNVPROC pglCombinerOutputNV = (PFUNCGLCOMBINEROUTPUTNVPROC) EmptyFunc;
Expand All @@ -50,11 +51,18 @@ PFUNCGLCLIENTACTIVETEXTUREARBPROC pglClientActiveTextureARB = (PFUNCGLCLIENTA

void OGLExtensions_Init(void)
{
INIT_ENTRY_POINT(PFUNCGLCOMBINERPARAMETERFVNVPROC, glCombinerParameterfvNV);
INIT_ENTRY_POINT(PFUNCGLFINALCOMBINERINPUTNVPROC, glFinalCombinerInputNV);
INIT_ENTRY_POINT(PFUNCGLCOMBINEROUTPUTNVPROC, glCombinerOutputNV);
INIT_ENTRY_POINT(PFUNCGLCOMBINERINPUTNVPROC, glCombinerInputNV);
INIT_ENTRY_POINT(PFUNCGLCOMBINERPARAMETERINVPROC, glCombinerParameteriNV);
/* nvidia extensions are a special case */
bNvidiaExtensionsSupported = true;
pglCombinerParameterfvNV = (PFUNCGLCOMBINERPARAMETERFVNVPROC) CoreVideo_GL_GetProcAddress("glCombinerParameterfvNV");
if (pglCombinerParameterfvNV == NULL) bNvidiaExtensionsSupported = false;
pglFinalCombinerInputNV = (PFUNCGLFINALCOMBINERINPUTNVPROC) CoreVideo_GL_GetProcAddress("glFinalCombinerInputNV");
if (pglFinalCombinerInputNV == NULL) bNvidiaExtensionsSupported = false;
pglCombinerOutputNV = (PFUNCGLCOMBINEROUTPUTNVPROC) CoreVideo_GL_GetProcAddress("glCombinerOutputNV");
if (pglCombinerOutputNV == NULL) bNvidiaExtensionsSupported = false;
pglCombinerInputNV = (PFUNCGLCOMBINERINPUTNVPROC) CoreVideo_GL_GetProcAddress("glCombinerInputNV");
if (pglCombinerInputNV == NULL) bNvidiaExtensionsSupported = false;
pglCombinerParameteriNV = (PFUNCGLCOMBINERPARAMETERINVPROC) CoreVideo_GL_GetProcAddress("glCombinerParameteriNV");
if (pglCombinerParameteriNV == NULL) bNvidiaExtensionsSupported = false;

INIT_ENTRY_POINT(PFUNCGLACTIVETEXTUREPROC, glActiveTexture);
INIT_ENTRY_POINT(PFUNCGLACTIVETEXTUREARBPROC, glActiveTextureARB);
Expand Down
1 change: 1 addition & 0 deletions src/OGLExtensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ typedef void (APIENTRYP PFUNCGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GL
typedef void (APIENTRYP PFUNCGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
typedef void (APIENTRYP PFUNCGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);

extern bool bNvidiaExtensionsSupported;
extern PFUNCGLCOMBINERPARAMETERFVNVPROC pglCombinerParameterfvNV;
extern PFUNCGLFINALCOMBINERINPUTNVPROC pglFinalCombinerInputNV;
extern PFUNCGLCOMBINEROUTPUTNVPROC pglCombinerOutputNV;
Expand Down

0 comments on commit 420266b

Please sign in to comment.