mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 23:00:45 -04:00
Call eglGetDisplay() before make current to no context
This commit is contained in:
parent
696c415564
commit
8331aeaf73
@ -49,87 +49,88 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglInit(JNIEnv* env, j
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglMakeCurrent(JNIEnv* env, jclass clazz) {
|
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglMakeCurrent(JNIEnv* env, jclass clazz) {
|
||||||
|
if (potatoBridge.eglDisplay == NULL || potatoBridge.eglDisplay == EGL_NO_DISPLAY) {
|
||||||
|
potatoBridge.eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
|
if (potatoBridge.eglDisplay == EGL_NO_DISPLAY) {
|
||||||
|
printf("Error: eglGetDefaultDisplay() failed: %p\n", eglGetError());
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
eglMakeCurrent(potatoBridge.eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
eglMakeCurrent(potatoBridge.eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||||
|
|
||||||
if (potatoBridge.eglContext == NULL || potatoBridge.eglContext == EGL_NO_CONTEXT) {
|
if (potatoBridge.eglContext == NULL || potatoBridge.eglContext == EGL_NO_CONTEXT) {
|
||||||
printf("EGLBridge: Initializing\n");
|
printf("EGLBridge: Initializing\n");
|
||||||
printf("ANativeWindow pointer = %p\n", potatoBridge.androidWindow);
|
printf("ANativeWindow pointer = %p\n", potatoBridge.androidWindow);
|
||||||
|
|
||||||
potatoBridge.eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
if (!eglInitialize(potatoBridge.eglDisplay, NULL, NULL)) {
|
||||||
if (potatoBridge.eglDisplay == EGL_NO_DISPLAY) {
|
printf("Error: eglInitialize() failed\n");
|
||||||
printf("Error: eglGetDefaultDisplay() failed: %p\n", eglGetError());
|
return JNI_FALSE;
|
||||||
return JNI_FALSE;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!eglInitialize(potatoBridge.eglDisplay, NULL, NULL)) {
|
static const EGLint attribs[] = {
|
||||||
printf("Error: eglInitialize() failed\n");
|
EGL_RED_SIZE, 8,
|
||||||
return JNI_FALSE;
|
EGL_GREEN_SIZE, 8,
|
||||||
}
|
EGL_BLUE_SIZE, 8,
|
||||||
|
EGL_ALPHA_SIZE, 8,
|
||||||
|
EGL_DEPTH_SIZE, 24,
|
||||||
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
static const EGLint ctx_attribs[] = {
|
||||||
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
|
||||||
static const EGLint attribs[] = {
|
EGLConfig config;
|
||||||
EGL_RED_SIZE, 8,
|
EGLint num_configs;
|
||||||
EGL_GREEN_SIZE, 8,
|
EGLint vid;
|
||||||
EGL_BLUE_SIZE, 8,
|
|
||||||
EGL_ALPHA_SIZE, 8,
|
|
||||||
EGL_DEPTH_SIZE, 24,
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
static const EGLint ctx_attribs[] = {
|
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
EGLConfig config;
|
if (!eglChooseConfig(potatoBridge.eglDisplay, attribs, &config, 1, &num_configs)) {
|
||||||
EGLint num_configs;
|
printf("Error: couldn't get an EGL visual config\n");
|
||||||
EGLint vid;
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!eglChooseConfig(potatoBridge.eglDisplay, attribs, &config, 1, &num_configs)) {
|
assert(config);
|
||||||
printf("Error: couldn't get an EGL visual config\n");
|
assert(num_configs > 0);
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(config);
|
if (!eglGetConfigAttrib(potatoBridge.eglDisplay, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||||
assert(num_configs > 0);
|
printf("Error: eglGetConfigAttrib() failed\n");
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!eglGetConfigAttrib(potatoBridge.eglDisplay, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
ANativeWindow_setBuffersGeometry(potatoBridge.androidWindow, 0, 0, vid);
|
||||||
printf("Error: eglGetConfigAttrib() failed\n");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ANativeWindow_setBuffersGeometry(potatoBridge.androidWindow, 0, 0, vid);
|
eglBindAPI(EGL_OPENGL_ES_API);
|
||||||
|
|
||||||
eglBindAPI(EGL_OPENGL_ES_API);
|
potatoBridge.eglContext = eglCreateContext(potatoBridge.eglDisplay, config, EGL_NO_CONTEXT, ctx_attribs);
|
||||||
|
if (!potatoBridge.eglContext) {
|
||||||
|
printf("Error: eglCreateContext failed\n");
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
potatoBridge.eglContext = eglCreateContext(potatoBridge.eglDisplay, config, EGL_NO_CONTEXT, ctx_attribs);
|
// test eglQueryContext()
|
||||||
if (!potatoBridge.eglContext) {
|
{
|
||||||
printf("Error: eglCreateContext failed\n");
|
EGLint val;
|
||||||
return JNI_FALSE;
|
eglQueryContext(potatoBridge.eglDisplay, potatoBridge.eglContext, EGL_CONTEXT_CLIENT_VERSION, &val);
|
||||||
}
|
printf("OpenGL ES from eglQueryContext: %i\n", val);
|
||||||
|
// assert(val >= 2);
|
||||||
|
}
|
||||||
|
|
||||||
// test eglQueryContext()
|
potatoBridge.eglSurface = eglCreateWindowSurface(potatoBridge.eglDisplay, config, potatoBridge.androidWindow, NULL);
|
||||||
{
|
|
||||||
EGLint val;
|
|
||||||
eglQueryContext(potatoBridge.eglDisplay, potatoBridge.eglContext, EGL_CONTEXT_CLIENT_VERSION, &val);
|
|
||||||
printf("OpenGL ES from eglQueryContext: %i\n", val);
|
|
||||||
// assert(val >= 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
potatoBridge.eglSurface = eglCreateWindowSurface(potatoBridge.eglDisplay, config, potatoBridge.androidWindow, NULL);
|
if (!potatoBridge.eglSurface) {
|
||||||
|
printf("Error: eglCreateWindowSurface failed: %p\n", eglGetError());
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!potatoBridge.eglSurface) {
|
// sanity checks
|
||||||
printf("Error: eglCreateWindowSurface failed: %p\n", eglGetError());
|
{
|
||||||
return JNI_FALSE;
|
EGLint val;
|
||||||
}
|
assert(eglGetConfigAttrib(potatoBridge.eglDisplay, config, EGL_SURFACE_TYPE, &val));
|
||||||
|
assert(val & EGL_WINDOW_BIT);
|
||||||
// sanity checks
|
}
|
||||||
{
|
|
||||||
EGLint val;
|
|
||||||
assert(eglGetConfigAttrib(potatoBridge.eglDisplay, config, EGL_SURFACE_TYPE, &val));
|
|
||||||
assert(val & EGL_WINDOW_BIT);
|
|
||||||
}
|
|
||||||
// return JNI_TRUE;
|
// return JNI_TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("EGLBridge: Making current\n");
|
printf("EGLBridge: Making current\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user