All elements of pre-DRI_NEW_INTERFACE_ONLY are removed. This allows
[mesa.git] / src / mesa / drivers / dri / mga / mga_xmesa.c
index 44e69dd1de424f5d76b14dec1c58193a543a33b3..aaa4e25c10382e2ce9093d8ae304a5d9c99a0493 100644 (file)
 
 #include "GL/internal/dri_interface.h"
 
+#define need_GL_ARB_multisample
+#define need_GL_ARB_texture_compression
+#define need_GL_ARB_vertex_program
+#define need_GL_EXT_fog_coord
+#define need_GL_EXT_multi_draw_arrays
+#define need_GL_EXT_secondary_color
+#if 0
+#define need_GL_EXT_paletted_texture
+#endif
+#define need_GL_NV_vertex_program
+#include "extension_helper.h"
+
 /* MGA configuration
  */
 #include "xmlpool.h"
@@ -92,9 +104,7 @@ DRI_CONF_BEGIN
 DRI_CONF_END;
 static const GLuint __driNConfigOptions = 6;
 
-#ifdef USE_NEW_INTERFACE
 static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
-#endif /* USE_NEW_INTERFACE */
 
 #ifndef MGA_DEBUG
 int MGA_DEBUG = 0;
@@ -102,7 +112,6 @@ int MGA_DEBUG = 0;
 
 static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
 
-#ifdef USE_NEW_INTERFACE
 static __GLcontextModes *
 mgaFillInModes( unsigned pixel_bits, unsigned depth_bits,
                unsigned stencil_bits, GLboolean have_back_buffer )
@@ -182,7 +191,6 @@ mgaFillInModes( unsigned pixel_bits, unsigned depth_bits,
 
     return modes;
 }
-#endif /* USE_NEW_INTERFACE */
 
 
 static GLboolean
@@ -190,8 +198,15 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
 {
    mgaScreenPrivate *mgaScreen;
    MGADRIPtr         serverInfo = (MGADRIPtr)sPriv->pDevPriv;
+   PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+       (PFNGLXSCRENABLEEXTENSIONPROC) glXGetProcAddress( (const GLubyte *) "__glXScrEnableExtension" );
+   void * const psc = sPriv->psc->screenConfigs;
 
 
+   if ( glx_enable_extension == NULL ) {
+      return GL_FALSE;
+   }
+
    /* Allocate the private area */
    mgaScreen = (mgaScreenPrivate *)MALLOC(sizeof(mgaScreenPrivate));
    if (!mgaScreen) {
@@ -220,24 +235,11 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
       }
    }
 
