Re: [D3D8 - 0] the number begin: new x11drv/GLX stuff [resend]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Saturday 11 January 2003 00:42, Raphaël Junqueira wrote:
> Hi,
>
>  This stuff is needed by the future D3D8 patches so it's numbered 0 ;)
> This have been developed with ddraw people and maybe they'll need it ;)
>
> Changelog:
>   - add a call to x11drv::ExtEscape to get openGL infos (extensions and
> caps) (only filled once at first call) - define in x11drv:
>         - X11DRV_OPENGL_INFO struct
>         - typedefs, if not defined by glext.h, for the extensions functions
>         - X11DRV_OPENGL_SUPPORTED_EXT enum for d3d* needs extensions
>
>

argh. a brown paper bag please

now second try with the diff

>  Raphael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+H2AIp7NA3AmQTU4RAm/FAJ9Duf9r1WM4KbjUpQNdNXo86tj3KACeKXSB
YG4agV/lPoWOl8dcSh/HvAI=
=4EHM
-----END PGP SIGNATURE-----
Index: include/x11drv.h
===================================================================
RCS file: /home/wine/wine/include/x11drv.h,v
retrieving revision 1.118
diff -u -r1.118 x11drv.h
--- include/x11drv.h	15 Nov 2002 04:16:38 -0000	1.118
+++ include/x11drv.h	10 Jan 2003 23:32:30 -0000
@@ -99,6 +99,142 @@
     XRENDERINFO   xrender;
 } X11DRV_PDEVICE;
 
