Pixel format selection spinner

This commit is contained in:
mittorn 2016-05-08 08:44:32 +00:00
parent 3903f06abb
commit aba773d1c0
3 changed files with 56 additions and 23 deletions

View file

@ -233,6 +233,14 @@
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:onClick="createShortcut" android:onClick="createShortcut"
android:text="@string/create_shortcut_button" /> android:text="@string/create_shortcut_button" />
<Spinner
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:id="@+id/pixelSpinner"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"/>
<TextView <TextView
android:id="@+id/textView7" android:id="@+id/textView7"

View file

@ -13,6 +13,9 @@ import android.widget.EditText;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.Button; import android.widget.Button;
import android.widget.Spinner;
import android.widget.ArrayAdapter;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -36,6 +39,7 @@ public class LauncherActivity extends Activity {
static ToggleButton useVolume; static ToggleButton useVolume;
static EditText resPath; static EditText resPath;
static SharedPreferences mPref; static SharedPreferences mPref;
static Spinner pixelSpinner;
String getDefaultPath() String getDefaultPath()
{ {
File dir = Environment.getExternalStorageDirectory(); File dir = Environment.getExternalStorageDirectory();
@ -67,6 +71,19 @@ public class LauncherActivity extends Activity {
tabSpec.setContent(R.id.tab2); tabSpec.setContent(R.id.tab2);
tabHost.addTab(tabSpec); tabHost.addTab(tabSpec);
final String[] list = {
"RGBA8888",
"RGBA888",
"RGB565",
"RGBA5551",
"RGBA4444",
"RGB332"
};
pixelSpinner = (Spinner) findViewById(R.id.pixelSpinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, list);
//ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, list, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
pixelSpinner.setAdapter(adapter);
Button selectFolderButton = ( Button ) findViewById( R.id.button_select ); Button selectFolderButton = ( Button ) findViewById( R.id.button_select );
selectFolderButton.setOnClickListener(new View.OnClickListener(){ selectFolderButton.setOnClickListener(new View.OnClickListener(){
@Override @Override
@ -101,6 +118,7 @@ public class LauncherActivity extends Activity {
useVolume.setChecked(mPref.getBoolean("usevolume",true)); useVolume.setChecked(mPref.getBoolean("usevolume",true));
resPath = ( EditText ) findViewById( R.id.cmdPath ); resPath = ( EditText ) findViewById( R.id.cmdPath );
resPath.setText(mPref.getString("basedir", getDefaultPath())); resPath.setText(mPref.getString("basedir", getDefaultPath()));
pixelSpinner.setSelection(mPref.getInt("pixelformat", 0));
} }
public void startXash(View view) public void startXash(View view)
@ -112,6 +130,7 @@ public class LauncherActivity extends Activity {
editor.putString("argv", cmdArgs.getText().toString()); editor.putString("argv", cmdArgs.getText().toString());
editor.putBoolean("usevolume",useVolume.isChecked()); editor.putBoolean("usevolume",useVolume.isChecked());
editor.putString("basedir", resPath.getText().toString()); editor.putString("basedir", resPath.getText().toString());
editor.putInt("pixelformat", pixelSpinner.getSelectedItemPosition());
editor.commit(); editor.commit();
startActivity(intent); startActivity(intent);
} }

View file

@ -30,6 +30,7 @@ public class XashActivity extends Activity {
private static EngineSurface mSurface; private static EngineSurface mSurface;
public static String mArgv[]; public static String mArgv[];
public static final int sdk = Integer.valueOf(Build.VERSION.SDK); public static final int sdk = Integer.valueOf(Build.VERSION.SDK);
public static int mPixelFormat;
// Preferences // Preferences
public static SharedPreferences mPref = null; public static SharedPreferences mPref = null;
@ -109,6 +110,7 @@ public class XashActivity extends Activity {
{ {
e.printStackTrace(); e.printStackTrace();
} }
mPixelFormat = mPref.getInt("pixelformat", 0);
} }
// Events // Events
@ -422,51 +424,55 @@ View.OnKeyListener {
int[] version = new int[2]; int[] version = new int[2];
egl.eglInitialize(dpy, version); egl.eglInitialize(dpy, version);
int[] configSpec1 = { int[][] configSpec = {{
EGL10.EGL_DEPTH_SIZE, 8, EGL10.EGL_DEPTH_SIZE, 8,
EGL10.EGL_RED_SIZE, 8, EGL10.EGL_RED_SIZE, 8,
EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8,
EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8,
EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8,
EGL10.EGL_NONE EGL10.EGL_NONE
}; }, {
int[] configSpec2 = { EGL10.EGL_DEPTH_SIZE, 8,
EGL10.EGL_RED_SIZE, 8,
EGL10.EGL_GREEN_SIZE, 8,
EGL10.EGL_BLUE_SIZE, 8,
EGL10.EGL_ALPHA_SIZE, 0,
EGL10.EGL_NONE
}, {
EGL10.EGL_DEPTH_SIZE, 8, EGL10.EGL_DEPTH_SIZE, 8,
EGL10.EGL_RED_SIZE, 5, EGL10.EGL_RED_SIZE, 5,
EGL10.EGL_GREEN_SIZE, 6, EGL10.EGL_GREEN_SIZE, 6,
EGL10.EGL_BLUE_SIZE, 5, EGL10.EGL_BLUE_SIZE, 5,
EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 0,
EGL10.EGL_NONE EGL10.EGL_NONE
}; }, {
int[] configSpec3 = {
EGL10.EGL_DEPTH_SIZE, 8, EGL10.EGL_DEPTH_SIZE, 8,
EGL10.EGL_RED_SIZE, 5, EGL10.EGL_RED_SIZE, 5,
EGL10.EGL_GREEN_SIZE, 6, EGL10.EGL_GREEN_SIZE, 5,
EGL10.EGL_BLUE_SIZE, 5, EGL10.EGL_BLUE_SIZE, 5,
EGL10.EGL_ALPHA_SIZE, 1, EGL10.EGL_ALPHA_SIZE, 1,
EGL10.EGL_NONE EGL10.EGL_NONE
}; }, {
int[] configSpec4 = {
EGL10.EGL_DEPTH_SIZE, 8, EGL10.EGL_DEPTH_SIZE, 8,
EGL10.EGL_RED_SIZE, 8, EGL10.EGL_RED_SIZE, 4,
EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_GREEN_SIZE, 4,
EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_BLUE_SIZE, 4,
EGL10.EGL_ALPHA_SIZE, 4,
EGL10.EGL_NONE EGL10.EGL_NONE
}; }, {
int[] configSpec5 = {
EGL10.EGL_DEPTH_SIZE, 8, EGL10.EGL_DEPTH_SIZE, 8,
EGL10.EGL_RED_SIZE, 5, EGL10.EGL_RED_SIZE, 3,
EGL10.EGL_GREEN_SIZE, 6, EGL10.EGL_GREEN_SIZE, 3,
EGL10.EGL_BLUE_SIZE, 5, EGL10.EGL_BLUE_SIZE, 2,
EGL10.EGL_ALPHA_SIZE, 0,
EGL10.EGL_NONE EGL10.EGL_NONE
}; }};
EGLConfig[] configs = new EGLConfig[1]; EGLConfig[] configs = new EGLConfig[1];
int[] num_config = new int[1]; int[] num_config = new int[1];
if (!egl.eglChooseConfig(dpy, configSpec1, configs, 1, num_config) || num_config[0] == 0) if (!egl.eglChooseConfig(dpy, configSpec[XashActivity.mPixelFormat], configs, 1, num_config) || num_config[0] == 0)
if (!egl.eglChooseConfig(dpy, configSpec2, configs, 1, num_config) || num_config[0] == 0)
if (!egl.eglChooseConfig(dpy, configSpec3, configs, 1, num_config) || num_config[0] == 0)
if (!egl.eglChooseConfig(dpy, configSpec4, configs, 1, num_config) || num_config[0] == 0)
if (!egl.eglChooseConfig(dpy, configSpec5, configs, 1, num_config) || num_config[0] == 0)
{ {
Log.e("SDL", "No EGL config available"); Log.e("SDL", "No EGL config available");
return false; return false;