gpu-gles: schtruck/fpse merge: gl error checks
authornotaz <notasas@gmail.com>
Mon, 16 Jan 2012 22:38:32 +0000 (00:38 +0200)
committernotaz <notasas@gmail.com>
Wed, 18 Jan 2012 23:42:10 +0000 (01:42 +0200)
useful debugging tool, yeah

plugins/gpu-gles/gpuDraw.c
plugins/gpu-gles/gpuPlugin.c
plugins/gpu-gles/gpuPrim.c
plugins/gpu-gles/gpuStdafx.h
plugins/gpu-gles/gpuTexture.c

index 3842503..69d2d7b 100644 (file)
@@ -175,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
@@ -193,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
@@ -207,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
@@ -430,10 +432,10 @@ int GLinitialize()
  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
@@ -441,35 +443,35 @@ int GLinitialize()
  glScalef(1.0f/255.99f,1.0f/255.99f,1.0f);             // geforce precision hack\r
 #endif \r
 \r
- glMatrixMode(GL_PROJECTION);                          // init projection with psx resolution\r
- glLoadIdentity();\r
+ glMatrixMode(GL_PROJECTION); glError();               // init projection with psx resolution\r
+ glLoadIdentity(); glError();\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
@@ -482,15 +484,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
@@ -1055,8 +1057,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
@@ -1115,8 +1117,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
@@ -1185,8 +1187,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
@@ -1257,7 +1259,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
@@ -1348,7 +1351,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
index fcc8f8b..45a0b92 100644 (file)
@@ -149,10 +149,10 @@ void ResizeWindow()
  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
@@ -160,10 +160,10 @@ void ResizeWindow()
  glScalef(1.0f/255.99f,1.0f/255.99f,1.0f);             // geforce precision hack\r
 #endif \r
 \r
- glMatrixMode(GL_PROJECTION);                          // init projection with psx resolution\r
- glLoadIdentity();\r
+ glMatrixMode(GL_PROJECTION); glError();               // init projection with psx resolution\r
+ glLoadIdentity(); glError();\r
  glOrtho(0,PSXDisplay.DisplayMode.x,\r
-         PSXDisplay.DisplayMode.y, 0, -1, 1);\r
+         PSXDisplay.DisplayMode.y, 0, -1, 1); glError();\r
  if (bKeepRatio)\r
  SetAspectRatio();\r
 }\r
@@ -550,15 +550,15 @@ long CALLBACK GPUshutdown()
 void PaintBlackBorders(void)\r
 {\r
  short s;\r
+ glDisable(GL_SCISSOR_TEST); glError();\r
+ if(bTexEnabled) {glDisable(GL_TEXTURE_2D);bTexEnabled=FALSE;} glError();\r
+ if(bOldSmoothShaded) {glShadeModel(GL_FLAT);bOldSmoothShaded=FALSE;} glError();\r
+ if(bBlendEnable)     {glDisable(GL_BLEND);bBlendEnable=FALSE;} glError();\r
+ glDisable(GL_ALPHA_TEST); glError();\r
 \r
- glDisable(GL_SCISSOR_TEST);\r
- if(bTexEnabled) {glDisable(GL_TEXTURE_2D);bTexEnabled=FALSE;}\r
- if(bOldSmoothShaded) {glShadeModel(GL_FLAT);bOldSmoothShaded=FALSE;}\r
- if(bBlendEnable)     {glDisable(GL_BLEND);bBlendEnable=FALSE;}\r
- glDisable(GL_ALPHA_TEST);\r
+ glEnable(GL_ALPHA_TEST); glError();\r
+ glEnable(GL_SCISSOR_TEST); glError();\r
 \r
- glEnable(GL_ALPHA_TEST);\r
- glEnable(GL_SCISSOR_TEST);\r
 }\r
 \r
 ////////////////////////////////////////////////////////////////////////\r