+/**
+ * OpenGL/GLX Extensions
+ */
+#ifdef HAVE_OPENGL
+#ifndef GL_ARB_vertex_blend
+#define GL_ARB_vertex_blend 1
+void glWeightfvARB(int size, float* weights);
+void glWeightPointerARB(int size, unsigned int type, int stride, void* pointer);
+void glVertexBlendARB(int count);
+#endif
+/* TODO GL_ARB_fog_coord => GL 1.4 */
+/* TODO GL_ARB_vertex_program => GL 1.4 */
+/* TODO GL_EXT_fog_coord */
+/* GL_EXT_secondary_color */
+#ifndef GL_EXT_secondary_color
+#define GL_EXT_secondary_color 1
+typedef void (*PFNGLSECONDARYCOLOR3UBEXTPROC)(unsigned char red, unsigned char green, unsigned char blue);
+typedef void (*PFNGLSECONDARYCOLOR3FEXTPROC)(float red, float green, float blue);
+typedef void (*PFNGLSECONDARYCOLOR3FVEXTPROC)(float* v);
+typedef void (*PFNGLSECONDARYCOLORPOINTEREXTPROC)(int, unsigned int, int, void*);
+#endif
+/* GL_EXT_paletted_texture */
+#ifndef GL_EXT_paletted_texture
+#define GL_EXT_paletted_texture 1
+typedef void (*PFNGLCOLORTABLEEXTPROC)(unsigned int target, unsigned int internalFormat, int width, unsigned int format, unsigned int type, const void *table);
+#endif
+/* GL_EXT_vertex_shader */
+#ifndef GL_EXT_vertex_shader
+#define GL_EXT_vertex_shader 1
+typedef void (*PFNGLBINDVERTEXSHADEREXTPROC)(unsigned int id);
+typedef void (*PFNGLDELETEVERTEXSHADEREXTPROC)(unsigned int id);
+typedef unsigned int (*PFNGLGENVERTEXSHADERSEXTPROC)(unsigned int range);
+typedef void (*PFNGLBEGINVERTEXSHADEREXTPROC)(void);
+typedef void (*PFNGLENDVERTEXSHADEREXTPROC)(void);
+#endif
+/* GL_EXT_vertex_weighting */
+#ifndef GL_EXT_vertex_weighting
+#define GL_EXT_vertex_weighting 1
+typedef void (*PFNGLVERTEXWEIGHTFEXTPROC)(float weight);
+typedef void (*PFNGLVERTEXWEIGHTFVEXTPROC)(const float* weight);
+typedef void (*PFNGLVERTEXWEIGHTPOINTEREXTPROC) (int size, unsigned int type, int stride, const void* pointer);
+#endif
+/* GL_NV_vertex_program */
+#ifndef GL_NV_vertex_program
+#define GL_NV_vertex_program 1
+typedef void (*PFNGLBINDPROGRAMNVPROC)(unsigned int target, unsigned int id);
+typedef void (*PFNGLDELETEPROGRAMSNVPROC)(int n, const unsigned int *programs);
+typedef void (*PFNGLGENPROGRAMSNVPROC)(int n, unsigned int *programs);
+typedef void (*PFNGLLOADPROGRAMNVPROC)(unsigned int target, unsigned int id, int len, const unsigned char *program);
+typedef void (*PFNGLPROGRAMPARAMETER4DNVPROC)(unsigned int target, unsigned int index, double x, double y, double z, double w);
+typedef void (*PFNGLPROGRAMPARAMETER4DVNVPROC)(unsigned int target, unsigned int index, const double *v);
+typedef void (*PFNGLPROGRAMPARAMETER4FNVPROC)(unsigned int target, unsigned int index, float x, float y, float z, float w);
+typedef void (*PFNGLPROGRAMPARAMETER4FVNVPROC)(unsigned int target, unsigned int index, const float *v);
+typedef void (*PFNGLPROGRAMPARAMETERS4DVNVPROC)(unsigned int target, unsigned int index, unsigned int count, const double *v);
+typedef void (*PFNGLPROGRAMPARAMETERS4FVNVPROC)(unsigned int target, unsigned int index, unsigned int count, const float *v);
+typedef void (*PFNGLVERTEXATTRIBPOINTERNVPROC)(unsigned int index, int fsize, unsigned int type, int stride, const void *pointer);
+#endif
+
+
+#define GL_EXT_FUNCS_GEN \
+    /** EXT Extensions **/ \
+    /* GL_EXT_fog_coord */ \
+    /* GL_EXT_paletted_texture */ \
+    USE_GL_FUNC(PFNGLCOLORTABLEEXTPROC,            glColorTableEXT); \
+    /* GL_EXT_secondary_color */ \
+    USE_GL_FUNC(PFNGLSECONDARYCOLOR3UBEXTPROC,     glSecondaryColor3ubEXT); \
+    USE_GL_FUNC(PFNGLSECONDARYCOLOR3FEXTPROC,      glSecondaryColor3fEXT); \
+    USE_GL_FUNC(PFNGLSECONDARYCOLOR3FVEXTPROC,     glSecondaryColor3fvEXT); \
+    USE_GL_FUNC(PFNGLSECONDARYCOLORPOINTEREXTPROC, glSecondaryColorPointerEXT); \
+    /* GL_EXT_vertex_weighting */ \
+    USE_GL_FUNC(PFNGLVERTEXWEIGHTFEXTPROC,         glVertexWeightfEXT); \
+    USE_GL_FUNC(PFNGLVERTEXWEIGHTFVEXTPROC,        glVertexWeightfvEXT); \
+    USE_GL_FUNC(PFNGLVERTEXWEIGHTPOINTEREXTPROC,   glVertexWeightPointerEXT); \
+    /** NVIDIA Extensions **/ \
+    /* GL_NV_vertex_program */ \
+    USE_GL_FUNC(PFNGLBINDPROGRAMNVPROC,            glBindProgramNV); \
+    /** ATI Extensions **/ \
+    /* GL_EXT_vertex_shader */ \
+    USE_GL_FUNC(PFNGLBINDVERTEXSHADEREXTPROC,      glBindVertexShaderEXT); \
+    USE_GL_FUNC(PFNGLDELETEVERTEXSHADEREXTPROC,    glDeleteVertexShaderEXT); \
+    USE_GL_FUNC(PFNGLGENVERTEXSHADERSEXTPROC,      glGenVertexShadersEXT); \
+    USE_GL_FUNC(PFNGLBEGINVERTEXSHADEREXTPROC,     glBeginVertexShaderEXT); \
+    USE_GL_FUNC(PFNGLENDVERTEXSHADEREXTPROC,       glEndVertexShaderEXT); \
+
+
+typedef enum _X11DRV_OPENGL_VS_VERSION {
+    VS_VERSION_NOT_SUPPORTED = 0x0,
+    VS_VERSION_10 = 0x10,
+    VS_VERSION_11 = 0x11,
+    VS_VERSION_20 = 0x20,
+    VS_VERSION_30 = 0x30,
+    /*Force 32-bits*/
+    VS_VERSION_FORCE_DWORD = 0x7FFFFFFF
+} X11DRV_OPENGL_VS_VERSION;
+
+typedef enum _X11DRV_OPENGL_SUPPORTED_EXT {
+  /* ARB */
+  ARB_MULTITEXTURE,
+  ARB_POINT_PARAMETERS,
+  ARB_TEXTURE_COMPRESSION,
+  ARB_TEXTURE_CUBE_MAP,
+  ARB_TEXTURE_ENV_DOT3,
+  ARB_VERTEX_PROGRAM,
+  ARB_VERTEX_BLEND,
+  /* EXT */
+  EXT_FOG_COORD,
+  EXT_PALETTED_TEXTURE,
+  EXT_SECONDARY_COLOR,
+  EXT_VERTEX_WEIGHTING,
+  /* NVIDIA */
+  NV_VERTEX_PROGRAM,
+  /* ATI */
+  EXT_VERTEX_SHADER,
+
+  OPENGL_SUPPORTED_EXT_END
+} X11DRV_OPENGL_SUPPORTED_EXT;
+
+#define USE_GL_FUNC(type, pfn) type pfn;
+typedef struct _X11DRV_OPENGL_INFO {
+    /** 
+     * CAPS Constants 
+     */
+    int   max_lights;
+    int   max_textures;
+    X11DRV_OPENGL_VS_VERSION vs_arb_version;
+    X11DRV_OPENGL_VS_VERSION vs_nv_version;
+    X11DRV_OPENGL_VS_VERSION vs_ati_version;
+
+    /**
+     *  OpenGL EXT Functions 
+     */
+    GL_EXT_FUNCS_GEN;
+    BOOL supported[25];
+} X11DRV_OPENGL_INFO;
+#undef USE_GL_FUNC
+#endif /* defined(HAVE_OPENGL) */
 
   /* GCs used for B&W and color bitmap operations */
 extern GC BITMAP_monoGC, BITMAP_colorGC;
