mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
[Android] Finally check if regular OpenGL is possible on devices and display/hide it's fragment based upon this in AboutActivity.java.
Also added another constructor to EGLHelper which can be used to quickly query for information.
This commit is contained in:
parent
f8abdbf91a
commit
0dc437e94d
@ -1,7 +1,7 @@
|
||||
package org.dolphinemu.dolphinemu.about;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.settings.video.VideoSettingsFragment;
|
||||
import org.dolphinemu.dolphinemu.utils.EGLHelper;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.ActionBar.Tab;
|
||||
@ -21,7 +21,7 @@ import android.support.v4.view.ViewPager;
|
||||
public final class AboutActivity extends Activity implements TabListener
|
||||
{
|
||||
private ViewPager viewPager;
|
||||
private boolean supportsGles3;
|
||||
private EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES2_BIT);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
@ -32,9 +32,6 @@ public final class AboutActivity extends Activity implements TabListener
|
||||
setContentView(R.layout.viewpager);
|
||||
viewPager = (ViewPager) findViewById(R.id.pager);
|
||||
|
||||
// Check if GLES3 is supported
|
||||
supportsGles3 = VideoSettingsFragment.SupportsGLES3();
|
||||
|
||||
// Initialize the ViewPager adapter.
|
||||
final ViewPagerAdapter adapter = new ViewPagerAdapter(getFragmentManager());
|
||||
viewPager.setAdapter(adapter);
|
||||
@ -45,10 +42,10 @@ public final class AboutActivity extends Activity implements TabListener
|
||||
actionBar.addTab(actionBar.newTab().setText(R.string.general).setTabListener(this));
|
||||
actionBar.addTab(actionBar.newTab().setText(R.string.cpu).setTabListener(this));
|
||||
actionBar.addTab(actionBar.newTab().setText(R.string.gles_two).setTabListener(this));
|
||||
if (supportsGles3)
|
||||
if (eglHelper.supportsGLES3())
|
||||
actionBar.addTab(actionBar.newTab().setText(R.string.gles_three).setTabListener(this));
|
||||
// TODO: Check if Desktop GL is possible before enabling.
|
||||
actionBar.addTab(actionBar.newTab().setText(R.string.desktop_gl).setTabListener(this));
|
||||
if (eglHelper.supportsOpenGL())
|
||||
actionBar.addTab(actionBar.newTab().setText(R.string.desktop_gl).setTabListener(this));
|
||||
|
||||
// Set the page change listener
|
||||
viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener()
|
||||
@ -61,6 +58,14 @@ public final class AboutActivity extends Activity implements TabListener
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy()
|
||||
{
|
||||
super.onDestroy();
|
||||
|
||||
eglHelper.closeHelper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabSelected(Tab tab, FragmentTransaction ft)
|
||||
{
|
||||
@ -94,30 +99,46 @@ public final class AboutActivity extends Activity implements TabListener
|
||||
@Override
|
||||
public Fragment getItem(int position)
|
||||
{
|
||||
switch (position)
|
||||
if (position == 0)
|
||||
{
|
||||
case 0: return new DolphinInfoFragment();
|
||||
// TODO: The rest of these fragments
|
||||
case 1: return new Fragment(); // CPU
|
||||
case 2: return new Fragment(); // GLES 2
|
||||
case 3: return new Fragment(); // GLES 3
|
||||
case 4: return new Fragment(); // Desktop GL
|
||||
|
||||
default: // Should never happen
|
||||
return null;
|
||||
return new DolphinInfoFragment();
|
||||
}
|
||||
else if (position == 1)
|
||||
{
|
||||
return new Fragment(); // CPU
|
||||
}
|
||||
else if (position == 2) // GLES 2
|
||||
{
|
||||
return new Fragment();
|
||||
}
|
||||
else if (position == 3) // GLES 3 or OpenGL (depending on circumstances)
|
||||
{
|
||||
if (eglHelper.supportsGLES3())
|
||||
return new Fragment(); // TODO: Return the GLES 3 fragment in this case (normal case)
|
||||
else
|
||||
return new Fragment(); // TODO: Return the OpenGL fragment in this case (GLES3 not supported case)
|
||||
}
|
||||
else if (position == 4) // OpenGL fragment
|
||||
{
|
||||
return new Fragment();
|
||||
}
|
||||
|
||||
// This should never happen.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount()
|
||||
{
|
||||
// TODO: In the future, make sure to take into account
|
||||
// whether or not regular Desktop GL is possible.
|
||||
if (supportsGles3)
|
||||
if (eglHelper.supportsGLES3() && eglHelper.supportsOpenGL())
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
else
|
||||
else if (!eglHelper.supportsGLES3() && !eglHelper.supportsOpenGL())
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
else // Either regular OpenGL or GLES3 isn't supported
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
@ -34,6 +34,21 @@ public final class EGLHelper
|
||||
public static final int EGL_OPENGL_BIT = 0x0008;
|
||||
public static final int EGL_OPENGL_ES3_BIT_KHR = 0x0040;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* <p>
|
||||
* Initializes the underlying {@link EGLSurface} with a width and height of 1.
|
||||
* This is useful if all you need to use this class for is to query information
|
||||
* from specific API contexts.
|
||||
*
|
||||
* @param renderableType Bitmask indicating which types of client API contexts
|
||||
* the framebuffer config must support.
|
||||
*/
|
||||
public EGLHelper(int renderableType)
|
||||
{
|
||||
this(1, 1, renderableType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -85,8 +100,8 @@ public final class EGLHelper
|
||||
* Gets information through EGL.<br/>
|
||||
* <p>
|
||||
* Index 0: Vendor <br/>
|
||||
* Index 1: Renderer <br/>
|
||||
* Index 2: Version <br/>
|
||||
* Index 1: Version <br/>
|
||||
* Index 2: Renderer <br/>
|
||||
* Index 3: Extensions <br/>
|
||||
*
|
||||
* @return information retrieved through EGL.
|
||||
@ -95,8 +110,8 @@ public final class EGLHelper
|
||||
{
|
||||
String[] info = {
|
||||
mGL.glGetString(GL10.GL_VENDOR),
|
||||
mGL.glGetString(GL10.GL_RENDERER),
|
||||
mGL.glGetString(GL10.GL_VERSION),
|
||||
mGL.glGetString(GL10.GL_RENDERER),
|
||||
mGL.glGetString(GL10.GL_EXTENSIONS),
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user