I'm trying to make sense how OpenGL works on X Window System.
Compiling example program I got error at glXChooseVisual() call.
This error persists on different Unix clones and hardware configurations.
glxinfo program prints the following table where required mode is present.
visual x bf lv rg d st colorbuffer ax dp st accumbuffer ms cav
id dep cl sp sz l ci b ro r g b a bf th cl r g b a ns b eat
----------------------------------------------------------------------
0x22 24 tc 0 24 0 r y . 8 8 8 0 0 16 0 0 0 0 0 0 0 None
0x23 24 tc 0 24 0 r y . 8 8 8 0 0 16 8 16 16 16 0 0 0 None
0x24 24 tc 0 32 0 r y . 8 8 8 8 0 16 8 16 16 16 16 0 0 None
0x25 24 tc 0 32 0 r . . 8 8 8 8 0 16 8 16 16 16 16 0 0 None
Can you explain what's wrong with following code:
/*
* Example of an X Window System OpenGL program.
* OpenGL code is taken from auxdemo.c in the Win32 SDK
*/
#include <GL/glx.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdio.h>
/* X globals, defines, and prototypes */
Display *dpy;
Window glwin;
static int attributes[] = {GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None};
....
int
main(int argc, char **argv)
{
XVisualInfo *vi;
Colormap cmap;
XSetWindowAttributes swa;
GLXContext cx;
XEvent event;
GLboolean needRedraw = GL_FALSE, recalcModelView = GL_TRUE;
int dummy;
dpy = XOpenDisplay(NULL);
if (dpy == NULL){
fprintf(stderr, "could not open display\n");
return 1;
}
if(!glXQueryExtension(dpy, &dummy, &dummy)){
fprintf(stderr, "could not open display");
return 1;
}
/* find an OpenGL-capable Color Index visual with depth buffer */
vi = glXChooseVisual(dpy, DefaultScreen(dpy), attributes);
if (vi == NULL) {
fprintf(stderr, "could not get visual\n");
return 1;
}
.......
}
Compiling example program I got error at glXChooseVisual() call.
This error persists on different Unix clones and hardware configurations.
glxinfo program prints the following table where required mode is present.
visual x bf lv rg d st colorbuffer ax dp st accumbuffer ms cav
id dep cl sp sz l ci b ro r g b a bf th cl r g b a ns b eat
----------------------------------------------------------------------
0x22 24 tc 0 24 0 r y . 8 8 8 0 0 16 0 0 0 0 0 0 0 None
0x23 24 tc 0 24 0 r y . 8 8 8 0 0 16 8 16 16 16 0 0 0 None
0x24 24 tc 0 32 0 r y . 8 8 8 8 0 16 8 16 16 16 16 0 0 None
0x25 24 tc 0 32 0 r . . 8 8 8 8 0 16 8 16 16 16 16 0 0 None
Can you explain what's wrong with following code:
/*
* Example of an X Window System OpenGL program.
* OpenGL code is taken from auxdemo.c in the Win32 SDK
*/
#include <GL/glx.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdio.h>
/* X globals, defines, and prototypes */
Display *dpy;
Window glwin;
static int attributes[] = {GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None};
....
int
main(int argc, char **argv)
{
XVisualInfo *vi;
Colormap cmap;
XSetWindowAttributes swa;
GLXContext cx;
XEvent event;
GLboolean needRedraw = GL_FALSE, recalcModelView = GL_TRUE;
int dummy;
dpy = XOpenDisplay(NULL);
if (dpy == NULL){
fprintf(stderr, "could not open display\n");
return 1;
}
if(!glXQueryExtension(dpy, &dummy, &dummy)){
fprintf(stderr, "could not open display");
return 1;
}
/* find an OpenGL-capable Color Index visual with depth buffer */
vi = glXChooseVisual(dpy, DefaultScreen(dpy), attributes);
if (vi == NULL) {
fprintf(stderr, "could not get visual\n");
return 1;
}
.......
}