gpulib: eliminate list scan-ahead
[pcsx_rearmed.git] / plugins / gpu-gles / gpuDraw.c
index 3d09c33..ebb3bf0 100644 (file)
 \r
 #define _IN_DRAW\r
 \r
-#ifdef _WINDOWS\r
-#include "stdafx.h"\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <math.h>\r
-#include "externals.h"\r
-#include "gpu.h"\r
-#include "draw.h"\r
-#include "prim.h"\r
-#include "texture.h"\r
-#else\r
+\r
 #include "gpuExternals.h"\r
-#include "GPUPlugin.h"\r
+#include "gpuPlugin.h"\r
 #include "gpuDraw.h"\r
 #include "gpuPrim.h"\r
 #include "gpuTexture.h"\r
@@ -48,7 +38,6 @@
 #include <stdio.h>\r
 #include <stdlib.h>\r
 #include <math.h>\r
-#endif\r
 //#include "menu.h"\r
             \r
 ////////////////////////////////////////////////////////////////////////////////////\r
 ////////////////////////////////////////////////////////////////////////////////////\r
 // draw globals\r
 \r
-#ifdef _WINDOWS\r
-HDC            dcGlobal=NULL;\r
-HWND           hWWindow;\r
-#else\r
 void  glBlendEquationEXT(GLenum mode);\r
 void  glColorTableEXT(GLenum target, GLenum internalFormat, GLsizei width, GLenum format,GLenum type, const GLvoid *data);\r
-#endif\r
 \r
 // draw globals; most will be initialized again later (by config or checks) \r
 \r
@@ -158,50 +142,6 @@ GLbitfield     uiBufferBits=GL_COLOR_BUFFER_BIT;
 // Set OGL pixel format\r
 ////////////////////////////////////////////////////////////////////////\r
  \r
-#ifdef _WINDOWS\r
-BOOL bSetupPixelFormat(HDC hDC)\r
-{\r
- int pixelformat;\r
- static PIXELFORMATDESCRIPTOR pfd = \r
-  {\r
-   sizeof(PIXELFORMATDESCRIPTOR),    // size of this pfd\r
-    1,                               // version number\r
-    PFD_DRAW_TO_WINDOW |             // support window\r
-      PFD_SUPPORT_OPENGL |           // support OpenGL\r
-      PFD_DOUBLEBUFFER,              // double buffered\r
-    PFD_TYPE_RGBA,                   // RGBA type\r
-    16,                              // 16-bit color depth  (adjusted later)\r
-    0, 0, 0, 0, 0, 0,                // color bits ignored\r
-    0,                               // no alpha buffer\r
-    0,                               // shift bit ignored\r
-    0,                               // no accumulation buffer\r
-    0, 0, 0, 0,                      // accum bits ignored\r
-    0,                               // z-buffer    \r
-    0,\r
-    0,                               // no auxiliary buffer\r
-    PFD_MAIN_PLANE,                  // main layer\r
-    0,                               // reserved\r
-    0, 0, 0                          // layer masks ignored\r
-  };\r
\r
- pfd.cColorBits=iColDepth;                             // set user color depth\r
- pfd.cDepthBits=iZBufferDepth;                         // set user zbuffer (by psx mask)\r
-\r
- if((pixelformat=ChoosePixelFormat(hDC,&pfd))==0)     \r
-  {\r
-   MessageBox(NULL,"ChoosePixelFormat failed","Error",MB_OK);\r
-   return FALSE;\r
-  }\r
-\r
- if(SetPixelFormat(hDC,pixelformat, &pfd)==FALSE)\r
-  {\r
-   MessageBox(NULL,"SetPixelFormat failed","Error",MB_OK);\r
-   return FALSE;\r
-  }\r
-\r
- return TRUE;\r
-}\r
-#endif\r
 \r
 ////////////////////////////////////////////////////////////////////////\r
 // Get extension infos (f.e. pal textures / packed pixels)\r
