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