diff --git a/CMakeLists.txt b/CMakeLists.txt index 398b36eb1..2cf901ae4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ include(GNUInstallDirs) include(CMakeDependentOption) if (GLFW_USE_OSMESA) - message(FATAL_ERROR "GLFW_USE_OSMESA has been removed; set the GLFW_PLATFORM init hint") + message(FATAL_ERROR "OSMesa support has been removed") endif() if (DEFINED GLFW_USE_WAYLAND AND UNIX AND NOT APPLE) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 27c4b3f67..b4b364879 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -2312,7 +2312,6 @@ PREDEFINED = GLFWAPI= \ GLFW_EXPOSE_NATIVE_COCOA \ GLFW_EXPOSE_NATIVE_NSGL \ GLFW_EXPOSE_NATIVE_EGL \ - GLFW_EXPOSE_NATIVE_OSMESA \ VK_VERSION_1_0 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this diff --git a/docs/compile.md b/docs/compile.md index 3b10ea575..56e5d46fd 100644 --- a/docs/compile.md +++ b/docs/compile.md @@ -359,10 +359,10 @@ attempts to detect the appropriate platform at initialization. If you are building GLFW as a shared library / dynamic library / DLL then you must also define @b _GLFW_BUILD_DLL. Otherwise, you must not define it. -If you are using a custom name for the Vulkan, EGL, GLX, OSMesa, OpenGL, GLESv1 +If you are using a custom name for the Vulkan, EGL, GLX, OpenGL, GLESv1 or GLESv2 library, you can override the default names by defining those you need of @b _GLFW_VULKAN_LIBRARY, @b _GLFW_EGL_LIBRARY, @b _GLFW_GLX_LIBRARY, @b -_GLFW_OSMESA_LIBRARY, @b _GLFW_OPENGL_LIBRARY, @b _GLFW_GLESV1_LIBRARY and @b +_GLFW_OPENGL_LIBRARY, @b _GLFW_GLESV1_LIBRARY and @b _GLFW_GLESV2_LIBRARY. Otherwise, GLFW will use the built-in default names. @note None of the @ref build_macros may be defined during the compilation of diff --git a/docs/intro.md b/docs/intro.md index e09989e03..3b0d59a73 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -618,20 +618,20 @@ The format of the string is as follows: - For each supported platform: - The name of the window system API - The name of the window system specific context creation API, if applicable - - The names of the always supported context creation APIs EGL and OSMesa + - The names of the always supported context creation APIs and EGL - Any additional compile-time options, APIs and (on Windows) what compiler was used For example, compiling GLFW 3.5 with MinGW-64 as a DLL for Windows, may result in a version string like this: ```c -3.5.0 Win32 WGL Null EGL OSMesa MinGW-w64 DLL +3.5.0 Win32 WGL Null EGL MinGW-w64 DLL ``` Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may result in a version string like this: ```c -3.5.0 Wayland X11 GLX Null EGL OSMesa monotonic +3.5.0 Wayland X11 GLX Null EGL monotonic ``` diff --git a/docs/window.md b/docs/window.md index 2140f0975..2d8c52521 100644 --- a/docs/window.md +++ b/docs/window.md @@ -354,9 +354,9 @@ This is a hard constraint. @anchor GLFW_CONTEXT_CREATION_API_hint __GLFW_CONTEXT_CREATION_API__ specifies which context creation API to use to -create the context. Possible values are `GLFW_NATIVE_CONTEXT_API`, -`GLFW_EGL_CONTEXT_API` and `GLFW_OSMESA_CONTEXT_API`. This is a hard -constraint. If no client API is requested, this hint is ignored. +create the context. Possible values are `GLFW_NATIVE_CONTEXT_API` and +`GLFW_EGL_CONTEXT_API`. This is a hard constraint. If no client API is requested, +this hint is ignored. An [extension loader library](@ref context_glext_auto) that assumes it knows which API was used to create the current context may fail if you change this @@ -370,11 +370,6 @@ will have no effect. APIs in a single process will cause the application to segfault. Stick to one API or the other on Linux for now. -@note __OSMesa:__ As its name implies, an OpenGL context created with OSMesa -does not update the window contents when its buffers are swapped. Use OpenGL -functions or the OSMesa native access functions @ref glfwGetOSMesaColorBuffer -and @ref glfwGetOSMesaDepthBuffer to retrieve the framebuffer contents. - @anchor GLFW_CONTEXT_VERSION_MAJOR_hint @anchor GLFW_CONTEXT_VERSION_MINOR_hint __GLFW_CONTEXT_VERSION_MAJOR__ and __GLFW_CONTEXT_VERSION_MINOR__ specify the @@ -565,7 +560,7 @@ GLFW_STEREO | `GLFW_FALSE` | `GLFW_TRUE` or `GL GLFW_SRGB_CAPABLE | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_DOUBLEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_CLIENT_API | `GLFW_OPENGL_API` | `GLFW_OPENGL_API`, `GLFW_OPENGL_ES_API` or `GLFW_NO_API` -GLFW_CONTEXT_CREATION_API | `GLFW_NATIVE_CONTEXT_API` | `GLFW_NATIVE_CONTEXT_API`, `GLFW_EGL_CONTEXT_API` or `GLFW_OSMESA_CONTEXT_API` +GLFW_CONTEXT_CREATION_API | `GLFW_NATIVE_CONTEXT_API` | `GLFW_NATIVE_CONTEXT_API` or `GLFW_EGL_CONTEXT_API` GLFW_CONTEXT_VERSION_MAJOR | 1 | Any valid major version number of the chosen client API GLFW_CONTEXT_VERSION_MINOR | 0 | Any valid minor version number of the chosen client API GLFW_CONTEXT_ROBUSTNESS | `GLFW_NO_ROBUSTNESS` | `GLFW_NO_ROBUSTNESS`, `GLFW_NO_RESET_NOTIFICATION` or `GLFW_LOSE_CONTEXT_ON_RESET` @@ -1407,8 +1402,7 @@ either `GLFW_OPENGL_API`, `GLFW_OPENGL_ES_API` or `GLFW_NO_API`. @anchor GLFW_CONTEXT_CREATION_API_attrib __GLFW_CONTEXT_CREATION_API__ indicates the context creation API used to create -the window's context; either `GLFW_NATIVE_CONTEXT_API`, `GLFW_EGL_CONTEXT_API` -or `GLFW_OSMESA_CONTEXT_API`. +the window's context; either `GLFW_NATIVE_CONTEXT_API` or `GLFW_EGL_CONTEXT_API`. @anchor GLFW_CONTEXT_VERSION_MAJOR_attrib @anchor GLFW_CONTEXT_VERSION_MINOR_attrib diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 8db2cfa3b..ed6d72005 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -68,7 +68,6 @@ extern "C" { * * `GLFW_EXPOSE_NATIVE_NSGL` * * `GLFW_EXPOSE_NATIVE_GLX` * * `GLFW_EXPOSE_NATIVE_EGL` - * * `GLFW_EXPOSE_NATIVE_OSMESA` * * These macros select which of the native access functions that are declared * and which platform-specific headers to include. It is then up your (by @@ -143,17 +142,6 @@ extern "C" { #if defined(GLFW_EXPOSE_NATIVE_EGL) #include #endif - #if defined(GLFW_EXPOSE_NATIVE_OSMESA) - /* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by - * default it also acts as an OpenGL header - * However, osmesa.h will include gl.h, which will define it unconditionally - */ - #if defined(GLFW_GLAPIENTRY_DEFINED) - #undef GLAPIENTRY - #undef GLFW_GLAPIENTRY_DEFINED - #endif - #include - #endif #endif /*GLFW_NATIVE_INCLUDE_NONE*/ @@ -634,73 +622,6 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window); GLFWAPI int glfwGetEGLConfig(GLFWwindow* window, EGLConfig* config); #endif -#if defined(GLFW_EXPOSE_NATIVE_OSMESA) -/*! @brief Retrieves the color buffer associated with the specified window. - * - * @param[in] window The window whose color buffer to retrieve. - * @param[out] width Where to store the width of the color buffer, or `NULL`. - * @param[out] height Where to store the height of the color buffer, or `NULL`. - * @param[out] format Where to store the OSMesa pixel format of the color - * buffer, or `NULL`. - * @param[out] buffer Where to store the address of the color buffer, or - * `NULL`. - * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_NO_WINDOW_CONTEXT. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.3. - * - * @ingroup native - */ -GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height, int* format, void** buffer); - -/*! @brief Retrieves the depth buffer associated with the specified window. - * - * @param[in] window The window whose depth buffer to retrieve. - * @param[out] width Where to store the width of the depth buffer, or `NULL`. - * @param[out] height Where to store the height of the depth buffer, or `NULL`. - * @param[out] bytesPerValue Where to store the number of bytes per depth - * buffer element, or `NULL`. - * @param[out] buffer Where to store the address of the depth buffer, or - * `NULL`. - * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_NO_WINDOW_CONTEXT. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.3. - * - * @ingroup native - */ -GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height, int* bytesPerValue, void** buffer); - -/*! @brief Returns the `OSMesaContext` of the specified window. - * - * @return The `OSMesaContext` of the specified window, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_NO_WINDOW_CONTEXT. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.3. - * - * @ingroup native - */ -GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window); -#endif - #ifdef __cplusplus } #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2cbe8a733..fba1bb3ec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,7 +4,7 @@ add_library(glfw ${GLFW_LIBRARY_TYPE} "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h" internal.h platform.h mappings.h context.c init.c input.c monitor.c platform.c vulkan.c window.c - egl_context.c osmesa_context.c null_platform.h null_joystick.h + egl_context.c null_platform.h null_joystick.h null_init.c null_monitor.c null_window.c null_joystick.c) # The time, thread and module code is shared between all backends on a given OS, diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 15dc4ec4c..6721ead8e 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -686,7 +686,6 @@ void _glfwTerminateCocoa(void) _glfwTerminateNSGL(); _glfwTerminateEGL(); - _glfwTerminateOSMesa(); } // autoreleasepool } diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 2bff22a6b..4dddef2cc 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -948,13 +948,6 @@ GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) return GLFW_FALSE; } - else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API) - { - if (!_glfwInitOSMesa()) - return GLFW_FALSE; - if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) - return GLFW_FALSE; - } if (!_glfwRefreshContextAttribs(window, ctxconfig)) return GLFW_FALSE; diff --git a/src/context.c b/src/context.c index f4fa63ad7..16a2cfbae 100644 --- a/src/context.c +++ b/src/context.c @@ -46,9 +46,14 @@ // GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig) { + if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API) + { + _glfwInputError(GLFW_API_UNAVAILABLE, "OSMesa support has been removed"); + return GLFW_FALSE; + } + if (ctxconfig->source != GLFW_NATIVE_CONTEXT_API && - ctxconfig->source != GLFW_EGL_CONTEXT_API && - ctxconfig->source != GLFW_OSMESA_CONTEXT_API) + ctxconfig->source != GLFW_EGL_CONTEXT_API) { _glfwInputError(GLFW_INVALID_ENUM, "Invalid context creation API 0x%08X", diff --git a/src/internal.h b/src/internal.h index de703740f..16ac2d7d3 100644 --- a/src/internal.h +++ b/src/internal.h @@ -240,35 +240,6 @@ typedef EGLSurface (APIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisp #define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT #define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT -#define OSMESA_RGBA 0x1908 -#define OSMESA_FORMAT 0x22 -#define OSMESA_DEPTH_BITS 0x30 -#define OSMESA_STENCIL_BITS 0x31 -#define OSMESA_ACCUM_BITS 0x32 -#define OSMESA_PROFILE 0x33 -#define OSMESA_CORE_PROFILE 0x34 -#define OSMESA_COMPAT_PROFILE 0x35 -#define OSMESA_CONTEXT_MAJOR_VERSION 0x36 -#define OSMESA_CONTEXT_MINOR_VERSION 0x37 - -typedef void* OSMesaContext; -typedef void (*OSMESAproc)(void); - -typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext); -typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext); -typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext); -typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int); -typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**); -typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**); -typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*); -#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt -#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs -#define OSMesaDestroyContext _glfw.osmesa.DestroyContext -#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent -#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer -#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer -#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress - #define VK_NULL_HANDLE 0 typedef void* VkInstance; @@ -513,13 +484,6 @@ struct _GLFWcontext void* client; } egl; - struct { - OSMesaContext handle; - int width; - int height; - void* buffer; - } osmesa; - // This is defined in platform.h GLFW_PLATFORM_CONTEXT_STATE }; @@ -846,19 +810,6 @@ struct _GLFWlibrary PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT; } egl; - struct { - void* handle; - - PFN_OSMesaCreateContextExt CreateContextExt; - PFN_OSMesaCreateContextAttribs CreateContextAttribs; - PFN_OSMesaDestroyContext DestroyContext; - PFN_OSMesaMakeCurrent MakeCurrent; - PFN_OSMesaGetColorBuffer GetColorBuffer; - PFN_OSMesaGetDepthBuffer GetDepthBuffer; - PFN_OSMesaGetProcAddress GetProcAddress; - - } osmesa; - struct { GLFWbool available; void* handle; @@ -998,12 +949,6 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig, Visual** visual, int* depth); #endif /*_GLFW_X11*/ -GLFWbool _glfwInitOSMesa(void); -void _glfwTerminateOSMesa(void); -GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig); - GLFWbool _glfwInitVulkan(int mode); void _glfwTerminateVulkan(void); const char* _glfwGetVulkanResultString(VkResult result); diff --git a/src/null_init.c b/src/null_init.c index 8c10f5e67..4cfd740fc 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -258,7 +258,6 @@ int _glfwInitNull(void) void _glfwTerminateNull(void) { free(_glfw.null.clipboardString); - _glfwTerminateOSMesa(); _glfwTerminateEGL(); } diff --git a/src/null_window.c b/src/null_window.c index f0e1dcc9a..a6b736609 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -121,22 +121,10 @@ GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, if (ctxconfig->client != GLFW_NO_API) { - if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API || - ctxconfig->source == GLFW_OSMESA_CONTEXT_API) - { - if (!_glfwInitOSMesa()) - return GLFW_FALSE; - if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) - return GLFW_FALSE; - } - else if (ctxconfig->source == GLFW_EGL_CONTEXT_API) - { - if (!_glfwInitEGL()) - return GLFW_FALSE; - if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) - return GLFW_FALSE; - } - + if (!_glfwInitEGL()) + return GLFW_FALSE; + if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) + return GLFW_FALSE; if (!_glfwRefreshContextAttribs(window, ctxconfig)) return GLFW_FALSE; } diff --git a/src/osmesa_context.c b/src/osmesa_context.c deleted file mode 100644 index 0bb375a8b..000000000 --- a/src/osmesa_context.c +++ /dev/null @@ -1,387 +0,0 @@ -//======================================================================== -// GLFW 3.5 OSMesa - www.glfw.org -//------------------------------------------------------------------------ -// Copyright (c) 2016 Google Inc. -// Copyright (c) 2016-2017 Camilla Löwy -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== - -#include "internal.h" - -#include -#include -#include - -static void makeContextCurrentOSMesa(_GLFWwindow* window) -{ - if (window) - { - int width, height; - _glfw.platform.getFramebufferSize(window, &width, &height); - - // Check to see if we need to allocate a new buffer - if ((window->context.osmesa.buffer == NULL) || - (width != window->context.osmesa.width) || - (height != window->context.osmesa.height)) - { - _glfw_free(window->context.osmesa.buffer); - - // Allocate the new buffer (width * height * 8-bit RGBA) - window->context.osmesa.buffer = _glfw_calloc(4, (size_t) width * height); - window->context.osmesa.width = width; - window->context.osmesa.height = height; - } - - if (!OSMesaMakeCurrent(window->context.osmesa.handle, - window->context.osmesa.buffer, - GL_UNSIGNED_BYTE, - width, height)) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "OSMesa: Failed to make context current"); - return; - } - } - - _glfwPlatformSetTls(&_glfw.contextSlot, window); -} - -static GLFWglproc getProcAddressOSMesa(const char* procname) -{ - return (GLFWglproc) OSMesaGetProcAddress(procname); -} - -static void destroyContextOSMesa(_GLFWwindow* window) -{ - if (window->context.osmesa.handle) - { - OSMesaDestroyContext(window->context.osmesa.handle); - window->context.osmesa.handle = NULL; - } - - if (window->context.osmesa.buffer) - { - _glfw_free(window->context.osmesa.buffer); - window->context.osmesa.width = 0; - window->context.osmesa.height = 0; - } -} - -static void swapBuffersOSMesa(_GLFWwindow* window) -{ - // No double buffering on OSMesa -} - -static void swapIntervalOSMesa(int interval) -{ - // No swap interval on OSMesa -} - -static int extensionSupportedOSMesa(const char* extension) -{ - // OSMesa does not have extensions - return GLFW_FALSE; -} - - -////////////////////////////////////////////////////////////////////////// -////// GLFW internal API ////// -////////////////////////////////////////////////////////////////////////// - -GLFWbool _glfwInitOSMesa(void) -{ - int i; - const char* sonames[] = - { -#if defined(_GLFW_OSMESA_LIBRARY) - _GLFW_OSMESA_LIBRARY, -#elif defined(_WIN32) - "libOSMesa.dll", - "OSMesa.dll", -#elif defined(__APPLE__) - "libOSMesa.8.dylib", -#elif defined(__CYGWIN__) - "libOSMesa-8.so", -#elif defined(__OpenBSD__) || defined(__NetBSD__) - "libOSMesa.so", -#else - "libOSMesa.so.8", - "libOSMesa.so.6", -#endif - NULL - }; - - if (_glfw.osmesa.handle) - return GLFW_TRUE; - - for (i = 0; sonames[i]; i++) - { - _glfw.osmesa.handle = _glfwPlatformLoadModule(sonames[i]); - if (_glfw.osmesa.handle) - break; - } - - if (!_glfw.osmesa.handle) - { - _glfwInputError(GLFW_API_UNAVAILABLE, "OSMesa: Library not found"); - return GLFW_FALSE; - } - - _glfw.osmesa.CreateContextExt = (PFN_OSMesaCreateContextExt) - _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaCreateContextExt"); - _glfw.osmesa.CreateContextAttribs = (PFN_OSMesaCreateContextAttribs) - _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaCreateContextAttribs"); - _glfw.osmesa.DestroyContext = (PFN_OSMesaDestroyContext) - _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaDestroyContext"); - _glfw.osmesa.MakeCurrent = (PFN_OSMesaMakeCurrent) - _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaMakeCurrent"); - _glfw.osmesa.GetColorBuffer = (PFN_OSMesaGetColorBuffer) - _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetColorBuffer"); - _glfw.osmesa.GetDepthBuffer = (PFN_OSMesaGetDepthBuffer) - _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetDepthBuffer"); - _glfw.osmesa.GetProcAddress = (PFN_OSMesaGetProcAddress) - _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetProcAddress"); - - if (!_glfw.osmesa.CreateContextExt || - !_glfw.osmesa.DestroyContext || - !_glfw.osmesa.MakeCurrent || - !_glfw.osmesa.GetColorBuffer || - !_glfw.osmesa.GetDepthBuffer || - !_glfw.osmesa.GetProcAddress) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "OSMesa: Failed to load required entry points"); - - _glfwTerminateOSMesa(); - return GLFW_FALSE; - } - - return GLFW_TRUE; -} - -void _glfwTerminateOSMesa(void) -{ - if (_glfw.osmesa.handle) - { - _glfwPlatformFreeModule(_glfw.osmesa.handle); - _glfw.osmesa.handle = NULL; - } -} - -#define SET_ATTRIB(a, v) \ -{ \ - assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \ - attribs[index++] = a; \ - attribs[index++] = v; \ -} - -GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig) -{ - OSMesaContext share = NULL; - const int accumBits = fbconfig->accumRedBits + - fbconfig->accumGreenBits + - fbconfig->accumBlueBits + - fbconfig->accumAlphaBits; - - if (ctxconfig->client == GLFW_OPENGL_ES_API) - { - _glfwInputError(GLFW_API_UNAVAILABLE, - "OSMesa: OpenGL ES is not available on OSMesa"); - return GLFW_FALSE; - } - - if (ctxconfig->share) - share = ctxconfig->share->context.osmesa.handle; - - if (OSMesaCreateContextAttribs) - { - int index = 0, attribs[40]; - - SET_ATTRIB(OSMESA_FORMAT, OSMESA_RGBA); - SET_ATTRIB(OSMESA_DEPTH_BITS, fbconfig->depthBits); - SET_ATTRIB(OSMESA_STENCIL_BITS, fbconfig->stencilBits); - SET_ATTRIB(OSMESA_ACCUM_BITS, accumBits); - - if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE) - { - SET_ATTRIB(OSMESA_PROFILE, OSMESA_CORE_PROFILE); - } - else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE) - { - SET_ATTRIB(OSMESA_PROFILE, OSMESA_COMPAT_PROFILE); - } - - if (ctxconfig->major != 1 || ctxconfig->minor != 0) - { - SET_ATTRIB(OSMESA_CONTEXT_MAJOR_VERSION, ctxconfig->major); - SET_ATTRIB(OSMESA_CONTEXT_MINOR_VERSION, ctxconfig->minor); - } - - if (ctxconfig->forward) - { - _glfwInputError(GLFW_VERSION_UNAVAILABLE, - "OSMesa: Forward-compatible contexts not supported"); - return GLFW_FALSE; - } - - SET_ATTRIB(0, 0); - - window->context.osmesa.handle = - OSMesaCreateContextAttribs(attribs, share); - } - else - { - if (ctxconfig->profile) - { - _glfwInputError(GLFW_VERSION_UNAVAILABLE, - "OSMesa: OpenGL profiles unavailable"); - return GLFW_FALSE; - } - - window->context.osmesa.handle = - OSMesaCreateContextExt(OSMESA_RGBA, - fbconfig->depthBits, - fbconfig->stencilBits, - accumBits, - share); - } - - if (window->context.osmesa.handle == NULL) - { - _glfwInputError(GLFW_VERSION_UNAVAILABLE, - "OSMesa: Failed to create context"); - return GLFW_FALSE; - } - - window->context.makeCurrent = makeContextCurrentOSMesa; - window->context.swapBuffers = swapBuffersOSMesa; - window->context.swapInterval = swapIntervalOSMesa; - window->context.extensionSupported = extensionSupportedOSMesa; - window->context.getProcAddress = getProcAddressOSMesa; - window->context.destroy = destroyContextOSMesa; - - return GLFW_TRUE; -} - -#undef SET_ATTRIB - - -////////////////////////////////////////////////////////////////////////// -////// GLFW native API ////// -////////////////////////////////////////////////////////////////////////// - -GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* handle, int* width, - int* height, int* format, void** buffer) -{ - void* mesaBuffer; - GLint mesaWidth, mesaHeight, mesaFormat; - - _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); - - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - - if (window->context.source != GLFW_OSMESA_CONTEXT_API) - { - _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); - return GLFW_FALSE; - } - - if (!OSMesaGetColorBuffer(window->context.osmesa.handle, - &mesaWidth, &mesaHeight, - &mesaFormat, &mesaBuffer)) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "OSMesa: Failed to retrieve color buffer"); - return GLFW_FALSE; - } - - if (width) - *width = mesaWidth; - if (height) - *height = mesaHeight; - if (format) - *format = mesaFormat; - if (buffer) - *buffer = mesaBuffer; - - return GLFW_TRUE; -} - -GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle, - int* width, int* height, - int* bytesPerValue, - void** buffer) -{ - void* mesaBuffer; - GLint mesaWidth, mesaHeight, mesaBytes; - - _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); - - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - - if (window->context.source != GLFW_OSMESA_CONTEXT_API) - { - _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); - return GLFW_FALSE; - } - - if (!OSMesaGetDepthBuffer(window->context.osmesa.handle, - &mesaWidth, &mesaHeight, - &mesaBytes, &mesaBuffer)) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "OSMesa: Failed to retrieve depth buffer"); - return GLFW_FALSE; - } - - if (width) - *width = mesaWidth; - if (height) - *height = mesaHeight; - if (bytesPerValue) - *bytesPerValue = mesaBytes; - if (buffer) - *buffer = mesaBuffer; - - return GLFW_TRUE; -} - -GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle) -{ - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - - if (window->context.source != GLFW_OSMESA_CONTEXT_API) - { - _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); - return NULL; - } - - return window->context.osmesa.handle; -} - diff --git a/src/platform.c b/src/platform.c index 95b8d0b58..9ebd0185a 100644 --- a/src/platform.c +++ b/src/platform.c @@ -184,7 +184,6 @@ GLFWAPI const char* glfwGetVersionString(void) #endif " Null" " EGL" - " OSMesa" #if defined(__MINGW64_VERSION_MAJOR) " MinGW-w64" #elif defined(_MSC_VER) diff --git a/src/platform.h b/src/platform.h index 7ce4e015a..74cc504cb 100644 --- a/src/platform.h +++ b/src/platform.h @@ -39,7 +39,6 @@ #include "null_platform.h" #define GLFW_EXPOSE_NATIVE_EGL -#define GLFW_EXPOSE_NATIVE_OSMESA #if defined(_GLFW_WIN32) #include "win32_platform.h" diff --git a/src/win32_init.c b/src/win32_init.c index 6b6e9d08e..41e1d38c8 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -718,7 +718,6 @@ void _glfwTerminateWin32(void) _glfwTerminateWGL(); _glfwTerminateEGL(); - _glfwTerminateOSMesa(); freeLibraries(); } diff --git a/src/win32_window.c b/src/win32_window.c index 6427a673e..f3b859bb8 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1506,13 +1506,6 @@ GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) return GLFW_FALSE; } - else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API) - { - if (!_glfwInitOSMesa()) - return GLFW_FALSE; - if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) - return GLFW_FALSE; - } if (!_glfwRefreshContextAttribs(window, ctxconfig)) return GLFW_FALSE; diff --git a/src/wl_init.c b/src/wl_init.c index ef9e45036..60050a70a 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -895,7 +895,6 @@ int _glfwInitWayland(void) void _glfwTerminateWayland(void) { _glfwTerminateEGL(); - _glfwTerminateOSMesa(); if (_glfw.wl.libdecor.context) { diff --git a/src/wl_window.c b/src/wl_window.c index 4220d17e0..77eeded92 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2176,32 +2176,20 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, if (ctxconfig->client != GLFW_NO_API) { - if (ctxconfig->source == GLFW_EGL_CONTEXT_API || - ctxconfig->source == GLFW_NATIVE_CONTEXT_API) + window->wl.egl.window = wl_egl_window_create(window->wl.surface, + window->wl.fbWidth, + window->wl.fbHeight); + if (!window->wl.egl.window) { - window->wl.egl.window = wl_egl_window_create(window->wl.surface, - window->wl.fbWidth, - window->wl.fbHeight); - if (!window->wl.egl.window) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to create EGL window"); - return GLFW_FALSE; - } - - if (!_glfwInitEGL()) - return GLFW_FALSE; - if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) - return GLFW_FALSE; - } - else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API) - { - if (!_glfwInitOSMesa()) - return GLFW_FALSE; - if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) - return GLFW_FALSE; + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to create EGL window"); + return GLFW_FALSE; } + if (!_glfwInitEGL()) + return GLFW_FALSE; + if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) + return GLFW_FALSE; if (!_glfwRefreshContextAttribs(window, ctxconfig)) return GLFW_FALSE; } diff --git a/src/x11_init.c b/src/x11_init.c index 6b34c2639..a88cf56b1 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1634,7 +1634,6 @@ void _glfwTerminateX11(void) _glfw.x11.xi.handle = NULL; } - _glfwTerminateOSMesa(); // NOTE: These need to be unloaded after XCloseDisplay, as they register // cleanup callbacks that get called by that function _glfwTerminateEGL(); diff --git a/src/x11_window.c b/src/x11_window.c index 986bfb93b..c2fda4d35 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1980,11 +1980,6 @@ GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, if (!_glfwChooseVisualEGL(wndconfig, ctxconfig, fbconfig, &visual, &depth)) return GLFW_FALSE; } - else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API) - { - if (!_glfwInitOSMesa()) - return GLFW_FALSE; - } } if (!visual) @@ -2008,11 +2003,6 @@ GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) return GLFW_FALSE; } - else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API) - { - if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) - return GLFW_FALSE; - } if (!_glfwRefreshContextAttribs(window, ctxconfig)) return GLFW_FALSE; diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 12acbccca..9fba00eb6 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -46,7 +46,6 @@ #define API_NAME_NATIVE "native" #define API_NAME_EGL "egl" -#define API_NAME_OSMESA "osmesa" #define PROFILE_NAME_CORE "core" #define PROFILE_NAME_COMPAT "compat" @@ -90,8 +89,7 @@ static void usage(void) BEHAVIOR_NAME_FLUSH ")\n"); printf(" -c, --context-api=API the context creation API to use (" API_NAME_NATIVE " or " - API_NAME_EGL " or " - API_NAME_OSMESA ")\n"); + API_NAME_EGL ")\n"); printf(" -d, --debug request a debug context\n"); printf(" -f, --forward require a forward-compatible context\n"); printf(" -h, --help show this help\n"); @@ -482,8 +480,6 @@ int main(int argc, char** argv) context_creation_api = GLFW_NATIVE_CONTEXT_API; else if (strcasecmp(optarg, API_NAME_EGL) == 0) context_creation_api = GLFW_EGL_CONTEXT_API; - else if (strcasecmp(optarg, API_NAME_OSMESA) == 0) - context_creation_api = GLFW_OSMESA_CONTEXT_API; else { usage();