-   if ( driCompareGLXAPIVersion( 20030813 ) >= 0 ) {
-      PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
-          (PFNGLXSCRENABLEEXTENSIONPROC) glXGetProcAddress( (const GLubyte *) "__glXScrEnableExtension" );
-      void * const psc = sPriv->psc->screenConfigs;
-
-      if ( glx_enable_extension != NULL ) {
-        (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
-        (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
-        (*glx_enable_extension)( psc, "GLX_SGI_make_current_read" );
-        (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
-        (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
-
-        if ( driCompareGLXAPIVersion( 20030915 ) >= 0 ) {
-           (*glx_enable_extension)( psc, "GLX_SGIX_fbconfig" );
-           (*glx_enable_extension)( psc, "GLX_OML_swap_method" );
-        }
-      }
-   }
+   (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
+   (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
+   (*glx_enable_extension)( psc, "GLX_SGI_make_current_read" );
+   (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
+   (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
 
    if (serverInfo->chipset != MGA_CARD_TYPE_G200 &&
        serverInfo->chipset != MGA_CARD_TYPE_G400) {
@@ -380,39 +382,47 @@ static const struct tnl_pipeline_stage *mga_pipeline[] = {
 };
 
 
-static const char * const g400_extensions[] =
+static const struct dri_extension g400_extensions[] =
 {
-   "GL_ARB_multitexture",
-   "GL_ARB_texture_env_add",
-   "GL_ARB_texture_env_combine",
-   "GL_ARB_texture_env_crossbar",
-   "GL_EXT_texture_env_combine",
-   "GL_EXT_texture_edge_clamp",
-   "GL_ATI_texture_env_combine3",
-#if defined (MESA_packed_depth_stencil)
-   "GL_MESA_packed_depth_stencil",
-#endif
-   NULL
+   { "GL_ARB_multitexture",           NULL },
+   { "GL_ARB_texture_env_add",        NULL },
+   { "GL_ARB_texture_env_combine",    NULL },
+   { "GL_ARB_texture_env_crossbar",   NULL },
+   { "GL_EXT_texture_env_combine",    NULL },
+   { "GL_EXT_texture_edge_clamp",     NULL },
+   { "GL_ATI_texture_env_combine3",   NULL },
+   { NULL,                            NULL }
 };
 
-static const char * const card_extensions[] =
+static const struct dri_extension card_extensions[] =
 {
-   "GL_ARB_multisample",
-   "GL_ARB_texture_compression",
-   "GL_ARB_texture_rectangle",
-   "GL_EXT_blend_logic_op",
-   "GL_EXT_fog_coord",
-   "GL_EXT_multi_draw_arrays",
+   { "GL_ARB_multisample",            GL_ARB_multisample_functions },
+   { "GL_ARB_texture_compression",    GL_ARB_texture_compression_functions },
+   { "GL_ARB_texture_rectangle",      NULL },
+   { "GL_EXT_blend_logic_op",         NULL },
+   { "GL_EXT_fog_coord",              GL_EXT_fog_coord_functions },
+   { "GL_EXT_multi_draw_arrays",      GL_EXT_multi_draw_arrays_functions },
    /* paletted_textures currently doesn't work, but we could fix them later */
-#if 0
-   "GL_EXT_shared_texture_palette",
-   "GL_EXT_paletted_texture",
+#if defined( need_GL_EXT_paletted_texture )
+   { "GL_EXT_shared_texture_palette", NULL },
+   { "GL_EXT_paletted_texture",       GL_EXT_paletted_texture_functions },
 #endif
-   "GL_EXT_secondary_color",
-   "GL_EXT_stencil_wrap",
-   "GL_MESA_ycbcr_texture",
-   "GL_SGIS_generate_mipmap",
-   NULL
+   { "GL_EXT_secondary_color",        GL_EXT_secondary_color_functions },
+   { "GL_EXT_stencil_wrap",           NULL },
+   { "GL_MESA_ycbcr_texture",         NULL },
+   { "GL_SGIS_generate_mipmap",       NULL },
+   { NULL,                            NULL }
+};
+
+static const struct dri_extension ARB_vp_extension[] = {
+   { "GL_ARB_vertex_program",         GL_ARB_vertex_program_functions },
+   { NULL,                            NULL }
+};
+
+static const struct dri_extension NV_vp_extensions[] = {
+   { "GL_NV_vertex_program",          GL_NV_vertex_program_functions },
+   { "GL_NV_vertex_program1_1",       NULL },
+   { NULL,                            NULL }
 };
 
 static const struct dri_debug_control debug_control[] =
@@ -617,12 +627,11 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
    }
 
    if ( driQueryOptionb( &mmesa->optionCache, "arb_vertex_program" ) ) {
-      _mesa_enable_extension( ctx, "GL_ARB_vertex_program" );
+      driInitSingleExtension( ctx, ARB_vp_extension );
    }
    
    if ( driQueryOptionb( &mmesa->optionCache, "nv_vertex_program" ) ) {
-      _mesa_enable_extension( ctx, "GL_NV_vertex_program" );
-      _mesa_enable_extension( ctx, "GL_NV_vertex_program1_1" );
+      driInitExtensions( ctx, NV_vp_extensions, GL_FALSE );
    }
 
        
@@ -929,22 +938,6 @@ static const struct __DriverAPIRec mgaAPI = {
 };
 
 
-/*
- * This is the bootstrap function for the driver.
- * The __driCreateScreen name is the symbol that libGL.so fetches.
- * Return:  pointer to a __DRIscreenPrivate.
- */
-#if !defined(DRI_NEW_INTERFACE_ONLY)
-void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
-                        int numConfigs, __GLXvisualConfig *config)
-{
-   __DRIscreenPrivate *psp;
-   psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &mgaAPI);
-   return (void *) psp;
-}
-#endif /* !defined(DRI_NEW_INTERFACE_ONLY) */
-
-
 /**
  * This is the bootstrap function for the driver.  libGL supplies all of the
  * requisite information about the system, and the driver initializes itself.
@@ -955,9 +948,8 @@ void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
  * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
  *         failure.
  */
-#ifdef USE_NEW_INTERFACE
 PUBLIC
-void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
+void * __driCreateNewScreen_20050722( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
                             const __GLcontextModes * modes,
                             const __DRIversion * ddx_version,
                             const __DRIversion * dri_version,
@@ -998,7 +990,6 @@ void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc
 
    return (void *) psp;
 }
-#endif /* USE_NEW_INTERFACE */
 
 
 /**