CG Updates and some SDL2 changes

This commit is contained in:
Gerhard Stein
2013-11-04 15:54:30 +01:00
parent 303d53c8d3
commit 462068679e
7 changed files with 83 additions and 75 deletions

View File

@@ -844,36 +844,36 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
/*
* Get an EGL instance
*/
mEgl = (EGL10) EGLContext.getEGL();
//mEgl = (EGL10) EGLContext.getEGL();
/*
* Get to the default display.
*/
mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
//mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
/*
* We can now initialize EGL for that display
*/
int[] version = new int[2];
/*int[] version = new int[2];
mEgl.eglInitialize(mEglDisplay, version);
mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);
if( mEglConfig == null )
Log.e("SDL", "GLSurfaceView_SDL::EglHelper::start(): mEglConfig is NULL");
Log.e("SDL", "GLSurfaceView_SDL::EglHelper::start(): mEglConfig is NULL");*/
/*
* Create an OpenGL ES context. This must be done only once, an
* OpenGL context is a somewhat heavy object.
*/
final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
/*final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
final int[] gles2_attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
mEglContext = mEgl.eglCreateContext(mEglDisplay, mEglConfig,
EGL10.EGL_NO_CONTEXT, mEGLConfigChooser.isGles2Required() ? gles2_attrib_list : null );
if( mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT )
Log.e("SDL", "GLSurfaceView_SDL::EglHelper::start(): mEglContext is EGL_NO_CONTEXT, error: " + mEgl.eglGetError());
Log.e("SDL", "GLSurfaceView_SDL::EglHelper::start(): mEglContext is EGL_NO_CONTEXT, error: " + mEgl.eglGetError());*/
mEglSurface = null;
//mEglSurface = null;
}
/*
@@ -886,16 +886,16 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* The window size has changed, so we need to create a new
* surface.
*/
if (mEglSurface != null) {
/*if (mEglSurface != null) {*/
/*
* Unbind and destroy the old EGL surface, if
* there is one.
*/
mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE,
/*mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE,
EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
mEgl.eglDestroySurface(mEglDisplay, mEglSurface);
}
}*/
/*
* Create an EGL surface we can render into.
@@ -908,23 +908,24 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
attribList[2] = mEgl.EGL_NONE;
attribList[3] = mEgl.EGL_NONE;
*/
mEglSurface = mEgl.eglCreateWindowSurface(mEglDisplay,
mEglConfig, holder, null);
/*mEglSurface = mEgl.eglCreateWindowSurface(mEglDisplay,
mEglConfig, holder, null);*/
/*
* Before we can issue GL commands, we need to make sure
* the context is current and bound to a surface.
*/
mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
mEglContext);
/*mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
mEglContext);*/
GL gl = mEglContext.getGL();
/*GL gl = mEglContext.getGL();
if (mGLWrapper != null) {
gl = mGLWrapper.wrap(gl);
}
}*/
return gl;
//return gl;
return null;
}
/**
@@ -932,7 +933,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* @return false if the context has been lost.
*/
public boolean swap() {
mEgl.eglSwapBuffers(mEglDisplay, mEglSurface);
//mEgl.eglSwapBuffers(mEglDisplay, mEglSurface);
/*
* Always check for EGL_CONTEXT_LOST, which means the context
@@ -940,17 +941,18 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* the device went to sleep). We need to sleep until we
* get a new surface.
*/
return mEgl.eglGetError() != EGL11.EGL_CONTEXT_LOST;
//return mEgl.eglGetError() != EGL11.EGL_CONTEXT_LOST;
return true;
}
public void finish() {
Log.v("SDL", "GLSurfaceView_SDL::EglHelper::finish(): destroying GL context");
if (mEglSurface != null) {
/*if (mEglSurface != null) {
mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE,
EGL10.EGL_NO_SURFACE,
EGL10.EGL_NO_CONTEXT);
mEgl.eglDestroySurface(mEglDisplay, mEglSurface);
mEglSurface = null;
//mEgl.eglDestroySurface(mEglDisplay, mEglSurface);
//mEglSurface = null;
}
if (mEglContext != null) {
mEgl.eglDestroyContext(mEglDisplay, mEglContext);
@@ -959,14 +961,14 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
if (mEglDisplay != null) {
mEgl.eglTerminate(mEglDisplay);
mEglDisplay = null;
}
}*/
}
EGL10 mEgl;
/*EGL10 mEgl;
EGLDisplay mEglDisplay;
EGLSurface mEglSurface;
EGLConfig mEglConfig;
EGLContext mEglContext;
EGLContext mEglContext;*/
}
/**
@@ -1081,7 +1083,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
tellRendererSurfaceChanged = true;
}
if (tellRendererSurfaceCreated) {
mRenderer.onSurfaceCreated(mGL, mEglHelper.mEglConfig);
//mRenderer.onSurfaceCreated(mGL, mEglHelper.mEglConfig);
tellRendererSurfaceCreated = false;
}
if (tellRendererSurfaceChanged) {

View File

@@ -323,7 +323,7 @@ public class MainActivity extends SDLActivity
_layout2 = null;
_btn = null;
_tv = null;
_inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
//_inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
/*_videoLayout = new FrameLayout(this);
SetLayerType.get().setLayerType(_videoLayout);
setContentView(_videoLayout);*/
@@ -432,9 +432,9 @@ public class MainActivity extends SDLActivity
public void showScreenKeyboardWithoutTextInputField()
{
_inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
_inputManager.showSoftInput(mGLView, InputMethodManager.SHOW_FORCED);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
//_inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
//_inputManager.showSoftInput(mGLView, InputMethodManager.SHOW_FORCED);
//getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}
public void showScreenKeyboard(final String oldText, boolean sendBackspace)
@@ -466,7 +466,7 @@ public class MainActivity extends SDLActivity
keyCode == KeyEvent.KEYCODE_BUTTON_3 ||
keyCode == KeyEvent.KEYCODE_BUTTON_4 ))
{
_parent.hideScreenKeyboard();
//_parent.hideScreenKeyboard();
return true;
}
if (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_CLEAR)
@@ -554,19 +554,19 @@ public class MainActivity extends SDLActivity
}, 500 );
};
public void hideScreenKeyboard()
/*public void hideScreenKeyboard()
{
if(_screenKeyboard == null)
return;
synchronized(textInput)
{
String text = _screenKeyboard.getText().toString();
String text = _screenKeyboard.getText().toString();*/
/*for(int i = 0; i < text.length(); i++)
{
DemoRenderer.nativeTextInput( (int)text.charAt(i), (int)text.codePointAt(i) );
}*/
}
/*}
//DemoRenderer.nativeTextInputFinished();
_inputManager.hideSoftInputFromWindow(_screenKeyboard.getWindowToken(), 0);
mLayout.removeView(_screenKeyboard);
@@ -574,9 +574,9 @@ public class MainActivity extends SDLActivity
mGLView.setFocusableInTouchMode(true);
mGLView.setFocusable(true);
mGLView.requestFocus();
};
};*/
public boolean isScreenKeyboardShown()
/*public boolean isScreenKeyboardShown()
{
return _screenKeyboard != null;
};
@@ -670,8 +670,8 @@ public class MainActivity extends SDLActivity
params[3] = _ad.getView().getMeasuredWidth();
params[4] = _ad.getView().getMeasuredHeight();
}
}
public void requestNewAdvertisement()
}*/
/*public void requestNewAdvertisement()
{
if( _ad.getView() != null )
{
@@ -684,9 +684,9 @@ public class MainActivity extends SDLActivity
}
runOnUiThread(new Callback());
}
}
}*/
@Override
/*@Override
public boolean onKeyDown(int keyCode, final KeyEvent event)
{
if(_screenKeyboard != null)
@@ -696,7 +696,7 @@ public class MainActivity extends SDLActivity
{
if( mGLView.nativeKey( keyCode, 1 ) == 0 )
return super.onKeyDown(keyCode, event);
}
}*/
/*
else
if( keyCode == KeyEvent.KEYCODE_BACK && downloader != null )
@@ -707,15 +707,15 @@ public class MainActivity extends SDLActivity
onStop();
}
*/
else
/*else
if( keyListener != null )
{
keyListener.onKeyEvent(keyCode);
}
return true;
}
return true;*/
//}
@Override
/*@Override
public boolean onKeyUp(int keyCode, final KeyEvent event)
{
if(_screenKeyboard != null)
@@ -732,13 +732,13 @@ public class MainActivity extends SDLActivity
}
}
return true;
}
}*/
/*@Override
public boolean dispatchTouchEvent(final MotionEvent ev)
{
{*/
//Log.i("SDL", "dispatchTouchEvent: " + ev.getAction() + " coords " + ev.getX() + ":" + ev.getY() );
if(_screenKeyboard != null)
/*if(_screenKeyboard != null)
_screenKeyboard.dispatchTouchEvent(ev);
else
if( _ad.getView() != null && // User clicked the advertisement, ignore when user moved finger from game screen to advertisement or touches screen with several fingers
@@ -756,14 +756,15 @@ public class MainActivity extends SDLActivity
if( _btn != null )
return _btn.dispatchTouchEvent(ev);
else
if( touchListener != null )
touchListener.onTouchEvent(ev);
/*if( touchListener != null )
touchListener.onTouchEvent(ev);*/
/*
return true;
}*/
@Override
/* @Override
public boolean dispatchGenericMotionEvent (MotionEvent ev)
{
{*/
//Log.i("SDL", "dispatchGenericMotionEvent: " + ev.getAction() + " coords " + ev.getX() + ":" + ev.getY() );
// This code fails to run for Android 1.6, so there will be no generic motion event for Andorid screen keyboard
/*
@@ -771,10 +772,10 @@ public class MainActivity extends SDLActivity
_screenKeyboard.dispatchGenericMotionEvent(ev);
else
*/
if(mGLView != null)
/*if(mGLView != null)
mGLView.onGenericMotionEvent(ev);
return true;
}
return true;*/
// }
@Override
public void onConfigurationChanged(Configuration newConfig)
@@ -1129,7 +1130,7 @@ public class MainActivity extends SDLActivity
static int NOTIFY_ID = 12367098; // Random ID
private static DemoGLSurfaceView mGLView = null;
// private static DemoGLSurfaceView mGLView = null;
private static AudioThread mAudioThread = null;
private static DataDownloader downloader = null;

