Added texture filtering setting
This commit is contained in:
@@ -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