CG Updates and some SDL2 changes
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user