OSDN Git Service

accomodated new driver_func initialization
authorDaniel Borca <dborca@users.sourceforge.net>
Fri, 23 Jan 2004 15:57:52 +0000 (15:57 +0000)
committerDaniel Borca <dborca@users.sourceforge.net>
Fri, 23 Jan 2004 15:57:52 +0000 (15:57 +0000)
added DMesaGetProcAddress
some other minor fixes
updated documentation

docs/README.DJ
include/GL/dmesa.h
src/mesa/Makefile.DJ
src/mesa/Makefile.mgw
src/mesa/drivers/dos/dmesa.c
src/mesa/drivers/glide/fxapi.c
src/mesa/drivers/glide/fxdd.c
src/mesa/drivers/glide/fxddtex.c
src/mesa/drivers/glide/fxdrv.h
src/mesa/drivers/glide/fxtris.c
src/mesa/drivers/glide/fxwgl.c

index 2571a53..15bff62 100644 (file)
@@ -116,6 +116,16 @@ FAQ:
       lazy programmer and I found that the easiest way to keep buffer handling
       at peak performance ;-).
 
+   Q) I'm getting a "bad font!" fatal error.
+   A) By default, DOS GLUT compiles with GLUT_IMPORT_LIB, to cope with variable
+      access inside dynamic modules (same mechanism used for Win32 _DLL). Since
+      -DGLUT_IMPORT_LIB affects Mesa's `glut.h', your apps must be compiled the
+      same way GLUT was compiled (either with or without defining it). If you
+      want to use another `glut.h' when building your own demos, or just don't
+      feel happy about this, make sure you remove the line with GLUT_IMPORT_LIB
+      from `Mesa/src/glut/dos/Makefile.DJ' before (re)making GLUT. Beware, this
+      means you will never EVER be able to safely use `glut.dxe'!
+
    Q) How do I query for a list of available video modes to choose as a visual?
    A) This is an ugly hack, for which I'm sure I'll burn in hell.
       First, query for a list of modes:
@@ -238,7 +248,8 @@ v1.5 (jan-2004)
        x more changes to the 3dfx driver
 
 v1.6 (???-2004)
-       * fixed a horrible bug in VGA initialization routine
+       + added DMesaGetProcAddress
+       ! fixed a horrible bug in VGA initialization routine
 
 
 
index 364792a..e67e54a 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  5.0
+ * Version:  6.1
  * 
- * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2004  Brian Paul   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"),
@@ -23,7 +23,7 @@
  */
 
 /*
- * DOS/DJGPP device driver v1.5 for Mesa
+ * DOS/DJGPP device driver v1.6 for Mesa
  *
  *  Copyright (C) 2002 - Borca Daniel
  *  Email : dborca@users.sourceforge.net
@@ -34,8 +34,8 @@
 #ifndef DMESA_H_included
 #define DMESA_H_included
 
-#define DMESA_MAJOR_VERSION 5
-#define DMESA_MINOR_VERSION 0
+#define DMESA_MAJOR_VERSION 6
+#define DMESA_MINOR_VERSION 1
 
 /* Sample Usage:
  *
@@ -131,6 +131,11 @@ GLboolean DMesaResizeBuffer (GLint width, GLint height);
 void DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue);
 
 /*
+ * DMesa functions
+ */
+void *DMesaGetProcAddress (const char *name);
+
+/*
  * DMesa state retrieval.
  */
 #define DMESA_GET_SCREEN_SIZE 0x0100
index 517e24b..bd8e6f0 100644 (file)
@@ -20,7 +20,7 @@
 # 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.
 
-# DOS/DJGPP core makefile v1.5 for Mesa
+# DOS/DJGPP core makefile v1.6 for Mesa
 #
 #  Copyright (C) 2002 - Borca Daniel
 #  Email : dborca@users.sourceforge.net
@@ -174,7 +174,7 @@ DRIVER_SOURCES += \
        drivers/dos/dpmi.c
 endif
 
-SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(DRIVER_SOURCES)
+SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(COMMON_DRIVER_SOURCES) $(DRIVER_SOURCES)
 
 OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
 
index 2068667..bb370d8 100644 (file)
@@ -20,7 +20,7 @@
 # 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.
 
-# MinGW core makefile v1.1 for Mesa
+# MinGW core makefile v1.2 for Mesa
 #
 #  Copyright (C) 2002 - Borca Daniel
 #  Email : dborca@users.sourceforge.net
@@ -170,7 +170,7 @@ DRIVER_SOURCES = \
        drivers/windows/gdi/wgl.c
 endif
 
-SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(DRIVER_SOURCES)
+SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(COMMON_DRIVER_SOURCES) $(DRIVER_SOURCES)
 
 OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
 
index 5432371..c8fd918 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  5.1
+ * Version:  6.1
  * 
- * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2004  Brian Paul   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"),
@@ -23,7 +23,7 @@
  */
 
 /*
- * DOS/DJGPP device driver v1.5 for Mesa
+ * DOS/DJGPP device driver v1.6 for Mesa
  *
  *  Copyright (c) 2003 - Borca Daniel
  *  Email : dborca@users.sourceforge.net
@@ -53,6 +53,7 @@
 #include "tnl/tnl.h"
 #include "tnl/t_context.h"
 #include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
 #include "video.h"
 #else  /* FX */
 #include "GL/fxmesa.h"
@@ -868,76 +869,45 @@ static void dmesa_register_swrast_functions (GLcontext *ctx)
 
 
 
+static void dmesa_update_state (GLcontext *ctx, GLuint new_state)
+{
+ /* Propagate statechange information to swrast and swrast_setup
+  * modules. The DMesa driver has no internal GL-dependent state.
+  */
+ _swrast_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+}
+
+
+
+/* Initialize the device driver function table with the functions
+ * we implement in this driver.
+ */
+static void dmesa_init_driver_functions (DMesaVisual visual,
+                                         struct dd_function_table *driver)
+{
+ driver->UpdateState = dmesa_update_state;
+ driver->GetString = get_string;
+ driver->GetBufferSize = get_buffer_size;
+ driver->Flush = flush;
+ driver->Finish = finish;
+ driver->Clear = clear;
+ driver->ClearColor = clear_color;
+ driver->ClearIndex = clear_index;
+}
+
+
+
 /* Setup pointers and other driver state that is constant for the life
  * of a context.
  */
 static void dmesa_init_pointers (GLcontext *ctx)
 {
- TNLcontext *tnl;
  struct swrast_device_driver *dd = _swrast_GetDeviceDriverReference(ctx);
 
- ctx->Driver.GetString = get_string;
- ctx->Driver.GetBufferSize = get_buffer_size;
- ctx->Driver.Flush = flush;
- ctx->Driver.Finish = finish;
-    
- /* Software rasterizer pixel paths:
-  */
- ctx->Driver.Accum = _swrast_Accum;
- ctx->Driver.Bitmap = _swrast_Bitmap;
- ctx->Driver.Clear = clear;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.CopyPixels = _swrast_CopyPixels;
- ctx->Driver.DrawPixels = _swrast_DrawPixels;
- ctx->Driver.ReadPixels = _swrast_ReadPixels;
- ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
-
- /* Software texture functions:
-  */
- ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = _mesa_store_teximage2d;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
- ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
- ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
- ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
- ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
- ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
-
- ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
- ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
- ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
- ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
- ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
- ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
-
- /* Swrast hooks for imaging extensions:
-  */
- ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
- ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
- ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
- ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
-
- /* Statechange callbacks:
-  */
- ctx->Driver.ClearColor = clear_color;
- ctx->Driver.ClearIndex = clear_index;
-
- /* Initialize the TNL driver interface:
-  */
- tnl = TNL_CONTEXT(ctx);
- tnl->Driver.RunPipeline = _tnl_run_pipeline;
-
  dd->SetBuffer = set_buffer;
-   
- /* Install swsetup for tnl->Driver.Render.*:
-  */
- _swsetup_Wakeup(ctx);
 
  /* The span functions should be in `dmesa_update_state', but I'm
   * pretty sure they will never change during the life of the Visual