@@ -227,6 +363,7 @@
 extern void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE *physDev);
 
 extern void X11DRV_OpenGL_Init(Display *display);
+extern BOOL X11DRV_OpenGL_GetInfo(X11DRV_PDEVICE *physDev, X11DRV_OPENGL_INFO *info);
 extern XVisualInfo *X11DRV_setup_opengl_visual(Display *display);
 
 /* exported dib functions for now */
@@ -320,9 +457,10 @@
 #define X11DRV_ESCAPE 6789
 enum x11drv_escape_codes
 {
-    X11DRV_GET_DISPLAY,   /* get X11 display for a DC */
-    X11DRV_GET_DRAWABLE,  /* get current drawable for a DC */
-    X11DRV_GET_FONT,      /* get current X font for a DC */
+    X11DRV_GET_DISPLAY,     /* get X11 display for a DC */
+    X11DRV_GET_DRAWABLE,    /* get current drawable for a DC */
+    X11DRV_GET_FONT,        /* get current X font for a DC */
+    X11DRV_GET_OPENGL_INFO  /* get OpenGL info */
 };
 
 /**************************************************************************
Index: graphics/x11drv/init.c
===================================================================
RCS file: /home/wine/wine/graphics/x11drv/init.c,v
retrieving revision 1.55
diff -u -r1.55 init.c
--- graphics/x11drv/init.c	10 Dec 2002 22:56:45 -0000	1.55
+++ graphics/x11drv/init.c	10 Jan 2003 23:33:04 -0000
@@ -294,6 +294,12 @@
                     *(Font *)out_data = pfo->fs->fid;
                     return TRUE;
                 }
+	    case X11DRV_GET_OPENGL_INFO:
+	        if (out_count >= sizeof(X11DRV_OPENGL_INFO))
+                {
+                    X11DRV_OpenGL_GetInfo(physDev, (X11DRV_OPENGL_INFO*)out_data);
+                    return TRUE;
+                }
             }
         }
         break;
Index: graphics/x11drv/opengl.c
===================================================================
RCS file: /home/wine/wine/graphics/x11drv/opengl.c,v
retrieving revision 1.15
diff -u -r1.15 opengl.c
--- graphics/x11drv/opengl.c	27 Nov 2002 20:21:24 -0000	1.15
+++ graphics/x11drv/opengl.c	10 Jan 2003 23:33:10 -0000
@@ -113,15 +113,167 @@
 #define SONAME_LIBGL "libGL.so"
 #endif
 
-static void *opengl_handle;
+static void* opengl_handle;
+static BOOL opengl_info_valid = FALSE;
+static X11DRV_OPENGL_INFO opengl_info;
+
 
 #define MAKE_FUNCPTR(f) static typeof(f) * p##f;
 MAKE_FUNCPTR(glXChooseVisual)
 MAKE_FUNCPTR(glXGetConfig)
 MAKE_FUNCPTR(glXSwapBuffers)
 MAKE_FUNCPTR(glXQueryExtension)
+MAKE_FUNCPTR(glXQueryExtensionsString)
+MAKE_FUNCPTR(glXCreateContext)
+MAKE_FUNCPTR(glXDestroyContext)
+MAKE_FUNCPTR(glXMakeCurrent)
+MAKE_FUNCPTR(glXGetProcAddressARB)
+MAKE_FUNCPTR(glGetIntegerv)
+MAKE_FUNCPTR(glGetString)
 #undef MAKE_FUNCPTR
 
+static VOID X11DRV_OpenGL_GetInfoInit(VOID) {
+    const char* GL_Extensions = NULL;
+    XVisualInfo* vis = NULL;
+    GLXContext gl_context;
+
+    opengl_info_valid = FALSE;
+
+    TRACE("Init OpenGL Info struct\n");
+
+    vis = X11DRV_setup_opengl_visual(gdi_display);
+    wine_tsx11_lock();
+    gl_context = pglXCreateContext(gdi_display, vis, NULL, GL_TRUE);
+    if (!gl_context) {
+        ERR("Error in creating contex\n");
+       goto _exit;
+    }
+    if (pglXMakeCurrent(gdi_display, root_window, gl_context) == False) {
+       ERR("Error in setting current context (context %p drawable %ld)!\n", gl_context, root_window);
+       goto _exit;
+    }
+
+    /**
+     * Get some basic OpenGL caps
+     */
+    pglGetIntegerv(GL_MAX_LIGHTS, &opengl_info.max_lights);
+    
+    /** 
+     * Handle OpenGL extensions
+     */    
+    /** Default values */
+    memset(&opengl_info.supported, 0, sizeof(opengl_info.supported));
+    opengl_info.max_textures = 1;
+    opengl_info.vs_arb_version  = VS_VERSION_NOT_SUPPORTED;
+    opengl_info.vs_nv_version   = VS_VERSION_NOT_SUPPORTED;
+
+#define USE_GL_FUNC(type, pfn) opengl_info.pfn = NULL;
+    GL_EXT_FUNCS_GEN;
+#undef USE_GL_FUNC
+
+    GL_Extensions = pglGetString(GL_EXTENSIONS);
+    if (NULL == GL_Extensions) {
+      ERR("GL_EXTENSIONS returns NULL\n");
+    } else {
+      TRACE("GL_EXTENSIONS reported:\n"); 
+      while (*GL_Extensions != 0x00) {
+        const char* Start = GL_Extensions;
+        char ThisExtn[256];
+
+        memset(ThisExtn, 0x00, sizeof(ThisExtn));
+        while (*GL_Extensions != ' ' && *GL_Extensions != 0x00) {
+	  ++GL_Extensions;
+        }
+        memcpy(ThisExtn, Start, (GL_Extensions - Start));
+        TRACE ("- %s\n", ThisExtn);
+
+#define USE_GL_FUNC(type, pfn) opengl_info.pfn = (type) pglXGetProcAddressARB(#pfn);
+
+	/**
+	 * ARB 
+	 */
+        if (strcmp(ThisExtn, "GL_ARB_multitexture") == 0) {
+	  /* handle multi texturing extensions */
+	  pglGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &opengl_info.max_textures);
+	  TRACE(" FOUND: ARB Multitexture support - GL_MAX_TEXTURE_UNITS_ARB=%u\n", opengl_info.max_textures);
+	  opengl_info.supported[ARB_MULTITEXTURE] = TRUE;
+        } else if (strcmp(ThisExtn, "GL_ARB_texture_compression") == 0) {
+	  FIXME(" FOUND: ARB Texture Compression support\n");
+	  opengl_info.supported[ARB_TEXTURE_COMPRESSION] = TRUE;
+        } else if (strcmp(ThisExtn, "GL_ARB_texture_cube_map") == 0) {
+	  FIXME(" FOUND: ARB Texture Cube Map support\n");
+	  opengl_info.supported[ARB_TEXTURE_CUBE_MAP] = TRUE;
+	} else if (strcmp(ThisExtn, "GL_ARB_vertex_program") == 0) {
+	  opengl_info.vs_arb_version = VS_VERSION_11;
+	  FIXME(" FOUND: ARB Vertex Shader support - version=%02x\n", opengl_info.vs_arb_version);
+	  opengl_info.supported[ARB_VERTEX_PROGRAM] = TRUE;
+	} else if (strcmp(ThisExtn, "GL_ARB_vertex_blend") == 0) {
+	  FIXME(" FOUND: ARB Vertex Blend Support\n");
+	  opengl_info.supported[ARB_VERTEX_BLEND] = TRUE;
+
+	/**
+	 * EXT
+	 */
+        } else if (strcmp(ThisExtn, "GL_EXT_fog_coord") == 0) {
+	  FIXME(" FOUND: EXT Fog coord\n");
+	  opengl_info.supported[EXT_FOG_COORD] = TRUE;
+        } else if (strcmp(ThisExtn, "GL_EXT_paletted_texture") == 0) {
+	  /* handle paletted texture extensions */
+	  USE_GL_FUNC(PFNGLCOLORTABLEEXTPROC,            glColorTableEXT);
+	  TRACE(" FOUND: EXT Paletted texture support\n");
+	  opengl_info.supported[EXT_PALETTED_TEXTURE] = TRUE;
+	} else if (strcmp(ThisExtn, "GL_EXT_secondary_color") == 0) {
+	  USE_GL_FUNC(PFNGLSECONDARYCOLOR3UBEXTPROC,     glSecondaryColor3ubEXT); 
+	  USE_GL_FUNC(PFNGLSECONDARYCOLOR3FEXTPROC,      glSecondaryColor3fEXT); 
+	  USE_GL_FUNC(PFNGLSECONDARYCOLOR3FVEXTPROC,     glSecondaryColor3fvEXT); 
+	  USE_GL_FUNC(PFNGLSECONDARYCOLORPOINTEREXTPROC, glSecondaryColorPointerEXT); 
+	  FIXME(" FOUND: EXT Secondary coord\n");
+	  opengl_info.supported[EXT_SECONDARY_COLOR] = TRUE;
+	} else if (strcmp(ThisExtn, "GL_EXT_vertex_weighting") == 0) {
+	  USE_GL_FUNC(PFNGLVERTEXWEIGHTFEXTPROC,         glVertexWeightfEXT);
+	  USE_GL_FUNC(PFNGLVERTEXWEIGHTFVEXTPROC,        glVertexWeightfvEXT);
+	  USE_GL_FUNC(PFNGLVERTEXWEIGHTPOINTEREXTPROC,   glVertexWeightPointerEXT); 
+	  FIXME(" FOUND: EXT Vertex weighting\n");
+	  opengl_info.supported[EXT_VERTEX_WEIGHTING] = TRUE;
+
+	/**
+	 * NVIDIA 
+	 */
+	} else if (strstr(ThisExtn, "GL_NV_vertex_program")) {
+	  opengl_info.vs_nv_version = max(opengl_info.vs_nv_version, (0 == strcmp(ThisExtn, "GL_NV_vertex_program1_1")) ? VS_VERSION_11 : VS_VERSION_10);
+	  opengl_info.vs_nv_version = max(opengl_info.vs_nv_version, (0 == strcmp(ThisExtn, "GL_NV_vertex_program2"))   ? VS_VERSION_20 : VS_VERSION_10);
+	  if (NULL == opengl_info.glBindProgramNV) { USE_GL_FUNC(PFNGLBINDPROGRAMNVPROC, glBindProgramNV); }
+	  TRACE(" FOUND: NVIDIA Vertex Shader support - version=%02x\n", opengl_info.vs_nv_version);
+	  opengl_info.supported[NV_VERTEX_PROGRAM] = TRUE;
+
+	/**
+	 * ATI
+	 */
+	/** TODO */
+	} else if (strcmp(ThisExtn, "GL_EXT_vertex_shader") == 0) {
+	  opengl_info.vs_ati_version = VS_VERSION_11;
+	  USE_GL_FUNC(PFNGLBINDVERTEXSHADEREXTPROC,      glBindVertexShaderEXT); 
+	  USE_GL_FUNC(PFNGLDELETEVERTEXSHADEREXTPROC,    glDeleteVertexShaderEXT); 
+	  USE_GL_FUNC(PFNGLGENVERTEXSHADERSEXTPROC,      glGenVertexShadersEXT); 
+	  USE_GL_FUNC(PFNGLBEGINVERTEXSHADEREXTPROC,     glBeginVertexShaderEXT); 
+	  USE_GL_FUNC(PFNGLENDVERTEXSHADEREXTPROC,       glEndVertexShaderEXT); 
+	  TRACE(" FOUND: AIT (EXT) Vertex Shader support - version=%02x\n", opengl_info.vs_ati_version);
+	  opengl_info.supported[EXT_VERTEX_SHADER] = TRUE;
+	}
+
+#undef USE_GL_FUNC
+
+        if (*GL_Extensions == ' ') ++GL_Extensions;
+      }
+    }
+
+    opengl_info_valid = TRUE;
+    pglXDestroyContext(gdi_display, gl_context);
+
+_exit:
+    wine_tsx11_unlock();
+}
+
 void X11DRV_OpenGL_Init(Display *display) {
     int error_base, event_base;
 
@@ -133,6 +285,13 @@
 LOAD_FUNCPTR(glXGetConfig)
 LOAD_FUNCPTR(glXSwapBuffers)
 LOAD_FUNCPTR(glXQueryExtension)
+LOAD_FUNCPTR(glXQueryExtensionsString)
+LOAD_FUNCPTR(glXCreateContext)
+LOAD_FUNCPTR(glXDestroyContext)
+LOAD_FUNCPTR(glXMakeCurrent)
+LOAD_FUNCPTR(glXGetProcAddressARB)
+LOAD_FUNCPTR(glGetIntegerv)
+LOAD_FUNCPTR(glGetString)
 #undef LOAD_FUNCPTR
 
     wine_tsx11_lock();
@@ -150,6 +309,20 @@
     opengl_handle = NULL;
 }
 
+BOOL X11DRV_OpenGL_GetInfo(X11DRV_PDEVICE* physDev, X11DRV_OPENGL_INFO* info) {
+  static int _isInit = 0;
+  if (0 == _isInit) {
+    /** Init opengl caps struct */
+    X11DRV_OpenGL_GetInfoInit();
+    _isInit = 1;
+  } 
+  if (TRUE == opengl_info_valid) {
+    memcpy(info, &opengl_info, sizeof(X11DRV_OPENGL_INFO));
+  }
+  return  opengl_info_valid;
+}
+
+
 /* X11DRV_ChoosePixelFormat
 
      Equivalent of glXChooseVisual
@@ -433,6 +606,11 @@
 
 void X11DRV_OpenGL_Init(Display *display)
 {
+}
+
+BOOL X11DRV_OpenGL_GetInfo(X11DRV_PDEVICE *physDev, X11DRV_OPENGL_INFO* info) {
+  ERR("No OpenGL support compiled in.\n");
+  return FALSE;
 }
 
 /***********************************************************************

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux