예제 #1
0
파일: wl_window.c 프로젝트: Delwin9999/glfw
int _glfwPlatformCreateWindow(_GLFWwindow* window,
                              const _GLFWwndconfig* wndconfig,
                              const _GLFWctxconfig* ctxconfig,
                              const _GLFWfbconfig* fbconfig)
{
    if (!_glfwCreateContext(window, ctxconfig, fbconfig))
        return GL_FALSE;

    if (!createSurface(window, wndconfig))
        return GL_FALSE;

    if (wndconfig->monitor)
    {
        wl_shell_surface_set_fullscreen(
            window->wl.shell_surface,
            WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
            0,
            wndconfig->monitor->wl.output);
    }
    else
    {
        wl_shell_surface_set_toplevel(window->wl.shell_surface);
    }

    return GL_TRUE;
}
예제 #2
0
int _glfwPlatformCreateWindow(_GLFWwindow* window,
			      const _GLFWwndconfig* wndconfig,
			      const _GLFWfbconfig* fbconfig)
{
    window->refreshRate = wndconfig->refreshRate;

    if (!_glfwCreateContext(window, wndconfig, fbconfig))
	return GL_FALSE;

    if (!createWindow(window, wndconfig))
	return GL_FALSE;

    if (wndconfig->mode == GLFW_FULLSCREEN)
    {
#if defined(_GLFW_HAS_XRANDR)
	// Request screen change notifications
	if (_glfwLibrary.X11.RandR.available)
	{
	    XRRSelectInput(_glfwLibrary.X11.display,
			   window->X11.handle,
			   RRScreenChangeNotifyMask);
	}
#endif /*_GLFW_HAS_XRANDR*/

	_glfwPlatformShowWindow(window);
	enterFullscreenMode(window);
    }

    // Retrieve and set initial cursor position
    {
	Window cursorWindow, cursorRoot;
	int windowX, windowY, rootX, rootY;
	unsigned int mask;

	XQueryPointer(_glfwLibrary.X11.display,
		      window->X11.handle,
		      &cursorRoot,
		      &cursorWindow,
		      &rootX, &rootY,
		      &windowX, &windowY,
		      &mask);

	// TODO: Probably check for some corner cases here.

	window->cursorPosX = windowX;
	window->cursorPosY = windowY;
    }

    return GL_TRUE;
}
예제 #3
0
int _glfwPlatformCreateWindow(_GLFWwindow* window,
                              const _GLFWwndconfig* wndconfig,
                              const _GLFWctxconfig* ctxconfig,
                              const _GLFWfbconfig* fbconfig)
{
    int rc;
    int nbuffers = fbconfig->doublebuffer ? 2 : 1;
    int format = SCREEN_FORMAT_RGBX8888; // TODO: check fbconfig
    int usage = SCREEN_USAGE_OPENGL_ES2|SCREEN_USAGE_OVERLAY; // TODO: check context config
    int size[2] = { wndconfig->width, wndconfig->height };
    int pos[2] = { 0, 0 };
    int interval = 1;

    if (!_glfwCreateContext(window, ctxconfig, fbconfig))
        return GL_FALSE;

    rc = screen_create_window(&window->screen.window, _glfw.screen.context);
    if (rc)
    {
    	_glfwInputError(GLFW_PLATFORM_ERROR,
    	                    "screen: Error creating window %s", strerror(errno));
    	return GL_FALSE;
    }

    if (wndconfig->monitor)
    {
    	rc = screen_set_window_property_pv(window->screen.window, SCREEN_PROPERTY_DISPLAY, (void**)&wndconfig->monitor->screen.display);
    	if (rc)
    	{
    		_glfwInputError(GLFW_PLATFORM_ERROR,
    	                    "screen: Error set window property %s", strerror(errno));
    		return GL_FALSE;
    	}
    }

    rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_FORMAT, &format);
    if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set format property: %s", strerror(errno)); return GL_FALSE; }
    rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_USAGE, &usage);
    if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set usage property: %s", strerror(errno)); return GL_FALSE; }
    rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_SWAP_INTERVAL, &interval);
    if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set swap interval property: %s", strerror(errno)); return GL_FALSE; }
    rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_SIZE, size);
    if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set size property: %s", strerror(errno)); return GL_FALSE; }
    rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_POSITION, pos);
    if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set position property: %s", strerror(errno)); return GL_FALSE; }
    rc = screen_create_window_buffers(window->screen.window, nbuffers);
    if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to create window buffers: %s", strerror(errno)); return GL_FALSE; }

    return GL_TRUE;
}
예제 #4
0
int _glfwPlatformCreateWindow(_GLFWwindow* window,
                              const _GLFWwndconfig* wndconfig,
                              const _GLFWfbconfig* fbconfig)
{
    if (!_glfwCreateContext(window, wndconfig, fbconfig))
        return GL_FALSE;

    if (!createWindow(window, wndconfig))
        return GL_FALSE;

    if (wndconfig->monitor)
    {
        _glfwPlatformShowWindow(window);
        enterFullscreenMode(window);
    }

    return GL_TRUE;
}
예제 #5
0
int _glfwPlatformCreateWindow(_GLFWwindow* window,
                              const _GLFWwndconfig* wndconfig,
                              const _GLFWfbconfig* fbconfig)
{
    if (!_glfwCreateContext(window, wndconfig, fbconfig))
        return GL_FALSE;

    if (!createWindow(window, wndconfig))
        return GL_FALSE;

    if (wndconfig->monitor)
    {
        _glfwPlatformShowWindow(window);
        enterFullscreenMode(window);
    }

    // Retrieve and set initial cursor position
    {
        Window cursorWindow, cursorRoot;
        int windowX, windowY, rootX, rootY;
        unsigned int mask;

        XQueryPointer(_glfw.x11.display,
                      window->x11.handle,
                      &cursorRoot,
                      &cursorWindow,
                      &rootX, &rootY,
                      &windowX, &windowY,
                      &mask);

        // TODO: Probably check for some corner cases here.

        window->cursorPosX = windowX;
        window->cursorPosY = windowY;
    }

    return GL_TRUE;
}
예제 #6
0
파일: mir_window.c 프로젝트: odinsbane/glfw
int _glfwPlatformCreateWindow(_GLFWwindow* window,
                              const _GLFWwndconfig* wndconfig,
                              const _GLFWctxconfig* ctxconfig,
                              const _GLFWfbconfig* fbconfig)
{
    if (!_glfwCreateContext(window, ctxconfig, fbconfig))
        return GL_FALSE;

    if (wndconfig->monitor)
    {
        GLFWvidmode mode;
        _glfwPlatformGetVideoMode(wndconfig->monitor, &mode);

        mir_surface_set_state(window->mir.surface, mir_surface_state_fullscreen);

        if (wndconfig->width > mode.width || wndconfig->height > mode.height)
        {
            _glfwInputError(GLFW_PLATFORM_ERROR,
                            "Mir: Requested surface size too large: %ix%i",
                            wndconfig->width, wndconfig->height);

            return GL_FALSE;
        }
    }

    window->mir.width  = wndconfig->width;
    window->mir.height = wndconfig->height;

    if (!createSurface(window))
        return GL_FALSE;

    window->mir.window = mir_buffer_stream_get_egl_native_window(
                                   mir_surface_get_buffer_stream(window->mir.surface));

    return GL_TRUE;
}
// Creates the GLFW window and rendering context
//
static int createWindow(_GLFWwindow* window,
                        const _GLFWwndconfig* wndconfig,
                        const _GLFWctxconfig* ctxconfig,
                        const _GLFWfbconfig* fbconfig)
{
    int xpos, ypos, fullWidth, fullHeight;
    WCHAR* wideTitle;

    window->win32.dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
    window->win32.dwExStyle = WS_EX_APPWINDOW;

    if (window->monitor)
    {
        window->win32.dwStyle |= WS_POPUP;

        // NOTE: This window placement is temporary and approximate, as the
        //       correct position and size cannot be known until the monitor
        //       video mode has been set
        _glfwPlatformGetMonitorPos(wndconfig->monitor, &xpos, &ypos);
        fullWidth  = wndconfig->width;
        fullHeight = wndconfig->height;
    }
    else
    {
        if (wndconfig->decorated)
        {
            window->win32.dwStyle |= WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;

            if (wndconfig->resizable)
            {
                window->win32.dwStyle |= WS_MAXIMIZEBOX | WS_SIZEBOX;
                window->win32.dwExStyle |= WS_EX_WINDOWEDGE;
            }
        }
        else
            window->win32.dwStyle |= WS_POPUP;

        xpos = CW_USEDEFAULT;
        ypos = CW_USEDEFAULT;

        getFullWindowSize(window,
                          wndconfig->width, wndconfig->height,
                          &fullWidth, &fullHeight);
    }

    wideTitle = _glfwCreateWideStringFromUTF8(wndconfig->title);
    if (!wideTitle)
    {
        _glfwInputError(GLFW_PLATFORM_ERROR,
                        "Win32: Failed to convert window title to UTF-16");
        return GL_FALSE;
    }

    window->win32.handle = CreateWindowExW(window->win32.dwExStyle,
                                           _GLFW_WNDCLASSNAME,
                                           wideTitle,
                                           window->win32.dwStyle,
                                           xpos, ypos,
                                           fullWidth, fullHeight,
                                           NULL, // No parent window
                                           NULL, // No window menu
                                           GetModuleHandleW(NULL),
                                           window); // Pass object to WM_CREATE

    free(wideTitle);

    if (!window->win32.handle)
    {
        _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to create window");
        return GL_FALSE;
    }

    if (_glfw_ChangeWindowMessageFilterEx)
    {
        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
                                          WM_DROPFILES, MSGFLT_ALLOW, NULL);
        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
                                          WM_COPYDATA, MSGFLT_ALLOW, NULL);
        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
                                          WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
    }

    if (wndconfig->floating && !wndconfig->monitor)
    {
        SetWindowPos(window->win32.handle,
                        HWND_TOPMOST,
                        0, 0, 0, 0,
                        SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
    }

    DragAcceptFiles(window->win32.handle, TRUE);

    if (!_glfwCreateContext(window, ctxconfig, fbconfig))
        return GL_FALSE;

    return GL_TRUE;
}
예제 #8
0
파일: win32_window.c 프로젝트: notetau/glfw
// Creates the GLFW window and rendering context
//
static GLFWbool createWindow(_GLFWwindow* window,
                             const _GLFWwndconfig* wndconfig,
                             const _GLFWctxconfig* ctxconfig,
                             const _GLFWfbconfig* fbconfig)
{
    int xpos, ypos, fullWidth, fullHeight;
    WCHAR* wideTitle;

    if (wndconfig->monitor)
    {
        GLFWvidmode mode;

        // NOTE: This window placement is temporary and approximate, as the
        //       correct position and size cannot be known until the monitor
        //       video mode has been set
        _glfwPlatformGetMonitorPos(wndconfig->monitor, &xpos, &ypos);
        _glfwPlatformGetVideoMode(wndconfig->monitor, &mode);
        fullWidth  = mode.width;
        fullHeight = mode.height;
    }
    else
    {
        xpos = CW_USEDEFAULT;
        ypos = CW_USEDEFAULT;

        getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
                          wndconfig->width, wndconfig->height,
                          &fullWidth, &fullHeight);
    }

    wideTitle = _glfwCreateWideStringFromUTF8(wndconfig->title);
    if (!wideTitle)
    {
        _glfwInputError(GLFW_PLATFORM_ERROR,
                        "Win32: Failed to convert window title to UTF-16");
        return GLFW_FALSE;
    }

    window->win32.handle = CreateWindowExW(getWindowExStyle(window),
                                           _GLFW_WNDCLASSNAME,
                                           wideTitle,
                                           getWindowStyle(window),
                                           xpos, ypos,
                                           fullWidth, fullHeight,
                                           NULL, // No parent window
                                           NULL, // No window menu
                                           GetModuleHandleW(NULL),
                                           window); // Pass object to WM_CREATE

    free(wideTitle);

    if (!window->win32.handle)
    {
        _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to create window");
        return GLFW_FALSE;
    }

    if (_glfw_ChangeWindowMessageFilterEx)
    {
        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
                                          WM_DROPFILES, MSGFLT_ALLOW, NULL);
        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
                                          WM_COPYDATA, MSGFLT_ALLOW, NULL);
        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
                                          WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
    }

    if (wndconfig->floating && !wndconfig->monitor)
    {
        SetWindowPos(window->win32.handle,
                     HWND_TOPMOST,
                     0, 0, 0, 0,
                     SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
    }

    DragAcceptFiles(window->win32.handle, TRUE);

    if (!_glfwCreateContext(window, ctxconfig, fbconfig))
        return GLFW_FALSE;

    window->win32.minwidth  = GLFW_DONT_CARE;
    window->win32.minheight = GLFW_DONT_CARE;
    window->win32.maxwidth  = GLFW_DONT_CARE;
    window->win32.maxheight = GLFW_DONT_CARE;
    window->win32.numer     = GLFW_DONT_CARE;
    window->win32.denom     = GLFW_DONT_CARE;

    return GLFW_TRUE;
}
예제 #9
0
파일: win32_window.c 프로젝트: edensal/glfw
int _glfwPlatformCreateWindow(_GLFWwindow* window,
                              const _GLFWwndconfig* wndconfig,
                              const _GLFWctxconfig* ctxconfig,
                              const _GLFWfbconfig* fbconfig)
{
    int status;

    if (!createWindow(window, wndconfig))
        return GLFW_FALSE;

    if (ctxconfig->api != GLFW_NO_API)
    {
        if (!_glfwCreateContext(window, ctxconfig, fbconfig))
            return GLFW_FALSE;

#if defined(_GLFW_WGL)
        status = _glfwAnalyzeContext(window, ctxconfig, fbconfig);

        if (status == _GLFW_RECREATION_IMPOSSIBLE)
            return GLFW_FALSE;

        if (status == _GLFW_RECREATION_REQUIRED)
        {
            // Some window hints require us to re-create the context using WGL
            // extensions retrieved through the current context, as we cannot
            // check for WGL extensions or retrieve WGL entry points before we
            // have a current context (actually until we have implicitly loaded
            // the vendor ICD)

            // Yes, this is strange, and yes, this is the proper way on WGL

            // As Windows only allows you to set the pixel format once for
            // a window, we need to destroy the current window and create a new
            // one to be able to use the new pixel format

            // Technically, it may be possible to keep the old window around if
            // we're just creating an OpenGL 3.0+ context with the same pixel
            // format, but it's not worth the added code complexity

            // First we clear the current context (the one we just created)
            // This is usually done by glfwDestroyWindow, but as we're not doing
            // full GLFW window destruction, it's duplicated here
            _glfwPlatformMakeContextCurrent(NULL);

            // Next destroy the Win32 window and WGL context (without resetting
            // or destroying the GLFW window object)
            _glfwDestroyContext(window);
            destroyWindow(window);

            // ...and then create them again, this time with better APIs
            if (!createWindow(window, wndconfig))
                return GLFW_FALSE;
            if (!_glfwCreateContext(window, ctxconfig, fbconfig))
                return GLFW_FALSE;
        }
#endif // _GLFW_WGL
    }
    
    if (wndconfig->fullscreen)
    {
        _glfwPlatformShowWindow(window);
        if (!enterFullscreenMode(window))
            return GLFW_FALSE;
    }

    return GLFW_TRUE;
}