示例#1
0
		int32_t run(int _argc, char** _argv)
		{
			emscripten_set_mousedown_callback("#canvas", this, true, mouseCb);
			emscripten_set_mouseup_callback("#canvas", this, true, mouseCb);
			emscripten_set_mousemove_callback("#canvas", this, true, mouseCb);

			emscripten_set_wheel_callback("#canvas", this, true, wheelCb);

			emscripten_set_keypress_callback(NULL, this, true, keyCb);
			emscripten_set_keydown_callback(NULL, this, true, keyCb);
			emscripten_set_keyup_callback(NULL, this, true, keyCb);

			emscripten_set_resize_callback(0, this, true, resizeCb);

			EmscriptenFullscreenStrategy fullscreenStrategy = {};
			fullscreenStrategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_DEFAULT;
			fullscreenStrategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_NONE;
			fullscreenStrategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT;
			fullscreenStrategy.canvasResizedCallback = canvasResizeCb;
			fullscreenStrategy.canvasResizedCallbackUserData = this;

			emscripten_request_fullscreen_strategy("#canvas", false, &fullscreenStrategy);

			emscripten_set_focus_callback(NULL, this, true, focusCb);
			emscripten_set_focusin_callback(NULL, this, true, focusCb);
			emscripten_set_focusout_callback(NULL, this, true, focusCb);

			int32_t result = main(_argc, _argv);
			return result;
		}
void CoreWindow::MainLoop(void)
{
    emscripten_set_keyup_callback("#window", NULL, 0, keyUpEvent);
    emscripten_set_keydown_callback("#window", NULL, 0, keyDownEvent);
    emscripten_set_mousedown_callback("#window", NULL, 0, mouseEvent);
    emscripten_set_mouseup_callback("#window", NULL, 0, mouseEvent);
    emscripten_set_mousemove_callback("#window", NULL, 0, mouseEvent);
    
    emscripten_set_resize_callback("#window", NULL, 0, resizeEvent);

    emscripten_set_main_loop (idleloop, 0, 1);
}
示例#3
0
	EmInputWindow::EmInputWindow(EmRenderWindow& renderWindow)
		: InputWindow()
		, m_renderWindow(renderWindow)
	{
		emscripten_set_mousemove_callback(0, this, true, [](int eventType, const EmscriptenMouseEvent* mouseEvent, void* window) { return EM_BOOL(static_cast<EmInputWindow*>(window)->injectMouseMove(*mouseEvent)); });

		emscripten_set_mousedown_callback(0, this, true, [](int eventType, const EmscriptenMouseEvent* mouseEvent, void* window) { return EM_BOOL(static_cast<EmInputWindow*>(window)->injectMouseDown(*mouseEvent)); });
		emscripten_set_mouseup_callback(0, this, true, [](int eventType, const EmscriptenMouseEvent* mouseEvent, void* window) { return EM_BOOL(static_cast<EmInputWindow*>(window)->injectMouseUp(*mouseEvent)); });

		emscripten_set_wheel_callback(0, this, true, [](int eventType, const EmscriptenWheelEvent* wheelEvent, void* window) { return EM_BOOL(static_cast<EmInputWindow*>(window)->injectWheel(*wheelEvent)); });

		emscripten_set_keydown_callback(0, this, true, [](int eventType, const EmscriptenKeyboardEvent* keyEvent, void* window) { return EM_BOOL(static_cast<EmInputWindow*>(window)->injectKeyDown(*keyEvent)); });
		emscripten_set_keyup_callback(0, this, true, [](int eventType, const EmscriptenKeyboardEvent* keyEvent, void* window) { return EM_BOOL(static_cast<EmInputWindow*>(window)->injectKeyUp(*keyEvent)); });
		emscripten_set_keypress_callback(0, this, true, [](int eventType, const EmscriptenKeyboardEvent* keyEvent, void* window) { return EM_BOOL(static_cast<EmInputWindow*>(window)->injectKeyPress(*keyEvent)); });

		//glfwSetScrollCallback(m_glWindow, [](GLFWwindow* w, double x, double y) { static_cast<GlInputWindow*>(glfwGetWindowUserPointer(w))->injectWheel(x, y); });

		//glfwMakeContextCurrent(m_glWindow);
		//glfwSetInputMode(m_glWindow, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
	}