@@ -211,16 +151,12 @@ void GetExtInfos(void)
 {\r
  BOOL bPacked=FALSE;                                   // default: no packed pixel support\r
 \r
- if(strstr((s8 *)glGetString(GL_EXTENSIONS),         // packed pixels available?\r
+ if(strstr((char *)glGetString(GL_EXTENSIONS),         // packed pixels available?\r
     "GL_EXT_packed_pixels"))                          \r
   bPacked=TRUE;                                        // -> ok\r
 \r
  \r
- #ifdef _WINDOWS\r
- iClampType=GL_CLAMP;\r
-#else\r
  iClampType=GL_CLAMP_TO_EDGE;\r
-#endif\r
 }\r
 \r
 ////////////////////////////////////////////////////////////////////////\r
@@ -239,8 +175,7 @@ void SetExtGLFuncs(void)
    if(bAdvancedBlend) bUseMultiPass=TRUE;              // -> pseudo-advanced with 2 passes\r
    else               bUseMultiPass=FALSE;             // -> or simple 'bright color' mode\r
 //   bGLBlend=FALSE;                                     // -> no ext blending!\r
-\r
-   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);    \r
+   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glError();\r
   }\r
 \r
  if(bOpaquePass)                                        // opaque mode?\r
@@ -257,13 +192,15 @@ void SetExtGLFuncs(void)
     }\r
 \r
    TCF[1]=XP8RGBA_1;\r
-   glAlphaFuncx(GL_GREATER,0.49f);\r
+   glAlphaFuncx(GL_GREATER,0.49f); glError();\r
+\r
   }\r
  else                                                  // no opaque mode?\r
   {\r
    TCF[0]=TCF[1]=P8RGBA;\r
    PalTexturedColourFn=P8RGBA;                         // -> init col func\r
-   glAlphaFuncx(GL_NOTEQUAL,0);                         // --> set alpha func\r
+   glAlphaFuncx(GL_NOTEQUAL,0); glError();             // --> set alpha func\r
+\r
   }\r
 \r
  //----------------------------------------------------//\r
@@ -271,7 +208,8 @@ void SetExtGLFuncs(void)
  LoadSubTexFn=LoadSubTexturePageSort;                  // init load tex ptr\r
 \r
  bBlendEnable=FALSE;                                   // init blending: off\r
- glDisable(GL_BLEND);\r
+ glDisable(GL_BLEND); glError();\r
+\r
 \r
  SetScanTrans();                                       // init scan lines (if wanted)\r
 }\r
@@ -304,11 +242,45 @@ void CreateScanLines(void)
 // Initialize OGL\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-#ifdef _WINDOWS    \r
-HGLRC GLCONTEXT=NULL;\r
+#define MODE_RAW 0\r
+#define MODE_X11 1\r
+#define MODE_SDL 2\r
+int use_fsaa = 0;\r
+\r
+EGLDisplay display;\r
+EGLConfig  config;\r
+EGLContext context;\r
+EGLSurface surface;\r
+\r
+#if defined(USE_X11)\r
+#include "X11/Xlib.h"\r
+#include "X11/Xutil.h"\r
+#include "X11/Xatom.h"\r
+\r
+Window                 x11Window       = 0;\r
+Display*               x11Display      = 0;\r
+long                   x11Screen       = 0;\r
+XVisualInfo            x11Visual;\r
+XVisualInfo*   px11Visual      = 0;\r
+Colormap        x11Colormap    = 0;\r
 #endif\r
 \r