View File

@@ -507,7 +507,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
Globals.CommandLine,
( (Globals.SwVideoMode && Globals.MultiThreadedVideo) || Globals.CompatibilityHacksVideo ) ? 1 : 0,
android.os.Debug.isDebuggerConnected() ? 1 : 0 );*/
System.exit(0); // The main() returns here - I don't bother with deinit stuff, just terminate process
//System.exit(0); // The main() returns here - I don't bother with deinit stuff, just terminate process
}
public int swapBuffers() // Called from native code
@@ -539,12 +539,12 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
this.notify();
}
}
if( context.isScreenKeyboardShown() )
/*if( context.isScreenKeyboardShown() )
{
try {
Thread.sleep(50); // Give some time to the keyboard input thread
} catch(Exception e) { };
}
}*/
return 1;
}
@@ -589,7 +589,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
public MainActivity parent;
public void run()
{
parent.hideScreenKeyboard();
//parent.hideScreenKeyboard();
}
}
Callback cb = new Callback();
@@ -599,12 +599,13 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
public int isScreenKeyboardShown() // Called from native code
{
return context.isScreenKeyboardShown() ? 1 : 0;
//return context.isScreenKeyboardShown() ? 1 : 0;
return 0;
}
public void setScreenKeyboardHintMessage(String s)
{
context.setScreenKeyboardHintMessage(s);
//context.setScreenKeyboardHintMessage(s);
}
public void startAccelerometerGyroscope(int started)
@@ -623,19 +624,19 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
public void getAdvertisementParams(int params[])
{
context.getAdvertisementParams(params);
//context.getAdvertisementParams(params);
}
public void setAdvertisementVisible(int visible)
{
context.setAdvertisementVisible(visible);
//context.setAdvertisementVisible(visible);
}
public void setAdvertisementPosition(int left, int top)
{
context.setAdvertisementPosition(left, top);
//context.setAdvertisementPosition(left, top);
}
public void requestNewAdvertisement()
{
context.requestNewAdvertisement();
//context.requestNewAdvertisement();
}
private int PowerOf2(int i)
@@ -719,7 +720,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
private EGL10 mEgl = null;
private EGLDisplay mEglDisplay = null;
private EGLSurface mEglSurface = null;
private EGLContext mEglContext = null;
//private EGLContext mEglContext = null;
private boolean mGlContextLost = false;
public boolean mGlSurfaceCreated = false;
public boolean mPaused = false;

