test/testnativex11.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 09 Feb 2009 05:32:12 +0000
changeset 3057 089a77aebb7d
child 5535 96594ac5fd1a
permissions -rw-r--r--
Added test program for SDL_CreateWindowFrom()
Make sure OpenGL library is loaded before working with OpenGL windows,
even those created with SDL_CreateWindowFrom()
slouken@3057
     1
slouken@3057
     2
#include "testnative.h"
slouken@3057
     3
slouken@3057
     4
#ifdef TEST_NATIVE_X11
slouken@3057
     5
slouken@3057
     6
static void *CreateWindowX11(int w, int h);
slouken@3057
     7
static void DestroyWindowX11(void *window);
slouken@3057
     8
slouken@3057
     9
NativeWindowFactory X11WindowFactory = {
slouken@3057
    10
    "x11",
slouken@3057
    11
    CreateWindowX11,
slouken@3057
    12
    DestroyWindowX11
slouken@3057
    13
};
slouken@3057
    14
slouken@3057
    15
static Display *dpy;
slouken@3057
    16
slouken@3057
    17
static void *
slouken@3057
    18
CreateWindowX11(int w, int h)
slouken@3057
    19
{
slouken@3057
    20
    Window window = 0;
slouken@3057
    21
slouken@3057
    22
    dpy = XOpenDisplay(NULL);
slouken@3057
    23
    if (dpy) {
slouken@3057
    24
        window =
slouken@3057
    25
            XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, w, h, 0, 0,
slouken@3057
    26
                                0);
slouken@3057
    27
        XMapRaised(dpy, window);
slouken@3057
    28
        XSync(dpy, False);
slouken@3057
    29
    }
slouken@3057
    30
    return (void *) window;
slouken@3057
    31
}
slouken@3057
    32
slouken@3057
    33
static void
slouken@3057
    34
DestroyWindowX11(void *window)
slouken@3057
    35
{
slouken@3057
    36
    if (dpy) {
slouken@3057
    37
        XDestroyWindow(dpy, (Window) window);
slouken@3057
    38
        XCloseDisplay(dpy);
slouken@3057
    39
    }
slouken@3057
    40
}
slouken@3057
    41
slouken@3057
    42
#endif