diff options
author | Sam Lantinga <slouken@libsdl.org> | 2009-02-09 05:32:12 +0000 |
---|---|---|
committer | Sam Lantinga <slouken@libsdl.org> | 2009-02-09 05:32:12 +0000 |
commit | 2aab251e3855170cfe6fa40ddabdb1c561f5b7ab (patch) | |
tree | 3fe8922a35fd5ad51fb77e9d136feed0a5cdfebd /test/testnativex11.c | |
parent | 0f598a332fd7a258e1d9945e87c373e90ff6fcf9 (diff) |
Added test program for SDL_CreateWindowFrom()
Make sure OpenGL library is loaded before working with OpenGL windows,
even those created with SDL_CreateWindowFrom()
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403521
Diffstat (limited to 'test/testnativex11.c')
-rw-r--r-- | test/testnativex11.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/testnativex11.c b/test/testnativex11.c new file mode 100644 index 00000000..0f84aa97 --- /dev/null +++ b/test/testnativex11.c @@ -0,0 +1,42 @@ + +#include "testnative.h" + +#ifdef TEST_NATIVE_X11 + +static void *CreateWindowX11(int w, int h); +static void DestroyWindowX11(void *window); + +NativeWindowFactory X11WindowFactory = { + "x11", + CreateWindowX11, + DestroyWindowX11 +}; + +static Display *dpy; + +static void * +CreateWindowX11(int w, int h) +{ + Window window = 0; + + dpy = XOpenDisplay(NULL); + if (dpy) { + window = + XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, w, h, 0, 0, + 0); + XMapRaised(dpy, window); + XSync(dpy, False); + } + return (void *) window; +} + +static void +DestroyWindowX11(void *window) +{ + if (dpy) { + XDestroyWindow(dpy, (Window) window); + XCloseDisplay(dpy); + } +} + +#endif |