@@ -640,11 +640,13 @@ if(PreviousPSXDisplay.Range.x0||                      // paint black borders aro
 \r
 if(PSXDisplay.Disabled)                               // display disabled?\r
  {\r
+  //LOGE("PSXDisplay.Disabled");\r
+\r
   // moved here\r
-  glDisable(GL_SCISSOR_TEST);                       \r
-  glClearColor(0,0,0,128);                            // -> clear whole backbuffer\r
-  glClear(uiBufferBits);\r
-  glEnable(GL_SCISSOR_TEST);                       \r
+  glDisable(GL_SCISSOR_TEST); glError();                       \r
+  glClearColor(0,0,0,128); glError();                 // -> clear whole backbuffer\r
+  glClear(uiBufferBits); glError();\r
+  glEnable(GL_SCISSOR_TEST); glError();                       \r
   gl_z=0.0f;\r
   bDisplayNotSet = TRUE;\r
  }\r
@@ -712,11 +714,10 @@ if(lClearOnSwap)                                      // clear buffer after swap
   g=((GLclampf)GREEN(lClearOnSwapColor))/255.0f;      // -> get col\r
   b=((GLclampf)BLUE(lClearOnSwapColor))/255.0f;\r
   r=((GLclampf)RED(lClearOnSwapColor))/255.0f;\r
-  \r
-  glDisable(GL_SCISSOR_TEST);                       \r
-  glClearColor(r,g,b,128);                            // -> clear \r
-  glClear(uiBufferBits);\r
-  glEnable(GL_SCISSOR_TEST);                       \r
+  glDisable(GL_SCISSOR_TEST); glError();                       \r
+  glClearColor(r,g,b,128); glError();                 // -> clear \r
+  glClear(uiBufferBits); glError();\r
+  glEnable(GL_SCISSOR_TEST); glError();                       \r
   lClearOnSwap=0;                                     // -> done\r
  }\r
 else \r
@@ -725,11 +726,12 @@ else
 \r
   if(iZBufferDepth)                                   // clear zbuffer as well (if activated)\r
    {\r
-    glDisable(GL_SCISSOR_TEST);                       \r
-    glClear(GL_DEPTH_BUFFER_BIT);\r
-    glEnable(GL_SCISSOR_TEST);                       \r
+    glDisable(GL_SCISSOR_TEST); glError();\r
+    glClear(GL_DEPTH_BUFFER_BIT); glError();\r
+    glEnable(GL_SCISSOR_TEST); glError();\r
    }\r
  }\r
+\r
 gl_z=0.0f;\r
 \r
 //----------------------------------------------------//\r
@@ -776,7 +778,7 @@ if(iRumbleTime)                                       // shake screen by modifyi
   glViewport(rRatioRect.left+i1,                      \r
              iResY-(rRatioRect.top+rRatioRect.bottom)+i2,\r
              rRatioRect.right+i3, \r
-             rRatioRect.bottom+i4);            \r
+             rRatioRect.bottom+i4); glError();\r
  }\r
 \r
 //----------------------------------------------------//\r
@@ -915,12 +917,11 @@ if(r.bottom < 1)     r.bottom = 1;
 \r
 r.left = (iResX-r.right)/2;\r
 r.top  = (iResY-r.bottom)/2;\r
-\r
 if(r.bottom<rRatioRect.bottom ||\r
    r.right <rRatioRect.right)\r
  {\r
   RECT rC;\r
-  glClearColor(0,0,0,128);                         \r
+  glClearColor(0,0,0,128); glError();\r
 \r
   if(r.right <rRatioRect.right)\r
    {\r
@@ -928,11 +929,12 @@ if(r.bottom<rRatioRect.bottom ||
     rC.top=0;\r
     rC.right=r.left;\r
     rC.bottom=iResY;\r
-    glScissor(rC.left,rC.top,rC.right,rC.bottom);\r
-    glClear(uiBufferBits);\r
+    glScissor(rC.left,rC.top,rC.right,rC.bottom); glError();\r
+    glClear(uiBufferBits); glError();\r
     rC.left=iResX-rC.right;\r
-    glScissor(rC.left,rC.top,rC.right,rC.bottom);\r
-    glClear(uiBufferBits);\r
+    glScissor(rC.left,rC.top,rC.right,rC.bottom); glError();\r
+    \r
+    glClear(uiBufferBits); glError();\r
    }\r
 \r
   if(r.bottom <rRatioRect.bottom)\r
@@ -941,11 +943,12 @@ if(r.bottom<rRatioRect.bottom ||
     rC.top=0;\r
     rC.right=iResX;\r
     rC.bottom=r.top;\r
-    glScissor(rC.left,rC.top,rC.right,rC.bottom);\r
-    glClear(uiBufferBits);\r
+    glScissor(rC.left,rC.top,rC.right,rC.bottom); glError();\r
+\r
+    glClear(uiBufferBits); glError();\r
     rC.top=iResY-rC.bottom;\r
-    glScissor(rC.left,rC.top,rC.right,rC.bottom);\r
-    glClear(uiBufferBits);\r
+    glScissor(rC.left,rC.top,rC.right,rC.bottom); glError();\r
+    glClear(uiBufferBits); glError();\r
    }\r
   \r
   bSetClip=TRUE;\r
@@ -962,7 +965,7 @@ rRatioRect=r;
 glViewport(rRatioRect.left,\r
            iResY-(rRatioRect.top+rRatioRect.bottom),\r
            rRatioRect.right,\r
-           rRatioRect.bottom);                         // init viewport\r
+           rRatioRect.bottom); glError();              // init viewport\r
 }\r
 \r
 ////////////////////////////////////////////////////////////////////////\r
