Skip to content

Commit

Permalink
Fix the OpenGL About tab.
Browse files Browse the repository at this point in the history
Move EGLHelper to be local to the creation of the about GL/GLES tabs so we don't have 3 EGL contexts running at a time.
Fix issues with OpenGL context creation here so we show the correct information.
This requires adding an EGL function to the NativeLibrary since Android's JAVA bindings don't expose eglBindAPI.
  • Loading branch information
RyanHoudek committed Feb 23, 2014
1 parent f9ed70b commit 1f75090
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ public static final class ButtonState
/** Stops emulation. */
public static native void StopEmulation();

/** Native EGL functions not exposed by Java bindings **/
public static native void eglBindAPI(int api);

static
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
*/
public final class GLES2InfoFragment extends ListFragment
{
private final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES2_BIT);

private final Limit[] Limits = {
new Limit("Vendor", GLES20.GL_VENDOR, Type.STRING),
new Limit("Version", GLES20.GL_VERSION, Type.STRING),
Expand All @@ -56,6 +54,8 @@ public final class GLES2InfoFragment extends ListFragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES2_BIT);

ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
List<AboutActivity.AboutFragmentItem> Input = new ArrayList<AboutActivity.AboutFragmentItem>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
*/
public final class GLES3InfoFragment extends ListFragment
{
private final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES3_BIT_KHR);

private final Limit[] Limits = {
new Limit("Vendor", GLES30.GL_VENDOR, Type.STRING),
new Limit("Version", GLES30.GL_VERSION, Type.STRING),
Expand Down Expand Up @@ -88,6 +86,8 @@ public final class GLES3InfoFragment extends ListFragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES3_BIT_KHR);

ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
List<AboutActivity.AboutFragmentItem> Input = new ArrayList<AboutActivity.AboutFragmentItem>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
*/
public final class GLInfoFragment extends ListFragment
{
private final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_BIT);

private final Limit[] Limits = {
new Limit("Vendor", GL10.GL_VENDOR, Type.STRING),
new Limit("Version", GL10.GL_VERSION, Type.STRING),
Expand All @@ -43,6 +41,8 @@ public final class GLInfoFragment extends ListFragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_BIT);

ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
List<AboutActivity.AboutFragmentItem> Input = new ArrayList<AboutActivity.AboutFragmentItem>();

Expand Down
10 changes: 10 additions & 0 deletions Source/Android/src/org/dolphinemu/dolphinemu/utils/EGLHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import android.opengl.GLES30;
import android.util.Log;

import org.dolphinemu.dolphinemu.NativeLibrary;

/**
* Utility class that abstracts all the stuff about
* EGL initialization out of the way if all that is
Expand All @@ -41,6 +43,10 @@ public final class EGLHelper
public static final int EGL_OPENGL_BIT = 0x0008;
public static final int EGL_OPENGL_ES3_BIT_KHR = 0x0040;

// API types
public static final int EGL_OPENGL_ES_API = 0x30A0;
public static final int EGL_OPENGL_API = 0x30A2;

/**
* Constructor
* <p>
Expand Down Expand Up @@ -295,6 +301,10 @@ private void create(int width, int height, int renderableType)
ctx_attribs[1] = 2;
break;
}
if (renderableType == EGL_OPENGL_BIT)
NativeLibrary.eglBindAPI(EGL_OPENGL_API);
else
NativeLibrary.eglBindAPI(EGL_OPENGL_ES_API);

mEGLContext = mEGL.eglCreateContext(mDisplay, mEGLConfigs[0], EGL10.EGL_NO_CONTEXT, ctx_attribs);
mEGLSurface = mEGL.eglCreatePbufferSurface(mDisplay, mEGLConfigs[0], attribs);
Expand Down
6 changes: 6 additions & 0 deletions Source/Core/DolphinWX/MainAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <jni.h>
#include <android/log.h>
#include <android/native_window_jni.h>
#include <EGL/egl.h>

#include "Android/ButtonManager.h"
#include "Common/Common.h"
Expand Down Expand Up @@ -297,6 +298,11 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenSh
Core::SaveScreenShot();
}

JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_eglBindAPI(JNIEnv *env, jobject obj, jint api)
{
eglBindAPI(api);
}

JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jKey, jstring jValue, jstring jDefault)
{
IniFile ini;
Expand Down

0 comments on commit 1f75090

Please sign in to comment.