View File

@@ -3,7 +3,7 @@
AppSettingVersion=19
# libSDL version to use (1.2 or 1.3, specify 1.3 for SDL2)
LibSdlVersion=2.0
LibSdlVersion=1.2
# Specify application name (e.x. My Application)
AppName="Commander Genius"
@@ -143,7 +143,7 @@ RedefinedKeysScreenKbNames="LCTRL LALT SPACE RETURN"
# 1 = Simple Theme by Beholder (white, with gamepad joystick)
# 2 = Sun by Sirea (yellow, with round joystick)
# 3 = Keen by Gerstrong (multicolor, with round joystick)
TouchscreenKeysTheme=4
TouchscreenKeysTheme=3
# Redefine gamepad keys to SDL keysyms, button order is:
# A B X Y L1 R1 L2 R2 LThumb RThumb
@@ -153,13 +153,13 @@ RedefinedKeysGamepad="LCTRL LALT SPACE RETURN"
StartupMenuButtonTimeout=3000
# Menu items to hide from startup menu, available menu items:
#
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
HiddenMenuOptions=''
# Menu items to show at startup - this is Java code snippet, leave empty for default
# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()
# Available menu items:
#
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
FirstStartMenuOptions=''
# Enable multi-ABI binary, with hardware FPU support - it will also work on old devices,
@@ -170,10 +170,10 @@ MultiABI=n
AppMinimumRAM=64
# Application version code (integer)
AppVersionCode=161000
AppVersionCode=165000
# Application user-visible version name (string)
AppVersionName="1.6.1 Release"
AppVersionName="1.6.5 Beta"
# Reset SDL config when updating application to the new version (y) / (n)
ResetSdlConfigForThisVersion=n
@@ -184,7 +184,7 @@ DeleteFilesOnUpgrade="%"
# Optional shared libraries to compile - removing some of them will save space
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
CompiledLibraries="tremor ogg sdl2_image boost_system"
CompiledLibraries="tremor ogg sdl_image boost_system"
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
CustomBuildScript=n

View File

@@ -732,6 +732,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
public boolean onTouch(View v, MotionEvent event) {
final int touchDevId = event.getDeviceId();
final int pointerCount = event.getPointerCount();
// touchId, pointerId, action, x, y, pressure
int actionPointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT; /* API 8: event.getActionIndex(); */
int pointerFingerId = event.getPointerId(actionPointerIndex);

View File

@@ -9,6 +9,9 @@
#include "jniwrapperstuff.h"
// System specific functions