Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

glxinfo.c 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* $Id: glxinfo.c,v 1.1 1999/09/16 16:40:46 brianp Exp $ */
  2. /*
  3. * Query GLX extensions, version, vendor, etc.
  4. * This program is in the public domain.
  5. * brian_paul@mesa3d.org
  6. */
  7. #include <GL/gl.h>
  8. #include <GL/glx.h>
  9. #include <GL/glu.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. static void
  13. query_glx( Display *dpy, int scr )
  14. {
  15. printf("GL_VERSION: %s\n", (char *) glGetString(GL_VERSION));
  16. printf("GL_EXTENSIONS: %s\n", (char *) glGetString(GL_EXTENSIONS));
  17. printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER));
  18. printf("GL_VENDOR: %s\n", (char *) glGetString(GL_VENDOR));
  19. printf("GLU_VERSION: %s\n", (char *) gluGetString(GLU_VERSION));
  20. printf("GLU_EXTENSIONS: %s\n", (char *) gluGetString(GLU_EXTENSIONS));
  21. printf("server GLX_VENDOR: %s\n", (char *) glXQueryServerString( dpy, scr, GLX_VENDOR));
  22. printf("server GLX_VERSION: %s\n", (char *) glXQueryServerString( dpy, scr, GLX_VERSION));
  23. printf("server GLX_EXTENSIONS: %s\n", (char *) glXQueryServerString( dpy, scr, GLX_EXTENSIONS));
  24. printf("client GLX_VENDOR: %s\n", (char *) glXGetClientString( dpy, GLX_VENDOR));
  25. printf("client GLX_VERSION: %s\n", (char *) glXGetClientString( dpy, GLX_VERSION));
  26. printf("client GLX_EXTENSIONS: %s\n", (char *) glXGetClientString( dpy, GLX_EXTENSIONS));
  27. printf("GLX extensions: %s\n", (char *) glXQueryExtensionsString(dpy, scr));
  28. }
  29. int
  30. main( int argc, char *argv[] )
  31. {
  32. Display *dpy;
  33. Window win;
  34. int attrib[] = { GLX_RGBA,
  35. GLX_RED_SIZE, 1,
  36. GLX_GREEN_SIZE, 1,
  37. GLX_BLUE_SIZE, 1,
  38. None };
  39. int scrnum;
  40. XSetWindowAttributes attr;
  41. unsigned long mask;
  42. Window root;
  43. GLXContext ctx;
  44. XVisualInfo *visinfo;
  45. int width = 100, height = 100;
  46. dpy = XOpenDisplay(NULL);
  47. if (!dpy) {
  48. fprintf(stderr, "Unable to open default display!\n");
  49. return 1;
  50. }
  51. scrnum = DefaultScreen( dpy );
  52. root = RootWindow( dpy, scrnum );
  53. visinfo = glXChooseVisual( dpy, scrnum, attrib );
  54. if (!visinfo) {
  55. fprintf(stderr, "Error: couldn't find RGB GLX visual!\n");
  56. return 1;
  57. }
  58. /* window attributes */
  59. attr.background_pixel = 0;
  60. attr.border_pixel = 0;
  61. attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
  62. attr.event_mask = StructureNotifyMask | ExposureMask;
  63. mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
  64. win = XCreateWindow( dpy, root, 0, 0, width, height,
  65. 0, visinfo->depth, InputOutput,
  66. visinfo->visual, mask, &attr );
  67. ctx = glXCreateContext( dpy, visinfo, NULL, True );
  68. glXMakeCurrent( dpy, win, ctx );
  69. query_glx(dpy, scrnum);
  70. glXDestroyContext(dpy, ctx);
  71. XDestroyWindow(dpy, win);
  72. XCloseDisplay(dpy);
  73. return 0;
  74. }