-#ifdef MAEMO_CHANGES\r
+EGLint attrib_list_fsaa[] =\r
+{\r
+       EGL_SURFACE_TYPE, EGL_WINDOW_BIT,\r
+       EGL_BUFFER_SIZE,    0,\r
+       EGL_DEPTH_SIZE,     16,\r
+       EGL_SAMPLE_BUFFERS, 1,\r
+       EGL_SAMPLES,        4,\r
+       EGL_NONE\r
+};\r
+\r
+EGLint attrib_list[] =\r
+{\r
+//     EGL_DEPTH_SIZE,   16,\r
+       EGL_NONE\r
+};\r
+\r
 bool TestEGLError(const char* pszLocation)\r
 {\r
        /*\r
@@ -319,144 +291,204 @@ bool TestEGLError(const char* pszLocation)
        EGLint iErr = eglGetError();\r
        if (iErr != EGL_SUCCESS)\r
        {\r
-               printf("%s failed (%d).\n", pszLocation, iErr);\r
-               return false;\r
+               printf("%s failed (0x%x).\n", pszLocation, iErr);\r
+               return FALSE;\r
        }\r
 \r
-       return true;\r
+       return TRUE;\r
 }\r
 \r
-void maemoGLinit(){\r
-       iResX= 800;\r
-    iResY =480;\r
+static int initEGL(void)\r
+{\r
+       NativeWindowType window = 0;\r
 \r
+       printf ("GL init\n");\r
+\r
+       EGLint numConfigs;\r
+       EGLint majorVersion;\r
+       EGLint minorVersion;\r
+#if defined(USE_X11)\r
+       enum\r
+       {\r
+       _NET_WM_STATE_REMOVE =0,\r
+       _NET_WM_STATE_ADD = 1,\r
+       _NET_WM_STATE_TOGGLE =2\r
+       };\r
        \r
-       printf ("maemo GL init\n");\r
-       long int winxid=GDK_WINDOW_XID(GTK_WIDGET(windowG)->window);\r
-       printf ("%d\n",winxid);\r
-       \r
-       EGLContext                      context = 0;\r
-       EGLConfig                       eglConfig       = 0;\r
-       EGLContext                      eglContext      = 0;\r
-       display = eglGetDisplay( EGL_DEFAULT_DISPLAY );\r
+       Window                          sRootWindow;\r
+       XSetWindowAttributes    sWA;\r
+       unsigned int                ui32Mask;\r
+       int                                 i32Depth;\r
+#endif\r
        \r
-       if( eglInitialize( display, NULL, NULL ) == EGL_FALSE )\r
-            {            \r
-                printf( "EGL Initialize failed!\n" );\r
-                               \r
-                       }\r
-\r
-const EGLint attributeList[] = { \r
-                                     EGL_SURFACE_TYPE, EGL_WINDOW_BIT, \r
-                                     /*EGL_BUFFER_SIZE, 32, */\r
-                                     EGL_NONE \r
-                                   };\r
-                                                          \r
-       EGLint pi32ConfigAttribs[5];\r
-       pi32ConfigAttribs[0] = EGL_SURFACE_TYPE;\r
-       pi32ConfigAttribs[1] = EGL_WINDOW_BIT;\r
-       pi32ConfigAttribs[2] = EGL_RENDERABLE_TYPE;\r
-       pi32ConfigAttribs[3] = EGL_OPENGL_ES2_BIT;      \r
-       pi32ConfigAttribs[4] = EGL_NONE;\r
-\r
-       EGLint pi32ContextAttribs[3];\r
-       pi32ContextAttribs[0] = EGL_CONTEXT_CLIENT_VERSION;\r
-       pi32ContextAttribs[1] = 2;\r
-       pi32ContextAttribs[2] = EGL_NONE;\r
-\r
-       int iConfigs;\r
-       if (!eglChooseConfig(display, attributeList, &eglConfig, 1, &iConfigs) || (iConfigs != 1))\r
+       EGLint *attribList = NULL;\r
+       if (use_fsaa)\r
+       {\r
+               printf( "GLES: Using Full Scene Antialiasing\n" );\r
+               attribList = attrib_list_fsaa;\r
+       }\r
+       else\r
        {\r
-               printf("Error: eglChooseConfig() failed.\n");\r
+               attribList = attrib_list;\r
        }\r