@@ -961,19 +931,6 @@ static void dmesa_init_pointers (GLcontext *ctx)
  dd->ReadRGBASpan = read_rgba_span;
  dd->ReadRGBAPixels = read_rgba_pixels;
 }
-
-
-
-static void dmesa_update_state (GLcontext *ctx, GLuint new_state)
-{
- /* Propagate statechange information to swrast and swrast_setup
-  * modules. The DMesa driver has no internal GL-dependent state.
-  */
- _swrast_InvalidateState( ctx, new_state );
- _ac_InvalidateState( ctx, new_state );
- _tnl_InvalidateState( ctx, new_state );
- _swsetup_InvalidateState( ctx, new_state );
-}
 #endif /* FX */
 
 
@@ -1188,36 +1145,46 @@ DMesaContext DMesaCreateContext (DMesaVisual visual,
                                  DMesaContext share)
 {
 #ifndef FX
- DMesaContext c;
- GLboolean direct = GL_FALSE;
+ GLcontext *c;
+ TNLcontext *tnl;
+ struct dd_function_table functions;
 
- if ((c=(DMesaContext)CALLOC_STRUCT(dmesa_context)) != NULL) {
-    _mesa_initialize_context((GLcontext *)c,
+ if ((c=(GLcontext *)CALLOC_STRUCT(dmesa_context)) != NULL) {
+    /* Initialize device driver function table */
+    _mesa_init_driver_functions(&functions);
+    /* override with our functions */
+    dmesa_init_driver_functions(visual, &functions);
+
+    _mesa_initialize_context(c,
                              (GLvisual *)visual,
                              (GLcontext *)share,
-                             (void *)c, direct);
-
-    _mesa_enable_sw_extensions((GLcontext *)c);
-    _mesa_enable_1_3_extensions((GLcontext *)c);
-    _mesa_enable_1_4_extensions((GLcontext *)c);
-    _mesa_enable_1_5_extensions((GLcontext *)c);
+                             &functions,
+                             (void *)c);
+    _mesa_enable_sw_extensions(c);
+    _mesa_enable_1_3_extensions(c);
+    _mesa_enable_1_4_extensions(c);
+    _mesa_enable_1_5_extensions(c);
 
     /* you probably have to do a bunch of other initializations here. */
-    c->visual = visual;
-
-    ((GLcontext *)c)->Driver.UpdateState = dmesa_update_state;
+    ((DMesaContext)c)->visual = visual;
 
     /* Initialize the software rasterizer and helper modules.
      */
-    _swrast_CreateContext((GLcontext *)c);
-    _ac_CreateContext((GLcontext *)c);
-    _tnl_CreateContext((GLcontext *)c);
-    _swsetup_CreateContext((GLcontext *)c);
-    if (visual->rgb_flag) dmesa_register_swrast_functions((GLcontext *)c);
-    dmesa_init_pointers((GLcontext *)c);
+    _swrast_CreateContext(c);
+    _ac_CreateContext(c);
+    _tnl_CreateContext(c);
+    _swsetup_CreateContext(c);
+    /* tnl setup */
+    tnl = TNL_CONTEXT(c);
+    tnl->Driver.RunPipeline = _tnl_run_pipeline;
+    /* swrast setup */
+    if (visual->rgb_flag) dmesa_register_swrast_functions(c);
+    dmesa_init_pointers(c);
+    _swsetup_Wakeup(c);
  }
 
- return c;
+ return (DMesaContext)c;
 
 #else  /* FX */
  return (DMesaContext)visual;
@@ -1350,6 +1317,20 @@ void *DMesaGetCurrentContext (void)
 
 
 
+void *DMesaGetProcAddress (const char *name)
+{
+ void *p = (void *)_glapi_get_proc_address(name);
+
+/* TODO: handle DMesa* namespace
+ if (p == NULL) {
+ }
+*/
+
+ return p;
+}
+
+
+
 int DMesaGetIntegerv (GLenum pname, GLint *params)
 {
  switch (pname) {
index 75629cb..50f783f 100644 (file)
@@ -42,6 +42,8 @@
 #if defined(FX)
 #include "fxdrv.h"
 
+#include "drivers/common/driverfuncs.h"
+
 #ifndef TDFX_DEBUG
 int TDFX_DEBUG = (0 
 /*               | VERBOSE_VARRAY */
@@ -653,7 +655,6 @@ fxMesaCreateContext(GLuint win,
    }
 
    _mesa_init_driver_functions(&functions);
-   ctx->Driver.
    ctx = fxMesa->glCtx = _mesa_create_context(fxMesa->glVis, shareCtx,
                                              &functions, (void *) fxMesa);
    if (!ctx) {
index 6e66f59..a07a27b 100644 (file)
@@ -1498,6 +1498,11 @@ fxDDInitExtensions(GLcontext * ctx)
    if (fxMesa->HaveMirExt) {
       _mesa_enable_extension(ctx, "GL_ARB_texture_mirrored_repeat");
    }
+
+   /* core-level extensions */
+#if 1
+   _mesa_enable_extension(ctx, "GL_ARB_vertex_buffer_object");
+#endif
 }
 
 
@@ -1666,9 +1671,6 @@ fxSetupDDPointers(GLcontext * ctx)
    ctx->Driver.Clear = fxDDClear;
    ctx->Driver.DrawBuffer = fxDDSetDrawBuffer;
    ctx->Driver.GetBufferSize = fxDDBufferSize;
-   ctx->Driver.Accum = _swrast_Accum;
-   ctx->Driver.CopyPixels = _swrast_CopyPixels;
-   ctx->Driver.DrawPixels = _swrast_DrawPixels;
    switch (fxMesa->colDepth) {
           case 15:
                ctx->Driver.ReadPixels = fxDDReadPixels555;
@@ -1684,34 +1686,15 @@ fxSetupDDPointers(GLcontext * ctx)
                ctx->Driver.Bitmap = fxDDDrawBitmap4;
                break;
    }
-   ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
    ctx->Driver.Finish = fxDDFinish;
    ctx->Driver.Flush = NULL;
    ctx->Driver.ChooseTextureFormat = fxDDChooseTextureFormat;
-   ctx->Driver.TexImage1D = _mesa_store_teximage1d;
    ctx->Driver.TexImage2D = fxDDTexImage2D;
-   ctx->Driver.TexImage3D = _mesa_store_teximage3d;
-   ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
    ctx->Driver.TexSubImage2D = fxDDTexSubImage2D;
-   ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
-   ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
    ctx->Driver.CompressedTexImage2D = fxDDCompressedTexImage2D;
-   ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
-   ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
    ctx->Driver.CompressedTexSubImage2D = fxDDCompressedTexSubImage2D;
-   ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
    ctx->Driver.IsCompressedFormat = fxDDIsCompressedFormat;
    ctx->Driver.CompressedTextureSize = fxDDCompressedTextureSize;
-   ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
-   ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
-   ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
-   ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
-   ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
-   ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-   ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
-   ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
-   ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
-   ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
    ctx->Driver.TexEnv = fxDDTexEnv;
    ctx->Driver.TexParameter = fxDDTexParam;
    ctx->Driver.BindTexture = fxDDTexBind;
index 62f4ad1..a6a5dc5 100644 (file)
@@ -148,7 +148,6 @@ fxDDTexBind(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj)
       tObj->DriverData = fxAllocTexObjData(fxMesa);
    }
    ti = fxTMGetTexInfo(tObj);
-   assert(ti);
 
    fxMesa->texBindNumber++;
    ti->lastTimeUsed = fxMesa->texBindNumber;
@@ -203,7 +202,6 @@ fxDDTexParam(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj,
    if (!tObj->DriverData)
       tObj->DriverData = fxAllocTexObjData(fxMesa);
    ti = fxTMGetTexInfo(tObj);
-   assert(ti);
 
    switch (pname) {
    case GL_TEXTURE_MIN_FILTER:
@@ -482,7 +480,6 @@ fxDDTexPalette(GLcontext * ctx, struct gl_texture_object *tObj)
       if (!tObj->DriverData)
          tObj->DriverData = fxAllocTexObjData(fxMesa);
       ti = fxTMGetTexInfo(tObj);
-      assert(ti);
       ti->paltype = convertPalette(fxMesa, ti->palette.data, &tObj->Palette);
       fxTexInvalidate(ctx, tObj);
    }
@@ -519,7 +516,6 @@ fxDDTexUseGlbPalette(GLcontext * ctx, GLboolean state)
         struct gl_texture_object *tObj = ctx->Texture.Unit[0]._Current;
          if (!tObj->DriverData)
            tObj->DriverData = fxAllocTexObjData(fxMesa);
-        assert(tObj->DriverData);
         fxTexInvalidate(ctx, tObj);
       }
    }
index 1f31f62..1b42be8 100644 (file)
@@ -59,8 +59,6 @@
 
 #include "math/m_vector.h"
 
-#include "drivers/common/driverfuncs.h"
-
 
 /* Define some shorter names for these things.
  */
index a516568..3b82b57 100644 (file)
@@ -1215,14 +1215,14 @@ static void fxRunPipeline( GLcontext *ctx )
          struct gl_texture_unit *t0 = &ctx->Texture.Unit[fxMesa->tmu_source[0]];
          struct gl_texture_unit *t1 = &ctx->Texture.Unit[fxMesa->tmu_source[1]];
       
-         if (t0 && t0->_Current && FX_TEXTURE_DATA(t0)) {
+         if (t0->_Current && FX_TEXTURE_DATA(t0)) {
             fxMesa->s0scale = FX_TEXTURE_DATA(t0)->sScale;
             fxMesa->t0scale = FX_TEXTURE_DATA(t0)->tScale;
             fxMesa->inv_s0scale = 1.0 / fxMesa->s0scale;
             fxMesa->inv_t0scale = 1.0 / fxMesa->t0scale;
          }
       
-         if (t1 && t1->_Current && FX_TEXTURE_DATA(t1)) {
+         if (t1->_Current && FX_TEXTURE_DATA(t1)) {
             fxMesa->s1scale = FX_TEXTURE_DATA(t1)->sScale;
             fxMesa->t1scale = FX_TEXTURE_DATA(t1)->tScale;
             fxMesa->inv_s1scale = 1.0 / fxMesa->s1scale;
index adf88a4..ae1d913 100644 (file)
@@ -218,7 +218,6 @@ struct __pixelformat__ pix[] = {
      FXMESA_NONE}
    }
 };
-static int qt_pix = sizeof(pix) / sizeof(pix[0]);
 
 static fxMesaContext ctx = NULL;
 static WNDPROC hWNDOldProc;
@@ -676,6 +675,14 @@ wglSwapLayerBuffers(HDC hdc, UINT fuPlanes)
    return (FALSE);
 }
 
+static int pfd_tablen (void)
+{
+ /* we should take an envvar for `fxMesaSelectCurrentBoard' */
+ return (fxMesaSelectCurrentBoard(0) < GR_SSTTYPE_Voodoo4)
+        ? 2                               /* only 16bit entries */
+        : sizeof(pix) / sizeof(pix[0]);   /* full table */
+}
+
 GLAPI int GLAPIENTRY
 wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR * ppfd)
 {
@@ -723,7 +730,7 @@ wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR * ppfd)
   }
 #endif
 
-   qt_valid_pix = qt_pix;
+   qt_valid_pix = pfd_tablen();
 
    if (ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR) || ppfd->nVersion != 1) {
       SetLastError(0);
@@ -787,7 +794,7 @@ wglDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes,
 {
    int qt_valid_pix;
 
-   qt_valid_pix = qt_pix;
+   qt_valid_pix = pfd_tablen();
 
    if (iPixelFormat < 1 || iPixelFormat > qt_valid_pix ||
        ((nBytes != sizeof(PIXELFORMATDESCRIPTOR)) && (nBytes != 0))) {
@@ -830,7 +837,7 @@ wglSetPixelFormat(HDC hdc, int iPixelFormat, const PIXELFORMATDESCRIPTOR * ppfd)
 {
    int qt_valid_pix;
 
-   qt_valid_pix = qt_pix;
+   qt_valid_pix = pfd_tablen();
 
    if (iPixelFormat < 1 || iPixelFormat > qt_valid_pix) {
       if (ppfd == NULL) {