示例#4
0
void application::init_context()
{
  auto attrs = EmscriptenWebGLContextAttributes{};
  attrs.stencil = EM_TRUE;
  attrs.enableExtensionsByDefault = EM_FALSE;

  emscripten_webgl_init_context_attributes(&attrs);

  const auto ctx = emscripten_webgl_create_context(canvas_target, &attrs);

  emscripten_webgl_make_context_current(ctx);

  glctx = ctx;

  emscripten_webgl_enable_extension(glctx, "ANGLE_instanced_arrays");

  emscripten_set_mousedown_callback(
   canvas_target, this, false, &enable_drag_handler);
  emscripten_set_touchstart_callback(
   canvas_target, this, false, &enable_drag_handler);

  emscripten_set_mouseup_callback(
   canvas_target, this, false, &disable_drag_handler);
  emscripten_set_mouseleave_callback(
   canvas_target, this, false, &disable_drag_handler);
  emscripten_set_mouseout_callback(
   canvas_target, this, false, &disable_drag_handler);
  emscripten_set_touchend_callback(
   canvas_target, this, false, &disable_drag_handler);
  emscripten_set_touchcancel_callback(
   canvas_target, this, false, &disable_drag_handler);

  emscripten_set_mousemove_callback(
   canvas_target, this, false, &mouse_move_handler);
  emscripten_set_touchmove_callback(
   canvas_target, this, false, &mouse_move_handler);
};
示例#5
0
FHTML5InputInterface::FHTML5InputInterface( const TSharedRef< FGenericApplicationMessageHandler >& InMessageHandler, const TSharedPtr< ICursor >& InCursor )
	: MessageHandler( InMessageHandler )
	, Cursor( InCursor )
{
	emscripten_set_mousemove_callback("canvas", (void*)&Cursor, 1, mouse_move_callback);
}
void ofxAppEmscriptenWindow::setup(const ofGLESWindowSettings & settings){
	EGLint numConfigs;
	EGLint majorVersion;
	EGLint minorVersion;
	EGLConfig config;
	EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
	EGLint attribList[] =
	   {
		   EGL_RED_SIZE, EGL_DONT_CARE,
		   EGL_GREEN_SIZE, EGL_DONT_CARE,
		   EGL_BLUE_SIZE, EGL_DONT_CARE,
		   EGL_ALPHA_SIZE, EGL_DONT_CARE,
		   EGL_DEPTH_SIZE, EGL_DONT_CARE,
		   EGL_STENCIL_SIZE, EGL_DONT_CARE,
		   EGL_SAMPLE_BUFFERS, EGL_DONT_CARE,
		   EGL_NONE
	   };

	// Get Display
	display = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY);
	if ( display == EGL_NO_DISPLAY ){
		ofLogError() << "coudln't get display";
		return;
	}

	// Initialize EGL
	if ( !eglInitialize(display, &majorVersion, &minorVersion) ){
		ofLogError() << "couldn't initialize display";
		return;
	}

	// Get configs
	if ( !eglGetConfigs(display, NULL, 0, &numConfigs) ){
		ofLogError() << "couldn't get configs";
		return;
	}
	
	ofLogNotice("ofxAppEmscriptenWindow") << "Got " << numConfigs << " display configs";

	// Choose config
	if ( !eglChooseConfig(display, attribList, &config, 1, &numConfigs) ){
		ofLogError() << "couldn't choose display";
		return;
	}

	// Create a surface
	surface = eglCreateWindowSurface(display, config, NULL, NULL);
	if ( surface == EGL_NO_SURFACE ){
		ofLogError() << "couldn't create surface";
		return;
	}

	// Create a GL context
	context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs );
	if ( context == EGL_NO_CONTEXT ){
		ofLogError() << "couldn't create context";
	    return;
	}

	// Make the context current
	if ( !eglMakeCurrent(display, surface, surface, context) ){
		ofLogError() << "couldn't make current display";
		return;
	}

	setWindowShape(settings.width,settings.height);

	_renderer = make_shared<ofGLProgrammableRenderer>(this);
	((ofGLProgrammableRenderer*)_renderer.get())->setup(2,0);

    emscripten_set_keydown_callback(0,this,1,&keydown_cb);
    emscripten_set_keyup_callback(0,this,1,&keyup_cb);
    emscripten_set_mousedown_callback(0,this,1,&mousedown_cb);
    emscripten_set_mouseup_callback(0,this,1,&mouseup_cb);
    emscripten_set_mousemove_callback(0,this,1,&mousemoved_cb);
    
    emscripten_set_touchstart_callback(0,this,1,&touch_cb);
    emscripten_set_touchend_callback(0,this,1,&touch_cb);
    emscripten_set_touchmove_callback(0,this,1,&touch_cb);
    emscripten_set_touchcancel_callback(0,this,1,&touch_cb);
}