test/testnativex11.c
author Sam Lantinga <slouken@libsdl.org>
Thu, 07 Dec 2017 16:08:09 -0800
changeset 11730 ac6c607e065c
parent 10737 3406a0f8b041
child 11811 5d94cb6b24d3
permissions -rw-r--r--
Enable building the Metal renderer by default, and weak link the Metal framework so the SDL library is safe to use on older Macs
Also generate iOS versions of the Metal shaders
slouken@5535
     1
/*
slouken@10737
     2
  Copyright (C) 1997-2017 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