From 4821a22070c1f68f224ff670096c2bddf25b932a Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 23 Sep 2011 18:29:38 -0500
Subject: [PATCH] SH-2244 Fix for mac build?

---
 indra/llrender/llgl.cpp           | 17 ++++++++++++++---
 indra/llrender/llvertexbuffer.cpp | 12 ++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index f546e073205..4d0dfbf75d3 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -67,6 +67,12 @@ static const std::string HEADLESS_VERSION_STRING("1.0");
 
 std::ofstream gFailLog;
 
+#if GL_ARB_debug_output
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+
 void APIENTRY gl_debug_callback(GLenum source,
                                 GLenum type,
                                 GLuint id,
@@ -82,6 +88,7 @@ void APIENTRY gl_debug_callback(GLenum source,
 	llwarns << "Message: " << message << llendl;
 	llwarns << "-----------------------" << llendl;
 }
+#endif
 
 void ll_init_fail_log(std::string filename)
 {
@@ -127,7 +134,9 @@ std::list<LLGLUpdate*> LLGLUpdate::sGLQ;
 #if (LL_WINDOWS || LL_LINUX || LL_SOLARIS)  && !LL_MESA_HEADLESS
 // ATI prototypes
 
+#if LL_WINDOWS
 PFNGLGETSTRINGIPROC glGetStringi = NULL;
+#endif
 
 // vertex blending prototypes
 PFNGLWEIGHTPOINTERARBPROC			glWeightPointerARB = NULL;
@@ -484,6 +493,7 @@ bool LLGLManager::initGL()
 		LL_ERRS("RenderInit") << "Calling init on LLGLManager after already initialized!" << LL_ENDL;
 	}
 
+#if LL_WINDOWS
 	if (!glGetStringi)
 	{
 		glGetStringi = (PFNGLGETSTRINGIPROC) GLH_EXT_GET_PROC_ADDRESS("glGetStringi");
@@ -501,7 +511,6 @@ bool LLGLManager::initGL()
 			str << (const char*) glGetStringi(GL_EXTENSIONS, i) << " ";
 		}
 		
-#if LL_WINDOWS
 		{
 			PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = 0;
 			wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
@@ -510,12 +519,12 @@ bool LLGLManager::initGL()
 				str << (const char*) wglGetExtensionsStringARB(wglGetCurrentDC());
 			}
 		}
-#endif
+
 		free(gGLHExts.mSysExts);
 		std::string extensions = str.str();
 		gGLHExts.mSysExts = strdup(extensions.c_str());
-		
 	}
+#endif
 	
 	// Extract video card strings and convert to upper case to
 	// work around driver-to-driver variation in capitalization.
@@ -654,12 +663,14 @@ bool LLGLManager::initGL()
 		glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &mMaxSampleMaskWords);
 	}
 
+#if LL_WINDOWS
 	if (mHasDebugOutput && gDebugGL)
 	{ //setup debug output callback
 		glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW_ARB, 0, NULL, GL_TRUE);
 		glDebugMessageCallbackARB((GLDEBUGPROCARB) gl_debug_callback, NULL);
 		glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
 	}
+#endif
 
 	//HACK always disable texture multisample, use FXAA instead
 	mHasTextureMultisample = FALSE;
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index b2a0f6822d2..add3decee3a 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -575,7 +575,9 @@ void LLVertexBuffer::unbind()
 {
 	if (sGLRenderArray)
 	{
+#if GL_ARB_vertex_array_object
 		glBindVertexArray(0);
+#endif
 		sGLRenderArray = 0;
 	}
 
@@ -733,7 +735,9 @@ LLVertexBuffer::~LLVertexBuffer()
 
 	if (mGLArray)
 	{
+#if GL_ARB_vertex_array_object
 		glDeleteVertexArrays(1, &mGLArray);
+#endif
 	}
 
 	sCount--;
@@ -1049,7 +1053,9 @@ void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create)
 
 		if (gGLManager.mHasVertexArrayObject && useVBOs() && (LLRender::sGLCoreProfile || sUseVAO))
 		{
+#if GL_ARB_vertex_array_object
 			glGenVertexArrays(1, &mGLArray);
+#endif
 			setupVertexArray();
 		}
 	}
@@ -1128,7 +1134,9 @@ void LLVertexBuffer::setupVertexArray()
 		}
 	}
 
+#if GL_ARB_vertex_array_object
 	glBindVertexArray(0);
+#endif
 }
 
 void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
@@ -1864,7 +1872,9 @@ bool LLVertexBuffer::bindGLArray()
 {
 	if (mGLArray && sGLRenderArray != mGLArray)
 	{
+#if GL_ARB_vertex_array_object
 		glBindVertexArray(mGLArray);
+#endif
 		sGLRenderArray = mGLArray;
 		return true;
 	}
@@ -2072,7 +2082,9 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 	{	
 		if (sGLRenderArray)
 		{
+#if GL_ARB_vertex_array_object
 			glBindVertexArray(0);
+#endif
 			sGLRenderArray = 0;
 		}
 
-- 
GitLab