mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
internal/glfw: reduce TLS usages at refreshContextAttribs
This commit is contained in:
parent
02e87d027c
commit
18d3d91195
@ -326,7 +326,6 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig)
|
||||
{
|
||||
int i;
|
||||
_GLFWwindow* previous;
|
||||
const char* version;
|
||||
const char* prefixes[] =
|
||||
{
|
||||
@ -339,10 +338,9 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
||||
window->context.source = ctxconfig->source;
|
||||
window->context.client = GLFW_OPENGL_API;
|
||||
|
||||
previous = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
// In Ebitengine, only one window is created.
|
||||
// Always assume that the current context is not set.
|
||||
glfwMakeContextCurrent((GLFWwindow*) window);
|
||||
if (_glfwPlatformGetTls(&_glfw.contextSlot) != window)
|
||||
return GLFW_FALSE;
|
||||
|
||||
window->context.GetIntegerv = (PFNGLGETINTEGERVPROC)
|
||||
window->context.getProcAddress("glGetIntegerv");
|
||||
@ -351,7 +349,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
||||
if (!window->context.GetIntegerv || !window->context.GetString)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Entry point retrieval is broken");
|
||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||
glfwMakeContextCurrent(NULL);
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
@ -369,7 +367,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
||||
"OpenGL ES version string retrieval is broken");
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||
glfwMakeContextCurrent(NULL);
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
@ -401,7 +399,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
||||
"No version found in OpenGL ES version string");
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||
glfwMakeContextCurrent(NULL);
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
@ -431,7 +429,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
||||
window->context.major, window->context.minor);
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||
glfwMakeContextCurrent(NULL);
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
@ -447,7 +445,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Entry point retrieval is broken");
|
||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||
glfwMakeContextCurrent(NULL);
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
}
|
||||
@ -556,7 +554,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
||||
window->context.swapBuffers(window);
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||
glfwMakeContextCurrent(NULL);
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
|
@ -252,13 +252,10 @@ func (w *Window) refreshContextAttribs(ctxconfig *ctxconfig) (ferr error) {
|
||||
w.context.source = ctxconfig.source
|
||||
w.context.client = OpenGLAPI
|
||||
|
||||
p1, err := _glfw.contextSlot.get()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
previous := (*Window)(unsafe.Pointer(p1))
|
||||
// In Ebitengine, only one window is created.
|
||||
// Always assume that the current context is not set.
|
||||
defer func() {
|
||||
err := previous.MakeContextCurrent()
|
||||
err := (*Window)(nil).MakeContextCurrent()
|
||||
if ferr == nil {
|
||||
ferr = err
|
||||
}
|
||||
@ -267,14 +264,6 @@ func (w *Window) refreshContextAttribs(ctxconfig *ctxconfig) (ferr error) {
|
||||
return err
|
||||
}
|
||||
|
||||
p2, err := _glfw.contextSlot.get()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (*Window)(unsafe.Pointer(p2)) != w {
|
||||
return nil
|
||||
}
|
||||
|
||||
getIntegerv := w.context.getProcAddress("glGetIntegerv")
|
||||
getString := w.context.getProcAddress("glGetString")
|
||||
if getIntegerv == 0 || getString == 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user