Nvidia workarounds
authorJean-Luc Peurière <jlp@nerim.net>
Mon, 28 Nov 2005 13:50:44 +0000 (13:50 +0000)
committerJean-Luc Peurière <jlp@nerim.net>
Mon, 28 Nov 2005 13:50:44 +0000 (13:50 +0000)
- partially working workaround for nvidia bug on Os X 10.4.3
- brought back the raster ops hack for GT6800 with proper driver version
  check so that text works both on Os X 10.4.3 and older systems.
  this last patch was given by Kent Miller from Apple

intern/bmfont/intern/BMF_BitmapFont.cpp
intern/ghost/intern/GHOST_SystemCarbon.cpp
source/blender/src/ghostwinlay.c

index bbba2c978dd71597ab4d6568bb089b87e17af3c5..7997a94344b93d0f0df68f2bdd9bde38fda6c811 100644 (file)
 #include "BMF_BitmapFont.h"
 
 
+#ifdef __APPLE__        
+#include <stdio.h>
+
+static int needs_nvidia_rasterpos_workaround(void)
+{
+       static int well_is_it= -1;
+       
+       if (well_is_it==-1)
+       {
+               well_is_it= (strncmp((char *)glGetString(GL_RENDERER), "NVIDIA GeForce 6800", 18) == 0);
+               if ( well_is_it != 0)
+               {
+                       const GLubyte* vers = glGetString(GL_VERSION);
+                       const GLubyte* v = vers;
+                       int major = 0, minor = 0, sub = 0;
+                       
+                       //advance to the '-'
+                       while ((*v != 0) && (*v!='-'))
+                               v++;
+                       
+                       if (*v == '-')
+                       {
+                               int i = 0;
+                               v++;
+                               
+                               while ((v[i] <= '9') && (v[i] >= '0'))
+                               {
+                                       major *=10;
+                                       major += v[i]-'0';
+                                       i++;
+                               }
+                               
+                               if (v[i] == '.')
+                               {
+                                       i++;
+                                       while ((v[i] <= '9') && (v[i] >= '0'))
+                                       {
+                                               minor *=10;
+                                               minor += v[i]-'0';
+                                               i++;
+                                       }
+                               }
+                               else
+                                       major = -1;
+                               
+                               if (v[i] == '.')
+                               {
+                                       i++;
+                                       while ((v[i] <= '9') && (v[i] >= '0'))
+                                       {
+                                               sub *=10;
+                                               sub += v[i]-'0';
+                                               i++;
+                                       }
+                               }
+                               else
+                                       minor = -1;
+                       }
+
+                       //OS X 10.4.3 is the first version that contained the fix for this problem
+                       // and the 6800's driver version in it is 1.4.16.  So anything after that
+                       // doesn't need the workaround
+
+                       if ( (major == -1) || (minor == -1))
+                       //If anything went wrong don't do the workaround
+                       //
+                               well_is_it = 0;
+                       else if ( (major <= 1) && (minor <= 4) && (sub < 16))
+                               well_is_it = 1;
+                       else
+                               well_is_it = 0;
+               }       
+       }
+
+       return well_is_it;
+}
+
+
+#endif
+
 BMF_BitmapFont::BMF_BitmapFont(BMF_FontData* fontData)
 : m_fontData(fontData)
 {
@@ -74,7 +154,19 @@ void BMF_BitmapFont::DrawString(char* str)
        GLint alignment;
        unsigned char c;
 
-       glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+#ifdef __APPLE__        
+     GLint vp[4];  // hack stuff        
+     GLubyte nullm = 0;      // hack stuff      
+        
+     if(needs_nvidia_rasterpos_workaround()) {  // was is_a_really_crappy_nvidia_card()
+             glGetIntegerv(GL_VIEWPORT, vp);   // hack stuff    
+        
+             glBitmap(1, 1, 0, 0, -vp[0], vp[1], &nullm);       
+        
+         }      
+ #endif
+       glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
        
        while ( (c = (unsigned char) *str++) ) {
index d1caadab219edcf7f5d180fbe1c71d9f930f8b0d..ee76349ededded616172d377408535fed415fcf0 100644 (file)
@@ -655,6 +655,7 @@ OSStatus GHOST_SystemCarbon::handleWindowEvent(EventRef event)
                        case kEventWindowActivated:
                                m_windowManager->setActiveWindow(window);
                                window->loadCursor(window->getCursorVisibility(), window->getCursorShape());
+                               window->updateDrawingContext();
                                pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window) );
                                break;
                        case kEventWindowDeactivated:
@@ -663,6 +664,7 @@ OSStatus GHOST_SystemCarbon::handleWindowEvent(EventRef event)
                                break;
                        case kEventWindowUpdate:
                                //if (getFullScreen()) GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen update event\n");
+                               window->updateDrawingContext();
                                pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) );
                                break;
                        case kEventWindowBoundsChanged:
index 7a83dbcb2f55baec544837caed4409d632959e00..88beb6ea87406caffa3cd0d8e719dc783a2dd67f 100644 (file)
@@ -359,6 +359,8 @@ Window *window_open(char *title, int posx, int posy, int sizex, int sizey, int s
                        
                        win->lmouse[0]= win->size[0]/2;
                        win->lmouse[1]= win->size[1]/2;
+                       
+                       
                } else {
                        GHOST_DisposeWindow(g_system, ghostwin);
                }