Beispiel #1
0
// Init wx-widgets thread 
bool WxeApp::OnInit()
{
  /* Create a dummy window so wxWidgets don't automagicly quits the main loop 
     after the last window */
  global_me = new wxeMemEnv();
  wxe_batch = new wxList;
  wxe_batch_cb_saved = new wxList;

  create_dummy_window();
  wxe_ps_init();

  wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED);

  this->Connect(wxID_ANY, wxEVT_IDLE, 
		(wxObjectEventFunction) (wxEventFunction) &WxeApp::idle);
  this->Connect(CREATE_PORT, wxeEVT_META_COMMAND, 
		(wxObjectEventFunction) (wxEventFunction) &WxeApp::newMemEnv);
  this->Connect(DELETE_PORT, wxeEVT_META_COMMAND, 
		(wxObjectEventFunction) (wxEventFunction) &WxeApp::destroyMemEnv);
  this->Connect(WXE_SHUTDOWN, wxeEVT_META_COMMAND, 
		(wxObjectEventFunction) (wxEventFunction) &WxeApp::shutdown);

//   fprintf(stderr, "Size void* %d: long %d long long %d int64 %d \r\n",
// 	  sizeof(void *), sizeof(long), sizeof(long long), sizeof(wxInt64));
  initEventTable();
  wxInitAllImageHandlers();
  init_nonconsts(global_me, init_caller);
  erl_drv_mutex_lock(wxe_status_m);
  wxe_status = WXE_INITIATED;
  gl_initiated = FALSE;   
  erl_drv_cond_signal(wxe_status_c);
  erl_drv_mutex_unlock(wxe_status_m);
  return TRUE;
}
Beispiel #2
0
void Video::play_until_end( char *fileName, HINSTANCE hInstance, DWORD t)
{
	HANDLE  ahObjects[1];       // Handles that need to be waited on
	const int cObjects = 1;     // Number of objects that we have
	
	if(!init_success)
		return;

	hwnd = NULL;
#ifdef CREATE_DUMMY_WINDOW
	create_dummy_window(hInstance);
#endif

	play(fileName, t);

	while( state == PLAYING )
	{
		if( (ahObjects[ 0 ] = hGraphNotifyEvent) == NULL)
		{
			state = STOPPED;
			break;
		}
		DWORD Result = MsgWaitForMultipleObjects( cObjects, ahObjects,
			FALSE, INFINITE, QS_ALLINPUT);
		
		// Have we received an event notification
		if( Result >= WAIT_OBJECT_0 && Result < (WAIT_OBJECT_0 + cObjects) )
		{
			if( Result == WAIT_OBJECT_0 )
				on_graph_notify();
		}
		else if( Result == WAIT_OBJECT_0 + cObjects )
		{
			if( hwnd )
			{
				while (ProcessNextEvent() == 1) {};  // process everything we can
			}
		}
		else
		{
			// other event to wait ...
		}
	}

	if( hwnd )
	{
		DestroyWindow(hwnd);
	}
	hwnd = NULL;

	// after video end, go back to the game
	if( sys.init_flag )
	{
          ShowMainWindow();
	  FocusMainWindow();
	}
}
Beispiel #3
0
SkWGLExtensions::SkWGLExtensions()
    : fGetExtensionsString(nullptr)
    , fChoosePixelFormat(nullptr)
    , fGetPixelFormatAttribfv(nullptr)
    , fGetPixelFormatAttribiv(nullptr)
    , fCreateContextAttribs(nullptr)
    , fSwapInterval(nullptr)
    , fCreatePbuffer(nullptr)
    , fGetPbufferDC(nullptr)
    , fReleasePbufferDC(nullptr)
    , fDestroyPbuffer(nullptr)
 {
    HDC prevDC = wglGetCurrentDC();
    HGLRC prevGLRC = wglGetCurrentContext();

    PIXELFORMATDESCRIPTOR dummyPFD;

    ZeroMemory(&dummyPFD, sizeof(dummyPFD));
    dummyPFD.nSize = sizeof(dummyPFD);
    dummyPFD.nVersion = 1;
    dummyPFD.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
    dummyPFD.iPixelType = PFD_TYPE_RGBA;
    dummyPFD.cColorBits  = 32;
    dummyPFD.cDepthBits  = 0;
    dummyPFD.cStencilBits = 8;
    dummyPFD.iLayerType = PFD_MAIN_PLANE;
    HWND dummyWND = create_dummy_window();
    if (dummyWND) {
        HDC dummyDC = GetDC(dummyWND);
        int dummyFormat = ChoosePixelFormat(dummyDC, &dummyPFD);
        SetPixelFormat(dummyDC, dummyFormat, &dummyPFD);
        HGLRC dummyGLRC = wglCreateContext(dummyDC);
        SkASSERT(dummyGLRC);
        wglMakeCurrent(dummyDC, dummyGLRC);

        GET_PROC(GetExtensionsString, ARB);
        GET_PROC(ChoosePixelFormat, ARB);
        GET_PROC(GetPixelFormatAttribiv, ARB);
        GET_PROC(GetPixelFormatAttribfv, ARB);
        GET_PROC(CreateContextAttribs, ARB);
        GET_PROC(SwapInterval, EXT);
        GET_PROC(CreatePbuffer, ARB);
        GET_PROC(GetPbufferDC, ARB);
        GET_PROC(ReleasePbufferDC, ARB);
        GET_PROC(DestroyPbuffer, ARB);

        wglMakeCurrent(dummyDC, nullptr);
        wglDeleteContext(dummyGLRC);
        destroy_dummy_window(dummyWND);
    }

    wglMakeCurrent(prevDC, prevGLRC);
}
Beispiel #4
0
int
main (int argc, char *argv[])
{
 	GtkWidget *window;
	GError** error = NULL;
	GtkImage *imageKeypadBG;

#ifdef ENABLE_NLS
	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
#endif

	
	gtk_init (&argc, &argv);
	create_dummy_window();
	pixbufBGanm = gdk_pixbuf_animation_new_from_file(BG, error);

	window = create_window1 ();

	KeyPadBuilder = gtk_builder_new ();
	if (!gtk_builder_add_from_file (KeyPadBuilder, KEY_PAD_UI_FILE, error))
	{
		g_critical ("Couldn't load builder file: %s", (*error)->message);
		g_error_free (*error);
	}

	/* Auto-connect signal handlers */
	gtk_builder_connect_signals (MainBuilder, NULL);

	/* Get the window object from the ui file */
	KeyPadFrameWidget = GTK_WIDGET (gtk_builder_get_object (KeyPadBuilder, KEY_PAD_FRAME));
        if (!window)
        {
                g_critical ("Widget \"%s\" is missing in file %s.",
				KEY_PAD_FRAME,
				KEY_PAD_UI_FILE);
        }

	//gtk_widget_show (KeyPadFrameWidget);
	GdkPixbufAnimation * pixbufKeypadBGanm = gdk_pixbuf_animation_new_from_file(KEYPAD_BG, error);
	imageKeypadBG = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (KeyPadBuilder, "keypad_bg"));
	gtk_image_set_from_animation(GTK_IMAGE(imageKeypadBG), pixbufKeypadBGanm);
	
	gtk_widget_show (window);
	cur_active_screen = wev1_scrn;
	_start_ticker_timer();
	gtk_main();
	g_free (priv);
	return 0;
}
Beispiel #5
0
struct gl_platform *gl_platform_create(gs_device_t *device, uint32_t adapter)
{
	struct gl_platform *plat = bzalloc(sizeof(struct gl_platform));
	struct dummy_context dummy;
	struct gs_init_data info = {0};
	int pixel_format;
	PIXELFORMATDESCRIPTOR pfd;

