test/testnativex11.c
author David Ludwig <dludwig@pobox.com>
Wed, 25 Dec 2013 21:39:48 -0500
changeset 8563 c0e68f3b6bbb
parent 7517 965d57022c01
child 8149 681eb46b8ac4
permissions -rw-r--r--
WinRT: compiled the d3d11 renderer's shaders into SDL itself

Previously, the shaders would get compiled separately, the output of which would need to be packaged into the app. This change should make SDL's dll be the only binary needed to include SDL in a WinRT app.
slouken@5535
     1
/*
slouken@7517
     2
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
slouken@5535
     3
slouken@5535
     4
  This software is provided 'as-is', without any express or implied
slouken@5535
     5
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     6
  arising from the use of this software.
slouken@5535
     7
slouken@5535
     8
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
     9
  including commercial applications, and to alter it and redistribute it
slouken@5535
    10
  freely.
slouken@5535
    11
*/
slouken@3057
    12
slouken@3057
    13
#include "testnative.h"
slouken@3057
    14
slouken@3057
    15
#ifdef TEST_NATIVE_X11
slouken@3057
    16
slouken@3057
    17
static void *CreateWindowX11(int w, int h);
slouken@3057
    18
static void DestroyWindowX11(void *window);
slouken@3057
    19
slouken@3057
    20
NativeWindowFactory X11WindowFactory = {
slouken@3057
    21
    "x11",
slouken@3057
    22
    CreateWindowX11,
slouken@3057
    23
    DestroyWindowX11
slouken@3057
    24
};
slouken@3057
    25
slouken@3057
    26
static Display *dpy;
slouken@3057
    27
slouken@3057
    28
static void *
slouken@3057
    29
CreateWindowX11(int w, int h)
slouken@3057
    30
{
slouken@3057
    31
    Window window = 0;
slouken@3057
    32
slouken@3057
    33
    dpy = XOpenDisplay(NULL);
slouken@3057
    34
    if (dpy) {
slouken@3057
    35
        window =
slouken@3057
    36
            XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, w, h, 0, 0,
slouken@3057
    37
                                0);
slouken@3057
    38
        XMapRaised(dpy, window);
slouken@3057
    39
        XSync(dpy, False);
slouken@3057
    40
    }
slouken@3057
    41
    return (void *) window;
slouken@3057
    42
}
slouken@3057
    43
slouken@3057
    44
static void
slouken@3057
    45
DestroyWindowX11(void *window)
slouken@3057
    46
{
slouken@3057
    47
    if (dpy) {
slouken@3057
    48
        XDestroyWindow(dpy, (Window) window);
slouken@3057
    49
        XCloseDisplay(dpy);
slouken@3057
    50
    }
slouken@3057
    51
}
slouken@3057
    52
slouken@3057
    53
#endif