0
|
1 library(rdyncall)
|
|
2 dynport(SDL)
|
|
3 dynport(EGL)
|
|
4 dynbind("X11", "XOpenDisplay(Z)p;")
|
|
5
|
|
6 init <- function() {
|
|
7 SDL_Init(SDL_INIT_VIDEO)
|
|
8 srf <- SDL_SetVideoMode(640,480,32,SDL_SWSURFACE)
|
|
9 dpy <- XOpenDisplay(NULL)
|
|
10 egl <- eglGetDisplay(dpy)
|
|
11 if (is.nullptr(egl)) {
|
|
12 error("failed: eglGetDisplay")
|
|
13 }
|
|
14 status <- eglInitialize(egl,NULL,NULL)
|
|
15 if (!status) {
|
|
16 error("failed: eglInitialize")
|
|
17 }
|
|
18 numConfigOuts <- integer(1)
|
|
19 g_configAttribs <- as.integer(c(
|
|
20 EGL_RED_SIZE, 5,
|
|
21 EGL_GREEN_SIZE, 6,
|
|
22 EGL_BLUE_SIZE, 5,
|
|
23 EGL_DEPTH_SIZE, 16,
|
|
24 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
|
25 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
|
|
26 EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE,
|
|
27 EGL_NONE
|
|
28 ))
|
|
29
|
|
30 g_eglConfig <- raw(4)
|
|
31
|
|
32 s <- eglChooseConfig(egl, g_configAttribs, g_eglConfig, 1, numConfigOuts)
|
|
33 if (s != EGL_TRUE || numConfigOuts == 0) {
|
|
34 error("failed: eglChooseConfig")
|
|
35 }
|
|
36
|
|
37
|
|
38 }
|
|
39
|
|
40 init()
|
|
41
|
|
42
|
|
43
|