	memset(&dummy, 0, sizeof(struct dummy_context));
	init_dummy_swap_info(&info);

	if (!gl_dummy_context_init(&dummy))
		goto fail;
	if (!gl_init_extensions(dummy.hdc))
		goto fail;
	if (!register_dummy_class())
		return false;
	if (!create_dummy_window(plat))
		return false;

	/* you have to have a dummy context open before you can actually
	 * use wglChoosePixelFormatARB */
	if (!gl_getpixelformat(dummy.hdc, &info, &pixel_format, &pfd))
		goto fail;

	gl_dummy_context_free(&dummy);

	if (!init_default_swap(plat, device, pixel_format, &pfd))
		goto fail;

	plat->hrc = gl_init_context(plat->window.hdc);
	if (!plat->hrc)
		goto fail;

	if (!gladLoadGL()) {
		blog(LOG_ERROR, "Failed to initialize OpenGL entry functions.");
		goto fail;
	}

	UNUSED_PARAMETER(adapter);
	return plat;

fail:
	blog(LOG_ERROR, "gl_platform_create failed");
	gl_platform_destroy(plat);
	gl_dummy_context_free(&dummy);
	return NULL;
}
Beispiel #6
0
// wxMac really wants a top level window which command-q quits if there are no
// windows open, and this will kill the thread, so restart the dummy_window each
// time a we receive a close.
void WxeApp::dummy_close(wxEvent& Ev) {
  // fprintf(stderr, "Tried to close dummy window\r\n"); fflush(stderr);
  create_dummy_window();
}
Beispiel #7
0
void Video::play_until_end( char *fileName, HINSTANCE hInstance, DWORD t)
{
	HANDLE  ahObjects[1];       // Handles that need to be waited on
	const int cObjects = 1;     // Number of objects that we have
	
	if(!init_success)
		return;

	hwnd = NULL;
#ifdef CREATE_DUMMY_WINDOW
	create_dummy_window(hInstance);
#endif

	play(fileName, t);

	while( state == PLAYING )
	{
		if( (ahObjects[ 0 ] = hGraphNotifyEvent) == NULL)
		{
			state = STOPPED;
			break;
		}
		DWORD Result = MsgWaitForMultipleObjects( cObjects, ahObjects,
			0, INFINITE, QS_ALLINPUT);
		
		// Have we received an event notification
		if( Result >= WAIT_OBJECT_0 && Result < (WAIT_OBJECT_0 + cObjects) )
		{
			if( Result == WAIT_OBJECT_0 )
				on_graph_notify();
		}
		else if( Result == WAIT_OBJECT_0 + cObjects )
		{
			if( hwnd )
			{
				// message in the message queue
				MSG msg;
				while( PeekMessage(&msg, hwnd, 0, ~0UL, PM_NOREMOVE) )
				{
					if( !GetMessage(&msg, hwnd, 0, ~0UL) )
						break;
					TranslateMessage(&msg);
					DispatchMessage(&msg);
				}
			}
		}
		else
		{
			// other event to wait ...
		}
	}

	if( hwnd )
	{
		PostMessage( hwnd, WM_CLOSE, 0, 0 );

		//handle outstanding message
		MSG msg;
		while( GetMessage(&msg, hwnd, 0, ~0UL) )
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
	hwnd = NULL;
}