@@ -982,9 +985,9 @@ if ((PSXDisplay.DisplayMode.y == PSXDisplay.DisplayModeNew.y) &&
  }\r
 else                                                  // some res change?\r
  {\r
-  glLoadIdentity();\r
+  glLoadIdentity(); glError();\r
   glOrtho(0,PSXDisplay.DisplayModeNew.x,              // -> new psx resolution\r
-            PSXDisplay.DisplayModeNew.y, 0, -1, 1);\r
+            PSXDisplay.DisplayModeNew.y, 0, -1, 1); glError();\r
   if(bKeepRatio) SetAspectRatio();\r
  }\r
 \r
@@ -1581,7 +1584,7 @@ void CheckVRamReadEx(int x, int y, int dx, int dy)
 \r
  if(!pGfxCardScreen)\r
   {\r
-   glPixelStorei(GL_PACK_ALIGNMENT,1);\r
+   glPixelStorei(GL_PACK_ALIGNMENT,1); glError();\r
    pGfxCardScreen=(unsigned char *)malloc(iResX*iResY*4);\r
   }\r
 \r
@@ -1589,8 +1592,7 @@ void CheckVRamReadEx(int x, int y, int dx, int dy)
  \r
  //if(!sArea) glReadBuffer(GL_FRONT);\r
 \r
- glReadPixels(x,y,dx,dy,GL_RGB,GL_UNSIGNED_BYTE,ps);\r
-               \r
+ glReadPixels(x,y,dx,dy,GL_RGB,GL_UNSIGNED_BYTE,ps); glError();\r
  //if(!sArea) glReadBuffer(GL_BACK);\r
 \r
  s=0;\r
@@ -1729,7 +1731,7 @@ void CheckVRamRead(int x, int y, int dx, int dy, bool bFront)
 \r
  if(!pGfxCardScreen)\r
   {\r
-   glPixelStorei(GL_PACK_ALIGNMENT,1);\r
+   glPixelStorei(GL_PACK_ALIGNMENT,1); glError();\r
    pGfxCardScreen=(unsigned char *)malloc(iResX*iResY*4);\r
   }\r
 \r
@@ -1737,8 +1739,7 @@ void CheckVRamRead(int x, int y, int dx, int dy, bool bFront)
  \r
 // if(bFront) glReadBuffer(GL_FRONT);\r
 \r
- glReadPixels(x,y,dx,dy,GL_RGB,GL_UNSIGNED_BYTE,ps);\r
-               \r
+ glReadPixels(x,y,dx,dy,GL_RGB,GL_UNSIGNED_BYTE,ps); glError(); glError();\r
 // if(bFront) glReadBuffer(GL_BACK);\r
 \r
  XS=(float)dx/(float)(udx);\r
@@ -2532,7 +2533,7 @@ long CALLBACK GPUgetScreenPic(unsigned char * pMem)
 \r
  if(!pGfxCardScreen)\r
   {\r
-   glPixelStorei(GL_PACK_ALIGNMENT,1);\r
+   glPixelStorei(GL_PACK_ALIGNMENT,1); glError();\r
    pGfxCardScreen=(unsigned char *)malloc(iResX*iResY*4);\r
   }\r
 \r
@@ -2540,7 +2541,7 @@ long CALLBACK GPUgetScreenPic(unsigned char * pMem)
 \r
 // glReadBuffer(GL_FRONT);\r
 \r
- glReadPixels(0,0,iResX,iResY,GL_RGB,GL_UNSIGNED_BYTE,ps);\r
+ glReadPixels(0,0,iResX,iResY,GL_RGB,GL_UNSIGNED_BYTE,ps); glError();\r
                \r
 // glReadBuffer(GL_BACK);\r
 \r
index 37db052..5d17f2d 100644 (file)
@@ -661,7 +661,7 @@ void SetSemiTrans(void)
  if(!DrawSemiTrans)                                    // no semi trans at all?\r
   {\r
    if(bBlendEnable)\r
-    {glDisable(GL_BLEND);bBlendEnable=FALSE;}          // -> don't wanna blend\r
+    {glDisable(GL_BLEND);glError();bBlendEnable=FALSE;}// -> don't wanna blend\r
    ubGloAlpha=ubGloColAlpha=255;                       // -> full alpha\r
    return;                                             // -> and bye\r
   }\r
@@ -669,7 +669,7 @@ void SetSemiTrans(void)
  ubGloAlpha=ubGloColAlpha=TransSets[GlobalTextABR].alpha;\r
 \r
  if(!bBlendEnable)\r
-  {glEnable(GL_BLEND);bBlendEnable=TRUE;}              // wanna blend\r
+  {glEnable(GL_BLEND);glError();bBlendEnable=TRUE;}    // wanna blend\r
 \r
  if(TransSets[GlobalTextABR].srcFac!=obm1 || \r
     TransSets[GlobalTextABR].dstFac!=obm2)\r
