mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
OSMesa: Cleanup
Fixes formatting, semantics and documentation. Adds glfwGetOSMesaContext. Adds support for OSMesa context attributes. Updates changelog and credits. Adds license and copyright headers. Removes superfluous code (the shared code provides many conveniences). Removes loading of unused OSMesa functions. Removes empty platform structs. Fixes version string format. Removes build dependency on the OSMesa header and library (only the library is needed and only at runtime). Closes #850.
This commit is contained in:
parent
368fa9475d
commit
fef21361c5
@ -28,6 +28,10 @@ option(GLFW_INSTALL "Generate installation target" ON)
|
|||||||
option(GLFW_VULKAN_STATIC "Use the Vulkan loader statically linked into application" OFF)
|
option(GLFW_VULKAN_STATIC "Use the Vulkan loader statically linked into application" OFF)
|
||||||
option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF)
|
option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF)
|
||||||
|
|
||||||
|
if (UNIX)
|
||||||
|
option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF)
|
option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF)
|
||||||
endif()
|
endif()
|
||||||
@ -41,7 +45,6 @@ endif()
|
|||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF)
|
option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF)
|
||||||
option(GLFW_USE_MIR "Use Mir for window creation" OFF)
|
option(GLFW_USE_MIR "Use Mir for window creation" OFF)
|
||||||
option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
@ -142,26 +145,24 @@ endif()
|
|||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Detect and select backend APIs
|
# Detect and select backend APIs
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
if (WIN32)
|
if (GLFW_USE_WAYLAND)
|
||||||
|
set(_GLFW_WAYLAND 1)
|
||||||
|
message(STATUS "Using Wayland for window creation")
|
||||||
|
elseif (GLFW_USE_MIR)
|
||||||
|
set(_GLFW_MIR 1)
|
||||||
|
message(STATUS "Using Mir for window creation")
|
||||||
|
elseif (GLFW_USE_OSMESA)
|
||||||
|
set(_GLFW_OSMESA 1)
|
||||||
|
message(STATUS "Using OSMesa for headless context creation")
|
||||||
|
elseif (WIN32)
|
||||||
set(_GLFW_WIN32 1)
|
set(_GLFW_WIN32 1)
|
||||||
message(STATUS "Using Win32 for window creation")
|
message(STATUS "Using Win32 for window creation")
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
set(_GLFW_COCOA 1)
|
set(_GLFW_COCOA 1)
|
||||||
message(STATUS "Using Cocoa for window creation")
|
message(STATUS "Using Cocoa for window creation")
|
||||||
elseif (UNIX)
|
elseif (UNIX)
|
||||||
if (GLFW_USE_WAYLAND)
|
|
||||||
set(_GLFW_WAYLAND 1)
|
|
||||||
message(STATUS "Using Wayland for window creation")
|
|
||||||
elseif (GLFW_USE_MIR)
|
|
||||||
set(_GLFW_MIR 1)
|
|
||||||
message(STATUS "Using Mir for window creation")
|
|
||||||
elseif (GLFW_USE_OSMESA)
|
|
||||||
set(_GLFW_OSMESA 1)
|
|
||||||
message(STATUS "Using OSMesa for windowless context creation")
|
|
||||||
else()
|
|
||||||
set(_GLFW_X11 1)
|
set(_GLFW_X11 1)
|
||||||
message(STATUS "Using X11 for window creation")
|
message(STATUS "Using X11 for window creation")
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "No supported platform was detected")
|
message(FATAL_ERROR "No supported platform was detected")
|
||||||
endif()
|
endif()
|
||||||
@ -326,12 +327,8 @@ endif()
|
|||||||
# Use OSMesa for offscreen context creation
|
# Use OSMesa for offscreen context creation
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
if (_GLFW_OSMESA)
|
if (_GLFW_OSMESA)
|
||||||
find_package(osmesa REQUIRED)
|
find_package(OSMesa REQUIRED)
|
||||||
list(APPEND glfw_PKG_DEPS "osmesa")
|
list(APPEND glfw_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
|
||||||
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${OSMESA_INCLUDE_DIR}")
|
|
||||||
list(APPEND glfw_LIBRARIES "${OSMESA_LIBRARIES}"
|
|
||||||
"${CMAKE_THREAD_LIBS_INIT}")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
@ -104,6 +104,7 @@ information on what to include when reporting a bug.
|
|||||||
scancodes for keys (#830)
|
scancodes for keys (#830)
|
||||||
- Added `glfwSetWindowMaximizeCallback` and `GLFWwindowmaximizefun` for
|
- Added `glfwSetWindowMaximizeCallback` and `GLFWwindowmaximizefun` for
|
||||||
receiving window maximization events (#778)
|
receiving window maximization events (#778)
|
||||||
|
- Added headless [OSMesa](http://mesa3d.org/osmesa.html) backend (#281,#850)
|
||||||
- Added definition of `GLAPIENTRY` to public header
|
- Added definition of `GLAPIENTRY` to public header
|
||||||
- Bugfix: Calling `glfwMaximizeWindow` on a full screen window was not ignored
|
- Bugfix: Calling `glfwMaximizeWindow` on a full screen window was not ignored
|
||||||
- Bugfix: `GLFW_INCLUDE_VULKAN` could not be combined with the corresponding
|
- Bugfix: `GLFW_INCLUDE_VULKAN` could not be combined with the corresponding
|
||||||
@ -155,6 +156,7 @@ skills.
|
|||||||
- Lambert Clara
|
- Lambert Clara
|
||||||
- Andrew Corrigan
|
- Andrew Corrigan
|
||||||
- Noel Cower
|
- Noel Cower
|
||||||
|
- Jason Daly
|
||||||
- Jarrod Davis
|
- Jarrod Davis
|
||||||
- Olivier Delannoy
|
- Olivier Delannoy
|
||||||
- Paul R. Deppe
|
- Paul R. Deppe
|
||||||
|
@ -1577,6 +1577,7 @@ PREDEFINED = GLFWAPI= \
|
|||||||
GLFW_EXPOSE_NATIVE_COCOA \
|
GLFW_EXPOSE_NATIVE_COCOA \
|
||||||
GLFW_EXPOSE_NATIVE_NSGL \
|
GLFW_EXPOSE_NATIVE_NSGL \
|
||||||
GLFW_EXPOSE_NATIVE_EGL \
|
GLFW_EXPOSE_NATIVE_EGL \
|
||||||
|
GLFW_EXPOSE_NATIVE_OSMESA \
|
||||||
VK_VERSION_1_0
|
VK_VERSION_1_0
|
||||||
|
|
||||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
|
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
|
||||||
|
@ -97,6 +97,17 @@ Once you have installed the necessary packages, move on to @ref
|
|||||||
compile_generate.
|
compile_generate.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection compile_deps_osmesa Dependencies for Linux and OSMesa
|
||||||
|
|
||||||
|
To compile GLFW for OSMesa, you need to install the OSMesa library and header
|
||||||
|
packages. For example, on Ubuntu and other distributions based on Debian
|
||||||
|
GNU/Linux, you need to install the `libosmesa6-dev` package. The OSMesa library
|
||||||
|
is required at runtime for context creation and is loaded on demand.
|
||||||
|
|
||||||
|
Once you have installed the necessary packages, move on to @ref
|
||||||
|
compile_generate.
|
||||||
|
|
||||||
|
|
||||||
@subsection compile_generate Generating build files with CMake
|
@subsection compile_generate Generating build files with CMake
|
||||||
|
|
||||||
Once you have all necessary dependencies it is time to generate the project
|
Once you have all necessary dependencies it is time to generate the project
|
||||||
@ -249,6 +260,7 @@ ramps and clipboard. The options are:
|
|||||||
- `_GLFW_X11` to use the X Window System
|
- `_GLFW_X11` to use the X Window System
|
||||||
- `_GLFW_WAYLAND` to use the Wayland API (experimental and incomplete)
|
- `_GLFW_WAYLAND` to use the Wayland API (experimental and incomplete)
|
||||||
- `_GLFW_MIR` to use the Mir API (experimental and incomplete)
|
- `_GLFW_MIR` to use the Mir API (experimental and incomplete)
|
||||||
|
- `_GLFW_OSMESA` to use the OSMesa API (headless and non-interactive)
|
||||||
|
|
||||||
If you are building GLFW as a shared library / dynamic library / DLL then you
|
If you are building GLFW as a shared library / dynamic library / DLL then you
|
||||||
must also define `_GLFW_BUILD_DLL`. Otherwise, you must not define it.
|
must also define `_GLFW_BUILD_DLL`. Otherwise, you must not define it.
|
||||||
|
@ -22,6 +22,12 @@ GLFW now supports the `VK_MVK_macos_surface` window surface creation extension
|
|||||||
provided by MoltenVK.
|
provided by MoltenVK.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection news_33_osmesa OSMesa backend for headless software rendering
|
||||||
|
|
||||||
|
GLFW now supports headless context creation and software rendering via OSMesa,
|
||||||
|
intended for automated testing. This backend does not provide input.
|
||||||
|
|
||||||
|
|
||||||
@section news_32 New features in 3.2
|
@section news_32 New features in 3.2
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ extern "C" {
|
|||||||
* * `GLFW_EXPOSE_NATIVE_NSGL`
|
* * `GLFW_EXPOSE_NATIVE_NSGL`
|
||||||
* * `GLFW_EXPOSE_NATIVE_GLX`
|
* * `GLFW_EXPOSE_NATIVE_GLX`
|
||||||
* * `GLFW_EXPOSE_NATIVE_EGL`
|
* * `GLFW_EXPOSE_NATIVE_EGL`
|
||||||
|
* * `GLFW_EXPOSE_NATIVE_OSMESA`
|
||||||
*
|
*
|
||||||
* These macros select which of the native access functions that are declared
|
* 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
|
* and which platform-specific headers to include. It is then up your (by
|
||||||
@ -114,6 +115,9 @@ extern "C" {
|
|||||||
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
|
||||||
|
#include <GL/osmesa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@ -449,27 +453,59 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
|
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
|
||||||
/*! @brief Returns the color buffer associated with the specified window.
|
/*! @brief Retrieves the color buffer associated with the specified window.
|
||||||
*
|
*
|
||||||
* @param[out] width The width of the color buffer.
|
* @param[out] width Where to store the width of the color buffer, or `NULL`.
|
||||||
* @param[out] height The height of the color buffer.
|
* @param[out] height Where to store the height of the color buffer, or `NULL`.
|
||||||
* @param[out] format The pixel format of the color buffer (OSMESA_FORMAT_*).
|
* @param[out] format Where to store the OSMesa pixel format of the color
|
||||||
* @param[out] buffer The buffer data.
|
* buffer, or `NULL`.
|
||||||
* @return 1 if successful, or 0 if not.
|
* @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.
|
||||||
|
*
|
||||||
|
* @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,
|
GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height, int* format, void** buffer);
|
||||||
int* height, int* format, void** buffer);
|
|
||||||
|
|
||||||
/*! @brief Returns the depth buffer associated with the specified window.
|
/*! @brief Retrieves the depth buffer associated with the specified window.
|
||||||
*
|
*
|
||||||
* @param[out] width The width of the depth buffer.
|
* @param[out] width Where to store the width of the depth buffer, or `NULL`.
|
||||||
* @param[out] height The height of the depth buffer.
|
* @param[out] height Where to store the height of the depth buffer, or `NULL`.
|
||||||
* @param[out] bytesPerValue The number of bytes per depth buffer element.
|
* @param[out] bytesPerValue Where to store the number of bytes per depth
|
||||||
* @param[out] buffer The buffer data.
|
* buffer element, or `NULL`.
|
||||||
* @return 1 if successful, or 0 if not.
|
* @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.
|
||||||
|
*
|
||||||
|
* @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,
|
GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height, int* bytesPerValue, void** buffer);
|
||||||
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.
|
||||||
|
*
|
||||||
|
* @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
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -69,6 +69,7 @@ typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*);
|
|||||||
#define GL_VERSION 0x1f02
|
#define GL_VERSION 0x1f02
|
||||||
#define GL_NONE 0
|
#define GL_NONE 0
|
||||||
#define GL_COLOR_BUFFER_BIT 0x00004000
|
#define GL_COLOR_BUFFER_BIT 0x00004000
|
||||||
|
#define GL_UNSIGNED_BYTE 0x1401
|
||||||
#define GL_EXTENSIONS 0x1f03
|
#define GL_EXTENSIONS 0x1f03
|
||||||
#define GL_NUM_EXTENSIONS 0x821d
|
#define GL_NUM_EXTENSIONS 0x821d
|
||||||
#define GL_CONTEXT_FLAGS 0x821e
|
#define GL_CONTEXT_FLAGS 0x821e
|
||||||
|
@ -1,76 +1,84 @@
|
|||||||
|
//========================================================================
|
||||||
|
// GLFW 3.3 OSMesa - www.glfw.org
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2016 Google Inc.
|
||||||
|
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// 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 <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "osmesa_context.h"
|
|
||||||
|
|
||||||
static void makeContextCurrentOSMesa(_GLFWwindow* window)
|
static void makeContextCurrentOSMesa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
// Check to see if we need to allocate a new buffer.
|
// Check to see if we need to allocate a new buffer
|
||||||
if ((window->context.osmesa.buffer == NULL) ||
|
if ((window->context.osmesa.buffer == NULL) ||
|
||||||
(window->osmesa.width != window->context.osmesa.width) ||
|
(window->osmesa.width != window->context.osmesa.width) ||
|
||||||
(window->osmesa.height != window->context.osmesa.height))
|
(window->osmesa.height != window->context.osmesa.height))
|
||||||
{
|
|
||||||
// Free the current buffer, if necessary.
|
|
||||||
if (window->context.osmesa.buffer != NULL)
|
|
||||||
{
|
{
|
||||||
free(window->context.osmesa.buffer);
|
free(window->context.osmesa.buffer);
|
||||||
}
|
|
||||||
|
|
||||||
// Allocate the new buffer (width * height * 1 byte per RGBA
|
// Allocate the new buffer (width * height * 8-bit RGBA)
|
||||||
// channel).
|
window->context.osmesa.buffer =
|
||||||
window->context.osmesa.buffer = (unsigned char *) malloc(
|
calloc(4, window->osmesa.width * window->osmesa.height);
|
||||||
window->osmesa.width * window->osmesa.height * 4);
|
|
||||||
|
|
||||||
// Update the context size.
|
|
||||||
window->context.osmesa.width = window->osmesa.width;
|
window->context.osmesa.width = window->osmesa.width;
|
||||||
window->context.osmesa.height = window->osmesa.height;
|
window->context.osmesa.height = window->osmesa.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the context current.
|
|
||||||
if (!OSMesaMakeCurrent(window->context.osmesa.handle,
|
if (!OSMesaMakeCurrent(window->context.osmesa.handle,
|
||||||
window->context.osmesa.buffer,
|
window->context.osmesa.buffer,
|
||||||
0x1401, // GL_UNSIGNED_BYTE
|
GL_UNSIGNED_BYTE,
|
||||||
window->osmesa.width, window->osmesa.height))
|
window->osmesa.width, window->osmesa.height))
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"OSMesa: Failed to make context current.");
|
"OSMesa: Failed to make context current");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
||||||
"OSMesa: Releasing the current context is not supported.");
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfwPlatformSetCurrentContext(window);
|
_glfwPlatformSetCurrentContext(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLFWglproc getProcAddressOSMesa(const char* procname)
|
static GLFWglproc getProcAddressOSMesa(const char* procname)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
|
|
||||||
|
|
||||||
if (window->context.osmesa.handle)
|
|
||||||
{
|
|
||||||
return (GLFWglproc) OSMesaGetProcAddress(procname);
|
return (GLFWglproc) OSMesaGetProcAddress(procname);
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyContextOSMesa(_GLFWwindow* window)
|
static void destroyContextOSMesa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window->context.osmesa.handle != NULL)
|
if (window->context.osmesa.handle)
|
||||||
{
|
{
|
||||||
OSMesaDestroyContext(window->context.osmesa.handle);
|
OSMesaDestroyContext(window->context.osmesa.handle);
|
||||||
window->context.osmesa.handle = NULL;
|
window->context.osmesa.handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->context.osmesa.buffer != NULL)
|
if (window->context.osmesa.buffer)
|
||||||
{
|
{
|
||||||
free(window->context.osmesa.buffer);
|
free(window->context.osmesa.buffer);
|
||||||
window->context.osmesa.width = 0;
|
window->context.osmesa.width = 0;
|
||||||
@ -78,15 +86,23 @@ static void destroyContextOSMesa(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void swapBuffersOSMesa(_GLFWwindow* window) {}
|
static void swapBuffersOSMesa(_GLFWwindow* window)
|
||||||
|
|
||||||
static void swapIntervalOSMesa(int interval) {}
|
|
||||||
|
|
||||||
static int extensionSupportedOSMesa()
|
|
||||||
{
|
{
|
||||||
|
// 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;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -96,11 +112,13 @@ GLFWbool _glfwInitOSMesa(void)
|
|||||||
int i;
|
int i;
|
||||||
const char* sonames[] =
|
const char* sonames[] =
|
||||||
{
|
{
|
||||||
#if defined(_GLFW_WIN32)
|
#if defined(_WIN32)
|
||||||
"libOSMesa.dll",
|
"libOSMesa.dll",
|
||||||
"OSMesa.dll",
|
"OSMesa.dll",
|
||||||
#elif defined(_GLFW_COCOA)
|
#elif defined(__APPLE__)
|
||||||
"libOSMesa.dylib",
|
"libOSMesa.8.dylib",
|
||||||
|
#elif defined(__CYGWIN__)
|
||||||
|
"libOSMesa-8.so",
|
||||||
#else
|
#else
|
||||||
"libOSMesa.so.6",
|
"libOSMesa.so.6",
|
||||||
#endif
|
#endif
|
||||||
@ -123,20 +141,12 @@ GLFWbool _glfwInitOSMesa(void)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw.osmesa.prefix = (strncmp(sonames[i], "lib", 3) == 0);
|
_glfw.osmesa.CreateContextAttribs = (PFNOSMESACREATECONTEXTATTRIBSPROC)
|
||||||
|
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextAttribs");
|
||||||
_glfw.osmesa.CreateContext = (PFNOSMESACREATECONTEXTPROC)
|
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContext");
|
|
||||||
_glfw.osmesa.DestroyContext = (PFNOSMESADESTROYCONTEXTPROC)
|
_glfw.osmesa.DestroyContext = (PFNOSMESADESTROYCONTEXTPROC)
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaDestroyContext");
|
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaDestroyContext");
|
||||||
_glfw.osmesa.MakeCurrent = (PFNOSMESAMAKECURRENTPROC)
|
_glfw.osmesa.MakeCurrent = (PFNOSMESAMAKECURRENTPROC)
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaMakeCurrent");
|
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaMakeCurrent");
|
||||||
_glfw.osmesa.GetCurrentContext = (PFNOSMESAGETCURRENTCONTEXTPROC)
|
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetCurrentContext");
|
|
||||||
_glfw.osmesa.PixelStore = (PFNOSMESAPIXELSTOREPROC)
|
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaPixelStore");
|
|
||||||
_glfw.osmesa.GetIntegerv = (PFNOSMESAGETINTEGERVPROC)
|
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetIntegerv");
|
|
||||||
_glfw.osmesa.GetColorBuffer = (PFNOSMESAGETCOLORBUFFERPROC)
|
_glfw.osmesa.GetColorBuffer = (PFNOSMESAGETCOLORBUFFERPROC)
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetColorBuffer");
|
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetColorBuffer");
|
||||||
_glfw.osmesa.GetDepthBuffer = (PFNOSMESAGETDEPTHBUFFERPROC)
|
_glfw.osmesa.GetDepthBuffer = (PFNOSMESAGETDEPTHBUFFERPROC)
|
||||||
@ -144,12 +154,9 @@ GLFWbool _glfwInitOSMesa(void)
|
|||||||
_glfw.osmesa.GetProcAddress = (PFNOSMESAGETPROCADDRESSPROC)
|
_glfw.osmesa.GetProcAddress = (PFNOSMESAGETPROCADDRESSPROC)
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetProcAddress");
|
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetProcAddress");
|
||||||
|
|
||||||
if (!_glfw.osmesa.CreateContext ||
|
if (!_glfw.osmesa.CreateContextAttribs ||
|
||||||
!_glfw.osmesa.DestroyContext ||
|
!_glfw.osmesa.DestroyContext ||
|
||||||
!_glfw.osmesa.MakeCurrent ||
|
!_glfw.osmesa.MakeCurrent ||
|
||||||
!_glfw.osmesa.GetCurrentContext ||
|
|
||||||
!_glfw.osmesa.PixelStore ||
|
|
||||||
!_glfw.osmesa.GetIntegerv ||
|
|
||||||
!_glfw.osmesa.GetColorBuffer ||
|
!_glfw.osmesa.GetColorBuffer ||
|
||||||
!_glfw.osmesa.GetDepthBuffer ||
|
!_glfw.osmesa.GetDepthBuffer ||
|
||||||
!_glfw.osmesa.GetProcAddress)
|
!_glfw.osmesa.GetProcAddress)
|
||||||
@ -173,30 +180,56 @@ void _glfwTerminateOSMesa(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define setAttrib(attribName, attribValue) \
|
||||||
|
{ \
|
||||||
|
attribs[index++] = attribName; \
|
||||||
|
attribs[index++] = attribValue; \
|
||||||
|
assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
|
||||||
|
}
|
||||||
|
|
||||||
GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
|
GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
|
||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
OSMesaContext share;
|
OSMesaContext share = NULL;
|
||||||
|
int index = 0, attribs[40];
|
||||||
|
|
||||||
if (ctxconfig->share)
|
if (ctxconfig->share)
|
||||||
share = ctxconfig->share->context.osmesa.handle;
|
share = ctxconfig->share->context.osmesa.handle;
|
||||||
|
|
||||||
// Initialize the context.
|
setAttrib(OSMESA_FORMAT, OSMESA_RGBA);
|
||||||
window->context.osmesa.buffer = NULL;
|
setAttrib(OSMESA_DEPTH_BITS, fbconfig->depthBits);
|
||||||
window->context.osmesa.width = 0;
|
setAttrib(OSMESA_STENCIL_BITS, fbconfig->stencilBits);
|
||||||
window->context.osmesa.height = 0;
|
setAttrib(OSMESA_ACCUM_BITS, fbconfig->accumRedBits +
|
||||||
|
fbconfig->accumGreenBits +
|
||||||
|
fbconfig->accumBlueBits +
|
||||||
|
fbconfig->accumAlphaBits);
|
||||||
|
|
||||||
// Create to create an OSMesa context.
|
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
|
||||||
window->context.osmesa.handle = OSMesaCreateContext(OSMESA_RGBA, share);
|
{
|
||||||
if (window->context.osmesa.handle == 0)
|
setAttrib(OSMESA_PROFILE, OSMESA_CORE_PROFILE);
|
||||||
|
}
|
||||||
|
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||||
|
{
|
||||||
|
setAttrib(OSMESA_PROFILE, OSMESA_COMPAT_PROFILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
||||||
|
{
|
||||||
|
setAttrib(OSMESA_CONTEXT_MAJOR_VERSION, ctxconfig->major);
|
||||||
|
setAttrib(OSMESA_CONTEXT_MINOR_VERSION, ctxconfig->minor);
|
||||||
|
}
|
||||||
|
|
||||||
|
setAttrib(0, 0);
|
||||||
|
|
||||||
|
window->context.osmesa.handle = OSMesaCreateContextAttribs(attribs, share);
|
||||||
|
if (window->context.osmesa.handle == NULL)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||||
"OSMesa: Failed to create context.");
|
"OSMesa: Failed to create context");
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the context API.
|
|
||||||
window->context.makeCurrent = makeContextCurrentOSMesa;
|
window->context.makeCurrent = makeContextCurrentOSMesa;
|
||||||
window->context.swapBuffers = swapBuffersOSMesa;
|
window->context.swapBuffers = swapBuffersOSMesa;
|
||||||
window->context.swapInterval = swapIntervalOSMesa;
|
window->context.swapInterval = swapIntervalOSMesa;
|
||||||
@ -207,7 +240,88 @@ GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
|
|||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef setAttrib
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW native API //////
|
////// GLFW native API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* handle, int* width,
|
||||||
|
int* height, int* format, void** buffer)
|
||||||
|
{
|
||||||
|
void* mesaBuffer;
|
||||||
|
GLint mesaWidth, mesaHeight, mesaFormat;
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
|
assert(window != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_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;
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
|
assert(window != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_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)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
|
||||||
|
if (window->context.client == GLFW_NO_API)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return window->context.osmesa.handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,49 +1,62 @@
|
|||||||
|
//========================================================================
|
||||||
|
// GLFW 3.3 OSMesa - www.glfw.org
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2016 Google Inc.
|
||||||
|
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#ifndef _glfw3_osmesa_context_h_
|
#ifndef _glfw3_osmesa_context_h_
|
||||||
#define _glfw3_osmesa_context_h_
|
#define _glfw3_osmesa_context_h_
|
||||||
|
|
||||||
#define OSMESA_COLOR_INDEX GL_COLOR_INDEX
|
|
||||||
#define OSMESA_RGBA 0x1908
|
#define OSMESA_RGBA 0x1908
|
||||||
#define OSMESA_BGRA 0x1
|
|
||||||
#define OSMESA_ARGB 0x2
|
|
||||||
#define OSMESA_RGB 0x1907
|
|
||||||
#define OSMESA_BGR 0x4
|
|
||||||
#define OSMESA_RGB_565 0x5
|
|
||||||
|
|
||||||
#define OSMESA_ROW_LENGTH 0x10
|
|
||||||
#define OSMESA_Y_UP 0x11
|
|
||||||
|
|
||||||
#define OSMESA_WIDTH 0x20
|
|
||||||
#define OSMESA_HEIGHT 0x21
|
|
||||||
#define OSMESA_FORMAT 0x22
|
#define OSMESA_FORMAT 0x22
|
||||||
#define OSMESA_TYPE 0x23
|
#define OSMESA_DEPTH_BITS 0x30
|
||||||
#define OSMESA_MAX_WIDTH 0x24
|
#define OSMESA_STENCIL_BITS 0x31
|
||||||
#define OSMESA_MAX_HEIGHT 0x25
|
#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* OSMesaContext;
|
||||||
typedef void (*OSMESAproc)();
|
typedef void (*OSMESAproc)();
|
||||||
|
|
||||||
typedef OSMesaContext (* PFNOSMESACREATECONTEXTPROC)(GLenum, OSMesaContext);
|
typedef OSMesaContext (* PFNOSMESACREATECONTEXTATTRIBSPROC)(const int*,OSMesaContext);
|
||||||
typedef void (* PFNOSMESADESTROYCONTEXTPROC)(OSMesaContext);
|
typedef void (* PFNOSMESADESTROYCONTEXTPROC)(OSMesaContext);
|
||||||
typedef int (* PFNOSMESAMAKECURRENTPROC)(OSMesaContext, void*, int, int, int);
|
typedef int (* PFNOSMESAMAKECURRENTPROC)(OSMesaContext,void*,int,int,int);
|
||||||
typedef OSMesaContext (* PFNOSMESAGETCURRENTCONTEXTPROC)();
|
typedef int (* PFNOSMESAGETCOLORBUFFERPROC)(OSMesaContext,int*,int*,int*,void**);
|
||||||
typedef void (* PFNOSMESAPIXELSTOREPROC)(int, int);
|
typedef int (* PFNOSMESAGETDEPTHBUFFERPROC)(OSMesaContext,int*,int*,int*,void**);
|
||||||
typedef void (* PFNOSMESAGETINTEGERVPROC)(int, int*);
|
|
||||||
typedef int (* PFNOSMESAGETCOLORBUFFERPROC)(OSMesaContext, int*, int*, int*, void**);
|
|
||||||
typedef int (* PFNOSMESAGETDEPTHBUFFERPROC)(OSMesaContext, int*, int*, int*, void**);
|
|
||||||
typedef GLFWglproc (* PFNOSMESAGETPROCADDRESSPROC)(const char*);
|
typedef GLFWglproc (* PFNOSMESAGETPROCADDRESSPROC)(const char*);
|
||||||
#define OSMesaCreateContext _glfw.osmesa.CreateContext
|
#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs
|
||||||
#define OSMesaDestroyContext _glfw.osmesa.DestroyContext
|
#define OSMesaDestroyContext _glfw.osmesa.DestroyContext
|
||||||
#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent
|
#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent
|
||||||
#define OSMesaGetCurrentContext _glfw.osmesa.GetCurrentContext
|
|
||||||
#define OSMesaPixelStore _glfw.osmesa.PixelStore
|
|
||||||
#define OSMesaGetIntegerv _glfw.osmesa.GetIntegerv
|
|
||||||
#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer
|
#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer
|
||||||
#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer
|
#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer
|
||||||
#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress
|
#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextOSMesa osmesa
|
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextOSMesa osmesa
|
||||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWctxlibraryOSMesa osmesa
|
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryOSMesa osmesa
|
||||||
|
|
||||||
|
|
||||||
// OSMesa-specific per-context data
|
// OSMesa-specific per-context data
|
||||||
@ -53,29 +66,24 @@ typedef struct _GLFWcontextOSMesa
|
|||||||
OSMesaContext handle;
|
OSMesaContext handle;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
void * buffer;
|
void* buffer;
|
||||||
|
|
||||||
} _GLFWcontextOSMesa;
|
} _GLFWcontextOSMesa;
|
||||||
|
|
||||||
// OSMesa-specific global data
|
// OSMesa-specific global data
|
||||||
//
|
//
|
||||||
typedef struct _GLFWctxlibraryOSMesa
|
typedef struct _GLFWlibraryOSMesa
|
||||||
{
|
{
|
||||||
GLFWbool prefix;
|
|
||||||
|
|
||||||
void* handle;
|
void* handle;
|
||||||
|
|
||||||
PFNOSMESACREATECONTEXTPROC CreateContext;
|
PFNOSMESACREATECONTEXTATTRIBSPROC CreateContextAttribs;
|
||||||
PFNOSMESADESTROYCONTEXTPROC DestroyContext;
|
PFNOSMESADESTROYCONTEXTPROC DestroyContext;
|
||||||
PFNOSMESAMAKECURRENTPROC MakeCurrent;
|
PFNOSMESAMAKECURRENTPROC MakeCurrent;
|
||||||
PFNOSMESAGETCURRENTCONTEXTPROC GetCurrentContext;
|
|
||||||
PFNOSMESAPIXELSTOREPROC PixelStore;
|
|
||||||
PFNOSMESAGETINTEGERVPROC GetIntegerv;
|
|
||||||
PFNOSMESAGETCOLORBUFFERPROC GetColorBuffer;
|
PFNOSMESAGETCOLORBUFFERPROC GetColorBuffer;
|
||||||
PFNOSMESAGETDEPTHBUFFERPROC GetDepthBuffer;
|
PFNOSMESAGETDEPTHBUFFERPROC GetDepthBuffer;
|
||||||
PFNOSMESAGETPROCADDRESSPROC GetProcAddress;
|
PFNOSMESAGETPROCADDRESSPROC GetProcAddress;
|
||||||
|
|
||||||
} _GLFWctxlibraryOSMesa;
|
} _GLFWlibraryOSMesa;
|
||||||
|
|
||||||
|
|
||||||
GLFWbool _glfwInitOSMesa(void);
|
GLFWbool _glfwInitOSMesa(void);
|
||||||
|
@ -1,10 +1,32 @@
|
|||||||
|
//========================================================================
|
||||||
|
// GLFW 3.3 OSMesa - www.glfw.org
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2016 Google Inc.
|
||||||
|
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// 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 "internal.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW internal API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
@ -12,12 +34,10 @@
|
|||||||
|
|
||||||
int _glfwPlatformInit(void)
|
int _glfwPlatformInit(void)
|
||||||
{
|
{
|
||||||
if (!_glfwInitThreadLocalStoragePOSIX()) {
|
if (!_glfwInitThreadLocalStoragePOSIX())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
_glfwInitTimerPOSIX();
|
_glfwInitTimerPOSIX();
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +49,6 @@ void _glfwPlatformTerminate(void)
|
|||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
const char* _glfwPlatformGetVersionString(void)
|
||||||
{
|
{
|
||||||
const char* version = _GLFW_VERSION_NUMBER " OSMESA";
|
return _GLFW_VERSION_NUMBER " none OSMesa";
|
||||||
return version;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,32 @@
|
|||||||
|
//========================================================================
|
||||||
|
// GLFW 3.3 OSMesa - www.glfw.org
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2016 Google Inc.
|
||||||
|
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// 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 "internal.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW internal API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
@ -11,12 +34,9 @@
|
|||||||
|
|
||||||
_GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
_GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||||
{
|
{
|
||||||
// OSMesa is headless, so no monitors.
|
// OSMesa is headless, so no monitors
|
||||||
_GLFWmonitor** monitors = NULL;
|
|
||||||
if (count != NULL) {
|
|
||||||
*count = 0;
|
*count = 0;
|
||||||
}
|
return NULL;
|
||||||
return monitors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)
|
int _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)
|
||||||
@ -24,20 +44,24 @@ int _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) {}
|
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) {}
|
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) {}
|
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor,
|
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||||
const GLFWgammaramp* ramp) {}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW native API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
@ -1,15 +1,40 @@
|
|||||||
|
//========================================================================
|
||||||
|
// GLFW 3.3 OSMesa - www.glfw.org
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2016 Google Inc.
|
||||||
|
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#ifndef _osmesa_platform_h_
|
#ifndef _glfw3_osmesa_platform_h_
|
||||||
#define _osmesa_platform_h_
|
#define _glfw3_osmesa_platform_h_
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowOSMesa osmesa
|
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowOSMesa osmesa
|
||||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorOSMesa osmesa
|
|
||||||
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorOSMesa osmesa
|
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWwinlibraryOSMesa osmesawin
|
|
||||||
|
|
||||||
|
#define _GLFW_PLATFORM_MONITOR_STATE
|
||||||
|
#define _GLFW_PLATFORM_CURSOR_STATE
|
||||||
|
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE
|
||||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE
|
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE
|
||||||
#define _GLFW_EGL_CONTEXT_STATE
|
#define _GLFW_EGL_CONTEXT_STATE
|
||||||
#define _GLFW_EGL_LIBRARY_CONTEXT_STATE
|
#define _GLFW_EGL_LIBRARY_CONTEXT_STATE
|
||||||
@ -18,12 +43,15 @@
|
|||||||
#include "posix_time.h"
|
#include "posix_time.h"
|
||||||
#include "posix_tls.h"
|
#include "posix_tls.h"
|
||||||
|
|
||||||
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
|
#if defined(_GLFW_WIN32)
|
||||||
#define _glfw_dlclose(handle) dlclose(handle)
|
#define _glfw_dlopen(name) LoadLibraryA(name)
|
||||||
#define _glfw_dlsym(handle, name) dlsym(handle, name)
|
#define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)
|
||||||
|
#define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)
|
||||||
// TODO(dalyj) "PLACEHOLDER" variables are there to silence "empty struct"
|
#else
|
||||||
// warnings
|
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
|
||||||
|
#define _glfw_dlclose(handle) dlclose(handle)
|
||||||
|
#define _glfw_dlsym(handle, name) dlsym(handle, name)
|
||||||
|
#endif
|
||||||
|
|
||||||
// OSMesa-specific per-window data
|
// OSMesa-specific per-window data
|
||||||
//
|
//
|
||||||
@ -34,28 +62,4 @@ typedef struct _GLFWwindowOSMesa
|
|||||||
} _GLFWwindowOSMesa;
|
} _GLFWwindowOSMesa;
|
||||||
|
|
||||||
|
|
||||||
// OSMesa-specific global data
|
#endif // _glfw3_osmesa_platform_h_
|
||||||
//
|
|
||||||
typedef struct _GLFWwinlibraryOSMesa
|
|
||||||
{
|
|
||||||
int PLACEHOLDER;
|
|
||||||
} _GLFWwinlibraryOSMesa;
|
|
||||||
|
|
||||||
|
|
||||||
// OSMesa-specific per-monitor data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWmonitorOSMesa
|
|
||||||
{
|
|
||||||
int PLACEHOLDER;
|
|
||||||
} _GLFWmonitorOSMesa;
|
|
||||||
|
|
||||||
|
|
||||||
// OSMesa-specific per-cursor data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWcursorOSMesa
|
|
||||||
{
|
|
||||||
int PLACEHOLDER;
|
|
||||||
} _GLFWcursorOSMesa;
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _osmesa_platform_h_
|
|
||||||
|
@ -1,9 +1,35 @@
|
|||||||
|
//========================================================================
|
||||||
|
// GLFW 3.3 OSMesa - www.glfw.org
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2016 Google Inc.
|
||||||
|
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// 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 "internal.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
int createWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig)
|
static int createNativeWindow(_GLFWwindow* window,
|
||||||
|
const _GLFWwndconfig* wndconfig)
|
||||||
{
|
{
|
||||||
window->osmesa.width = wndconfig->width;
|
window->osmesa.width = wndconfig->width;
|
||||||
window->osmesa.height = wndconfig->height;
|
window->osmesa.height = wndconfig->height;
|
||||||
@ -11,9 +37,6 @@ int createWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig)
|
|||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW internal API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
@ -27,10 +50,13 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
if (!_glfwInitOSMesa())
|
if (!_glfwInitOSMesa())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
|
if (ctxconfig->client != GLFW_NO_API)
|
||||||
|
{
|
||||||
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!createWindow(window, wndconfig))
|
if (!createNativeWindow(window, wndconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
@ -42,29 +68,37 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
|||||||
window->context.destroy(window);
|
window->context.destroy(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) {}
|
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count,
|
void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count,
|
||||||
const GLFWimage* images) {}
|
const GLFWimage* images)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||||
_GLFWmonitor* monitor,
|
_GLFWmonitor* monitor,
|
||||||
int xpos, int ypos,
|
int xpos, int ypos,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int refreshRate) {}
|
int refreshRate)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||||
{
|
{
|
||||||
if (xpos != NULL) *xpos = 0;
|
|
||||||
if (ypos != NULL) *ypos = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) {}
|
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
||||||
{
|
{
|
||||||
if (width != NULL) *width = window->osmesa.width;
|
if (width)
|
||||||
if (height != NULL) *height = window->osmesa.height;
|
*width = window->osmesa.width;
|
||||||
|
if (height)
|
||||||
|
*height = window->osmesa.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||||
@ -75,70 +109,114 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||||||
|
|
||||||
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
||||||
int minwidth, int minheight,
|
int minwidth, int minheight,
|
||||||
int maxwidth, int maxheight) {}
|
int maxwidth, int maxheight)
|
||||||
|
|
||||||
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d) {}
|
|
||||||
|
|
||||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width,
|
|
||||||
int* height)
|
|
||||||
{
|
{
|
||||||
if (width != NULL) *width = window->osmesa.width;
|
|
||||||
if (height != NULL) *height = window->osmesa.height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, int* left, int* top,
|
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
|
||||||
|
{
|
||||||
|
if (width)
|
||||||
|
*width = window->osmesa.width;
|
||||||
|
if (height)
|
||||||
|
*height = window->osmesa.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||||
|
int* left, int* top,
|
||||||
int* right, int* bottom)
|
int* right, int* bottom)
|
||||||
{
|
{
|
||||||
if (left != NULL) *left = 0;
|
if (right)
|
||||||
if (top != NULL) *top = 0;
|
*right = window->osmesa.width;
|
||||||
if (right != NULL) *right = window->osmesa.width;
|
if (bottom)
|
||||||
if (bottom != NULL) *top = window->osmesa.height;
|
*top = window->osmesa.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window) {}
|
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||||
|
{
|
||||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window) {}
|
|
||||||
|
|
||||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window) {}
|
|
||||||
|
|
||||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window) {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformShowWindow(_GLFWwindow* window) {}
|
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||||
|
{
|
||||||
void _glfwPlatformUnhideWindow(_GLFWwindow* window) {}
|
|
||||||
|
|
||||||
void _glfwPlatformHideWindow(_GLFWwindow* window) {}
|
|
||||||
|
|
||||||
void _glfwPlatformFocusWindow(_GLFWwindow* window) {}
|
|
||||||
|
|
||||||
int _glfwPlatformWindowFocused(_GLFWwindow* window) { return GLFW_FALSE; }
|
|
||||||
|
|
||||||
int _glfwPlatformWindowIconified(_GLFWwindow* window) { return GLFW_FALSE; }
|
|
||||||
|
|
||||||
int _glfwPlatformWindowVisible(_GLFWwindow* window) { return GLFW_FALSE; }
|
|
||||||
|
|
||||||
void _glfwPlatformPollEvents(void) {}
|
|
||||||
|
|
||||||
void _glfwPlatformWaitEvents(void) {}
|
|
||||||
|
|
||||||
void _glfwPlatformWaitEventsTimeout(double timeout) {}
|
|
||||||
|
|
||||||
void _glfwPlatformPostEmptyEvent(void) {}
|
|
||||||
|
|
||||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) {
|
|
||||||
if (xpos != NULL) *xpos = 0;
|
|
||||||
if (ypos != NULL) *ypos = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) {}
|
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) {}
|
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformApplyCursorMode(_GLFWwindow* window) {}
|
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor, const GLFWimage* image,
|
void _glfwPlatformUnhideWindow(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformWindowFocused(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformWindowIconified(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformPollEvents(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformWaitEvents(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformPostEmptyEvent(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformApplyCursorMode(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||||
|
const GLFWimage* image,
|
||||||
int xhot, int yhot)
|
int xhot, int yhot)
|
||||||
{
|
{
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
@ -149,41 +227,57 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) {}
|
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) {}
|
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string) {}
|
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetKeyName(int key, int scancode) { return ""; }
|
const char* _glfwPlatformGetKeyName(int key, int scancode)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
int _glfwPlatformJoystickPresent(int joy) { return 0; }
|
int _glfwPlatformGetKeyScancode(int key)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformJoystickPresent(int joy)
|
||||||
|
{
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
|
const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
|
||||||
{
|
{
|
||||||
if (count != NULL) *count = 0;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
|
const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
|
||||||
{
|
{
|
||||||
if (count != NULL) *count = 0;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetJoystickName(int joy) { return NULL; }
|
const char* _glfwPlatformGetJoystickName(int joy)
|
||||||
|
|
||||||
char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count)
|
|
||||||
{
|
{
|
||||||
if (count != NULL) *count = 0;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
||||||
VkPhysicalDevice device,
|
VkPhysicalDevice device,
|
||||||
uint32_t queuefamily)
|
uint32_t queuefamily)
|
||||||
@ -196,64 +290,7 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
|||||||
const VkAllocationCallbacks* allocator,
|
const VkAllocationCallbacks* allocator,
|
||||||
VkSurfaceKHR* surface)
|
VkSurfaceKHR* surface)
|
||||||
{
|
{
|
||||||
// This seems like the most appropriate error to return here.
|
// This seems like the most appropriate error to return here
|
||||||
return VK_ERROR_INITIALIZATION_FAILED;
|
return VK_ERROR_INITIALIZATION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW native API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width,
|
|
||||||
int* height, int* format, void** buffer)
|
|
||||||
{
|
|
||||||
GLint mesaWidth;
|
|
||||||
GLint mesaHeight;
|
|
||||||
GLint mesaFormat;
|
|
||||||
void* mesaBuffer;
|
|
||||||
|
|
||||||
assert(window != NULL);
|
|
||||||
|
|
||||||
OSMesaContext ctx = ((_GLFWwindow*) window)->context.osmesa.handle;
|
|
||||||
|
|
||||||
// Query OSMesa for the color buffer data.
|
|
||||||
int result = OSMesaGetColorBuffer(
|
|
||||||
ctx, &mesaWidth, &mesaHeight, &mesaFormat, &mesaBuffer);
|
|
||||||
if (result) {
|
|
||||||
// Copy the values returned by OSMesa.
|
|
||||||
if (width != NULL) *width = mesaWidth;
|
|
||||||
if (height != NULL) *height = mesaHeight;
|
|
||||||
if (format != NULL) *format = mesaFormat;
|
|
||||||
if (buffer != NULL) *buffer = mesaBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width,
|
|
||||||
int* height, int* bytesPerValue,
|
|
||||||
void** buffer)
|
|
||||||
{
|
|
||||||
GLint mesaWidth;
|
|
||||||
GLint mesaHeight;
|
|
||||||
GLint mesaBytes;
|
|
||||||
void* mesaBuffer;
|
|
||||||
|
|
||||||
assert(window != NULL);
|
|
||||||
|
|
||||||
OSMesaContext ctx = ((_GLFWwindow*) window)->context.osmesa.handle;
|
|
||||||
|
|
||||||
// Query OSMesa for the color buffer data.
|
|
||||||
int result = OSMesaGetDepthBuffer(
|
|
||||||
ctx, &mesaWidth, &mesaHeight, &mesaBytes, &mesaBuffer);
|
|
||||||
if (result) {
|
|
||||||
// Copy the values returned by OSMesa.
|
|
||||||
if (width != NULL) *width = mesaWidth;
|
|
||||||
if (height != NULL) *height = mesaHeight;
|
|
||||||
if (bytesPerValue != NULL) *bytesPerValue = mesaBytes;
|
|
||||||
if (buffer != NULL) *buffer = mesaBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user