Use pbuffer for now for testing first

This commit is contained in:
khanhduytran0 2021-11-09 19:09:06 +07:00
parent 0967dae16c
commit d6ecad04d4
4 changed files with 38 additions and 29 deletions

View File

@ -617,6 +617,7 @@ EGLBoolean (*eglInitialize_p) (EGLDisplay dpy, EGLint *major, EGLint *minor);
EGLBoolean (*eglChooseConfig_p) (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
EGLBoolean (*eglGetConfigAttrib_p) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
EGLBoolean (*eglBindAPI_p) (EGLenum api);
EGLSurface (*eglCreatePbufferSurface_p) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
EGLSurface (*eglCreateWindowSurface_p) (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list);
EGLBoolean (*eglSwapBuffers_p) (EGLDisplay dpy, EGLSurface draw);
EGLint (*eglGetError_p) (void);
@ -686,6 +687,7 @@ void dlsym_EGL(void* dl_handle) {
eglBindAPI_p = dlsym(dl_handle,"eglBindAPI");
eglChooseConfig_p = dlsym(dl_handle, "eglChooseConfig");
eglCreateContext_p = dlsym(dl_handle, "eglCreateContext");
eglCreatePbufferSurface_p = dlsym(dl_handle, "eglCreatePbufferSurface");
eglCreateWindowSurface_p = dlsym(dl_handle, "eglCreateWindowSurface");
eglDestroyContext_p = dlsym(dl_handle, "eglDestroyContext");
eglDestroySurface_p = dlsym(dl_handle, "eglDestroySurface");
@ -834,7 +836,19 @@ int pojavInit() {
eglBindAPI_p(EGL_OPENGL_ES_API);
// VirGL TODO: switch to WindowSurface once fingure out how to call eglSwapBuffers from the loop
if (config_renderer == RENDERER_VIRGL) {
const EGLint pbufferAttribs[] = {
EGL_WIDTH,
savedWidth,
EGL_HEIGHT,
savedHeight,
EGL_NONE,
};
potatoBridge.eglSurface = eglCreatePbufferSurface_p(potatoBridge.eglDisplay, pbufferConfig);
} else {
potatoBridge.eglSurface = eglCreateWindowSurface_p(potatoBridge.eglDisplay, config, potatoBridge.androidWindow, NULL);
}
if (!potatoBridge.eglSurface) {
printf("EGLBridge: Error eglCreateWindowSurface failed: %p\n", eglGetError_p());

View File

@ -569,8 +569,6 @@ public class GLFW
*/
}
public static native long nativeEglCreateContext(long contextSrc);
private static native long nglfwSetCharCallback(long window, long ptr);
private static native long nglfwSetCharModsCallback(long window, long ptr);
private static native long nglfwSetCursorEnterCallback(long window, long ptr);
@ -609,6 +607,7 @@ public class GLFW
/** Function address. */
public static final long
Init = apiGetFunctionAddress(GLFW, "pojavInit"),
CreateContext = apiGetFunctionAddress(GLFW, "pojavCreateContext"),
GetCurrentContext = apiGetFunctionAddress(GLFW, "pojavGetCurrentContext"),
//DetachOnCurrentThread = apiGetFunctionAddress(GLFW, "pojavDetachOnCurrentThread"),
MakeContextCurrent = apiGetFunctionAddress(GLFW, "pojavMakeCurrent"),
@ -991,9 +990,6 @@ public class GLFW
public static void glfwSwapBuffers(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.SwapBuffers;
if (CHECKS) {
check(window);
}
invokePV(window, __functionAddress);
}
@ -1026,7 +1022,7 @@ public class GLFW
public static long glfwCreateWindow(int width, int height, CharSequence title, long monitor, long share) {
EventLoop.OffScreen.check();
// Create an ACTUAL EGL context
long ptr = nativeEglCreateContext(share);
long ptr = invokePP(window, Functions.CreateContext);
//nativeEglMakeCurrent(ptr);
GLFWWindowProperties win = new GLFWWindowProperties();
// win.width = width;
@ -1041,7 +1037,6 @@ public class GLFW
mainContext = ptr;
return ptr;
//Return our context
}
public static void glfwDestroyWindow(long window) {