forked from BabylonJS/BabylonNative
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.cpp
More file actions
59 lines (49 loc) · 1.95 KB
/
App.cpp
File metadata and controls
59 lines (49 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// gtest.h included here and in Shared/Tests.h because of a preprocessor conflict
#include <gtest/gtest.h>
#define XK_MISCELLANY
#define XK_LATIN1
#include <X11/Xlib.h> // will include X11 which #defines None... Don't mess with order of includes.
#include <X11/Xutil.h>
#undef None
#include "../Shared/Tests.h"
#include <Babylon/DebugTrace.h>
namespace
{
constexpr const char* applicationName = "Babylon Native Unit Tests";
constexpr const int width = 640;
constexpr const int height = 480;
constexpr const char* wmDeleteWindowName = "WM_DELETE_WINDOW";
}
int main()
{
XInitThreads();
Display* display = XOpenDisplay(NULL);
int32_t screen = DefaultScreen(display);
int32_t depth = DefaultDepth(display, screen);
Visual* visual = DefaultVisual(display, screen);
Window root = RootWindow(display, screen);
XSetWindowAttributes windowAttrs;
windowAttrs.background_pixel = 0;
windowAttrs.background_pixmap = 0;
windowAttrs.border_pixel = 0;
windowAttrs.event_mask = 0;
Window window = XCreateWindow(display, root, 0, 0, width, height, 0, depth, InputOutput, visual, CWBorderPixel | CWEventMask, &windowAttrs);
// Clear window to black.
XSetWindowAttributes attr;
memset(&attr, 0, sizeof(attr));
XChangeWindowAttributes(display, window, CWBackPixel, &attr);
Atom wmDeleteWindow;
XInternAtoms(display, (char**)&wmDeleteWindowName, 1, False, &wmDeleteWindow);
XSetWMProtocols(display, window, &wmDeleteWindow, 1);
XMapWindow(display, window);
XStoreName(display, window, applicationName);
Babylon::Graphics::Configuration config{};
config.Window = window;
config.Width = static_cast<size_t>(width);
config.Height = static_cast<size_t>(height);
Babylon::DebugTrace::EnableDebugTrace(true);
Babylon::DebugTrace::SetTraceOutput([](const char* trace) { printf("%s\n", trace); fflush(stdout); });
int ret = RunTests(config);
XCloseDisplay(display);
return ret;
}