@@ -678,7 +678,7 @@ void SetSemiTrans(void)
     {\r
      obm1=TransSets[GlobalTextABR].srcFac;\r
      obm2=TransSets[GlobalTextABR].dstFac;\r
-     glBlendFunc(obm1,obm2);                           // set blend func\r
+     glBlendFunc(obm1,obm2); glError();                // set blend func\r
     }\r
    /*else\r
    if(TransSets[GlobalTextABR].dstFac !=GL_ONE_MINUS_SRC_COLOR)\r
@@ -709,7 +709,7 @@ void SetScanTrans(void)                                // blending for scan line
 */\r
  obm1=TransSets[0].srcFac;\r
  obm2=TransSets[0].dstFac;\r
- glBlendFunc(obm1,obm2);                               // set blend func\r
+ glBlendFunc(obm1,obm2); glError();                    // set blend func\r
 }\r
 \r
 void SetScanTexTrans(void)                             // blending for scan mask texture\r
@@ -722,7 +722,7 @@ void SetScanTexTrans(void)                             // blending for scan mask
 */\r
  obm1=TransSets[2].srcFac;\r
  obm2=TransSets[2].dstFac;\r
- glBlendFunc(obm1,obm2);                               // set blend func\r
+ glBlendFunc(obm1,obm2); glError();                    // set blend func\r
 }\r
 \r
 ////////////////////////////////////////////////////////////////////////                                          \r
@@ -802,11 +802,11 @@ void SetSemiTransMulti(int Pass)
   }\r
 \r
  if(!bBlendEnable)\r
-  {glEnable(GL_BLEND);bBlendEnable=TRUE;}              // wanna blend\r
+  {glEnable(GL_BLEND);glError();bBlendEnable=TRUE;}    // wanna blend\r
 \r
  if(bm1!=obm1 || bm2!=obm2)\r
   {\r
-   glBlendFunc(bm1,bm2);                               // set blend func\r
+   glBlendFunc(bm1,bm2); glError();                    // set blend func\r
    obm1=bm1;obm2=bm2;\r
   }\r
 }\r
@@ -947,14 +947,14 @@ void SetRenderMode(unsigned long DrawAttributes,BOOL bSCol)
    else                 currTex=SelectSubTextureS(GlobalTextTP,ulClutID);\r
 \r
    if(gTexName!=currTex)\r
-    {gTexName=currTex;glBindTexture(GL_TEXTURE_2D,currTex);}\r
+    {gTexName=currTex;glBindTexture(GL_TEXTURE_2D,currTex); glError();}\r
 \r
    if(!bTexEnabled)                                    // -> turn texturing on\r
-    {bTexEnabled=TRUE;glEnable(GL_TEXTURE_2D);}\r
+    {bTexEnabled=TRUE;glEnable(GL_TEXTURE_2D); glError();}\r
   }\r
  else                                                  // no texture ?\r
  if(bTexEnabled) \r
-  {bTexEnabled=FALSE;glDisable(GL_TEXTURE_2D);}        // -> turn texturing off\r
+  {bTexEnabled=FALSE;glDisable(GL_TEXTURE_2D); glError();} // -> turn texturing off\r
 \r
  if(bSCol)                                             // also set color ?\r
   {\r
@@ -980,6 +980,7 @@ void SetRenderMode(unsigned long DrawAttributes,BOOL bSCol)
   {\r
    if(bDrawSmoothShaded) glShadeModel(GL_SMOOTH);      // -> set actual shading\r
    else                  glShadeModel(GL_FLAT);\r
+   glError();\r
    bOldSmoothShaded=bDrawSmoothShaded;\r
   }\r
 }\r
@@ -1452,14 +1453,14 @@ void UploadScreenEx(long Position)
  if(!PSXDisplay.DisplayMode.x) return;\r
  if(!PSXDisplay.DisplayMode.y) return;\r
 \r
- glDisable(GL_SCISSOR_TEST);\r
- glShadeModel(GL_FLAT);\r
+ glDisable(GL_SCISSOR_TEST); glError();\r
+ glShadeModel(GL_FLAT); glError();\r
  bOldSmoothShaded=FALSE;\r
- glDisable(GL_BLEND);\r
+ glDisable(GL_BLEND); glError();\r
  bBlendEnable=FALSE;\r
- glDisable(GL_TEXTURE_2D);\r
+ glDisable(GL_TEXTURE_2D); glError();\r
  bTexEnabled=FALSE;\r
- glDisable(GL_ALPHA_TEST);\r
+ glDisable(GL_ALPHA_TEST); glError();\r
 \r
  //glPixelZoom(((float)rRatioRect.right)/((float)PSXDisplay.DisplayMode.x),\r
  //            -1.0f*(((float)rRatioRect.bottom)/((float)PSXDisplay.DisplayMode.y)));\r
