mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 18:58:52 -05:00
Fixed EGLConfig nomenclature, simplified refresh.
This commit is contained in:
parent
0f4cdd5194
commit
ea1506ba67
|
@ -38,10 +38,10 @@
|
||||||
// Returns the specified attribute of the specified EGLConfig
|
// Returns the specified attribute of the specified EGLConfig
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static int getFBConfigAttrib(EGLConfig fbconfig, int attrib)
|
static int getConfigAttrib(EGLConfig config, int attrib)
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
eglGetConfigAttrib(_glfwLibrary.EGL.display, fbconfig, attrib, &value);
|
eglGetConfigAttrib(_glfwLibrary.EGL.display, config, attrib, &value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
unsigned int* found)
|
unsigned int* found)
|
||||||
{
|
{
|
||||||
EGLConfig* fbconfigs;
|
EGLConfig* configs;
|
||||||
_GLFWfbconfig* result;
|
_GLFWfbconfig* result;
|
||||||
int i, count = 0;
|
int i, count = 0;
|
||||||
|
|
||||||
|
@ -62,17 +62,17 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window,
|
||||||
|
|
||||||
eglGetConfigs(_glfwLibrary.EGL.display, NULL, 0, &count);
|
eglGetConfigs(_glfwLibrary.EGL.display, NULL, 0, &count);
|
||||||
|
|
||||||
fbconfigs = (EGLConfig*) malloc(sizeof(EGLConfig) * count);
|
configs = (EGLConfig*) malloc(sizeof(EGLConfig) * count);
|
||||||
if (!fbconfigs)
|
if (!configs)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_OUT_OF_MEMORY, NULL);
|
_glfwSetError(GLFW_OUT_OF_MEMORY, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
eglGetConfigs(_glfwLibrary.EGL.display, fbconfigs, count, &count);
|
eglGetConfigs(_glfwLibrary.EGL.display, configs, count, &count);
|
||||||
if (!count)
|
if (!count)
|
||||||
{
|
{
|
||||||
free(fbconfigs);
|
free(configs);
|
||||||
|
|
||||||
_glfwSetError(GLFW_OPENGL_UNAVAILABLE,
|
_glfwSetError(GLFW_OPENGL_UNAVAILABLE,
|
||||||
"X11/EGL: No EGLConfigs returned");
|
"X11/EGL: No EGLConfigs returned");
|
||||||
|
@ -82,7 +82,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window,
|
||||||
result = (_GLFWfbconfig*) malloc(sizeof(_GLFWfbconfig) * count);
|
result = (_GLFWfbconfig*) malloc(sizeof(_GLFWfbconfig) * count);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
free(fbconfigs);
|
free(configs);
|
||||||
|
|
||||||
_glfwSetError(GLFW_OUT_OF_MEMORY, NULL);
|
_glfwSetError(GLFW_OUT_OF_MEMORY, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -92,55 +92,54 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window,
|
||||||
{
|
{
|
||||||
_GLFWfbconfig* f = result + *found;
|
_GLFWfbconfig* f = result + *found;
|
||||||
|
|
||||||
if (!getFBConfigAttrib(fbconfigs[i], EGL_NATIVE_VISUAL_ID))
|
if (!getConfigAttrib(configs[i], EGL_NATIVE_VISUAL_ID))
|
||||||
{
|
{
|
||||||
// Only consider EGLConfigs with associated visuals
|
// Only consider EGLConfigs with associated visuals
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(getFBConfigAttrib(fbconfigs[i],
|
if (!(getConfigAttrib(configs[i], EGL_COLOR_BUFFER_TYPE) & EGL_RGB_BUFFER))
|
||||||
EGL_COLOR_BUFFER_TYPE) & EGL_RGB_BUFFER))
|
|
||||||
{
|
{
|
||||||
// Only consider RGB(A) EGLConfigs
|
// Only consider RGB(A) EGLConfigs
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(getFBConfigAttrib(fbconfigs[i], EGL_SURFACE_TYPE) & EGL_WINDOW_BIT))
|
if (!(getConfigAttrib(configs[i], EGL_SURFACE_TYPE) & EGL_WINDOW_BIT))
|
||||||
{
|
{
|
||||||
// Only consider window EGLConfigs
|
// Only consider window EGLConfigs
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(getFBConfigAttrib(fbconfigs[i], EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES_BIT) &&
|
if (!(getConfigAttrib(configs[i], EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES_BIT) &&
|
||||||
!(getFBConfigAttrib(fbconfigs[i], EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT))
|
!(getConfigAttrib(configs[i], EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT))
|
||||||
{
|
{
|
||||||
// Only consider OpenGL ES context
|
// Only consider OpenGL ES context
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glProfile == GLFW_OPENGL_ES2_PROFILE &&
|
if (wndconfig->glProfile == GLFW_OPENGL_ES2_PROFILE &&
|
||||||
!(getFBConfigAttrib(fbconfigs[i], EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT))
|
!(getConfigAttrib(configs[i], EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT))
|
||||||
{
|
{
|
||||||
// User requested only OpenGL ES 2.0 context
|
// User requested only OpenGL ES 2.0 context
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
f->redBits = getFBConfigAttrib(fbconfigs[i], EGL_RED_SIZE);
|
f->redBits = getConfigAttrib(configs[i], EGL_RED_SIZE);
|
||||||
f->greenBits = getFBConfigAttrib(fbconfigs[i], EGL_GREEN_SIZE);
|
f->greenBits = getConfigAttrib(configs[i], EGL_GREEN_SIZE);
|
||||||
f->blueBits = getFBConfigAttrib(fbconfigs[i], EGL_BLUE_SIZE);
|
f->blueBits = getConfigAttrib(configs[i], EGL_BLUE_SIZE);
|
||||||
|
|
||||||
f->alphaBits = getFBConfigAttrib(fbconfigs[i], EGL_ALPHA_SIZE);
|
f->alphaBits = getConfigAttrib(configs[i], EGL_ALPHA_SIZE);
|
||||||
f->depthBits = getFBConfigAttrib(fbconfigs[i], EGL_DEPTH_SIZE);
|
f->depthBits = getConfigAttrib(configs[i], EGL_DEPTH_SIZE);
|
||||||
f->stencilBits = getFBConfigAttrib(fbconfigs[i], EGL_STENCIL_SIZE);
|
f->stencilBits = getConfigAttrib(configs[i], EGL_STENCIL_SIZE);
|
||||||
|
|
||||||
f->samples = getFBConfigAttrib(fbconfigs[i], EGL_SAMPLES);
|
f->samples = getConfigAttrib(configs[i], EGL_SAMPLES);
|
||||||
|
|
||||||
f->platformID = (GLFWintptr) getFBConfigAttrib(fbconfigs[i], EGL_CONFIG_ID);
|
f->platformID = (GLFWintptr) getConfigAttrib(configs[i], EGL_CONFIG_ID);
|
||||||
|
|
||||||
(*found)++;
|
(*found)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(fbconfigs);
|
free(configs);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,37 +148,21 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window,
|
||||||
// Read back framebuffer parameters from the context
|
// Read back framebuffer parameters from the context
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void refreshContextParams(_GLFWwindow* window, EGLint fbconfigID)
|
static void refreshContextParams(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
EGLint count;
|
|
||||||
EGLConfig fbconfig;
|
|
||||||
|
|
||||||
int attribs[] = { EGL_CONFIG_ID, fbconfigID, EGL_NONE, EGL_NONE };
|
|
||||||
|
|
||||||
eglChooseConfig(_glfwLibrary.EGL.display, attribs, &fbconfig, 1, &count);
|
|
||||||
if (!count)
|
|
||||||
{
|
|
||||||
// This should never ever happen
|
|
||||||
// TODO: Flag this as an error and propagate up
|
|
||||||
_glfwSetError(GLFW_PLATFORM_ERROR, "X11/EGL: Cannot find known "
|
|
||||||
"EGLConfig by ID. This cannot "
|
|
||||||
"happen. Have a nice day.\n");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
// There is no clear definition of an "accelerated" context on X11/EGL, and
|
// There is no clear definition of an "accelerated" context on X11/EGL, and
|
||||||
// true sounds better than false, so we hardcode true here
|
// true sounds better than false, so we hardcode true here
|
||||||
window->accelerated = GL_TRUE;
|
window->accelerated = GL_TRUE;
|
||||||
|
|
||||||
window->redBits = getFBConfigAttrib(fbconfig, EGL_RED_SIZE);
|
window->redBits = getConfigAttrib(window->EGL.config, EGL_RED_SIZE);
|
||||||
window->greenBits = getFBConfigAttrib(fbconfig, EGL_GREEN_SIZE);
|
window->greenBits = getConfigAttrib(window->EGL.config, EGL_GREEN_SIZE);
|
||||||
window->blueBits = getFBConfigAttrib(fbconfig, EGL_BLUE_SIZE);
|
window->blueBits = getConfigAttrib(window->EGL.config, EGL_BLUE_SIZE);
|
||||||
|
|
||||||
window->alphaBits = getFBConfigAttrib(fbconfig, EGL_ALPHA_SIZE);
|
window->alphaBits = getConfigAttrib(window->EGL.config, EGL_ALPHA_SIZE);
|
||||||
window->depthBits = getFBConfigAttrib(fbconfig, EGL_DEPTH_SIZE);
|
window->depthBits = getConfigAttrib(window->EGL.config, EGL_DEPTH_SIZE);
|
||||||
window->stencilBits = getFBConfigAttrib(fbconfig, EGL_STENCIL_SIZE);
|
window->stencilBits = getConfigAttrib(window->EGL.config, EGL_STENCIL_SIZE);
|
||||||
|
|
||||||
window->samples = getFBConfigAttrib(fbconfig, EGL_SAMPLES);
|
window->samples = getConfigAttrib(window->EGL.config, EGL_SAMPLES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,7 +181,7 @@ static int createContext(_GLFWwindow* window,
|
||||||
int attribs[40], visMask;
|
int attribs[40], visMask;
|
||||||
EGLint count, index, visualID = 0;
|
EGLint count, index, visualID = 0;
|
||||||
EGLint red_size, green_size, blue_size, alpha_size;
|
EGLint red_size, green_size, blue_size, alpha_size;
|
||||||
EGLConfig fbconfig;
|
EGLConfig config;
|
||||||
EGLContext share = NULL;
|
EGLContext share = NULL;
|
||||||
XVisualInfo visTemplate;
|
XVisualInfo visTemplate;
|
||||||
|
|
||||||
|
@ -212,7 +195,7 @@ static int createContext(_GLFWwindow* window,
|
||||||
setEGLattrib(attribs, index, EGL_CONFIG_ID, fbconfigID);
|
setEGLattrib(attribs, index, EGL_CONFIG_ID, fbconfigID);
|
||||||
setEGLattrib(attribs, index, EGL_NONE, EGL_NONE);
|
setEGLattrib(attribs, index, EGL_NONE, EGL_NONE);
|
||||||
|
|
||||||
eglChooseConfig(_glfwLibrary.EGL.display, attribs, &fbconfig, 1, &count);
|
eglChooseConfig(_glfwLibrary.EGL.display, attribs, &config, 1, &count);
|
||||||
if (!count)
|
if (!count)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||||
|
@ -224,7 +207,7 @@ 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, fbconfig, EGL_NATIVE_VISUAL_ID, &visualID);
|
eglGetConfigAttrib(_glfwLibrary.EGL.display, config, EGL_NATIVE_VISUAL_ID, &visualID);
|
||||||
|
|
||||||
// Init visual template
|
// Init visual template
|
||||||
visTemplate.screen = _glfwLibrary.X11.screen;
|
visTemplate.screen = _glfwLibrary.X11.screen;
|
||||||
|
@ -241,13 +224,13 @@ static int createContext(_GLFWwindow* window,
|
||||||
// some EGL drivers don't implement the EGL_NATIVE_VISUAL_ID
|
// some EGL drivers don't implement the EGL_NATIVE_VISUAL_ID
|
||||||
// attribute, so attempt to find the closest match.
|
// attribute, so attempt to find the closest match.
|
||||||
|
|
||||||
eglGetConfigAttrib(_glfwLibrary.EGL.display, fbconfig,
|
eglGetConfigAttrib(_glfwLibrary.EGL.display, config,
|
||||||
EGL_RED_SIZE, &red_size);
|
EGL_RED_SIZE, &red_size);
|
||||||
eglGetConfigAttrib(_glfwLibrary.EGL.display, fbconfig,
|
eglGetConfigAttrib(_glfwLibrary.EGL.display, config,
|
||||||
EGL_GREEN_SIZE, &green_size);
|
EGL_GREEN_SIZE, &green_size);
|
||||||
eglGetConfigAttrib(_glfwLibrary.EGL.display, fbconfig,
|
eglGetConfigAttrib(_glfwLibrary.EGL.display, config,
|
||||||
EGL_BLUE_SIZE, &blue_size);
|
EGL_BLUE_SIZE, &blue_size);
|
||||||
eglGetConfigAttrib(_glfwLibrary.EGL.display, fbconfig,
|
eglGetConfigAttrib(_glfwLibrary.EGL.display, config,
|
||||||
EGL_ALPHA_SIZE, &alpha_size);
|
EGL_ALPHA_SIZE, &alpha_size);
|
||||||
|
|
||||||
visTemplate.depth = red_size + green_size + blue_size + alpha_size;
|
visTemplate.depth = red_size + green_size + blue_size + alpha_size;
|
||||||
|
@ -279,7 +262,7 @@ static int createContext(_GLFWwindow* window,
|
||||||
eglBindAPI(EGL_OPENGL_ES_API);
|
eglBindAPI(EGL_OPENGL_ES_API);
|
||||||
|
|
||||||
window->EGL.context = eglCreateContext(_glfwLibrary.EGL.display,
|
window->EGL.context = eglCreateContext(_glfwLibrary.EGL.display,
|
||||||
fbconfig, share, attribs);
|
config, share, attribs);
|
||||||
|
|
||||||
if (window->EGL.context == EGL_NO_CONTEXT)
|
if (window->EGL.context == EGL_NO_CONTEXT)
|
||||||
{
|
{
|
||||||
|
@ -290,9 +273,8 @@ static int createContext(_GLFWwindow* window,
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->EGL.config = fbconfig;
|
window->EGL.config = config;
|
||||||
|
refreshContextParams(window);
|
||||||
refreshContextParams(window, fbconfigID);
|
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user