From 4be2543f1e0e92d87fd83b9b8ddb3b6f0e651367 Mon Sep 17 00:00:00 2001 From: jgcodes2020 Date: Sun, 30 Jul 2023 21:47:07 -0400 Subject: [PATCH] begin work on window attachment --- src/internal.h | 2 ++ src/window.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/internal.h b/src/internal.h index fe0369aa..2af37d86 100644 --- a/src/internal.h +++ b/src/internal.h @@ -532,6 +532,7 @@ struct _GLFWwindow GLFWbool focusOnShow; GLFWbool mousePassthrough; GLFWbool shouldClose; + GLFWbool external; void* userPointer; GLFWbool doublebuffer; GLFWvidmode videoMode; @@ -706,6 +707,7 @@ struct _GLFWplatform void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*); // window GLFWbool (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*); + GLFWbool (*attachWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*); void (*destroyWindow)(_GLFWwindow*); void (*setWindowTitle)(_GLFWwindow*,const char*); void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*); diff --git a/src/window.c b/src/window.c index 1c8519ff..09a80d00 100644 --- a/src/window.c +++ b/src/window.c @@ -254,6 +254,50 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, return (GLFWwindow*) window; } +GLFWAPI GLFWwindow* glfwAttachWindow(intptr_t nativeWindow, GLFWwindow* share) { + _GLFWfbconfig fbconfig; + _GLFWctxconfig ctxconfig; + _GLFWwndconfig wndconfig; + _GLFWwindow* window; + + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + + fbconfig = _glfw.hints.framebuffer; + ctxconfig = _glfw.hints.context; + wndconfig = _glfw.hints.window; + + ctxconfig.share = (_GLFWwindow*) share; + if (ctxconfig.share) + { + if (ctxconfig.client == GLFW_NO_API || + ctxconfig.share->context.client == GLFW_NO_API) + { + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + return NULL; + } + } + + if (!_glfwIsValidContextConfig(&ctxconfig)) + return NULL; + + window = calloc(1, sizeof(_GLFWwindow)); + window->next = _glfw.windowListHead; + _glfw.windowListHead = window; + + window->autoIconify = wndconfig.autoIconify; + window->cursorMode = GLFW_CURSOR_NORMAL; + window->external = true; + + window->minwidth = GLFW_DONT_CARE; + window->minheight = GLFW_DONT_CARE; + window->maxwidth = GLFW_DONT_CARE; + window->maxheight = GLFW_DONT_CARE; + window->numer = GLFW_DONT_CARE; + window->denom = GLFW_DONT_CARE; + +// if (!_glfw.platform.attachWindow()) +} + void glfwDefaultWindowHints(void) { _GLFW_REQUIRE_INIT();