This commit is contained in:
Tungstend 2023-07-27 10:30:31 +08:00
parent 8f828b6c57
commit 45b00f8ab2
8 changed files with 98 additions and 1 deletions

View File

@ -1 +1 @@
1690399681223
1690424430137

View File

@ -9,6 +9,7 @@
#include <string.h>
#include <limits.h>
#include <stdio.h>
#include "fcl_bridge.h"
//////////////////////////////////////////////////////////////////////////
@ -389,6 +390,31 @@ GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI int glfwGetOSMesaWidth() {
struct ANativeWindow* window = fclGetNativeWindow();
return ANativeWindow_getWidth(window);
}
GLFWAPI int glfwGetOSMesaHeight() {
struct ANativeWindow* window = fclGetNativeWindow();
return ANativeWindow_getHeight(window);
}
GLFWAPI void* glfwGetOSMesaCurrentContext() {
if (!_glfw.osmesa.GetCurrentContext)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "OSMesa: Failed to load required entry points");
_glfwTerminateOSMesa();
return GLFW_FALSE;
}
return OSMesaGetCurrentContext();
}
GLFWAPI long glfwGetGraphicBuffersAddr(GLFWwindow* handle) {
_GLFWwindow* window = (_GLFWwindow*) handle;
return &window->context.osmesa.buffer;
}
GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;

View File

@ -5435,6 +5435,26 @@ GLFWAPI uint64_t glfwGetTimerValue(void);
*/
GLFWAPI uint64_t glfwGetTimerFrequency(void);
/*!
* This function is to get OSMesa width
*/
GLFWAPI int glfwGetOSMesaWidth();
/*!
* This function is to get OSMesa height
*/
GLFWAPI int glfwGetOSMesaHeight();
/*!
* This function is to get OSMesa Current Context
*/
GLFWAPI void* glfwGetOSMesaCurrentContext();
/*!
* This function is to get Graphic Buffers Addr
*/
GLFWAPI long glfwGetGraphicBuffersAddr(GLFWwindow* window);
/*! @brief Makes the context of the specified window current for the calling
* thread.
*

View File

@ -790,6 +790,10 @@ public class GLFW {
SetTime = apiGetFunctionAddress(GLFW, "glfwSetTime"),
GetTimerValue = apiGetFunctionAddress(GLFW, "glfwGetTimerValue"),
GetTimerFrequency = apiGetFunctionAddress(GLFW, "glfwGetTimerFrequency"),
GetOSMesaWidth = apiGetFunctionAddress(GLFW, "glfwGetOSMesaWidth"),
GetOSMesaHeight = apiGetFunctionAddress(GLFW, "glfwGetOSMesaHeight"),
GetOSMesaCurrentContext = apiGetFunctionAddress(GLFW, "glfwGetOSMesaCurrentContext"),
GetGraphicBuffersAddr = apiGetFunctionAddress(GLFW, "glfwGetGraphicBuffersAddr"),
MakeContextCurrent = apiGetFunctionAddress(GLFW, "glfwMakeContextCurrent"),
GetCurrentContext = apiGetFunctionAddress(GLFW, "glfwGetCurrentContext"),
SwapBuffers = apiGetFunctionAddress(GLFW, "glfwSwapBuffers"),
@ -4380,6 +4384,46 @@ public class GLFW {
return invokeJ(__functionAddress);
}
// --- [ glfwGetOSMesaWidth ] ---
/**
* Get OSMesa width
*/
public static int glfwGetOSMesaWidth() {
long __functionAddress = Functions.GetOSMesaWidth;
return invokeI(__functionAddress);
}
// --- [ glfwGetOSMesaHeight ] ---
/**
* Get OSMesa height
*/
public static int glfwGetOSMesaHeight() {
long __functionAddress = Functions.GetOSMesaHeight;
return invokeI(__functionAddress);
}
// --- [ glfwGetOSMesaContext ] ---
/**
* Get OSMesa Context
*/
public static long glfwGetOSMesaCurrentContext() {
long __functionAddress = Functions.GetOSMesaCurrentContext;
return invokeJ(__functionAddress);
}
// --- [ glfwGetGraphicBuffersAddr ] ---
/**
* Get Graphic Buffers Addr
*/
public static long glfwGetGraphicBuffersAddr(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.GetGraphicBuffersAddr;
return invokePJ(window, __functionAddress);
}
// --- [ glfwMakeContextCurrent ] ---
/**

View File

@ -4,6 +4,7 @@
*/
package org.lwjgl.opengl;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.system.*;
import org.lwjgl.system.macosx.*;
import org.lwjgl.system.windows.*;
@ -20,6 +21,7 @@ import static org.lwjgl.opengl.WGL.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import static org.lwjgl.system.JNI.callJPI;
import static org.lwjgl.system.MemoryStack.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.linux.X11.*;
@ -346,6 +348,11 @@ public final class GL {
GLCapabilities caps = null;
try {
if (System.getProperty("org.lwjgl.opengl.libname", "").equals("libOSMesa_8.so")) {
long window = GLFW.glfwGetCurrentContext();
callJPI(GLFW.glfwGetOSMesaCurrentContext(), GLFW.glfwGetGraphicBuffersAddr(window), GL_UNSIGNED_BYTE, GLFW.glfwGetOSMesaWidth(), GLFW.glfwGetOSMesaHeight(), functionProvider.getFunctionAddress("OSMesaMakeCurrent"));
}
// We don't have a current ContextCapabilities when this method is called
// so we have to use the native bindings directly.
long GetError = functionProvider.getFunctionAddress("glGetError");