diff options
author | Sven Gothel <sgothel@jausoft.com> | 2010-12-13 02:26:48 +0100 |
---|---|---|
committer | Sven Gothel <sgothel@jausoft.com> | 2010-12-13 02:26:48 +0100 |
commit | 84a76425dd10933a7ad033920a1e0ce12a2a107b (patch) | |
tree | 3f4b1c3d61edb539232bf6bbcf1e673cc011b1d4 /src/test/native/glExtensionsListGL2.c | |
parent | 519776330c78e296d9868e959ddc64d00acac496 (diff) |
Cleanup test/junit structure. com.jogamp.test -> com.jogamp.opengl.text; Compile posted Issue* Bug* snippets
Diffstat (limited to 'src/test/native/glExtensionsListGL2.c')
-rw-r--r-- | src/test/native/glExtensionsListGL2.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/test/native/glExtensionsListGL2.c b/src/test/native/glExtensionsListGL2.c new file mode 100644 index 000000000..89815e9c0 --- /dev/null +++ b/src/test/native/glExtensionsListGL2.c @@ -0,0 +1,95 @@ +/** + * compile with: gcc -o displayMultiple02 displayMultiple02.c -lX11 -lGL + */ + +#include <stdio.h> +#include <X11/X.h> +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <GL/glx.h> +#include <GL/gl.h> + +static void testExtensions(); + +int main(int nargs, char **vargs) { + testExtensions(); + return 0; +} + +static void createGLWin(Display *dpy, int width, int height, Window *rWin, GLXContext *rCtx); +static void useGL(Display *dpy, Window win, GLXContext ctx, int width, int height); + +void testExtensions() { + int major, minor; + Display *disp1; + Window win1; + GLXContext ctx1; + + disp1 = XOpenDisplay(NULL); + createGLWin(disp1, 200, 200, &win1, &ctx1); + if(0 != win1 && 0 != ctx1) { + useGL(disp1, win1, ctx1, 200, 200); + + glXMakeCurrent(disp1, 0, 0); + glXDestroyContext(disp1, ctx1); + } + XCloseDisplay(disp1); +} + +/* attributes for a double buffered visual in RGBA format with at least + * 4 bits per color and a 16 bit depth buffer */ +static int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER, + GLX_RED_SIZE, 4, + GLX_GREEN_SIZE, 4, + GLX_BLUE_SIZE, 4, + GLX_DEPTH_SIZE, 16, + None }; + +void createGLWin(Display *dpy, int width, int height, Window *rWin, GLXContext *rCtx) +{ + int screen = DefaultScreen(dpy); + XVisualInfo *vi = glXChooseVisual(dpy, screen, attrListDbl); + Colormap cmap; + XSetWindowAttributes attr; + + /* create a GLX context */ + *rCtx = glXCreateContext(dpy, vi, 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) +{ + PFNGLGETSTRINGIPROC glGetStringi = 0; + int i, n; + + glXMakeCurrent(dpy, win, ctx); + + fprintf(stderr, "GL_VENDOR: %s\n", glGetString(GL_VENDOR)); + + glGetIntegerv(GL_NUM_EXTENSIONS, &n); + fprintf(stderr, "GL_NUM_EXTENSIONS: %d\n", n); + + glGetStringi = (PFNGLGETSTRINGIPROC)glXGetProcAddressARB("glGetStringi"); + if(NULL==glGetStringi) { + return; + } + + for (i=0; i<n; i++) { + const char* extension = (const char*)glGetStringi(GL_EXTENSIONS, i); + fprintf(stderr, "GL_EXTENSION %d/%d: %s\n", (i+1), n, extension); + } + +} + |