@@ -1523,8 +1524,8 @@ void UploadScreenEx(long Position)
 \r
 // glPixelZoom(1.0F,1.0F);\r
 \r
- glEnable(GL_ALPHA_TEST);\r
- glEnable(GL_SCISSOR_TEST);\r
+ glEnable(GL_ALPHA_TEST); glError();\r
+ glEnable(GL_SCISSOR_TEST); glError();\r
 }\r
 \r
 ////////////////////////////////////////////////////////////////////////\r
@@ -1692,13 +1693,13 @@ void cmdSTP(unsigned char * baseAddr)
    bCheckMask=TRUE;\r
    if(iDepthFunc==0) return;\r
    iDepthFunc=0;\r
-   glDepthFunc(GL_LESS);\r
+   glDepthFunc(GL_LESS); glError();\r
   }\r
  else\r
   {\r
    bCheckMask=FALSE;\r
    if(iDepthFunc==1) return;\r
-   glDepthFunc(GL_ALWAYS);\r
+   glDepthFunc(GL_ALWAYS); glError();\r
    iDepthFunc=1;\r
   }\r
 }\r
@@ -2245,9 +2246,9 @@ void primBlkFill(unsigned char * baseAddr)
      b=((GLclampf)BLUE(gpuData[0]))/255.0f;\r
      r=((GLclampf)RED(gpuData[0]))/255.0f;\r
      \r
-     glDisable(GL_SCISSOR_TEST);                       \r
-     glClearColor(r,g,b,1.0f);\r
-     glClear(uiBufferBits); \r
+     glDisable(GL_SCISSOR_TEST); glError();\r
+     glClearColor(r,g,b,1.0f); glError();\r
+     glClear(uiBufferBits); glError();\r
      gl_z=0.0f;\r
 \r
      if(gpuData[0]!=0x02000000 &&\r
@@ -2278,7 +2279,7 @@ void primBlkFill(unsigned char * baseAddr)
         }\r
       }\r
 \r
-     glEnable(GL_SCISSOR_TEST);                       \r
+     glEnable(GL_SCISSOR_TEST); glError();\r
     }\r
    else\r
     {\r
@@ -2288,9 +2289,9 @@ void primBlkFill(unsigned char * baseAddr)
      SetRenderMode((unsigned long)0x01000000, FALSE);\r
      vertex[0].c.lcol=gpuData[0]|0xff000000;\r
      SETCOL(vertex[0]); \r
-     glDisable(GL_SCISSOR_TEST);                       \r
+     glDisable(GL_SCISSOR_TEST); glError();\r
      PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
-     glEnable(GL_SCISSOR_TEST);                       \r
+     glEnable(GL_SCISSOR_TEST); glError();\r
     }\r
   }\r
 \r
index 3a6a1c5..69050b3 100644 (file)
@@ -88,6 +88,18 @@ extern "C" {
 #endif\r
 #endif\r
 \r
+#if 0\r
+#define glError() { \\r
+       GLenum err = glGetError(); \\r
+       while (err != GL_NO_ERROR) { \\r
+               printf("glError: %d caught at %s:%u\n", err, __FILE__, __LINE__); \\r
+               err = glGetError(); \\r
+       } \\r
+}\r
+#else\r
+#define glError() \r
+#endif\r
+\r
 #ifdef __cplusplus\r
 }\r
 #endif\r
index c3d88f9..c5fa2be 100644 (file)
@@ -570,6 +570,7 @@ void CleanupTextureStore()
  int i,j;textureWndCacheEntry * tsx;\r
  //----------------------------------------------------//\r
  glBindTexture(GL_TEXTURE_2D,0);\r
+ glError();\r
  //----------------------------------------------------//\r
  free(texturepart);                                    // free tex part\r
  texturepart=0;\r
@@ -584,19 +585,23 @@ void CleanupTextureStore()
   {\r
    if(tsx->texname)                                    // -> some tex?\r
     glDeleteTextures(1,&tsx->texname);                 // --> delete it\r
+    glError();\r
   }\r
  iMaxTexWnds=0;                                        // no more tex wnds\r
  //----------------------------------------------------//\r
  if(gTexMovieName!=0)                                  // some movie tex?\r
   glDeleteTextures(1, &gTexMovieName);                 // -> delete it\r
+  glError();\r
  gTexMovieName=0;                                      // no more movie tex\r
  //----------------------------------------------------//\r
  if(gTexFrameName!=0)                                  // some 15bit framebuffer tex?\r
   glDeleteTextures(1, &gTexFrameName);                 // -> delete it\r
+  glError();\r
  gTexFrameName=0;                                      // no more movie tex\r
  //----------------------------------------------------//\r
  if(gTexBlurName!=0)                                   // some 15bit framebuffer tex?\r
   glDeleteTextures(1, &gTexBlurName);                  // -> delete it\r
