From 62fe7e9a9d0e211bc2ad4cdfedb2489c5f899133 Mon Sep 17 00:00:00 2001 From: Tomoaki Kawada Date: Sat, 1 Jun 2019 17:54:07 +0200 Subject: GPU: support default framebuffer with ID not equal to 0 --- intern/ghost/GHOST_C-api.h | 5 +++++ intern/ghost/GHOST_IWindow.h | 6 ++++++ intern/ghost/intern/GHOST_C-api.cpp | 7 +++++++ intern/ghost/intern/GHOST_Context.h | 9 +++++++++ intern/ghost/intern/GHOST_Window.cpp | 5 +++++ intern/ghost/intern/GHOST_Window.h | 6 ++++++ 6 files changed, 38 insertions(+) (limited to 'intern') diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index 3238be8fd87..ea9d6925e23 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -721,6 +721,11 @@ extern GHOST_TSuccess GHOST_ActivateOpenGLContext(GHOST_ContextHandle contexthan */ extern GHOST_TSuccess GHOST_ReleaseOpenGLContext(GHOST_ContextHandle contexthandle); +/** + * Get the OpenGL framebuffer handle that serves as a default framebuffer. + */ +extern unsigned int GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windwHandle); + /** * Set which tablet API to use. Only affects Windows, other platforms have a single API. * \param systemhandle The handle to the system diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h index 8042244c536..52894a7c38d 100644 --- a/intern/ghost/GHOST_IWindow.h +++ b/intern/ghost/GHOST_IWindow.h @@ -217,6 +217,12 @@ class GHOST_IWindow { */ virtual GHOST_TSuccess activateDrawingContext() = 0; + /** + * Gets the OpenGL framebuffer associated with the window's contents. + * \return The name of an OpenGL framebuffer object. + */ + virtual unsigned int getDefaultFramebuffer() = 0; + /** * Invalidates the contents of this window. * \return Indication of success. diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index 38ddf9819f9..ef653c114e8 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -633,6 +633,13 @@ GHOST_TSuccess GHOST_ReleaseOpenGLContext(GHOST_ContextHandle contexthandle) return context->releaseDrawingContext(); } +unsigned int GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windowhandle) +{ + GHOST_IWindow *window = (GHOST_IWindow *)windowhandle; + + return window->getDefaultFramebuffer(); +} + GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle) { GHOST_IWindow *window = (GHOST_IWindow *)windowhandle; diff --git a/intern/ghost/intern/GHOST_Context.h b/intern/ghost/intern/GHOST_Context.h index 7937fd1f7c7..bbf6d6a510d 100644 --- a/intern/ghost/intern/GHOST_Context.h +++ b/intern/ghost/intern/GHOST_Context.h @@ -119,6 +119,15 @@ class GHOST_Context : public GHOST_IContext { return m_stereoVisual; } + /** + * Gets the OpenGL framebuffer associated with the OpenGL context + * \return The ID of an OpenGL framebuffer object. + */ + virtual unsigned int getDefaultFramebuffer() + { + return 0; + } + protected: void initContextGLEW(); diff --git a/intern/ghost/intern/GHOST_Window.cpp b/intern/ghost/intern/GHOST_Window.cpp index 5649386063d..76f2d2347db 100644 --- a/intern/ghost/intern/GHOST_Window.cpp +++ b/intern/ghost/intern/GHOST_Window.cpp @@ -109,6 +109,11 @@ GHOST_TSuccess GHOST_Window::getSwapInterval(int &intervalOut) return m_context->getSwapInterval(intervalOut); } +unsigned int GHOST_Window::getDefaultFramebuffer() +{ + return (m_context) ? m_context->getDefaultFramebuffer() : 0; +} + GHOST_TSuccess GHOST_Window::activateDrawingContext() { return m_context->activateDrawingContext(); diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h index acd0c93ff87..50a563453f6 100644 --- a/intern/ghost/intern/GHOST_Window.h +++ b/intern/ghost/intern/GHOST_Window.h @@ -261,6 +261,12 @@ class GHOST_Window : public GHOST_IWindow { */ GHOST_TSuccess updateDrawingContext(); + /** + * Gets the OpenGL framebuffer associated with the window's contents. + * \return The ID of an OpenGL framebuffer object. + */ + virtual unsigned int getDefaultFramebuffer(); + /** * Returns the window user data. * \return The window user data. -- cgit v1.2.3