mirror of
https://github.com/glfw/glfw.git
synced 2024-11-11 13:03:52 +00:00
Further isolated X11-specific parts of EGL code.
This commit is contained in:
parent
0ca1e67d7a
commit
74488bec67
@ -163,12 +163,10 @@ static int createContext(_GLFWwindow* window,
|
|||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
EGLint fbconfigID)
|
EGLint fbconfigID)
|
||||||
{
|
{
|
||||||
int attribs[40], visMask;
|
int attribs[40];
|
||||||
EGLint count, index, visualID = 0;
|
EGLint count, index;
|
||||||
EGLint redBits, greenBits, blueBits, alphaBits;
|
|
||||||
EGLConfig config;
|
EGLConfig config;
|
||||||
EGLContext share = NULL;
|
EGLContext share = NULL;
|
||||||
XVisualInfo visTemplate;
|
|
||||||
|
|
||||||
if (wndconfig->share)
|
if (wndconfig->share)
|
||||||
share = wndconfig->share->EGL.context;
|
share = wndconfig->share->EGL.context;
|
||||||
@ -192,17 +190,23 @@ static int createContext(_GLFWwindow* window,
|
|||||||
// Retrieve the corresponding visual
|
// Retrieve the corresponding visual
|
||||||
// NOTE: This is the only non-portable code in this file.
|
// NOTE: This is the only non-portable code in this file.
|
||||||
// Maybe it would not hurt too much to add #ifdefs for different platforms?
|
// Maybe it would not hurt too much to add #ifdefs for different platforms?
|
||||||
eglGetConfigAttrib(_glfwLibrary.EGL.display, config, EGL_NATIVE_VISUAL_ID, &visualID);
|
#if defined(_GLFW_X11_EGL)
|
||||||
|
{
|
||||||
|
int mask;
|
||||||
|
EGLint redBits, greenBits, blueBits, alphaBits, visualID = 0;
|
||||||
|
XVisualInfo info;
|
||||||
|
|
||||||
// Init visual template
|
eglGetConfigAttrib(_glfwLibrary.EGL.display, config,
|
||||||
visTemplate.screen = _glfwLibrary.X11.screen;
|
EGL_NATIVE_VISUAL_ID, &visualID);
|
||||||
visMask = VisualScreenMask;
|
|
||||||
|
info.screen = _glfwLibrary.X11.screen;
|
||||||
|
mask = VisualScreenMask;
|
||||||
|
|
||||||
if (visualID)
|
if (visualID)
|
||||||
{
|
{
|
||||||
// The X window visual must match the EGL config
|
// The X window visual must match the EGL config
|
||||||
visTemplate.visualid = visualID;
|
info.visualid = visualID;
|
||||||
visMask |= VisualIDMask;
|
mask |= VisualIDMask;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -218,12 +222,12 @@ static int createContext(_GLFWwindow* window,
|
|||||||
eglGetConfigAttrib(_glfwLibrary.EGL.display, config,
|
eglGetConfigAttrib(_glfwLibrary.EGL.display, config,
|
||||||
EGL_ALPHA_SIZE, &alphaBits);
|
EGL_ALPHA_SIZE, &alphaBits);
|
||||||
|
|
||||||
visTemplate.depth = redBits + greenBits + blueBits + alphaBits;
|
info.depth = redBits + greenBits + blueBits + alphaBits;
|
||||||
visMask |= VisualDepthMask;
|
mask |= VisualDepthMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->EGL.visual = XGetVisualInfo(_glfwLibrary.X11.display,
|
window->EGL.visual = XGetVisualInfo(_glfwLibrary.X11.display,
|
||||||
visMask, &visTemplate, &count);
|
mask, &info, &count);
|
||||||
|
|
||||||
if (window->EGL.visual == NULL)
|
if (window->EGL.visual == NULL)
|
||||||
{
|
{
|
||||||
@ -231,6 +235,8 @@ static int createContext(_GLFWwindow* window,
|
|||||||
"EGL: Failed to retrieve visual for EGLConfig");
|
"EGL: Failed to retrieve visual for EGLConfig");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||||
{
|
{
|
||||||
@ -471,16 +477,6 @@ void _glfwDestroyContext(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Return the X visual associated with the specified context
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
XVisualInfo* _glfwGetContextVisual(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
return window->EGL.visual;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Make the OpenGL context associated with the specified window current
|
// Make the OpenGL context associated with the specified window current
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
@ -70,7 +70,10 @@ typedef struct _GLFWcontextEGL
|
|||||||
EGLConfig config;
|
EGLConfig config;
|
||||||
EGLContext context;
|
EGLContext context;
|
||||||
EGLSurface surface;
|
EGLSurface surface;
|
||||||
|
|
||||||
|
#if defined(_GLFW_X11_EGL)
|
||||||
XVisualInfo* visual;
|
XVisualInfo* visual;
|
||||||
|
#endif
|
||||||
} _GLFWcontextEGL;
|
} _GLFWcontextEGL;
|
||||||
|
|
||||||
|
|
||||||
|
@ -611,16 +611,6 @@ void _glfwDestroyContext(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Return the X visual associated with the specified context
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
XVisualInfo* _glfwGetContextVisual(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
return window->GLX.visual;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Make the OpenGL context associated with the specified window current
|
// Make the OpenGL context associated with the specified window current
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
@ -54,8 +54,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_GLFW_X11_GLX)
|
#if defined(_GLFW_X11_GLX)
|
||||||
|
#define _GLFW_X11_CONTEXT_VISUAL window->GLX.visual
|
||||||
#include "x11_glx_platform.h"
|
#include "x11_glx_platform.h"
|
||||||
#elif defined(_GLFW_X11_EGL)
|
#elif defined(_GLFW_X11_EGL)
|
||||||
|
#define _GLFW_X11_CONTEXT_VISUAL window->EGL.visual
|
||||||
#define _GLFW_EGL_NATIVE_WINDOW window->X11.handle
|
#define _GLFW_EGL_NATIVE_WINDOW window->X11.handle
|
||||||
#define _GLFW_EGL_NATIVE_DISPLAY _glfwLibrary.X11.display
|
#define _GLFW_EGL_NATIVE_DISPLAY _glfwLibrary.X11.display
|
||||||
#include "x11_egl_platform.h"
|
#include "x11_egl_platform.h"
|
||||||
@ -225,7 +227,6 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
const _GLFWfbconfig* fbconfig);
|
const _GLFWfbconfig* fbconfig);
|
||||||
void _glfwDestroyContext(_GLFWwindow* window);
|
void _glfwDestroyContext(_GLFWwindow* window);
|
||||||
XVisualInfo* _glfwGetContextVisual(_GLFWwindow* window);
|
|
||||||
|
|
||||||
// Fullscreen support
|
// Fullscreen support
|
||||||
int _glfwGetClosestVideoMode(int* width, int* height, int* rate);
|
int _glfwGetClosestVideoMode(int* width, int* height, int* rate);
|
||||||
|
@ -83,7 +83,7 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
unsigned long wamask;
|
unsigned long wamask;
|
||||||
XSetWindowAttributes wa;
|
XSetWindowAttributes wa;
|
||||||
XVisualInfo* visual = _glfwGetContextVisual(window);
|
XVisualInfo* visual = _GLFW_X11_CONTEXT_VISUAL;
|
||||||
|
|
||||||
// Every window needs a colormap
|
// Every window needs a colormap
|
||||||
// Create one based on the visual used by the current context
|
// Create one based on the visual used by the current context
|
||||||
|
Loading…
Reference in New Issue
Block a user