#include "pipe/p_debug.h"
#include "stw_pixelformat.h"
+#include "stw_public.h"
#define MAX_PIXELFORMATS 16
return count;
}
+/* Only used by the wgl code, but have it here to avoid exporting the
+ * pixelformat.h functionality.
+ */
+int stw_pixelformat_choose( HDC hdc,
+ CONST PIXELFORMATDESCRIPTOR *ppfd )
+{
+ uint count;
+ uint index;
+ uint bestindex;
+ uint bestdelta;
+
+ (void) hdc;
+
+ count = pixelformat_get_count();
+ bestindex = count;
+ bestdelta = 0xffffffff;
+
+ for (index = 0; index < count; index++) {
+ uint delta = 0;
+ const struct pixelformat_info *pf = pixelformat_get_info( index );
+
+ if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) &&
+ !!(ppfd->dwFlags & PFD_DOUBLEBUFFER) !=
+ !!(pf->flags & PF_FLAG_DOUBLEBUFFER))
+ continue;
+
+ if (ppfd->cColorBits != pf->color.redbits + pf->color.greenbits + pf->color.bluebits)
+ delta += 8;
+
+ if (ppfd->cDepthBits != pf->depth.depthbits)
+ delta += 4;
+
+ if (ppfd->cStencilBits != pf->depth.stencilbits)
+ delta += 2;
+
+ if (ppfd->cAlphaBits != pf->alpha.alphabits)
+ delta++;
+
+ if (delta < bestdelta) {
+ bestindex = index;
+ bestdelta = delta;
+ if (bestdelta == 0)
+ break;
+ }
+ }
+
+ if (bestindex == count)
+ return 0;
+
+ return bestindex + 1;
+}
+
int
stw_pixelformat_get(
}
+WINGDIAPI int APIENTRY
+wglChoosePixelFormat(
+ HDC hdc,
+ CONST PIXELFORMATDESCRIPTOR *ppfd )
+{
+ if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1)
+ return 0;
+ if (ppfd->iPixelType != PFD_TYPE_RGBA)
+ return 0;
+ if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW))
+ return 0;
+ if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL))
+ return 0;
+ if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP)
+ return 0;
+ if (ppfd->dwFlags & PFD_SUPPORT_GDI)
+ return 0;
+ if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO))
+ return 0;
+
+ return stw_pixelformat_choose( hdc, ppfd );
+}
+
+WINGDIAPI int APIENTRY
+wglDescribePixelFormat(
+ HDC hdc,
+ int iPixelFormat,
+ UINT nBytes,
+ LPPIXELFORMATDESCRIPTOR ppfd )
+{
+ return stw_pixelformat_describe( hdc, iPixelFormat, nBytes, ppfd );
+}
+
+WINGDIAPI int APIENTRY
+wglGetPixelFormat(
+ HDC hdc )
+{
+ return stw_pixelformat_get( hdc );
+}
+
+WINGDIAPI BOOL APIENTRY
+wglSetPixelFormat(
+ HDC hdc,
+ int iPixelFormat,
+ const PIXELFORMATDESCRIPTOR *ppfd )
+{
+ if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ))
+ return FALSE;
+
+ return stw_pixelformat_set( hdc, iPixelFormat );
+}
+
+
WINGDIAPI BOOL APIENTRY
wglUseFontBitmapsA(
HDC hdc,
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <windows.h>
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
-#include "shared/stw_public.h"
-#include "stw_wgl.h"
-
-WINGDIAPI int APIENTRY
-wglChoosePixelFormat(
- HDC hdc,
- CONST PIXELFORMATDESCRIPTOR *ppfd )
-{
- uint count;
- uint index;
- uint bestindex;
- uint bestdelta;
-
- (void) hdc;
-
- count = pixelformat_get_count();
- bestindex = count;
- bestdelta = 0xffffffff;
-
- if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1)
- return 0;
- if (ppfd->iPixelType != PFD_TYPE_RGBA)
- return 0;
- if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW))
- return 0;
- if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL))
- return 0;
- if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP)
- return 0;
- if (ppfd->dwFlags & PFD_SUPPORT_GDI)
- return 0;
- if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO))
- return 0;
-
- for (index = 0; index < count; index++) {
- uint delta = 0;
- const struct pixelformat_info *pf = pixelformat_get_info( index );
-
- if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE)) {
- if ((ppfd->dwFlags & PFD_DOUBLEBUFFER) && !(pf->flags & PF_FLAG_DOUBLEBUFFER))
- continue;
- if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER) && (pf->flags & PF_FLAG_DOUBLEBUFFER))
- continue;
- }
-
- if (ppfd->cColorBits != pf->color.redbits + pf->color.greenbits + pf->color.bluebits)
- delta += 8;
-
- if (ppfd->cDepthBits != pf->depth.depthbits)
- delta += 4;
-
- if (ppfd->cStencilBits != pf->depth.stencilbits)
- delta += 2;
-
- if (ppfd->cAlphaBits != pf->alpha.alphabits)
- delta++;
-
- if (delta < bestdelta) {
- bestindex = index;
- bestdelta = delta;
- if (bestdelta == 0)
- break;
- }
- }
-
- if (bestindex == count)
- return 0;
- return bestindex + 1;
-}
-
-WINGDIAPI int APIENTRY
-wglDescribePixelFormat(
- HDC hdc,
- int iPixelFormat,
- UINT nBytes,
- LPPIXELFORMATDESCRIPTOR ppfd )
-{
- return stw_pixelformat_describe( hdc, iPixelFormat, nBytes, ppfd );
-}
-
-WINGDIAPI int APIENTRY
-wglGetPixelFormat(
- HDC hdc )
-{
- return stw_pixelformat_get( hdc );
-}
-
-WINGDIAPI BOOL APIENTRY
-wglSetPixelFormat(
- HDC hdc,
- int iPixelFormat,
- const PIXELFORMATDESCRIPTOR *ppfd )
-{
- if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ))
- return FALSE;
-
- return stw_pixelformat_set( hdc, iPixelFormat );
-}