Exemple #1
0
	void EmRenderWindow::initContext()
	{
		printf("Setting Emscripten Canvas size\n");
		emscripten_set_canvas_size(m_width, m_height);

		EmscriptenWebGLContextAttributes attrs;
		emscripten_webgl_init_context_attributes(&attrs);
		attrs.depth = 1;
		attrs.stencil = 1;
		attrs.antialias = 1;
		attrs.majorVersion = 2;
		attrs.minorVersion = 0;

		assert(emscripten_webgl_get_current_context() == 0);

		printf("Creating Emscripten WebGL context\n");
		m_window = emscripten_webgl_create_context("canvas", &attrs);
		printf("Created Emscripten WebGL context %i\n", m_window);

		emscripten_webgl_make_context_current(m_window);

#if defined TOY_PLATFORM_LINUX || defined TOY_PLATFORM_BSD
		m_nativeHandle = (void*)(uintptr_t)glfwGetX11Window(_window);
#elif defined TOY_PLATFORM_OSX
		m_nativeHandle = glfwGetCocoaWindow(_window);
#elif defined TOY_PLATFORM_WINDOWS
		m_nativeHandle = glfwGetWin32Window(m_glWindow);
#endif
	}
int main()
{
  EmscriptenWebGLContextAttributes attrs;
  emscripten_webgl_init_context_attributes(&attrs);
  EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(0, &attrs);
  assert(context > 0); // Must have received a valid context.
  EMSCRIPTEN_RESULT res = emscripten_webgl_make_context_current(context);
  assert(res == EMSCRIPTEN_RESULT_SUCCESS);
  assert(emscripten_webgl_get_current_context() == context);
#ifdef REPORT_RESULT
  REPORT_RESULT(0);
#endif
}