svga: fix constant indices for texcoord scale factors and texture buffer size
[mesa.git] / src / gallium / state_trackers / wgl / stw_ext_pbuffer.c
index 7596cb6bd9502a6527bde6b589016d536b8d7d0e..d709faa60f24e2a1b70f77ee56f0989df67e49cb 100644 (file)
@@ -35,6 +35,8 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
 
+#include "util/u_debug.h"
+
 #include "stw_device.h"
 #include "stw_pixelformat.h"
 #include "stw_framebuffer.h"
@@ -84,6 +86,9 @@ wglCreatePbufferARB(HDC hCurrentDC,
    int iDisplayablePixelFormat;
    PIXELFORMATDESCRIPTOR pfd;
    BOOL bRet;
+   int textureFormat = WGL_NO_TEXTURE_ARB;
+   int textureTarget = WGL_NO_TEXTURE_ARB;
+   BOOL textureMipmap = FALSE;
 
    info = stw_pixelformat_get_info(iPixelFormat - 1);
    if (!info) {
@@ -102,8 +107,38 @@ wglCreatePbufferARB(HDC hCurrentDC,
          piAttrib++;
          useLargest = *piAttrib;
          break;
+       case WGL_TEXTURE_FORMAT_ARB:
+          /* WGL_ARB_render_texture */
+          piAttrib++;
+          textureFormat = *piAttrib;
+          if (textureFormat != WGL_TEXTURE_RGB_ARB &&
+             textureFormat != WGL_TEXTURE_RGBA_ARB &&
+             textureFormat != WGL_NO_TEXTURE_ARB) {
+             SetLastError(ERROR_INVALID_DATA);
+             return 0;
+          }
+          break;
+       case WGL_TEXTURE_TARGET_ARB:
+          /* WGL_ARB_render_texture */
+          piAttrib++;
+          textureTarget = *piAttrib;
+          if (textureTarget != WGL_TEXTURE_CUBE_MAP_ARB &&
+              textureTarget != WGL_TEXTURE_1D_ARB &&
+              textureTarget != WGL_TEXTURE_2D_ARB &&
+              textureTarget != WGL_NO_TEXTURE_ARB) {
+             SetLastError(ERROR_INVALID_DATA);
+             return 0;
+          }
+          break;
+      case WGL_MIPMAP_TEXTURE_ARB:
+         /* WGL_ARB_render_texture */
+         piAttrib++;
+         textureMipmap = !!*piAttrib;
+         break;
       default:
          SetLastError(ERROR_INVALID_DATA);
+         debug_printf("wgl: Unsupported attribute 0x%x in %s\n",
+                      *piAttrib, __func__);
          return 0;
       }
    }
@@ -218,9 +253,15 @@ wglCreatePbufferARB(HDC hCurrentDC,
    }
 
    fb->bPbuffer = TRUE;
+
+   /* WGL_ARB_render_texture fields */
+   fb->textureTarget = textureTarget;
+   fb->textureFormat = textureFormat;
+   fb->textureMipmap = textureMipmap;
+
    iDisplayablePixelFormat = fb->iDisplayablePixelFormat;
 
-   stw_framebuffer_release(fb);
+   stw_framebuffer_unlock(fb);
 
    /*
     * We need to set a displayable pixel format on the hidden window DC
@@ -244,12 +285,10 @@ wglGetPbufferDCARB(HPBUFFERARB hPbuffer)
       return NULL;
    }
 
-   fb = (struct stw_framebuffer *)hPbuffer;
+   fb = stw_framebuffer_from_HPBUFFERARB(hPbuffer);
 
    hDC = GetDC(fb->hWnd);
 
-   assert(hDC == fb->hDC);
-
    return hDC;
 }
 
@@ -265,7 +304,7 @@ wglReleasePbufferDCARB(HPBUFFERARB hPbuffer,
       return 0;
    }
 
-   fb = (struct stw_framebuffer *)hPbuffer;
+   fb = stw_framebuffer_from_HPBUFFERARB(hPbuffer);
 
    return ReleaseDC(fb->hWnd, hDC);
 }
@@ -281,7 +320,7 @@ wglDestroyPbufferARB(HPBUFFERARB hPbuffer)
       return FALSE;
    }
 
-   fb = (struct stw_framebuffer *)hPbuffer;
+   fb = stw_framebuffer_from_HPBUFFERARB(hPbuffer);
 
    /* This will destroy all our data */
    return DestroyWindow(fb->hWnd);
@@ -300,7 +339,7 @@ wglQueryPbufferARB(HPBUFFERARB hPbuffer,
       return FALSE;
    }
 
-   fb = (struct stw_framebuffer *)hPbuffer;
+   fb = stw_framebuffer_from_HPBUFFERARB(hPbuffer);
 
    switch (iAttribute) {
    case WGL_PBUFFER_WIDTH_ARB:
@@ -313,6 +352,22 @@ wglQueryPbufferARB(HPBUFFERARB hPbuffer,
       /* We assume that no content is ever lost due to display mode change */
       *piValue = FALSE;
       return TRUE;
+   /* WGL_ARB_render_texture */
+   case WGL_TEXTURE_TARGET_ARB:
+      *piValue = fb->textureTarget;
+      return TRUE;
+   case WGL_TEXTURE_FORMAT_ARB:
+      *piValue = fb->textureFormat;
+      return TRUE;
+   case WGL_MIPMAP_TEXTURE_ARB:
+      *piValue = fb->textureMipmap;
+      return TRUE;
+   case WGL_MIPMAP_LEVEL_ARB:
+      *piValue = fb->textureLevel;
+      return TRUE;
+   case WGL_CUBE_MAP_FACE_ARB:
+      *piValue = fb->textureFace + WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB;
+      return TRUE;
    default:
       SetLastError(ERROR_INVALID_DATA);
       return FALSE;