Re-enabled core to restore and save OpenGL state for on-screen keyboard, it just makes your life so much easier

This commit is contained in:
pelya
2012-06-19 20:16:18 +03:00
parent 8624100d5c
commit f476666b4b
6 changed files with 11 additions and 21 deletions

View File

@@ -567,6 +567,7 @@ public class MainActivity extends Activity {
}
catch( UnsatisfiedLinkError e )
{
System.out.println("libSDL: error loading lib " + l + ": " + e.toString());
System.loadLibrary(l);
}
}

View File

@@ -323,14 +323,14 @@ abstract class DifferentTouchInput
if( (device.getSources() & InputDevice.SOURCE_TOUCHPAD) != InputDevice.SOURCE_TOUCHPAD )
continue;
System.out.println("libSDL: input device ID " + id + " type " + device.getSources() + " name " + device.getName() + " is a touchpad" );
InputDevice.MotionRange range = device.getMotionRange(MotionEvent.AXIS_X, InputDevice.SOURCE_TOUCHPAD);
InputDevice.MotionRange range = device.getMotionRange(MotionEvent.AXIS_X /*, InputDevice.SOURCE_TOUCHPAD*/);
if(range != null)
{
xmin = range.getMin();
xmax = range.getMax() - range.getMin();
System.out.println("libSDL: touch pad X range " + xmin + ":" + xmax );
}
range = device.getMotionRange(MotionEvent.AXIS_Y, InputDevice.SOURCE_TOUCHPAD);
range = device.getMotionRange(MotionEvent.AXIS_Y /*, InputDevice.SOURCE_TOUCHPAD*/);
if(range != null)
{
ymin = range.getMin();

View File

@@ -36,7 +36,7 @@ FirstStartMenuOptions=''
MultiABI=n
AppVersionCode=40011
AppVersionName="0.4.0.11"
ResetSdlConfigForThisVersion=y
ResetSdlConfigForThisVersion=n
DeleteFilesOnUpgrade="%"
CompiledLibraries="tremor ogg"
CustomBuildScript=n

View File

@@ -16,7 +16,7 @@ LOCAL_SRC_FILES := $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wil
LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES := lzma
LOCAL_SHARED_LIBRARIES :=
LOCAL_LDLIBS := -lz

View File

@@ -115,8 +115,7 @@ oldGlState;
static inline void beginDrawingTex()
{
// Save OpenGL state
// TODO: this code does not work on 1.6 emulator, and on some devices
/*
// TODO: this code does not work on 1.6 emulator, and on some older devices
oldGlState.texture2d = glIsEnabled(GL_TEXTURE_2D);
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldGlState.textureId);
glGetFloatv(GL_CURRENT_COLOR, &(oldGlState.color[0]));
@@ -127,14 +126,12 @@ static inline void beginDrawingTex()
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &oldGlState.texFilter1);
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &oldGlState.texFilter2);
// It's very unlikely that some app will use GL_TEXTURE_CROP_RECT_OES, so just skip it
*/
glEnable(GL_TEXTURE_2D);
}
static inline void endDrawingTex()
{
/*
// Restore OpenGL state
if( oldGlState.texture2d == GL_FALSE)
glDisable(GL_TEXTURE_2D);
@@ -146,9 +143,11 @@ static inline void endDrawingTex()
glBlendFunc(oldGlState.blend1, oldGlState.blend2);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, oldGlState.texFilter1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, oldGlState.texFilter2);
*/
/*
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
*/
}
static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, int flipX, int flipY, Uint8 r, Uint8 g, Uint8 b, Uint8 a)

View File

@@ -102,18 +102,8 @@ Also make sure that your HW textures are not wider than 1024 pixels, or it will
texture on HTC G1, and other low-end devices. Software surfaces may be of any size of course.
If you want HW acceleration - just use OpenGL, that's the easiest and most cross-platform way,
however if you'll use on-screen keyboard (even the text input button) the OpenGL state will get
messed up after each frame - after each SDL_GL_SwapBuffers() you'll need to call:
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, your_texture_id);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glEnable(GL_BLEND);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Previously I've got the code to save/restore OpenGL state, but it doens't work on every device -
you may wish to uncomment it inside file SDL_touchscreenkeyboard.c in functions beginDrawingTex() and endDrawingTex().
however note that on-screen keyboard (even the text input button) is also drawn using OpenGL,
so it might mess up your GL state (although it should not do that due to recent code changes).
If you don't use on-screen keyboard you don't need to reinit OpenGL state - set following in AndroidAppSettings.cfg:
AppNeedsArrowKeys=n