-       printf ("%d\n",iConfigs);\r
-       surface = eglCreateWindowSurface(display, eglConfig, (void*)winxid, NULL);\r
-       printf ("%d\n",surface);\r
-    if (!TestEGLError("eglCreateWindowSurface"))\r
+\r
+#if defined(USE_X11)\r
+            // Initializes the display and screen\r
+            x11Display = XOpenDisplay( ":0" );\r
+            if (!x11Display)\r
+            {\r
+                printf("GLES Error: Unable to open X display\n");\r
+                return -1;\r
+            }\r
+            x11Screen = XDefaultScreen( x11Display );\r
+\r
+            // Gets the display parameters so we can pass the same parameters to the window to be created.\r
+            sRootWindow        = RootWindow(x11Display, x11Screen);\r
+            i32Depth   = DefaultDepth(x11Display, x11Screen);\r
+            px11Visual = &x11Visual;\r
+            XMatchVisualInfo( x11Display, x11Screen, i32Depth, TrueColor, px11Visual);\r
+            if (!px11Visual)\r
+            {\r
+                printf("GLES Error: Unable to acquire visual\n");\r
+                return -1;\r
+            }\r
+            // Colormap of the specified visual type for the display.\r
+            x11Colormap = XCreateColormap( x11Display, sRootWindow, px11Visual->visual, AllocNone );\r
+            sWA.colormap = x11Colormap;\r
+\r
+            // List of events to be handled by the application. Add to these for handling other events.\r
+            sWA.event_mask = StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask;\r
+\r
+            // Display capabilities list.\r
+            ui32Mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap;\r
+\r
+            // Creates the X11 window\r
+            x11Window = XCreateWindow( x11Display, RootWindow(x11Display, x11Screen), 0, 0, iResX, iResY,\r
+                                        0, CopyFromParent, InputOutput, CopyFromParent, ui32Mask, &sWA);\r
+\r
+            // Make the window viewable and flush the output buffer.\r
+            XMapWindow(x11Display, x11Window);\r
+            XFlush(x11Display);\r
+\r
+            // Make the window fullscreen\r
+            unsigned char fullScreen = 1;\r
+            Atom wmState = XInternAtom(x11Display, "_NET_WM_STATE", False);\r
+            Atom wmFullScreen = XInternAtom(x11Display,"_NET_WM_STATE_FULLSCREEN", False);\r
+\r
+            XEvent xev;\r
+            xev.xclient.type               = ClientMessage;\r
+            xev.xclient.serial             = 0;\r
+            xev.xclient.send_event      = True;\r
+            xev.xclient.window             = x11Window;\r
+            xev.xclient.message_type    = wmState;\r
+            xev.xclient.format             = 32;\r
+            xev.xclient.data.l[0]              = (fullScreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE);\r
+            xev.xclient.data.l[1]              = wmFullScreen;\r
+            xev.xclient.data.l[2]              = 0;\r
+\r
+            XSendEvent(x11Display, DefaultRootWindow(x11Display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);\r
+\r
+            display = eglGetDisplay( (EGLNativeDisplayType)x11Display );\r
+            window = x11Window;\r
+#else\r
+            display = eglGetDisplay( (EGLNativeDisplayType)0 );\r
+#endif\r
+\r
+       if( display == EGL_NO_DISPLAY )\r
        {\r
-               printf ("eglCreateWindowSurface fail");\r
+               printf( "GLES EGL Error: GL No Display\n" );\r
+               return -1;\r
        }\r
 \r
-       //context = eglCreateContext(display, eglConfig, NULL, pi32ContextAttribs);\r
-       context =eglCreateContext( display, eglConfig,\r
-                                    EGL_NO_CONTEXT, NULL \r
-                                  );\r
-printf ("%d\n",context);\r
-       if (!TestEGLError("eglCreateContext"))\r
+       if( !eglInitialize( display, &majorVersion, &minorVersion ) )\r
        {\r
-               printf("error eglCreateContext");\r
+               printf( "GLES EGL Error: eglInitialize failed\n" );\r
+               return -1;\r
        }\r
 \r
-       eglMakeCurrent(display, surface, surface, context);\r
+       if( !eglChooseConfig( display, attribList, &config, 1, &numConfigs ) )\r
+       {\r
+               printf( "GLES EGL Error: eglChooseConfig failed\n" );\r
+               return -1;\r
+       }\r
 \r
-       if (!TestEGLError("eglMakeCurrent"))\r
+       context = eglCreateContext( display, config, NULL, NULL );\r
+       if( context==0 )\r
        {\r
-               printf("error eglMakeCurrent");\r
+               printf( "GLES EGL Error: eglCreateContext failed\n" );\r
+               return -1;\r
        }\r
-}\r
+\r
+#ifdef FAKE_WINDOW\r
+       // broken Caanoo libs won't accept NULL window\r
+       window = (NativeWindowType)1;\r
 #endif\r
+       surface = eglCreateWindowSurface( display, config, window, NULL );\r
+       if (!TestEGLError("eglCreateWindowSurface"))\r
+               return -1;\r
+\r
+       eglMakeCurrent( display, surface, surface, context );\r
+       if (!TestEGLError("eglMakeCurrent"))\r
+               return -1;\r
+\r
+       printf("GLES init ok\n");\r
+       return 0;\r
+}\r
 \r
 int GLinitialize() \r
 {\r
- //----------------------------------------------------// \r
-#ifdef _WINDOWS\r
- HGLRC objectRC;\r
- // init\r
- dcGlobal = GetDC(hWWindow);                           // FIRST: dc/rc stuff\r
- objectRC = wglCreateContext(dcGlobal); \r
- GLCONTEXT=objectRC;\r
- wglMakeCurrent(dcGlobal, objectRC);\r
- // CheckWGLExtensions(dcGlobal);\r
- if(bWindowMode) ReleaseDC(hWWindow,dcGlobal);         // win mode: release dc again\r
-#endif\r
-#ifdef MAEMO_CHANGES\r
-        maemoGLinit();\r
-#endif\r
+ if(initEGL()!=0)\r
+  return -1;\r
+\r
  //----------------------------------------------------// \r
 \r
  glViewport(rRatioRect.left,                           // init viewport by ratio rect\r
             iResY-(rRatioRect.top+rRatioRect.bottom),\r
             rRatioRect.right, \r
-            rRatioRect.bottom);         \r
+            rRatioRect.bottom); glError();\r
                                                       \r
- glScissor(0, 0, iResX, iResY);                        // init clipping (fullscreen)\r
- glEnable(GL_SCISSOR_TEST);                       \r
+ glScissor(0, 0, iResX, iResY); glError();             // init clipping (fullscreen)\r
+ glEnable(GL_SCISSOR_TEST); glError();\r
 \r
 #ifndef OWNSCALE\r
  glMatrixMode(GL_TEXTURE);                             // init psx tex sow and tow if not "ownscale"\r
  glLoadIdentity();\r
  glScalef(1.0f/255.99f,1.0f/255.99f,1.0f);             // geforce precision hack\r
 #endif \r
+ glDepthRangef(0.0f, 1.0f);glError();\r
\r
+ glPolygonOffset( -0.2f, -0.2f );glError();\r
+\r
+ glMatrixMode(GL_PROJECTION); glError();               // init projection with psx resolution\r
+ glLoadIdentity(); glError();\r
 \r
- glMatrixMode(GL_PROJECTION);                          // init projection with psx resolution\r
- glLoadIdentity();\r
  glOrtho(0,PSXDisplay.DisplayMode.x,\r
-         PSXDisplay.DisplayMode.y, 0, -1, 1);\r
+         PSXDisplay.DisplayMode.y, 0, -1, 1); glError();\r
 \r
  if(iZBufferDepth)                                     // zbuffer?\r
   {\r
    uiBufferBits=GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT;\r
-   glEnable(GL_DEPTH_TEST);    \r
-   glDepthFunc(GL_ALWAYS);\r
+   glEnable(GL_DEPTH_TEST); glError();\r
+   glDepthFunc(GL_ALWAYS); glError();\r
    iDepthFunc=1;\r
   }\r
  else                                                  // no zbuffer?\r
   {\r
    uiBufferBits=GL_COLOR_BUFFER_BIT;\r
-   glDisable(GL_DEPTH_TEST);\r
+   glDisable(GL_DEPTH_TEST); glError();\r
   }\r
 \r
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);                 // first buffer clear\r
- glClear(uiBufferBits);\r
+ glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glError();      // first buffer clear\r
+ glClear(uiBufferBits); glError();\r
 \r
  GetExtInfos();                                        // get ext infos\r
  SetExtGLFuncs();                                      // init all kind of stuff (tex function pointers)\r
  \r
- glEnable(GL_ALPHA_TEST);                              // wanna alpha test\r
+ glEnable(GL_ALPHA_TEST); glError();                   // wanna alpha test\r
 \r
   {\r
-   glDisable(GL_LINE_SMOOTH);\r
-   glDisable(GL_POINT_SMOOTH);\r
+   glDisable(GL_LINE_SMOOTH); glError();\r
+   glDisable(GL_POINT_SMOOTH); glError();\r
   }\r
 \r
  ubGloAlpha=127;                                       // init some drawing vars\r
@@ -469,15 +501,15 @@ int GLinitialize()
       \r
  if(bDrawDither)  glEnable(GL_DITHER);                 // dither mode\r
  else             glDisable(GL_DITHER); \r
