Esempio n. 1
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;
}
Esempio n. 2
0
int _glfwPlatformInit(void)
{
    // HACK: If the current locale is C, apply the environment's locale
    //       This is done because the C locale breaks character input
    if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0)
        setlocale(LC_CTYPE, "");

    XInitThreads();

    _glfw.x11.display = XOpenDisplay(NULL);
    if (!_glfw.x11.display)
    {
        _glfwInputError(GLFW_PLATFORM_ERROR, "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 (XSupportsLocale())
    {
        XSetLocaleModifiers("");

        _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, 0, 0);
        if (_glfw.x11.im)
        {
            if (!hasUsableInputMethodStyle())
            {
                XCloseIM(_glfw.x11.im);
                _glfw.x11.im = NULL;
            }
        }
    }

    if (!_glfwInitContextAPI())
        return GL_FALSE;

    if (!_glfwInitJoysticks())
        return GL_FALSE;

    _glfwInitTimer();

    return GL_TRUE;
}
Esempio n. 3
0
int _glfwPlatformInit(void)
{
    XInitThreads();

    if (!initDisplay())
        return GL_FALSE;

    _glfwInitGammaRamp();

    if (!_glfwInitContextAPI())
        return GL_FALSE;

    _glfw.x11.cursor = createNULLCursor();

    if (!_glfwInitJoysticks())
        return GL_FALSE;

    _glfwInitTimer();

    return GL_TRUE;
}
Esempio n. 4
0
int _glfwPlatformInit(void)
{
    if (!initDisplay())
        return GL_FALSE;

    _glfwInitGammaRamp();

    initEWMH();

    _glfwLibrary.X11.cursor = createNULLCursor();

    // Try to load libGL.so if necessary
    initLibraries();

    _glfwInitJoysticks();

    // Start the timer
    _glfwInitTimer();

    return GL_TRUE;
}
Esempio n. 5
0
int _glfwPlatformInit(void)
{
    XInitThreads();

    if (!initDisplay())
        return GL_FALSE;

    _glfwInitGammaRamp();

    if (!_glfwInitOpenGL())
        return GL_FALSE;

    initEWMH();

    _glfwLibrary.X11.cursor = createNULLCursor();

    if (!_glfwInitJoysticks())
        return GL_FALSE;

    // Start the timer
    _glfwInitTimer();

    return GL_TRUE;
}
Esempio n. 6
0
File: x11_init.c Progetto: jku/glfw
int _glfwPlatformInit(void)
{
#if !defined(X_HAVE_UTF8_STRING)
    // HACK: If the current locale is C, apply the environment's locale
    //       This is done because the C locale breaks wide character input
    if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0)
        setlocale(LC_CTYPE, "");
#endif

    XInitThreads();

    _glfw.x11.display = XOpenDisplay(NULL);
    if (!_glfw.x11.display)
    {
        const char* display = getenv("DISPLAY");
        if (display)
        {
            _glfwInputError(GLFW_PLATFORM_ERROR,
                            "X11: Failed to open display %s", display);
        }
        else
        {
            _glfwInputError(GLFW_PLATFORM_ERROR,
                            "X11: The DISPLAY environment variable is missing");
        }

        return GLFW_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 GLFW_FALSE;

    _glfw.x11.cursor = createNULLCursor();

    if (XSupportsLocale())
    {
        XSetLocaleModifiers("");

        _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL);
        if (_glfw.x11.im)
        {
            if (!hasUsableInputMethodStyle())
            {
                XCloseIM(_glfw.x11.im);
                _glfw.x11.im = NULL;
            }
        }
    }

    if (!_glfwInitContextAPI())
        return GLFW_FALSE;

    if (!_glfwInitJoysticks())
        return GLFW_FALSE;

    _glfwInitTimer();

    return GLFW_TRUE;
}
Esempio n. 7
0
bool MWindow::create(const char * title, unsigned int width, unsigned int height, int colorBits, bool fullscreen)
{
	static int dblBuf[] = {GLX_RGBA, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None};
	XVisualInfo * vi;
	Colormap cmap;
	XSetWindowAttributes swa;


	// open display
	display = XOpenDisplay(NULL);

	// fullscreen
	
#ifndef __CYGWIN__
	
	int vmMajor, vmMinor;
	if(XF86VidModeQueryVersion(display, &vmMajor, &vmMinor) && fullscreen)
	{
		screen = DefaultScreen(display);

		int modeNum, screenMode=0;
		XF86VidModeModeInfo **modes;
		XF86VidModeGetAllModeLines(display, screen, &modeNum, &modes);

		if(modeNum > 0)
		{
			desktopMode = *modes[0];

			for(int i=0; i<modeNum; i++)
			{
				if((modes[i]->hdisplay == width) && (modes[i]->vdisplay == height))
					screenMode = i;
			}

			XF86VidModeSwitchToMode(display, screen, modes[screenMode]);
			XF86VidModeSetViewPort(display, screen, 0, 0);
			m_width = modes[screenMode]->hdisplay;
			m_height = modes[screenMode]->vdisplay;

			XFree(modes);

			swa.override_redirect = True;
			swa.event_mask =
			StructureNotifyMask | KeyPressMask | KeyReleaseMask |
			PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
			ExposureMask | FocusChangeMask | VisibilityChangeMask;

			rootWindow = RootWindow(display,vi->screen);

			window = XCreateWindow(
				display, rootWindow,
				0, 0, m_width, m_height, 0, vi->depth, InputOutput, vi->visual,
				CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect,
				&swa);

			XWarpPointer(display, None, window, 0, 0, 0, 0, 0, 0);
			XMapRaised(display, window);
			XGrabKeyboard(display, window, True, GrabModeAsync, GrabModeAsync, CurrentTime);
			XGrabPointer(display, window, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, window, None, CurrentTime);

			m_fullscreen = true;
		}
		else
		{
			return false;
		}
	}
	
	else
		
#endif
		
	// window
	{
		m_fullscreen = false;

		vi = glXChooseVisual(display, DefaultScreen(display), dblBuf);
		context = glXCreateContext(display, vi, None, True);
		rootWindow = RootWindow(display,vi->screen);
		cmap = XCreateColormap(display,rootWindow,vi->visual,AllocNone);
		swa.colormap = cmap; swa.border_pixel = 0;

		swa.event_mask =
		StructureNotifyMask | KeyPressMask | KeyReleaseMask |
		PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
		ExposureMask | FocusChangeMask | VisibilityChangeMask;

		m_width = width;
		m_height = height;

		window = XCreateWindow(
			display, rootWindow,
			0, 0, m_width, m_height, 0, vi->depth, InputOutput, vi->visual,
			CWBorderPixel | CWColormap | CWEventMask,
			&swa);

		wmDelete = XInternAtom(display, "WM_DELETE_WINDOW", False);
		XSetWMProtocols(display, window, &wmDelete, 1);

		XSetStandardProperties(display, window, title, title, None, NULL, 0, NULL);
		XMapWindow(display, window);
	}

	// make current context
	glXMakeCurrent(display, window, context);

	// cursor
	nullCursor = createNULLCursor(display, rootWindow);

	return true;
}