Example #1
0
int main(int argc, char **argv)
{
#if defined(Q_WS_X11)
#if QT_VERSION >= 0x040800
    QApplication::setAttribute(Qt::AA_X11InitThreads, true);
#else
    XInitThreads();
    QApplication::setAttribute(static_cast<Qt::ApplicationAttribute>(10), true);
#endif
#endif
    {
        QApplication app(argc, argv);
        {
            bool isOpenGL = false;
            for (int index = 1; index < argc; ++index) {
                if (strcmp(argv[index], "-opengl") == 0) {
                    isOpenGL = true;
                    break;
                }
            }

            QTestRunner runn(isOpenGL, argc, argv);
            QTimer::singleShot(0, &runn, SLOT(DropInStartup()));
            // These components must be loaded before app start
            QString componentPath(DEFAULT_COMPONENTS_PATH);
            QMozContext::GetInstance()->addComponentManifest(componentPath + QString("/components") + QString("/EmbedLiteBinComponents.manifest"));
            QMozContext::GetInstance()->addComponentManifest(componentPath + QString("/chrome") + QString("/EmbedLiteJSScripts.manifest"));
            QMozContext::GetInstance()->addComponentManifest(componentPath + QString("/chrome") + QString("/EmbedLiteOverrides.manifest"));
            QMozContext::GetInstance()->addComponentManifest(componentPath + QString("/components") + QString("/EmbedLiteJSComponents.manifest"));
            QMozContext::GetInstance()->runEmbedding();
        }
        app.quit();
    }
    return 0;
}
Example #2
0
JNIEXPORT jboolean JNICALL 
Java_jogamp_nativewindow_x11_X11Util_initialize0(JNIEnv *env, jclass clazz, jboolean firstUIActionOnProcess, jboolean debug) {
    if(0==_initialized) {
        if(debug) {
            errorHandlerDebug = 1;
        }
        X11UtilClazz = (jclass)(*env)->NewGlobalRef(env, clazz);
        if( JNI_TRUE == firstUIActionOnProcess ) {
            if( 0 == XInitThreads() ) {
                fprintf(stderr, "Warning: XInitThreads() failed\n");
            } else {
                _xinitThreadsOK=JNI_TRUE;
                if(debug) {
                    fprintf(stderr, "X11: XInitThreads() called for concurrent Thread support\n");
                }
            }
        } else if(debug) {
            fprintf(stderr, "X11: XInitThreads() _not_ called for concurrent Thread support\n");
        }

        _initClazzAccess(env);
        x11IOErrorHandlerEnable(1, env);
        _initialized=1;
        if(JNI_TRUE == debug) {
            fprintf(stderr, "Info: NativeWindow native init passed\n");
        }
    }
    return _xinitThreadsOK;
}
Example #3
0
void
uiinit_xorg(struct ui *ui, int argc, char *argv[])
{
    struct uienv_xorg *env = ui->env;
    Display           *disp;
    char              *dispname = uigetdisp_xorg(argc, argv);
    int                i;

    fprintf(stderr, "UI: opening display %s\n", dispname);
    XInitThreads();
    disp = XOpenDisplay(dispname);
    if (!disp) {
        fprintf(stderr, "failed to open display %s\n", dispname);

        exit(1);
    }
    env->display = disp;
    i = DefaultScreen(disp);
    env->screen = i;
    env->depth = DefaultDepth(disp, i);
    env->visual = DefaultVisual(disp, i);
    env->colormap = DefaultColormap(disp, i);

    return;
}
Example #4
0
void wsMainLoop( void )
{
 int delay=20;
 mp_msg( MSGT_GPLAYER,MSGL_V,"[ws] init threads: %d\n",XInitThreads() );
 XSynchronize( wsDisplay,False );
 XLockDisplay( wsDisplay );
// XIfEvent( wsDisplay,&wsEvent,wsEvents,NULL );

#if 1

while(wsTrue){
 // handle pending events
 while ( XPending(wsDisplay) ){
   XNextEvent( wsDisplay,&wsEvent );
   wsEvents( wsDisplay,&wsEvent,NULL );
   delay=0;
 }
 usleep(delay*1000); // FIXME!
 if(delay<10*20) delay+=20; // pump up delay up to 0.2 sec (low activity)
}

#else

 while( wsTrue )
  {
   XIfEvent( wsDisplay,&wsEvent,wsDummyEvents,NULL );
   wsEvents( wsDisplay,&wsEvent,NULL );
  }
#endif

 XUnlockDisplay( wsDisplay );
}
Example #5
0
void Renderer::Init()
{
#ifdef _WIN32
    m_CurrentContext = wglGetCurrentContext();
    m_CurrentDC      = wglGetCurrentDC();
    // release current context
    wglMakeCurrent( nullptr, nullptr );
#endif
#ifdef __linux__
    // Rendering works fine under X in a separate thread, but quitting breaks some SDL internals. Haven't figured it out yet.
    if (!XInitThreads())
    {
    	THROW( "XLib is not thread safe." );
    }
    SDL_SysWMinfo wm_info;
    SDL_VERSION( &wm_info.version );
    if ( SDL_GetWMInfo( &wm_info ) ) {
        // TODO: drag-n-drop for non win32
        Display *display = wm_info.info.x11.gfxdisplay;
        m_CurrentContext = glXGetCurrentContext();
        ASSERT( m_CurrentContext, "Error! No current GL context!" );
        glXMakeCurrent( display, None, nullptr );
        XSync( display, false );
    }
#endif
}
Example #6
0
int _glfwPlatformInit(void)
{
    XInitThreads();

    _glfw.x11.display = XOpenDisplay(NULL);
    if (!_glfw.x11.display)
    {
        _glfwInputError(GLFW_API_UNAVAILABLE, "X11: Failed to open X display");
        return GL_FALSE;
    }

    _glfw.x11.screen = DefaultScreen(_glfw.x11.display);
    _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
    _glfw.x11.context = XUniqueContext();

    if (!initExtensions())
        return GL_FALSE;

    _glfw.x11.cursor = createNULLCursor();

    if (!_glfwInitContextAPI())
        return GL_FALSE;

    _glfwInitTimer();
    _glfwInitJoysticks();
    _glfwInitGammaRamp();

    return GL_TRUE;
}
Example #7
0
bool GLimp_OpenDisplay( void ) {
	if ( dpy ) {
		return true;
	}

	if ( cvarSystem->GetCVarInteger( "net_serverDedicated" ) == 1 ) {
		common->DPrintf( "not opening the display: dedicated server\n" );
		return false;
	}

	common->Printf( "Setup X display connection\n" );

	// that should be the first call into X
	if ( !XInitThreads() ) {
		common->Printf("XInitThreads failed\n");
		return false;
	}
	
	// set up our custom error handler for X failures
	XSetErrorHandler( &idXErrorHandler );

	if ( !( dpy = XOpenDisplay(NULL) ) ) {
		common->Printf( "Couldn't open the X display\n" );
		return false;
	}
	scrnum = DefaultScreen( dpy );
	return true;
}
void setupSkypeFrameWork(JNIEnv *env)
{
	currentEnv = env;

	if (XInitThreads() == 0) {
		throwInternalError(env, "Xlib don't support multi-threads.");
		return;
	}

	_display = XOpenDisplay(NULL);
	if (_display == NULL) {
		throwInternalError(env, "Opening the diplay failed.");
		return;
	}
	
	_screen = DefaultScreen(_display);
	_desktop = XRootWindow(_display, _screen);
	_dummyWindow = XCreateSimpleWindow(_display, _desktop, 0, 0, 1, 1, 0, BlackPixel(_display, _screen), BlackPixel(_display, _screen));
	
	_skypeInstanceAtom = XInternAtom(_display, "_SKYPE_INSTANCE", False);
	_skypeControlApiMessageBeginAtom = XInternAtom(_display, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
	_skypeControlApiMessageAtom = XInternAtom(_display, "SKYPECONTROLAPI_MESSAGE", False);
	_stopEventLoopAtom = XInternAtom(_display, "_STOP_EVENT_LOOP", False);
	_windowNameAtom = XInternAtom(_display, "WM_NAME", True);
	
	_dispatching = True;
}
Example #9
0
static
void
library_constructor(void)
{
    XInitThreads();
    printf("XInitThreads()\n");
}
int main() {
#if USE_GLX
    XInitThreads();
#endif

    // TODO: test if OpenGL 4.1 with GL_ARB_ES2_compatibility is supported
    // If it is, use kCGLOGLPVersion_3_2_Core and enable that extension.
    CGLPixelFormatAttribute attributes[] = {
        kCGLPFAOpenGLProfile,
        (CGLPixelFormatAttribute) kCGLOGLPVersion_Legacy,
        kCGLPFAAccelerated,
        (CGLPixelFormatAttribute) 0
    };

    GLint num;
    CGLError error = CGLChoosePixelFormat(attributes, &pixelFormat, &num);
    if (error) {
        fprintf(stderr, "Error pixel format: %s\n", CGLErrorString(error));
        return error;
    }

    while (true) {
        std::thread t1(readPixels);
        std::thread t2(readPixels);
        std::thread t3(readPixels);

        t1.join();
        t2.join();
        t3.join();
    }

    return 0;
}
int
main(int argc, char **argv)
{
	int ret;
	pthread_t thread1, thread2;

	XInitThreads();

	pthread_mutex_init(&mutex, NULL);

	/* Now, spawn some threads that compile simple shaders.
	 */
	pthread_create(&thread1, NULL, thread_func, NULL);
	pthread_create(&thread2, NULL, thread_func, NULL);

	ret = pthread_join(thread1, NULL);
	assert(ret == 0);
	ret = pthread_join(thread2, NULL);
	assert(ret == 0);

	pthread_mutex_destroy(&mutex);

	piglit_report_result(PIGLIT_PASS);
	return 0;
}
Example #12
0
void* JobPoolWorker::Entry()
{
#ifdef LINUX
    XInitThreads();
#endif
    while ( true ) {
        // Did we get a request to terminate?
        if (TestDestroy())
            break;

        Job *job = GetJob();
        if (job) {
            // Call user's implementation for processing request
            ProcessJob(job);
            if (job->DeleteWhenComplete()) {
                delete job;
            }
            job = NULL;
        } else {
            std::unique_lock<std::mutex> mutLock(*lock);
            if (idleThreads > 5) {
                break;
            }
        }
    }
    std::unique_lock<std::mutex> mutLock(*lock);
    numThreads--;
    return NULL;
}
Example #13
0
static void x11_apply_video_params(VideoParams *params, Window window){
	XWindowChanges wc;
	unsigned int flags=0;
	static Display *display = NULL;
	const char *dname=getenv("DISPLAY");

	if (display==NULL && dname!=NULL){
		XInitThreads();
		display=XOpenDisplay(dname);
	}

	if (display==NULL){
		ms_error("Could not open display %s",dname);
		return;
	}
	memset(&wc,0,sizeof(wc));
	wc.x=params->x;
	wc.y=params->y;
	wc.width=params->w;
	wc.height=params->h;
	if (params->x!=-1 ){
		flags|=CWX|CWY;
	}
	if (params->w!=-1){
		flags|=CWWidth|CWHeight;
	}
	/*printf("XConfigureWindow x=%i,y=%i,w=%i,h=%i\n",
	       wc.x, wc.y ,wc.width, wc.height);*/
	XConfigureWindow(display,window,flags,&wc);
	if (params->show)
		XMapWindow(display,window);
	else
		XUnmapWindow(display,window);
	XSync(display,FALSE);
}
Example #14
0
int x11_shadow_subsystem_base_init(x11ShadowSubsystem* subsystem)
{
	if (subsystem->display)
		return 1; /* initialize once */

	if (!getenv("DISPLAY"))
		setenv("DISPLAY", ":0", 1);

	if (!XInitThreads())
		return -1;

	subsystem->display = XOpenDisplay(NULL);

	if (!subsystem->display)
	{
		WLog_ERR(TAG, "failed to open display: %s", XDisplayName(NULL));
		return -1;
	}

	subsystem->xfds = ConnectionNumber(subsystem->display);
	subsystem->number = DefaultScreen(subsystem->display);
	subsystem->screen = ScreenOfDisplay(subsystem->display, subsystem->number);
	subsystem->depth = DefaultDepthOfScreen(subsystem->screen);
	subsystem->width = WidthOfScreen(subsystem->screen);
	subsystem->height = HeightOfScreen(subsystem->screen);
	subsystem->root_window = RootWindow(subsystem->display, subsystem->number);

	return 1;
}
Example #15
0
int x11c_initialise(X11Common* x11Common, int reviewDuration, OnScreenDisplay* osd, X11WindowInfo* windowInfo)
{
    memset(x11Common, 0, sizeof(x11Common));

    x11Common->reviewDuration = reviewDuration;
    x11Common->osd = osd;

    x11Common->progressBarInput.data = x11Common;
    x11Common->progressBarInput.set_listener = x11c_set_pbar_listener;
    x11Common->progressBarInput.unset_listener = x11c_unset_pbar_listener;
    x11Common->progressBarInput.close = x11c_close_pbar;

    x11Common->keyboardInput.data = x11Common;
    x11Common->keyboardInput.set_listener = x11c_set_keyboard_listener;
    x11Common->keyboardInput.unset_listener = x11c_unset_keyboard_listener;
    x11Common->keyboardInput.close = x11c_close_keyboard;

    x11Common->mouseInput.data = x11Common;
    x11Common->mouseInput.set_listener = x11c_set_mouse_listener;
    x11Common->mouseInput.unset_listener = x11c_unset_mouse_listener;
    x11Common->mouseInput.close = x11c_close_mouse;

    if (windowInfo)
    {
        x11Common->windowInfo = *windowInfo;
    }

    CHK_ORET(XInitThreads() != 0);
    
    CHK_ORET(init_mutex(&x11Common->eventMutex));

    CHK_ORET(create_joinable_thread(&x11Common->processEventThreadId, process_event_thread, x11Common));

    return 1;
}
Example #16
0
void EarlyInit()
{
	// If you ever want to catch a particular allocation:
	//_CrtSetBreakAlloc(232647);

	ThreadUtil::SetMainThread();

	debug_SetThreadName("main");
	// add all debug_printf "tags" that we are interested in:
	debug_filter_add(L"TIMER");

	timer_LatchStartTime();

	// initialise profiler early so it can profile startup,
	// but only after LatchStartTime
	g_Profiler2.Initialise();

	FixLocales();

	// Because we do GL calls from a secondary thread, Xlib needs to
	// be told to support multiple threads safely.
	// This is needed for Atlas, but we have to call it before any other
	// Xlib functions (e.g. the ones used when drawing the main menu
	// before launching Atlas)
#if MUST_INIT_X11
	int status = XInitThreads();
	if (status == 0)
		debug_printf(L"Error enabling thread-safety via XInitThreads\n");
#endif

	// Initialise the low-quality rand function
	srand(time(NULL));	// NOTE: this rand should *not* be used for simulation!
}
Example #17
0
bool GLWindow::CreateWindow(void *pDisplay)
{
	bool ret = true;

    // init support of multi thread
    if (!XInitThreads())
        ZZLog::Error_Log("Failed to init the xlib concurent threads");

	NativeDisplay = XOpenDisplay(NULL);
	if (!NativeDisplay) ret = false;

	if (pDisplay == NULL)
	{
		ZZLog::Error_Log("Failed to create window. Exiting...");
		return false;
	}

	// Allow pad to use the display
	*(Display**)pDisplay = NativeDisplay;
	// Pad can use the window to grab the input. For the moment just set to 0 to avoid
	// to grab an unknow window... Anyway GSopen1 might be dropped in the future
	*((u32*)(pDisplay)+1) = 0;

#ifdef EGL_API
	if (!OpenEGLDisplay()) ret = false;
#endif

	return ret;
}
Example #18
0
bool DolphinApp::Initialize(int& c, wxChar **v)
{
#if defined HAVE_X11 && HAVE_X11
	XInitThreads();
#endif
	return wxApp::Initialize(c, v);
}
Example #19
0
int
main (int argc, char **argv)
{
  GjsContext *js_context;
  GError *error;

#ifdef GDK_WINDOWING_X11
  XInitThreads ();
#endif

  clutter_x11_set_use_argb_visual (TRUE);

  if (gtk_clutter_init (&argc, &argv) < 0)
    return EXIT_FAILURE;

  clutter_gst_init (0, NULL);

  parse_options (&argc, &argv);

  js_context = gjs_context_new_with_search_path (NULL);
  error = NULL;

  register_all_viewers (js_context);

  if (!gjs_context_eval (js_context,
                         "const Main = imports.ui.main;\n"
                         "Main.run();\n",
                         -1,
                         __FILE__,
                         NULL,
                         &error))
    g_error("Failed to load main javascript: %s", error->message);

  return EXIT_SUCCESS;
}
Example #20
0
int main(int argc, const char** argv)
{
	XInitThreads();
	s_display = XOpenDisplay(0);

	int32_t screen = DefaultScreen(s_display);
	int32_t depth = DefaultDepth(s_display, screen);
	Visual* visual = DefaultVisual(s_display, screen);
	Window root = RootWindow(s_display, screen);

	XSetWindowAttributes windowAttrs = { 0 };
	windowAttrs.background_pixmap = 0;
	windowAttrs.border_pixel = 0;
	windowAttrs.event_mask = 0
			| ButtonPressMask
			| ButtonReleaseMask
			| ExposureMask
			| KeyPressMask
			| KeyReleaseMask
			| PointerMotionMask
			| ResizeRedirectMask
			| StructureNotifyMask
			;

	int width = 800;
	int height = 600;

	s_window = XCreateWindow(s_display
							, root
							, 0, 0
							, width, height, 0, depth
							, InputOutput
							, visual
							, CWBorderPixel|CWEventMask
							, &windowAttrs
							);

	// Clear window to black.
	XSetWindowAttributes attr = { 0 };
	XChangeWindowAttributes(s_display, s_window, CWBackPixel, &attr);

	const char* wmDeleteWindowName = "WM_DELETE_WINDOW";
	XInternAtoms(s_display, (char **)&wmDeleteWindowName, 1, False, &wmDeleteWindow);
	XSetWMProtocols(s_display, s_window, &wmDeleteWindow, 1);

	XMapWindow(s_display, s_window);
	XStoreName(s_display, s_window, "ProDBG");

	bgfx::x11SetDisplayWindow(s_display, s_window);
    
    ProDBG_create((void*)s_window, width, height);

	processEvents();

	XUnmapWindow(s_display, s_window);
	XDestroyWindow(s_display, s_window);

	return EXIT_SUCCESS;
}
Example #21
0
/**
 *   fv_open_display: setup up X11, choose visual, create colomap and query fullscreen capabilities.
 */
int fv_open_display()
{
    char *display;

    fwl_thread_dump();

    /* Display */
    XInitThreads();

    display = getenv("DISPLAY");
    Xdpy = XOpenDisplay(display);
    if (!Xdpy) {
	ERROR_MSG("can't open display %s.\n", display);
	return FALSE;
    }

    /* start up a XLib error handler to catch issues with FreeWRL. There
       should not be any issues, but, if there are, we'll most likely just
       throw our hands up, and continue */
    XSetErrorHandler(fv_catch_XLIB); 

    Xscreen = DefaultScreen(Xdpy);
    Xroot_window = RootWindow(Xdpy,Xscreen);

    /* Visual */

    Xvi = fv_find_best_visual();
    if(!Xvi) { 
	    ERROR_MSG("FreeWRL can not find an appropriate visual from GLX\n");
	    return FALSE;
    }

    /* Fullscreen */

    if (fullscreen) {
#ifdef HAVE_XF86_VMODE
	    int i;
	    if (vmode_modes == NULL) {
		    if (XF86VidModeGetAllModeLines(Xdpy, Xscreen, &vmode_nb_modes, &vmode_modes) == 0) {
			    ERROR_MSG("can`t get mode lines through XF86VidModeGetAllModeLines.\n");
			    return FALSE;
		    }
		    qsort(vmode_modes, vmode_nb_modes, sizeof(XF86VidModeModeInfo*), mode_cmp);
	    }
	    for (i = 0; i < vmode_nb_modes; i++) {
		    if (vmode_modes[i]->hdisplay <= win_width && vmode_modes[i]->vdisplay <= win_height) {
			    fv_switch_to_mode(i);
			    break;
		    }
	    }
#endif
    }


    /* Color map */
    fv_create_colormap();

    return TRUE;
}
Example #22
0
// ------------------------  Phd App stuff -----------------------------
PhdApp::PhdApp(void)
{
    m_resetConfig = false;
    m_instanceNumber = 1;
#ifdef  __LINUX__
    XInitThreads();
#endif // __LINUX__
};
Example #23
0
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void g_init_threads()
{
	DEBUGLOGB;

	XInitThreads();

	DEBUGLOGE;
}
Example #24
0
/** Zainicjowanie bibliotek, utworzenie okna */
App::App(): logger("App"), pIsDone( false ), pEvent()
{
	logger.methodStart( "App()" );

    // bez tego sa problemy z watkami na linuxie
	#ifdef __linux__
		XInitThreads();
	#endif

    /** -- Inicjowanie SDL-a i wtyczek -- */
    if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER ) != 0 ) {
        logger.critical( "Failed to init SDL" );
        throw("App::App()");
    }

    if ( TTF_Init() == -1 ) {
        logger.critical( "Failed to init SDL ttf modules" );
        throw("App::App()");
    }

    /** --- Pobranie rozdzielczosci ekranu --- */
    const SDL_VideoInfo* myPointer = SDL_GetVideoInfo();
    pScreen_w = myPointer->current_w;
    pScreen_h = myPointer->current_h;


	// Konfiguracja dodatkowa okna
	#ifdef FULL_SCREEN_FLAG
	   SDL_ShowCursor( false );

	#else
	   SDL_ShowCursor( true );
	   pScreen_h = HEIGHT;
	   pScreen_w = WIDHT;
	#endif

    logger.info( "Screen resoulution: " );
    logger.info( "\tHeight: " + toString( pScreen_h ) + "px" );
    logger.info( "\tWidth: " + toString( pScreen_w ) + "px" );

    if(  pScreen_w > MAX_SCREEN_WIDTH || pScreen_h > MAX_SCREEN_HEIGHT ){
       /* w przypadku rozdzielczosci wiekszej niz full HD obraz ma wymiary 1920x1080 */
        logger.critical("Screen resoulution is to large. Maximum is: 1920x1080 px");
        pScreen_h = MAX_SCREEN_HEIGHT;
        pScreen_w = MAX_SCREEN_WIDTH;
    }
    else if ( pScreen_w < MIN_SCREEN_WIDTH || pScreen_h < MIN_SCREEN_HEIGHT ) {
        logger.critical("Screen resoulution is too small");
        throw("App::App()");
    }

	// Inicjowanie grafiki
   	initVideoGL();

	SDL_WM_SetCaption( "Astro Rush" VERSION, NULL );

	logger.methodEnd( "App" );
}
HeadlessDisplay::HeadlessDisplay() {
#if MBGL_USE_CGL
    // TODO: test if OpenGL 4.1 with GL_ARB_ES2_compatibility is supported
    // If it is, use kCGLOGLPVersion_3_2_Core and enable that extension.
    CGLPixelFormatAttribute attributes[] = {
        kCGLPFAOpenGLProfile,
        static_cast<CGLPixelFormatAttribute>(kCGLOGLPVersion_Legacy),
        kCGLPFAAccelerated,
        static_cast<CGLPixelFormatAttribute>(0)
    };

    GLint num;
    CGLError error = CGLChoosePixelFormat(attributes, &pixelFormat, &num);
    if (error != kCGLNoError) {
        throw std::runtime_error(std::string("Error choosing pixel format:") + CGLErrorString(error) + "\n");
    }
    if (num <= 0) {
        throw std::runtime_error("No pixel formats found.");
    }
#endif

#if MBGL_USE_GLX
    if (!XInitThreads()) {
        throw std::runtime_error("Failed to XInitThreads.");
    }

    xDisplay = XOpenDisplay(nullptr);
    if (xDisplay == nullptr) {
        throw std::runtime_error("Failed to open X display.");
    }

    const char *extensions = reinterpret_cast<const char *>(glXQueryServerString(xDisplay, DefaultScreen(xDisplay), GLX_EXTENSIONS));
    if (!extensions) {
        throw std::runtime_error("Cannot read GLX extensions.");
    }
    if (!strstr(extensions,"GLX_SGIX_fbconfig")) {
        throw std::runtime_error("Extension GLX_SGIX_fbconfig was not found.");
    }
    if (!strstr(extensions, "GLX_SGIX_pbuffer")) {
        throw std::runtime_error("Cannot find glXCreateContextAttribsARB.");
    }

    // We're creating a dummy pbuffer anyway that we're not using.
    static int pixelFormat[] = {
        GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
        None
    };

    int configs = 0;
    fbConfigs = glXChooseFBConfig(xDisplay, DefaultScreen(xDisplay), pixelFormat, &configs);
    if (fbConfigs == nullptr) {
        throw std::runtime_error("Failed to glXChooseFBConfig.");
    }
    if (configs <= 0) {
        throw std::runtime_error("No Framebuffer configurations.");
    }
#endif
}
Example #26
0
int main()
{
#ifdef _WIN32
#else
  XInitThreads();
#endif
  Client *cli = new Client(3);
  cli->Start();
}
CXlibToolkit::CXlibToolkit(void *parentWindow, CEditor *editor)
{
    this->parentWindow  = parentWindow;
    this->editor        = editor;

    char *displayName = getenv("DISPLAY");
    if (!displayName || !strlen(displayName))
    {
        displayName = (char*)":0.0";
    }
    if (!XInitThreads())
    {
        fprintf(stderr, "Xlib threads support unavailable");
        return;
    }
    this->display = XOpenDisplay(displayName);

    if (!parentWindow)
    {
        parentWindow = (void*)RootWindow(this->display, DefaultScreen(this->display));
    }

    window = XCreateWindow(this->display, (Window)parentWindow, 0, 0, GUI_WIDTH, GUI_HEIGHT, 0, 24, InputOutput, CopyFromParent, 0, 0);

    gc = XCreateGC(this->display, window, 0, 0);
    XSelectInput(this->display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask);
    XMapWindow(this->display, window);
    XFlush(this->display);

    this->WM_TIMER         = XInternAtom(this->display, "WM_TIMER"        , false);
    this->WM_DELETE_WINDOW = XInternAtom(this->display, "WM_DELETE_WINDOW", false);
    XSetWMProtocols(this->display, window, &WM_DELETE_WINDOW, 1);

    offscreen = XCreatePixmap(this->display, window, GUI_WIDTH, GUI_HEIGHT, 24);

    memset(bmps, 0, sizeof(bmps));
    bmps[BMP_CHARS  ] = LoadImageFromFile(BMP_PATH"/chars.bmp"  );
    bmps[BMP_KNOB   ] = LoadImageFromFile(BMP_PATH"/knob.bmp"   );
    bmps[BMP_KNOB2  ] = LoadImageFromFile(BMP_PATH"/knob2.bmp"  );
    bmps[BMP_KNOB3  ] = LoadImageFromFile(BMP_PATH"/knob3.bmp"  );
    bmps[BMP_KEY    ] = LoadImageFromFile(BMP_PATH"/key.bmp"    );
    bmps[BMP_BG     ] = LoadImageFromFile(BMP_PATH"/bg.bmp"     );
    bmps[BMP_BUTTONS] = LoadImageFromFile(BMP_PATH"/buttons.bmp");
    bmps[BMP_OPS    ] = LoadImageFromFile(BMP_PATH"/ops.bmp"    );

    if (!bmps[BMP_CHARS  ]) bmps[BMP_CHARS  ] = LoadImageFromBuffer(chars_bmp  );
    if (!bmps[BMP_KNOB   ]) bmps[BMP_KNOB   ] = LoadImageFromBuffer(knob_bmp   );
    if (!bmps[BMP_KNOB2  ]) bmps[BMP_KNOB2  ] = LoadImageFromBuffer(knob2_bmp  );
    if (!bmps[BMP_KNOB3  ]) bmps[BMP_KNOB3  ] = LoadImageFromBuffer(knob3_bmp  );
    if (!bmps[BMP_KEY    ]) bmps[BMP_KEY    ] = LoadImageFromBuffer(key_bmp    );
    if (!bmps[BMP_BG     ]) bmps[BMP_BG     ] = LoadImageFromBuffer(bg_bmp     );
    if (!bmps[BMP_BUTTONS]) bmps[BMP_BUTTONS] = LoadImageFromBuffer(buttons_bmp);
    if (!bmps[BMP_OPS    ]) bmps[BMP_OPS    ] = LoadImageFromBuffer(ops_bmp    );

    thread1Finished = true;
    thread2Finished = true;
}
Example #28
0
int main(int argc, char *argv[])
{
    XInitThreads();
    QApplication a(argc, argv);
    MainWindow w;
    w.showMaximized();
    
    return a.exec();
}
Example #29
0
int main(int argc, char ** argv)
{
  XInitThreads();
  QApplication app( argc, argv );
  MainWindowImpl win;
  win.show();
  app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
  return app.exec();
}
QOffscreenX11Connection::QOffscreenX11Connection()
{
    XInitThreads();

    QByteArray displayName = qgetenv("DISPLAY");
    Display *display = XOpenDisplay(displayName.constData());
    m_display = display;
    m_screenNumber = DefaultScreen(display);
}