Comment out GLX code for MacOS and (hopefully) add some MacOS AGL compattible code. More needs to be done though.

This commit is contained in:
ehofman
2005-02-01 10:35:43 +00:00
parent e5f82f53b9
commit 72f35dc914
2 changed files with 64 additions and 9 deletions
+62 -9
View File
@@ -122,6 +122,7 @@ RenderTexture::RenderTexture(const char *strMode)
_hPBuffer(NULL), _hPBuffer(NULL),
_hPreviousDC(0), _hPreviousDC(0),
_hPreviousContext(0), _hPreviousContext(0),
#elif defined( __APPLE__ )
#else #else
_pDisplay(NULL), _pDisplay(NULL),
_hGLContext(NULL), _hGLContext(NULL),
@@ -145,6 +146,7 @@ RenderTexture::RenderTexture(const char *strMode)
_pbufferAttribs.push_back(WGL_PBUFFER_LARGEST_ARB); _pbufferAttribs.push_back(WGL_PBUFFER_LARGEST_ARB);
_pbufferAttribs.push_back(true); _pbufferAttribs.push_back(true);
#elif defined( __APPLE__ )
#else #else
_pbufferAttribs.push_back(GLX_RENDER_TYPE_SGIX); _pbufferAttribs.push_back(GLX_RENDER_TYPE_SGIX);
_pbufferAttribs.push_back(GLX_RGBA_BIT_SGIX); _pbufferAttribs.push_back(GLX_RGBA_BIT_SGIX);
@@ -440,6 +442,7 @@ bool RenderTexture::Initialize(int width, int height,
fprintf(stderr, "\n"); fprintf(stderr, "\n");
#endif #endif
#elif defined( __APPLE__ )
#else // !_WIN32 #else // !_WIN32
_pDisplay = glXGetCurrentDisplay(); _pDisplay = glXGetCurrentDisplay();
GLXContext context = glXGetCurrentContext(); GLXContext context = glXGetCurrentContext();
@@ -521,6 +524,7 @@ bool RenderTexture::Initialize(int width, int height,
_wglGetLastError(); _wglGetLastError();
return false; return false;
} }
#elif defined( __APPLE__ )
#else #else
_hPreviousContext = glXGetCurrentContext(); _hPreviousContext = glXGetCurrentContext();
_hPreviousDrawable = glXGetCurrentDrawable(); _hPreviousDrawable = glXGetCurrentDrawable();
@@ -545,6 +549,7 @@ bool RenderTexture::Initialize(int width, int height,
_wglGetLastError(); _wglGetLastError();
return false; return false;
} }
#elif defined( __APPLE__ )
#else #else
if (False == glXMakeCurrent(_pDisplay, if (False == glXMakeCurrent(_pDisplay,
_hPreviousDrawable, _hPreviousContext)) _hPreviousDrawable, _hPreviousContext))
@@ -596,6 +601,7 @@ bool RenderTexture::_Invalidate()
_hPBuffer = 0; _hPBuffer = 0;
return true; return true;
} }
#elif defined( __APPLE__ )
#else #else
if ( _hPBuffer ) if ( _hPBuffer )
{ {
@@ -666,6 +672,7 @@ bool RenderTexture::Reset(const char *strMode, ...)
_pbufferAttribs.push_back(WGL_PBUFFER_LARGEST_ARB); _pbufferAttribs.push_back(WGL_PBUFFER_LARGEST_ARB);
_pbufferAttribs.push_back(true); _pbufferAttribs.push_back(true);
#elif defined( __APPLE__ )
#else #else
_pbufferAttribs.push_back(GLX_RENDER_TYPE_SGIX); _pbufferAttribs.push_back(GLX_RENDER_TYPE_SGIX);
_pbufferAttribs.push_back(GLX_RGBA_BIT_SGIX); _pbufferAttribs.push_back(GLX_RGBA_BIT_SGIX);
@@ -735,6 +742,7 @@ bool RenderTexture::Resize(int iWidth, int iHeight)
_hPBuffer = 0; _hPBuffer = 0;
return true; return true;
} }
#elif defined( __APPLE__ )
#else #else
if ( _hPBuffer ) if ( _hPBuffer )
{ {
@@ -777,6 +785,7 @@ bool RenderTexture::BeginCapture()
_hPreviousContext = wglGetCurrentContext(); _hPreviousContext = wglGetCurrentContext();
if (NULL == _hPreviousContext) if (NULL == _hPreviousContext)
_wglGetLastError(); _wglGetLastError();
#elif defined( __APPLE__ )
#else #else
_hPreviousContext = glXGetCurrentContext(); _hPreviousContext = glXGetCurrentContext();
_hPreviousDrawable = glXGetCurrentDrawable(); _hPreviousDrawable = glXGetCurrentDrawable();
@@ -814,6 +823,7 @@ bool RenderTexture::EndCapture()
_wglGetLastError(); _wglGetLastError();
return false; return false;
} }
#elif defined( __APPLE__ )
#else #else
if (False == glXMakeCurrent(_pDisplay, _hPreviousDrawable, if (False == glXMakeCurrent(_pDisplay, _hPreviousDrawable,
_hPreviousContext)) _hPreviousContext))
@@ -883,6 +893,7 @@ bool RenderTexture::BeginCapture(RenderTexture* current)
_hPreviousContext = current->_hPreviousContext; _hPreviousContext = current->_hPreviousContext;
if (NULL == _hPreviousContext) if (NULL == _hPreviousContext)
_wglGetLastError(); _wglGetLastError();
#elif defined( __APPLE__ )
#else #else
_hPreviousContext = current->_hPreviousContext; _hPreviousContext = current->_hPreviousContext;
_hPreviousDrawable = current->_hPreviousDrawable; _hPreviousDrawable = current->_hPreviousDrawable;
@@ -1066,17 +1077,22 @@ void RenderTexture::_ParseModeString(const char *modeString,
pfAttribs.push_back(bitVec[1]); pfAttribs.push_back(bitVec[1]);
pfAttribs.push_back(WGL_BLUE_BITS_ARB); pfAttribs.push_back(WGL_BLUE_BITS_ARB);
pfAttribs.push_back(bitVec[2]); pfAttribs.push_back(bitVec[2]);
#elif defined( __APPLE__ )
pfAttribs.push_back(AGL_RED_SIZE);
pfAttribs.push_back(bitVec[0]);
pfAttribs.push_back(AGL_GREEN_SIZE);
pfAttribs.push_back(bitVec[1]);
pfAttribs.push_back(AGL_BLUE_SIZE);
pfAttribs.push_back(bitVec[2]);
#else #else
# ifndef sgi
pfAttribs.push_back(GLX_RED_SIZE); pfAttribs.push_back(GLX_RED_SIZE);
pfAttribs.push_back(bitVec[0]); pfAttribs.push_back(bitVec[0]);
pfAttribs.push_back(GLX_GREEN_SIZE); pfAttribs.push_back(GLX_GREEN_SIZE);
pfAttribs.push_back(bitVec[1]); pfAttribs.push_back(bitVec[1]);
pfAttribs.push_back(GLX_BLUE_SIZE); pfAttribs.push_back(GLX_BLUE_SIZE);
pfAttribs.push_back(bitVec[2]); pfAttribs.push_back(bitVec[2]);
# endif
#endif #endif
_iNumComponents += 3; _iNumComponents += 3;
continue; continue;
} }
else if (kv.first == "rgb") else if (kv.first == "rgb")
@@ -1109,8 +1125,16 @@ void RenderTexture::_ParseModeString(const char *modeString,
pfAttribs.push_back(bitVec[2]); pfAttribs.push_back(bitVec[2]);
pfAttribs.push_back(WGL_ALPHA_BITS_ARB); pfAttribs.push_back(WGL_ALPHA_BITS_ARB);
pfAttribs.push_back(bitVec[3]); pfAttribs.push_back(bitVec[3]);
#elif defined( __APPLE__ )
pfAttribs.push_back(AGL_RED_SIZE);
pfAttribs.push_back(bitVec[0]);
pfAttribs.push_back(AGL_GREEN_SIZE);
pfAttribs.push_back(bitVec[1]);
pfAttribs.push_back(AGL_BLUE_SIZE);
pfAttribs.push_back(bitVec[2]);
pfAttribs.push_back(AGL_ALPHA_SIZE);
pfAttribs.push_back(bitVec[3]);
#else #else
# ifndef sgi
pfAttribs.push_back(GLX_RED_SIZE); pfAttribs.push_back(GLX_RED_SIZE);
pfAttribs.push_back(bitVec[0]); pfAttribs.push_back(bitVec[0]);
pfAttribs.push_back(GLX_GREEN_SIZE); pfAttribs.push_back(GLX_GREEN_SIZE);
@@ -1119,9 +1143,8 @@ void RenderTexture::_ParseModeString(const char *modeString,
pfAttribs.push_back(bitVec[2]); pfAttribs.push_back(bitVec[2]);
pfAttribs.push_back(GLX_ALPHA_SIZE); pfAttribs.push_back(GLX_ALPHA_SIZE);
pfAttribs.push_back(bitVec[3]); pfAttribs.push_back(bitVec[3]);
# endif
#endif #endif
_iNumComponents = 4; _iNumComponents = 4;
continue; continue;
} }
else if (kv.first == "rgba") else if (kv.first == "rgba")
@@ -1140,6 +1163,9 @@ void RenderTexture::_ParseModeString(const char *modeString,
#ifdef _WIN32 #ifdef _WIN32
pfAttribs.push_back(WGL_RED_BITS_ARB); pfAttribs.push_back(WGL_RED_BITS_ARB);
pfAttribs.push_back(bitVec[0]); pfAttribs.push_back(bitVec[0]);
#elif defined( __APPLE__ )
pfAttribs.push_back(AGL_RED_SIZE);
pfAttribs.push_back(bitVec[0]);
#else #else
pfAttribs.push_back(GLX_RED_SIZE); pfAttribs.push_back(GLX_RED_SIZE);
pfAttribs.push_back(bitVec[0]); pfAttribs.push_back(bitVec[0]);
@@ -1170,6 +1196,11 @@ void RenderTexture::_ParseModeString(const char *modeString,
pfAttribs.push_back(bitVec[0]); pfAttribs.push_back(bitVec[0]);
pfAttribs.push_back(WGL_GREEN_BITS_ARB); pfAttribs.push_back(WGL_GREEN_BITS_ARB);
pfAttribs.push_back(bitVec[1]); pfAttribs.push_back(bitVec[1]);
#elif defined( __APPLE__ )
pfAttribs.push_back(AGL_RED_SIZE);
pfAttribs.push_back(bitVec[0]);
pfAttribs.push_back(AGL_GREEN_SIZE);
pfAttribs.push_back(bitVec[1]);
#else #else
pfAttribs.push_back(GLX_RED_SIZE); pfAttribs.push_back(GLX_RED_SIZE);
pfAttribs.push_back(bitVec[0]); pfAttribs.push_back(bitVec[0]);
@@ -1199,6 +1230,8 @@ void RenderTexture::_ParseModeString(const char *modeString,
bHasStencil = true; bHasStencil = true;
#ifdef _WIN32 #ifdef _WIN32
pfAttribs.push_back(WGL_STENCIL_BITS_ARB); pfAttribs.push_back(WGL_STENCIL_BITS_ARB);
#elif defined( __APPLE__ )
pfAttribs.push_back(AGL_STENCIL_SIZE);
#else #else
pfAttribs.push_back(GLX_STENCIL_SIZE); pfAttribs.push_back(GLX_STENCIL_SIZE);
#endif #endif
@@ -1216,6 +1249,11 @@ void RenderTexture::_ParseModeString(const char *modeString,
pfAttribs.push_back(1); pfAttribs.push_back(1);
pfAttribs.push_back(WGL_SAMPLES_ARB); pfAttribs.push_back(WGL_SAMPLES_ARB);
pfAttribs.push_back(strtol(kv.second.c_str(), 0, 10)); pfAttribs.push_back(strtol(kv.second.c_str(), 0, 10));
#elif defined( __APPLE__ )
pfAttribs.push_back(AGL_SAMPLE_BUFFERS_ARB);
pfAttribs.push_back(1);
pfAttribs.push_back(AGL_SAMPLES_ARB);
pfAttribs.push_back(strtol(kv.second.c_str(), 0, 10));
#else #else
pfAttribs.push_back(GL_SAMPLE_BUFFERS_ARB); pfAttribs.push_back(GL_SAMPLE_BUFFERS_ARB);
pfAttribs.push_back(1); pfAttribs.push_back(1);
@@ -1231,6 +1269,9 @@ void RenderTexture::_ParseModeString(const char *modeString,
#ifdef _WIN32 #ifdef _WIN32
pfAttribs.push_back(WGL_DOUBLE_BUFFER_ARB); pfAttribs.push_back(WGL_DOUBLE_BUFFER_ARB);
pfAttribs.push_back(true); pfAttribs.push_back(true);
#elif defined( __APPLE__ )
pfAttribs.push_back(AGL_DOUBLEBUFFER);
pfAttribs.push_back(True);
#else #else
pfAttribs.push_back(GL_DOUBLEBUFFER); pfAttribs.push_back(GL_DOUBLEBUFFER);
pfAttribs.push_back(True); pfAttribs.push_back(True);
@@ -1242,6 +1283,8 @@ void RenderTexture::_ParseModeString(const char *modeString,
{ {
#ifdef _WIN32 #ifdef _WIN32
pfAttribs.push_back(WGL_AUX_BUFFERS_ARB); pfAttribs.push_back(WGL_AUX_BUFFERS_ARB);
#elif defined( __APPLE__ )
pfAttribs.push_back(AGL_AUX_BUFFERS);
#else #else
pfAttribs.push_back(GL_AUX_BUFFERS); pfAttribs.push_back(GL_AUX_BUFFERS);
#endif #endif
@@ -1349,6 +1392,8 @@ void RenderTexture::_ParseModeString(const char *modeString,
#ifdef _WIN32 #ifdef _WIN32
pfAttribs.push_back(WGL_DEPTH_BITS_ARB); pfAttribs.push_back(WGL_DEPTH_BITS_ARB);
#elif defined( __APPLE__ )
pfAttribs.push_back(AGL_DEPTH_SIZE);
#else #else
pfAttribs.push_back(GLX_DEPTH_SIZE); pfAttribs.push_back(GLX_DEPTH_SIZE);
#endif #endif
@@ -1359,6 +1404,9 @@ void RenderTexture::_ParseModeString(const char *modeString,
#ifdef _WIN32 #ifdef _WIN32
pfAttribs.push_back(WGL_STENCIL_BITS_ARB); pfAttribs.push_back(WGL_STENCIL_BITS_ARB);
pfAttribs.push_back(0); pfAttribs.push_back(0);
#elif defined( __APPLE__ )
pfAttribs.push_back(AGL_STENCIL_SIZE);
pfAttribs.push_back(0);
#else #else
pfAttribs.push_back(GLX_STENCIL_SIZE); pfAttribs.push_back(GLX_STENCIL_SIZE);
pfAttribs.push_back(0); pfAttribs.push_back(0);
@@ -1414,7 +1462,7 @@ void RenderTexture::_ParseModeString(const char *modeString,
#elif defined(DEBUG) || defined(_DEBUG) #elif defined(DEBUG) || defined(_DEBUG)
printf("RenderTexture Error: Render to Texture not " printf("RenderTexture Error: Render to Texture not "
"supported in Linux\n"); "supported in Linux or MacOS\n");
#endif #endif
} }
@@ -1435,6 +1483,7 @@ void RenderTexture::_ParseModeString(const char *modeString,
pfAttribs.push_back(WGL_PIXEL_TYPE_ARB); pfAttribs.push_back(WGL_PIXEL_TYPE_ARB);
pfAttribs.push_back(WGL_TYPE_RGBA_FLOAT_ATI); pfAttribs.push_back(WGL_TYPE_RGBA_FLOAT_ATI);
} }
#elif defined( __APPLE__ )
#else #else
if (GL_NV_float_buffer) if (GL_NV_float_buffer)
{ {
@@ -1548,7 +1597,7 @@ void RenderTexture::_ParseModeString(const char *modeString,
#elif defined(DEBUG) || defined(_DEBUG) #elif defined(DEBUG) || defined(_DEBUG)
fprintf(stderr, fprintf(stderr,
"RenderTexture Error: Render to Texture not supported in " "RenderTexture Error: Render to Texture not supported in "
"Linux\n"); "Linux or MacOS\ n");
#endif #endif
} }
@@ -1573,7 +1622,7 @@ void RenderTexture::_ParseModeString(const char *modeString,
} }
#elif defined(DEBUG) || defined(_DEBUG) #elif defined(DEBUG) || defined(_DEBUG)
printf("RenderTexture Error: Render to Texture not supported in " printf("RenderTexture Error: Render to Texture not supported in "
"Linux\n"); "Linux or MacOS\n");
#endif #endif
} }
} }
@@ -1720,6 +1769,7 @@ bool RenderTexture::_VerifyExtensions()
} }
SetLastError(0); SetLastError(0);
} }
#elif defined( __APPLE__ )
#else #else
if (!GLX_SGIX_pbuffer) if (!GLX_SGIX_pbuffer)
{ {
@@ -2042,6 +2092,7 @@ bool RenderTexture::_MakeCurrent()
_wglGetLastError(); _wglGetLastError();
return false; return false;
} }
#elif defined( __APPLE__ )
#else #else
if (false == glXMakeCurrent(_pDisplay, _hPBuffer, _hGLContext)) if (false == glXMakeCurrent(_pDisplay, _hPBuffer, _hGLContext))
{ {
@@ -2093,6 +2144,7 @@ RenderTexture::RenderTexture(int width, int height,
_hPBuffer(NULL), _hPBuffer(NULL),
_hPreviousDC(0), _hPreviousDC(0),
_hPreviousContext(0), _hPreviousContext(0),
#elif defined( __APPLE__ )
#else #else
_pDisplay(NULL), _pDisplay(NULL),
_hGLContext(NULL), _hGLContext(NULL),
@@ -2209,6 +2261,7 @@ bool RenderTexture::Initialize(bool bShare /* = true */,
_pbufferAttribs.push_back(WGL_PBUFFER_LARGEST_ARB); _pbufferAttribs.push_back(WGL_PBUFFER_LARGEST_ARB);
_pbufferAttribs.push_back(true); _pbufferAttribs.push_back(true);
#elif defined( __APPLE__ )
#else #else
_pixelFormatAttribs.push_back(GLX_RENDER_TYPE_SGIX); _pixelFormatAttribs.push_back(GLX_RENDER_TYPE_SGIX);
_pixelFormatAttribs.push_back(GLX_RGBA_BIT_SGIX); _pixelFormatAttribs.push_back(GLX_RGBA_BIT_SGIX);
+2
View File
@@ -337,6 +337,8 @@ protected: // data
HDC _hPreviousDC; HDC _hPreviousDC;
HGLRC _hPreviousContext; HGLRC _hPreviousContext;
#elif defined( __APPLE__ )
#else #else
Display *_pDisplay; Display *_pDisplay;
GLXContext _hGLContext; GLXContext _hGLContext;