From dc8d3bbbba7910b3e2453a0d7d37d2bf8a05f4b6 Mon Sep 17 00:00:00 2001 From: Martin Hegedus Date: Sun, 14 Apr 2013 23:32:26 +0200 Subject: Bug 705: This is the version of displayMultiple02 which uses glXCreateNewContext instead of glXCreateContext. Segmentation fault w/ Mesa 7.0 --- src/test-native/displayMultiple02_new_mch.c | 199 ++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 src/test-native/displayMultiple02_new_mch.c (limited to 'src/test-native/displayMultiple02_new_mch.c') diff --git a/src/test-native/displayMultiple02_new_mch.c b/src/test-native/displayMultiple02_new_mch.c new file mode 100644 index 000000000..f64d41472 --- /dev/null +++ b/src/test-native/displayMultiple02_new_mch.c @@ -0,0 +1,199 @@ +/** + * compile with: gcc -o displayMultiple02 displayMultiple02.c -lX11 -lGL + */ + +#include +#include +#include +#include +#include +#include + +static void testOrder(int reverseDestroyOrder, const char * msg); + +static int useXLockDisplay = 0; + +int main(int nargs, char **vargs) { + int arg=1; + while(argscreen), vi->visual, AllocNone); + attr.colormap = cmap; + attr.border_pixel = 0; + + /* create a window in window mode*/ + attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | + StructureNotifyMask; + *rWin = XCreateWindow(dpy, RootWindow(dpy, vi->screen), + 0, 0, width, height, 0, vi->depth, InputOutput, vi->visual, + CWBorderPixel | CWColormap | CWEventMask, &attr); + + XMapRaised(dpy, *rWin); +} + +void createGLWinNew(Display *dpy, int width, int height, Window *rWin, GLXContext *rCtx) +{ + int screen = DefaultScreen(dpy); + Colormap cmap; + XSetWindowAttributes attr; + + // create configs + int nelements; + GLXFBConfig *fbconfigs = glXChooseFBConfig(dpy,screen,attrListDblNew,&nelements ); + + // get visual + XVisualInfo *vi = glXGetVisualFromFBConfig(dpy,*fbconfigs); + + /* create a GLX context */ + *rCtx = glXCreateNewContext(dpy, *fbconfigs, GLX_RGBA_TYPE, 0, GL_TRUE); + + /* create a color map */ + cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone); + attr.colormap = cmap; + attr.border_pixel = 0; + + /* create a window in window mode*/ + attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | + StructureNotifyMask; + *rWin = XCreateWindow(dpy, RootWindow(dpy, vi->screen), + 0, 0, width, height, 0, vi->depth, InputOutput, vi->visual, + CWBorderPixel | CWColormap | CWEventMask, &attr); + + XMapRaised(dpy, *rWin); +} + +void useGL(Display *dpy, Window win, GLXContext ctx, int width, int height) +{ + glXMakeCurrent(dpy, win, ctx); + glShadeModel(GL_SMOOTH); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClearDepth(1.0f); + glViewport(0, 0, width, height); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glXSwapBuffers(dpy, win); + glXMakeCurrent(dpy, 0, 0); +} + -- cgit v1.2.3