annotate R/rdyncall/demo/gles.R @ 33:ba47a3d709d7

- pydc: added support to get libhandle's path
author Tassilo Philipp
date Sat, 11 Apr 2020 20:00:25 +0200
parents 0cfcc391201f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 library(rdyncall)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2 dynport(SDL)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3 dynport(EGL)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 dynbind("X11", "XOpenDisplay(Z)p;")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 init <- function() {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 SDL_Init(SDL_INIT_VIDEO)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8 srf <- SDL_SetVideoMode(640,480,32,SDL_SWSURFACE)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
9 dpy <- XOpenDisplay(NULL)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 egl <- eglGetDisplay(dpy)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11 if (is.nullptr(egl)) {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 error("failed: eglGetDisplay")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 status <- eglInitialize(egl,NULL,NULL)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15 if (!status) {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 error("failed: eglInitialize")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 numConfigOuts <- integer(1)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19 g_configAttribs <- as.integer(c(
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 EGL_RED_SIZE, 5,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 EGL_GREEN_SIZE, 6,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 EGL_BLUE_SIZE, 5,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23 EGL_DEPTH_SIZE, 16,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
25 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
26 EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
27 EGL_NONE
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
28 ))
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
29
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
30 g_eglConfig <- raw(4)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
31
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
32 s <- eglChooseConfig(egl, g_configAttribs, g_eglConfig, 1, numConfigOuts)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
33 if (s != EGL_TRUE || numConfigOuts == 0) {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
34 error("failed: eglChooseConfig")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
35 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
36
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
37
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
38 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
39
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
40 init()
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
41
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
42
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
43