Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/test/browser/html5_special_event_targets.cpp
4150 views
1
// Copyright 2016 The Emscripten Authors. All rights reserved.
2
// Emscripten is available under two separate licenses, the MIT license and the
3
// University of Illinois/NCSA Open Source License. Both these licenses can be
4
// found in the LICENSE file.
5
6
#include <GLES2/gl2.h>
7
#include <GLES2/gl2ext.h>
8
#include <assert.h>
9
10
#include <emscripten/emscripten.h>
11
#include <emscripten/html5.h>
12
13
int main()
14
{
15
EM_ASM({
16
specialHTMLTargets["!foovas"] = Module.canvas;
17
});
18
EmscriptenWebGLContextAttributes attrs;
19
emscripten_webgl_init_context_attributes(&attrs);
20
// Test that creating a context with #canvas target when -sDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0
21
// will create a canvas against Module.canvas
22
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context("!foovas", &attrs);
23
assert(context > 0); // Must have received a valid context.
24
EMSCRIPTEN_RESULT res = emscripten_webgl_make_context_current(context);
25
assert(res == EMSCRIPTEN_RESULT_SUCCESS);
26
assert(emscripten_webgl_get_current_context() == context);
27
return 0;
28
}
29
30