+  glError();\r
  gTexBlurName=0;                                       // no more movie tex\r
  //----------------------------------------------------//\r
  for(i=0;i<3;i++)                                    // -> loop\r
@@ -609,6 +614,7 @@ void CleanupTextureStore()
    if(uiStexturePage[i])                             // --> tex used ?\r
     {\r
      glDeleteTextures(1,&uiStexturePage[i]);\r
+     glError();\r
      uiStexturePage[i]=0;                            // --> delete it\r
     }\r
    free(pxSsubtexLeft[i]);                           // -> clean mem\r
@@ -629,7 +635,7 @@ void ResetTextureArea(BOOL bDelTex)
  dwTexPageComp=0;\r
 \r
  //----------------------------------------------------//\r
- if(bDelTex) {glBindTexture(GL_TEXTURE_2D,0);gTexName=0;}\r
+ if(bDelTex) {glBindTexture(GL_TEXTURE_2D,0); glError();gTexName=0;}\r
  //----------------------------------------------------//\r
  tsx=wcWndtexStore;\r
  for(i=0;i<MAXWNDTEXCACHE;i++,tsx++)\r
@@ -637,7 +643,7 @@ void ResetTextureArea(BOOL bDelTex)
    tsx->used=0;\r
    if(bDelTex && tsx->texname)\r
     {\r
-     glDeleteTextures(1,&tsx->texname);\r
+     glDeleteTextures(1,&tsx->texname); glError();\r
      tsx->texname=0;\r
     }\r
   }\r
@@ -659,7 +665,7 @@ void ResetTextureArea(BOOL bDelTex)
    lu=pxSsubtexLeft[i];\r
    lu->l=0;\r
    if(bDelTex && uiStexturePage[i])\r
-    {glDeleteTextures(1,&uiStexturePage[i]);uiStexturePage[i]=0;}\r
+    {glDeleteTextures(1,&uiStexturePage[i]); glError();uiStexturePage[i]=0;}\r
   }\r
 }\r
 \r
@@ -881,21 +887,25 @@ void DefineTextureWnd(void)
 {\r
  if(gTexName==0)\r
   glGenTextures(1, &gTexName);\r
-\r
+ glError();\r
  glBindTexture(GL_TEXTURE_2D, gTexName);\r
-\r
+ glError();\r
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);\r
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);\r
\r
+ glError(); \r
 {\r
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter);\r
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter);\r
+   glError();\r
   }\r
 \r
  glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, \r
               TWin.Position.x1, \r
               TWin.Position.y1, \r
               0, GL_RGBA, GL_UNSIGNED_BYTE, texturepart);\r
+ glError();\r
+ //LOGE("DefineTextureWnd x:%d y:%d",TWin.Position.x1,TWin.Position.y1);\r
+\r
 }\r
 \r
 ////////////////////////////////////////////////////////////////////////\r
@@ -1638,21 +1648,23 @@ void DefinePalTextureWnd(void)
 {\r
  if(gTexName==0)\r
   glGenTextures(1, &gTexName);\r
-\r
+ glError();\r
  glBindTexture(GL_TEXTURE_2D, gTexName);\r
-\r
+ glError();\r
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);\r
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);\r
\r
+ glError();\r
 {\r
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter);\r
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter);\r
   }\r
-\r
+ glError();\r
  glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, \r
               TWin.Position.x1, \r
               TWin.Position.y1, \r
               0, GL_RGBA, GL_UNSIGNED_BYTE,texturepart);\r
+  glError();\r
+  //LOGE("DefinePalTextureWnd x:%d y:%d",TWin.Position.x1,TWin.Position.y1);\r
 }\r
 \r
 ///////////////////////////////////////////////////////\r
@@ -1899,31 +1911,32 @@ void DefinePackedTextureMovie(void)
 {\r
  if(gTexMovieName==0)\r
   {\r
-   glGenTextures(1, &gTexMovieName);\r
+   glEnable(GL_TEXTURE_2D);\r
+   glGenTextures(1, &gTexMovieName); glError();\r
    gTexName=gTexMovieName;\r
-   glBindTexture(GL_TEXTURE_2D, gTexName);\r
+   glBindTexture(GL_TEXTURE_2D, gTexName); glError();\r
 \r
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType);\r
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType);\r
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); glError();\r
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); glError();\r
 \r
    if(!bUseFastMdec) \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
     }\r
    else\r
     {\r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter);\r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter);\r
