MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / create_context

Function create_context

test/browser/glgetattachedshaders.c:18–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18static void create_context(void) {
19 EGLint num_config;
20 EGLContext g_egl_ctx;
21 EGLDisplay g_egl_dpy;
22 EGLConfig g_config;
23
24 static const EGLint attribute_list[] = {
25 EGL_RED_SIZE, 8,
26 EGL_GREEN_SIZE, 8,
27 EGL_BLUE_SIZE, 8,
28 EGL_ALPHA_SIZE, 8,
29 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
30 EGL_NONE
31 };
32
33 static const EGLint context_attributes[] = {
34 EGL_CONTEXT_CLIENT_VERSION, 2,
35 EGL_NONE
36 };
37
38 g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
39 if (!g_egl_dpy)
40 die("failed to create display");
41
42 if (!eglInitialize(g_egl_dpy, NULL, NULL))
43 die("failed to initialize egl");
44
45 if (!eglChooseConfig(g_egl_dpy, attribute_list, &g_config, 1, &num_config))
46 die("failed to choose config");
47
48 g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, EGL_NO_CONTEXT, context_attributes);
49 if (!g_egl_ctx)
50 die("failed to create context");
51
52 EGLNativeWindowType dummyWindow;
53 EGLSurface surface = eglCreateWindowSurface(g_egl_dpy, g_config, dummyWindow, NULL);
54 if (!surface)
55 die("failed to create window surface");
56
57 if (!eglMakeCurrent(g_egl_dpy, surface, surface, g_egl_ctx))
58 die("failed to activate context");
59}
60
61int main(int argc, char *argv[]) {
62 unsigned i;

Callers 1

mainFunction · 0.85

Calls 1

dieFunction · 0.85

Tested by

no test coverage detected