-\r
- glDisable(GL_FOG);                                    // turn all (currently) unused modes off\r
- glDisable(GL_LIGHTING);  \r
- glDisable(GL_STENCIL_TEST);  \r
- glDisable(GL_TEXTURE_2D);\r
+ glError(); \r
+ glDisable(GL_FOG); glError();                          // turn all (currently) unused modes off\r
+ glDisable(GL_LIGHTING); glError();  \r
+ glDisable(GL_STENCIL_TEST); glError();  \r
+ glDisable(GL_TEXTURE_2D); glError();\r
  glDisable(GL_CULL_FACE);\r
 \r
- glFlush();                                            // we are done...\r
- glFinish();                           \r
+ glFlush(); glError();                                 // we are done...\r
+ glFinish(); glError();                           \r
 \r
  CreateScanLines();                                    // setup scanline stuff (if wanted)\r
 \r
@@ -499,11 +531,15 @@ void GLcleanup()
 {                                                     \r
  CleanupTextureStore();                                // bye textures\r
 \r
-#ifdef _WINDOWS \r
- wglMakeCurrent(NULL, NULL);                           // bye context\r
- if(GLCONTEXT) wglDeleteContext(GLCONTEXT);\r
- if(!bWindowMode && dcGlobal) \r
-  ReleaseDC(hWWindow,dcGlobal);\r
+       eglMakeCurrent( display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );\r
+       eglDestroySurface( display, surface );\r
+       eglDestroyContext( display, context );\r
+       eglTerminate( display );\r
+\r
+#if defined(USE_X11)\r
+               if (x11Window) XDestroyWindow(x11Display, x11Window);\r
+               if (x11Colormap) XFreeColormap( x11Display, x11Colormap );\r
+               if (x11Display) XCloseDisplay(x11Display);\r
 #endif\r
 }\r
 \r
@@ -1038,8 +1074,8 @@ void assignTextureSprite(void)
     {\r
      if(gLastTex!=gTexName || gLastFMode!=0)\r
       {\r
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glError();\r
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glError();\r
        gLastTex=gTexName;gLastFMode=0;\r
       }\r
     }\r
@@ -1098,8 +1134,8 @@ void assignTexture3(void)
     {\r
      if(gLastTex!=gTexName || gLastFMode!=1)\r
       {\r
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glError();\r
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glError();\r
        gLastTex=gTexName;gLastFMode=1;\r
       }\r
     }\r
@@ -1168,8 +1204,8 @@ void assignTexture4(void)
     {\r
      if(gLastTex!=gTexName || gLastFMode!=1)\r
       {\r
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glError();\r
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glError();\r
        gLastTex=gTexName;gLastFMode=1;\r
       }\r
     }\r
@@ -1204,9 +1240,7 @@ void assignTexture4(void)
 // render pos / buffers\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-#ifndef _WINDOWS\r
 #define EqualRect(pr1,pr2) ((pr1)->left==(pr2)->left && (pr1)->top==(pr2)->top && (pr1)->right==(pr2)->right && (pr1)->bottom==(pr2)->bottom)\r
-#endif\r
 \r
 ////////////////////////////////////////////////////////////////////////\r
 // SetDisplaySettings: "simply" calcs the new drawing area and updates\r
@@ -1242,7 +1276,8 @@ void SetOGLDisplaySettings(BOOL DisplaySet)
    if(bSetClip || !EqualRect(&rC,&rX))\r
     {\r
      rC=rX;\r
-     glScissor(rC.left,rC.top,rC.right,rC.bottom);\r
+     glScissor(rC.left,rC.top,rC.right,rC.bottom); glError();\r
+     //LOGE("glscissor:%d %d %d %d",rC.left,rC.top,rC.right,rC.bottom);\r
      bSetClip=FALSE; \r
     }\r
    return;\r
@@ -1333,7 +1368,8 @@ void SetOGLDisplaySettings(BOOL DisplaySet)
 \r
  if(bSetClip || !EqualRect(&r,&rC))\r
   {\r
-   glScissor(r.left,r.top,r.right,r.bottom);\r
+   glScissor(r.left,r.top,r.right,r.bottom); glError();\r
+\r
    rC=r;\r
    bSetClip=FALSE;\r
   }\r