+     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); glError();\r
+     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); glError();\r
     }\r
                                  \r
    glTexImage2D(GL_TEXTURE_2D, 0, //giWantedRGBA, \r
                 GL_RGBA,\r
-                256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturepart);\r
+                256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturepart); glError();\r
   }\r
  else \r
   {\r
-   gTexName=gTexMovieName;glBindTexture(GL_TEXTURE_2D, gTexName);\r
+   gTexName=gTexMovieName;glBindTexture(GL_TEXTURE_2D, gTexName); glError();\r
   }\r
 \r
  glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,\r
@@ -1931,7 +1944,9 @@ void DefinePackedTextureMovie(void)
                  (xrMovieArea.y1-xrMovieArea.y0), \r
                  GL_RGBA,\r
                  GL_UNSIGNED_SHORT,\r
-                 texturepart);\r
+                 texturepart); glError();\r
+ //LOGE("DefinePackedTextureMovie x:%d y:%d",(xrMovieArea.x1-xrMovieArea.x0),(xrMovieArea.y1-xrMovieArea.y0));\r
+\r
 }\r
 \r
 ////////////////////////////////////////////////////////////////////////\r
@@ -1940,35 +1955,36 @@ void DefineTextureMovie(void)
 {\r
  if(gTexMovieName==0)\r
   {\r
-   glGenTextures(1, &gTexMovieName);\r
+   glGenTextures(1, &gTexMovieName); glError();\r
    gTexName=gTexMovieName;\r
-   glBindTexture(GL_TEXTURE_2D, gTexName);\r
+   glBindTexture(GL_TEXTURE_2D, gTexName); glError();\r
 \r
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType);\r
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType);\r
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); glError();\r
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); glError();\r
  \r
    if(!bUseFastMdec) \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
     }\r
    else\r
     {\r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter);\r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter);\r
+     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); glError();\r
+     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); glError();\r
     }\r
 \r
-   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturepart);\r
+   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturepart); glError();\r
   }\r
  else \r
   {\r
-   gTexName=gTexMovieName;glBindTexture(GL_TEXTURE_2D, gTexName);\r
+   gTexName=gTexMovieName;glBindTexture(GL_TEXTURE_2D, gTexName); glError();\r
   }\r
 \r
  glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,\r
                  (xrMovieArea.x1-xrMovieArea.x0), \r
                  (xrMovieArea.y1-xrMovieArea.y0), \r
-                 GL_RGBA, GL_UNSIGNED_BYTE, texturepart);\r
+                 GL_RGBA, GL_UNSIGNED_BYTE, texturepart); glError();\r
+ //LOGE("DefineTextureMovie x:%d y:%d",(xrMovieArea.x1-xrMovieArea.x0),(xrMovieArea.y1-xrMovieArea.y0));\r
 }\r
 \r
 ////////////////////////////////////////////////////////////////////////\r
@@ -2222,14 +2238,14 @@ GLuint BlackFake15BitTexture(void)
   {\r
    if(!gTexFrameName)\r
     {\r
-     glGenTextures(1, &gTexFrameName);\r
+     glGenTextures(1, &gTexFrameName); glError();\r
      gTexName=gTexFrameName;\r
-     glBindTexture(GL_TEXTURE_2D, gTexName);\r
+     glBindTexture(GL_TEXTURE_2D, gTexName); glError();\r
 \r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType);\r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType);\r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter);\r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter);\r
+     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); glError();\r
+     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); glError();\r
+     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); glError();\r
+     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); glError();\r
  \r
      {\r
        unsigned long * ta=(unsigned long *)texturepart;\r
@@ -2237,14 +2253,15 @@ GLuint BlackFake15BitTexture(void)
         for(x1=0;x1<=4;x1++)\r
          *ta++=0xff000000;\r
       }\r
-     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturepart);\r
+     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturepart); glError();\r
+\r
     }\r
    else\r
     {\r
      gTexName=gTexFrameName;\r
-     glBindTexture(GL_TEXTURE_2D, gTexName);\r
+     glBindTexture(GL_TEXTURE_2D, gTexName); glError();\r
     }\r
-\r
+      //LOGE("BlackFake15BitTexture x:%d y:%d",4,4);\r
    ubOpaqueDraw=0;\r
 \r
    return (GLuint)gTexName;\r
@@ -2315,18 +2332,18 @@ GLuint Fake15BitTexture(void)
    if(iResX>640  || iResY>480)  iFTex=1024;\r
    else                         iFTex=512; \r
 \r
-   glGenTextures(1, &gTexFrameName);\r
+   glGenTextures(1, &gTexFrameName); glError();\r
    gTexName=gTexFrameName;\r
-   glBindTexture(GL_TEXTURE_2D, gTexName);\r
+   glBindTexture(GL_TEXTURE_2D, gTexName); glError();\r
 \r
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType);\r
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType);\r
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter);\r
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter);\r
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); glError();\r
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); glError();\r
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); glError();\r
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); glError();\r
 \r
    p=(char *)malloc(iFTex*iFTex*4);\r
    memset(p,0,iFTex*iFTex*4);\r
-   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iFTex, iFTex, 0, GL_RGBA, GL_UNSIGNED_BYTE, p);\r
+   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iFTex, iFTex, 0, GL_RGBA, GL_UNSIGNED_BYTE, p); glError();\r
    free(p);\r
 \r
    glGetError();\r
@@ -2334,9 +2351,9 @@ GLuint Fake15BitTexture(void)
  else \r
   {\r
    gTexName=gTexFrameName;\r
-   glBindTexture(GL_TEXTURE_2D, gTexName);\r
+   glBindTexture(GL_TEXTURE_2D, gTexName); glError();\r
   }\r
-\r
+      //LOGE("Fake15BitTexture x:%d y:%d",iFTex,iFTex);\r
  x1+=PreviousPSXDisplay.Range.x0;\r
  y1+=PreviousPSXDisplay.Range.y0;\r
 \r
@@ -2408,14 +2425,14 @@ GLuint Fake15BitTexture(void)
                       iYAdjust,\r
                       rSrc.left+rRatioRect.left,\r
                       iResY-rSrc.bottom-rRatioRect.top,\r
-                      x1,y1);\r
+                      x1,y1); glError();\r
 \r
  if(glGetError()) \r
   {\r
    char * p=(char *)malloc(iFTex*iFTex*4);\r
    memset(p,0,iFTex*iFTex*4);\r
    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, iFTex, iFTex,\r
-                   GL_RGBA, GL_UNSIGNED_BYTE, p);\r
+                   GL_RGBA, GL_UNSIGNED_BYTE, p); glError();\r
    free(p);\r
   }\r
 \r
@@ -3414,29 +3431,30 @@ void DefineSubTextureSortHiRes(void)
 \r
  if(!gTexName)             \r
   {\r
-   glGenTextures(1, &gTexName);\r
-   glBindTexture(GL_TEXTURE_2D, gTexName);\r
+   glGenTextures(1, &gTexName); glError();\r
+   glBindTexture(GL_TEXTURE_2D, gTexName); glError();\r
 \r
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType);\r
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType);\r
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); glError();\r
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); glError();\r
 \r
    if(iFilterType)\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
     }\r
    else\r
     {            \r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter);\r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter);\r
+     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); glError();\r
+     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); glError();\r
     }   \r
-   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturebuffer);\r
+   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturebuffer); glError();\r
   }\r
- else glBindTexture(GL_TEXTURE_2D, gTexName);\r
+ else glBindTexture(GL_TEXTURE_2D, gTexName); glError();\r
 \r
  glTexSubImage2D(GL_TEXTURE_2D, 0, XTexS<<1, YTexS<<1,\r
                  DXTexS<<1, DYTexS<<1,\r
-                 GL_RGBA, GL_UNSIGNED_BYTE, texturebuffer);\r
+                 GL_RGBA, GL_UNSIGNED_BYTE, texturebuffer); glError();\r
+ //LOGE("DefineSubTextureSortHiRes x:%d y:%d",XTexS<<1,YTexS<<1);\r
 }\r
 \r
 /////////////////////////////////////////////////////////////////////////////\r
@@ -3446,29 +3464,30 @@ void DefineSubTextureSort(void)
 \r
  if(!gTexName)\r
   {\r
-   glGenTextures(1, &gTexName);\r
-   glBindTexture(GL_TEXTURE_2D, gTexName);\r
+   glGenTextures(1, &gTexName); glError();\r
+   glBindTexture(GL_TEXTURE_2D, gTexName); glError();\r
 \r
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType);\r
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType);\r
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); glError();\r
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); glError();\r
 \r
    if(iFilterType)\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
     }\r
    else\r
     {\r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter);\r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter);\r
+     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); glError();\r
+     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); glError();\r
     }\r
-   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0,GL_RGBA, GL_UNSIGNED_BYTE, texturepart);\r
+   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0,GL_RGBA, GL_UNSIGNED_BYTE, texturepart); glError();\r
   }\r
- else glBindTexture(GL_TEXTURE_2D, gTexName);\r
+ else glBindTexture(GL_TEXTURE_2D, gTexName); glError();\r
 \r
  glTexSubImage2D(GL_TEXTURE_2D, 0, XTexS, YTexS,\r
                  DXTexS, DYTexS,\r
-                 GL_RGBA, GL_UNSIGNED_BYTE, texturepart);\r
+                 GL_RGBA, GL_UNSIGNED_BYTE, texturepart); glError();\r
+                                        //LOGE("DefineSubTextureSort x:%d y:%d w:%d h:%d",XTexS,YTexS,DXTexS,DYTexS);\r
 }\r
 \r
 /////////////////////////////////////////////////////////////////////////////\r