Added texture filtering setting
This commit is contained in:
@@ -92,6 +92,7 @@ class Globals {
|
||||
public static int MultitouchGestureSensitivity = 1;
|
||||
public static int TouchscreenCalibration[] = new int[4];
|
||||
public static String DataDir = new String("");
|
||||
public static boolean SmoothVideo = false;
|
||||
}
|
||||
|
||||
class LoadLibrary {
|
||||
|
||||
@@ -110,6 +110,7 @@ class Settings
|
||||
out.writeInt(Globals.ScreenKbControlsLayout[i][ii]);
|
||||
out.writeInt(Globals.LeftClickKey);
|
||||
out.writeInt(Globals.RightClickKey);
|
||||
out.writeBoolean(Globals.SmoothVideo);
|
||||
|
||||
out.close();
|
||||
settingsLoaded = true;
|
||||
@@ -234,6 +235,7 @@ class Settings
|
||||
Globals.ScreenKbControlsLayout[i][ii] = settingsFile.readInt();
|
||||
Globals.LeftClickKey = settingsFile.readInt();
|
||||
Globals.RightClickKey = settingsFile.readInt();
|
||||
Globals.SmoothVideo = settingsFile.readBoolean();
|
||||
|
||||
settingsLoaded = true;
|
||||
|
||||
@@ -318,6 +320,8 @@ class Settings
|
||||
|
||||
items.add(p.getResources().getString(R.string.remap_screenkb_button_gestures));
|
||||
|
||||
items.add(p.getResources().getString(R.string.video));
|
||||
|
||||
items.add(p.getResources().getString(R.string.ok));
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
@@ -385,6 +389,10 @@ class Settings
|
||||
showScreenGesturesConfig(p);
|
||||
selected++;
|
||||
|
||||
if( item == selected )
|
||||
showVideoSettingsConfig(p);
|
||||
selected++;
|
||||
|
||||
if( item == selected )
|
||||
{
|
||||
Save(p);
|
||||
@@ -667,14 +675,12 @@ class Settings
|
||||
{
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.controls_screenkb),
|
||||
p.getResources().getString(R.string.controls_accelnav),
|
||||
p.getResources().getString(R.string.pointandclick_keepaspectratio)
|
||||
p.getResources().getString(R.string.controls_accelnav)
|
||||
};
|
||||
|
||||
boolean defaults[] = {
|
||||
Globals.UseTouchscreenKeyboard,
|
||||
Globals.UseAccelerometerAsArrowKeys,
|
||||
Globals.KeepAspectRatio,
|
||||
Globals.UseAccelerometerAsArrowKeys
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
@@ -687,8 +693,6 @@ class Settings
|
||||
Globals.UseTouchscreenKeyboard = isChecked;
|
||||
if( item == 1 )
|
||||
Globals.UseAccelerometerAsArrowKeys = isChecked;
|
||||
if( item == 2 )
|
||||
Globals.KeepAspectRatio = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
@@ -964,14 +968,6 @@ class Settings
|
||||
|
||||
static void showAdditionalMouseConfig(final MainActivity p)
|
||||
{
|
||||
if( ! Globals.AppUsesMouse )
|
||||
{
|
||||
Globals.ShowScreenUnderFinger = false;
|
||||
Globals.MoveMouseWithJoystick = false;
|
||||
Globals.ClickMouseWithDpad = false;
|
||||
showMouseConfigMainMenu(p);
|
||||
}
|
||||
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.pointandclick_showcreenunderfinger2),
|
||||
p.getResources().getString(R.string.pointandclick_joystickmouse),
|
||||
@@ -1621,10 +1617,67 @@ class Settings
|
||||
}
|
||||
}
|
||||
|
||||
static void showVideoSettingsConfig(final MainActivity p)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.pointandclick_keepaspectratio),
|
||||
p.getResources().getString(R.string.pointandclick_showcreenunderfinger2),
|
||||
p.getResources().getString(R.string.video_smooth)
|
||||
};
|
||||
boolean defaults[] = {
|
||||
Globals.KeepAspectRatio,
|
||||
Globals.ShowScreenUnderFinger,
|
||||
Globals.SmoothVideo
|
||||
};
|
||||
|
||||
if(Globals.Using_SDL_1_3)
|
||||
{
|
||||
CharSequence[] items2 = {
|
||||
p.getResources().getString(R.string.pointandclick_keepaspectratio),
|
||||
p.getResources().getString(R.string.pointandclick_showcreenunderfinger2)
|
||||
};
|
||||
boolean defaults2[] = {
|
||||
Globals.KeepAspectRatio,
|
||||
Globals.ShowScreenUnderFinger
|
||||
};
|
||||
items = items2;
|
||||
defaults = defaults2;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.video));
|
||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
if( item == 0 )
|
||||
Globals.KeepAspectRatio = isChecked;
|
||||
if( item == 1 )
|
||||
Globals.ShowScreenUnderFinger = isChecked;
|
||||
if( item == 2 )
|
||||
Globals.SmoothVideo = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
showConfigMainMenu(p);
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
// ===============================================================================================
|
||||
|
||||
static void Apply(Activity p)
|
||||
{
|
||||
if(Globals.SmoothVideo)
|
||||
nativeSetSmoothVideo();
|
||||
if( Globals.PhoneHasTrackball )
|
||||
nativeSetTrackballUsed();
|
||||
if( Globals.AppUsesMouse )
|
||||
@@ -1724,6 +1777,7 @@ class Settings
|
||||
private static native void nativeSetJoystickUsed();
|
||||
private static native void nativeSetMultitouchUsed();
|
||||
private static native void nativeSetTouchscreenKeyboardUsed();
|
||||
private static native void nativeSetSmoothVideo();
|
||||
private static native void nativeSetupScreenKeyboard(int size, int theme, int nbuttonsAutoFire, int transparency);
|
||||
private static native void nativeSetupScreenKeyboardButtons(byte[] img);
|
||||
private static native void nativeInitKeymap();
|
||||
|
||||
@@ -109,4 +109,6 @@
|
||||
<string name="screenkb_custom_layout_help">Slide-Bildschirm hinzufügen Taste, drücken Sie Menü zum letzten Knopf rückgängig machen</string>
|
||||
<string name="rightclick_key">Physikalische Schlüssel</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">On-Screen-Lupe</string>
|
||||
<string name="video">Video-Einstellungen</string>
|
||||
<string name="video_smooth">Glatte Video</string>
|
||||
</resources>
|
||||
|
||||
@@ -109,4 +109,6 @@
|
||||
<string name="screenkb_custom_layout_help">Työnnä näytön lisätä painikkeen, paina Menu kumota viimeksi painike</string>
|
||||
<string name="rightclick_key">Fyysinen avain</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">Näytöllä suurennuslasi</string>
|
||||
<string name="video">Videon asetukset</string>
|
||||
<string name="video_smooth">Tasainen video</string>
|
||||
</resources>
|
||||
|
||||
@@ -112,4 +112,6 @@
|
||||
<string name="screenkb_custom_layout_help">Faites glisser l\u0026#39;écran pour ajouter le bouton, appuyez sur Menu pour annuler le dernier bouton</string>
|
||||
<string name="rightclick_key">Physique clés</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">Sur l\u0026#39;écran loupe</string>
|
||||
<string name="video">Paramètres vidéo</string>
|
||||
<string name="video_smooth">Smooth la vidéo</string>
|
||||
</resources>
|
||||
|
||||
@@ -102,4 +102,6 @@
|
||||
<string name="screenkb_custom_layout_help">Провезите по экрану, чтобы добавить кнопку, нажмите клавишу Меню, чтобы отменить последнюю кнопку</string>
|
||||
<string name="rightclick_key">Физическая кнопка</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">Наэкранная лупа</string>
|
||||
<string name="video">Настройки видео</string>
|
||||
<string name="video_smooth">Сгладить видео</string>
|
||||
</resources>
|
||||
|
||||
@@ -102,4 +102,6 @@
|
||||
<string name="screenkb_custom_layout_help">Провезiть по екрану, щоб додати кнопку, натисніть клавішу Меню, щоб скасувати останню кнопку</string>
|
||||
<string name="rightclick_key">Фізична кнопка</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">Наекранна лупа</string>
|
||||
<string name="video">Налаштування відео</string>
|
||||
<string name="video_smooth">Згладити відео</string>
|
||||
</resources>
|
||||
|
||||
@@ -124,4 +124,7 @@
|
||||
<string name="calibrate_touchscreen">Calibrate touchscreen</string>
|
||||
<string name="calibrate_touchscreen_touch">Touch all four edges of the screen, press Menu when done</string>
|
||||
|
||||
<string name="video">Video settings</string>
|
||||
<string name="video_smooth">Smooth the video</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -1 +1 @@
|
||||
fheroes2
|
||||
ballfield
|
||||
@@ -325,6 +325,9 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
|
||||
SDL_OutOfMemory();
|
||||
return(NULL);
|
||||
}
|
||||
if( SDL_ANDROID_SmoothVideo )
|
||||
SDL_SetTextureScaleMode((SDL_Texture *)current->hwdata, SDL_TEXTURESCALEMODE_SLOW);
|
||||
|
||||
// Register main video texture to be recreated when needed
|
||||
HwSurfaceCount++;
|
||||
HwSurfaceList = SDL_realloc( HwSurfaceList, HwSurfaceCount * sizeof(SDL_Surface *) );
|
||||
@@ -467,6 +470,9 @@ static int ANDROID_AllocHWSurface(_THIS, SDL_Surface *surface)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if( SDL_ANDROID_SmoothVideo )
|
||||
SDL_SetTextureScaleMode((SDL_Texture *)surface->hwdata, SDL_TEXTURESCALEMODE_SLOW);
|
||||
|
||||
if( surface->format->Amask )
|
||||
{
|
||||
SDL_SetTextureAlphaMod((struct SDL_Texture *)surface->hwdata, SDL_ALPHA_OPAQUE);
|
||||
@@ -553,6 +559,8 @@ static int ANDROID_LockHWSurface(_THIS, SDL_Surface *surface)
|
||||
SDL_OutOfMemory();
|
||||
return(-1);
|
||||
}
|
||||
if( SDL_ANDROID_SmoothVideo )
|
||||
SDL_SetTextureScaleMode((SDL_Texture *)SDL_CurrentVideoSurface->hwdata, SDL_TEXTURESCALEMODE_SLOW);
|
||||
// Register main video texture to be recreated when needed
|
||||
HwSurfaceCount++;
|
||||
HwSurfaceList = SDL_realloc( HwSurfaceList, HwSurfaceCount * sizeof(SDL_Surface *) );
|
||||
@@ -937,12 +945,15 @@ void SDL_ANDROID_VideoContextRecreated()
|
||||
if( HwSurfaceList[i] == SDL_CurrentVideoSurface )
|
||||
format = SDL_PIXELFORMAT_RGB565;
|
||||
HwSurfaceList[i]->hwdata = (struct private_hwdata *)SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, HwSurfaceList[i]->w, HwSurfaceList[i]->h);
|
||||
if( !HwSurfaceList[i]->hwdata )
|
||||
if( !HwSurfaceList[i]->hwdata )
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
return;
|
||||
}
|
||||
if( SDL_ANDROID_SmoothVideo )
|
||||
SDL_SetTextureScaleMode((SDL_Texture *)HwSurfaceList[i]->hwdata, SDL_TEXTURESCALEMODE_SLOW);
|
||||
ANDROID_UnlockHWSurface(NULL, HwSurfaceList[i]); // Re-fill texture with graphics
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1512,7 +1512,7 @@ JAVA_EXPORT_NAME(Settings_nativeSetScreenKbKeyLayout) (JNIEnv* env, jobject thiz
|
||||
{
|
||||
SDL_Rect rect = {x1, y1, x2-x1, y2-y1};
|
||||
int key = -1;
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "nativeSetScreenKbKeyLayout: %d %d %d %d", (int)rect.x, (int)rect.y, (int)rect.w, (int)rect.h);
|
||||
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "nativeSetScreenKbKeyLayout: %d %d %d %d", (int)rect.x, (int)rect.y, (int)rect.w, (int)rect.h);
|
||||
if( keynum == 0 )
|
||||
key = SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD;
|
||||
if( keynum == 1 )
|
||||
|
||||
@@ -63,6 +63,7 @@ static jmethodID JavaSwapBuffers = NULL;
|
||||
static jmethodID JavaShowScreenKeyboard = NULL;
|
||||
static int glContextLost = 0;
|
||||
static int showScreenKeyboardDeferred = 0;
|
||||
int SDL_ANDROID_SmoothVideo = 0;
|
||||
|
||||
static void appPutToBackgroundCallbackDefault(void)
|
||||
{
|
||||
@@ -228,7 +229,6 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject t
|
||||
JavaShowScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboard", "()V");
|
||||
|
||||
ANDROID_InitOSKeymap();
|
||||
|
||||
}
|
||||
|
||||
int SDL_ANDROID_SetApplicationPutToBackgroundCallback(
|
||||
@@ -244,3 +244,9 @@ int SDL_ANDROID_SetApplicationPutToBackgroundCallback(
|
||||
if( appRestoredCallback )
|
||||
appRestoredCallback = appRestored;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetSmoothVideo) (JNIEnv* env, jobject thiz)
|
||||
{
|
||||
SDL_ANDROID_SmoothVideo = 1;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ extern int SDL_ANDROID_TouchscreenCalibrationWidth;
|
||||
extern int SDL_ANDROID_TouchscreenCalibrationHeight;
|
||||
extern int SDL_ANDROID_TouchscreenCalibrationX;
|
||||
extern int SDL_ANDROID_TouchscreenCalibrationY;
|
||||
extern int SDL_ANDROID_SmoothVideo;
|
||||
extern SDL_Surface *SDL_CurrentVideoSurface;
|
||||
extern SDL_Rect SDL_ANDROID_ForceClearScreenRect;
|
||||
extern int SDL_ANDROID_ShowScreenUnderFinger;
|
||||
|
||||
@@ -165,13 +165,6 @@ static inline void beginDrawingTex()
|
||||
|
||||
static inline void endDrawingTex()
|
||||
{
|
||||
/*
|
||||
GLfloat texColor[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, texColor);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glDisable(GL_BLEND);
|
||||
*/
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
@@ -196,8 +189,16 @@ static inline void drawCharTex(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * des
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
if( SDL_ANDROID_SmoothVideo )
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
}
|
||||
|
||||
/*
|
||||
texColor[0] = r * onediv255;
|
||||
@@ -810,10 +811,7 @@ static int setupScreenKeyboardButton( int buttonID, Uint8 * charBuf )
|
||||
|
||||
glGenTextures(1, &data->id);
|
||||
glBindTexture(GL_TEXTURE_2D, data->id);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_w, texture_h, 0, GL_RGBA,
|
||||
format ? GL_UNSIGNED_SHORT_4_4_4_4 : GL_UNSIGNED_SHORT_5_5_5_1, NULL);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
@@ -822,6 +820,9 @@ static int setupScreenKeyboardButton( int buttonID, Uint8 * charBuf )
|
||||
format ? GL_UNSIGNED_SHORT_4_4_4_4 : GL_UNSIGNED_SHORT_5_5_5_1,
|
||||
charBuf + 3*sizeof(int) );
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
return 3*sizeof(int) + w * h * 2;
|
||||
|
||||
Reference in New Issue
Block a user