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

Function main

test/browser/html5_webgl.c:31–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31int main() {
32 EmscriptenWebGLContextAttributes attrs;
33 emscripten_webgl_init_context_attributes(&attrs);
34 attrs.majorVersion = 2;
35 attrs.proxyContextToMainThread = EMSCRIPTEN_WEBGL_CONTEXT_PROXY_FALLBACK;
36 attrs.renderViaOffscreenBackBuffer = true;
37 attrs.desynchronized = true;
38 EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context("#canvas", &attrs);
39 emscripten_webgl_make_context_current(context);
40
41 // #8406: desynchronized should round-trip on browsers that support it.
42 // Skipped for OffscreenCanvas, which doesn't honor it.
43 if (EXPECT_DESYNCHRONIZED >= 0) {
44 EmscriptenWebGLContextAttributes actualAttrs;
45 emscripten_webgl_get_context_attributes(context, &actualAttrs);
46 assert(actualAttrs.desynchronized == EXPECT_DESYNCHRONIZED);
47 }
48
49 // Test emscripten_webgl_get_supported_extensions() API
50 char *extensions = emscripten_webgl_get_supported_extensions();
51 assert(extensions);
52 assert(strlen(extensions) > 0);
53 assert(strstr(extensions, "WEBGL") != 0);
54 free(extensions);
55
56 // Test emscripten_webgl_get_parameter_d() API
57 assert(emscripten_webgl_get_parameter_d(GL_BLUE_BITS) == 8);
58
59 // Test emscripten_webgl_get_parameter_o() API
60 GLuint buf;
61 glGenBuffers(1, &buf);
62 assert(buf != 0);
63 glBindBuffer(GL_ARRAY_BUFFER, buf);
64 assert(emscripten_webgl_get_parameter_o(GL_ARRAY_BUFFER_BINDING) == buf);
65
66 // Test emscripten_webgl_get_parameter_utf8() API
67 char *version = emscripten_webgl_get_parameter_utf8(GL_VERSION);
68 assert(version);
69 assert(strstr(version, "WebGL") != 0);
70 free(version);
71
72 // Test emscripten_webgl_get_parameter_i64v API
73 int64_t components = 0;
74 emscripten_webgl_get_parameter_i64v(GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS, &components);
75 assert(components > 0);
76
77 // Test emscripten_webgl_get_parameter_v API with truncated read length
78 glViewport(1, 2, 3, 4);
79 int viewport[4] = { 0, 0, 0, 0 };
80 int numElements = emscripten_webgl_get_parameter_v(GL_VIEWPORT, viewport, 3, EMSCRIPTEN_WEBGL_PARAM_TYPE_INT);
81 assert(numElements == 4);
82 assert(viewport[0] == 1);
83 assert(viewport[1] == 2);
84 assert(viewport[2] == 3);
85 assert(viewport[3] == 0);
86
87 // Test emscripten_webgl_get_parameter_v API with full read length
88 numElements = emscripten_webgl_get_parameter_v(GL_VIEWPORT, viewport, 4, EMSCRIPTEN_WEBGL_PARAM_TYPE_INT);

Callers

nothing calls this directly

Calls 10

strlenFunction · 0.85
glBufferDataFunction · 0.85
compile_shaderFunction · 0.70
create_programFunction · 0.70
assertFunction · 0.50
strstrFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected