Draw the logo when app loads, until the first SDL_Flip(), also fixed small bug in menu
This commit is contained in:
@@ -595,6 +595,8 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
public void setSwapBuffersCallback( SwapBuffersCallback c ) {
|
public void setSwapBuffersCallback( SwapBuffersCallback c ) {
|
||||||
mSwapBuffersCallback = c;
|
mSwapBuffersCallback = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void DrawLogo(GL10 gl);
|
||||||
|
|
||||||
private SwapBuffersCallback mSwapBuffersCallback = null;
|
private SwapBuffersCallback mSwapBuffersCallback = null;
|
||||||
}
|
}
|
||||||
@@ -904,7 +906,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
mNeedStart = true;
|
mNeedStart = true;
|
||||||
mSizeChanged = true;
|
mSizeChanged = true;
|
||||||
SwapBuffers();
|
SwapBuffers();
|
||||||
DrawLogo();
|
mRenderer.DrawLogo(mGL);
|
||||||
SwapBuffers();
|
SwapBuffers();
|
||||||
|
|
||||||
mRenderer.onDrawFrame(mGL);
|
mRenderer.onDrawFrame(mGL);
|
||||||
@@ -1113,16 +1115,6 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawLogo() {
|
|
||||||
// TODO: draw some logo instead of making screen non-black
|
|
||||||
/*
|
|
||||||
mGL.glClearColor(0.0f, 0.5f, 0.7f, 1.0f);
|
|
||||||
mGL.glClear(mGL.GL_COLOR_BUFFER_BIT | mGL.GL_DEPTH_BUFFER_BIT);
|
|
||||||
mGL.glFlush();
|
|
||||||
mGL.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean mDone;
|
private boolean mDone;
|
||||||
private boolean mPaused;
|
private boolean mPaused;
|
||||||
private boolean mHasSurface;
|
private boolean mHasSurface;
|
||||||
|
|||||||
@@ -1072,7 +1072,6 @@ class Settings
|
|||||||
{
|
{
|
||||||
public void onClick(DialogInterface dialog, int item)
|
public void onClick(DialogInterface dialog, int item)
|
||||||
{
|
{
|
||||||
Globals.LeftClickMethod = item;
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
if( item == 0 )
|
if( item == 0 )
|
||||||
{
|
{
|
||||||
@@ -1107,7 +1106,9 @@ class Settings
|
|||||||
if( firstStart )
|
if( firstStart )
|
||||||
builder.setItems(items, new ClickListener());
|
builder.setItems(items, new ClickListener());
|
||||||
else
|
else
|
||||||
builder.setSingleChoiceItems(items, (Globals.LeftClickMethod == Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT && ! Globals.RelativeMouseMovement) ? 0 : 1, new ClickListener());
|
builder.setSingleChoiceItems(items,
|
||||||
|
(Globals.LeftClickMethod == Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT && ! Globals.RelativeMouseMovement) ? 0 : 1,
|
||||||
|
new ClickListener());
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||||
{
|
{
|
||||||
public void onCancel(DialogInterface dialog)
|
public void onCancel(DialogInterface dialog)
|
||||||
@@ -1142,9 +1143,10 @@ class Settings
|
|||||||
builder.setTitle(R.string.leftclick_question);
|
builder.setTitle(R.string.leftclick_question);
|
||||||
builder.setSingleChoiceItems(items, Globals.LeftClickMethod, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.LeftClickMethod, new DialogInterface.OnClickListener()
|
||||||
{
|
{
|
||||||
public void onClick(DialogInterface dialog, int item)
|
public void onClick(DialogInterface dialog, int item)
|
||||||
{
|
{
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
Globals.LeftClickMethod = item;
|
||||||
if( item == Mouse.LEFT_CLICK_WITH_KEY )
|
if( item == Mouse.LEFT_CLICK_WITH_KEY )
|
||||||
p.keyListener = new KeyRemapToolMouseClick(p, true);
|
p.keyListener = new KeyRemapToolMouseClick(p, true);
|
||||||
else if( item == Mouse.LEFT_CLICK_WITH_TIMEOUT || item == Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT )
|
else if( item == Mouse.LEFT_CLICK_WITH_TIMEOUT || item == Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT )
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
package net.sourceforge.clonekeenplus;
|
package net.sourceforge.clonekeenplus;
|
||||||
|
|
||||||
import javax.microedition.khronos.opengles.GL10;
|
import javax.microedition.khronos.opengles.GL10;
|
||||||
|
import javax.microedition.khronos.opengles.GL11;
|
||||||
|
import javax.microedition.khronos.opengles.GL11Ext;
|
||||||
|
|
||||||
import javax.microedition.khronos.egl.EGL10;
|
import javax.microedition.khronos.egl.EGL10;
|
||||||
import javax.microedition.khronos.egl.EGL11;
|
import javax.microedition.khronos.egl.EGL11;
|
||||||
@@ -29,6 +31,10 @@ import android.view.Window;
|
|||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.content.res.AssetManager;
|
||||||
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import java.lang.Thread;
|
import java.lang.Thread;
|
||||||
@@ -37,6 +43,9 @@ import android.os.Build;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
|
|
||||||
class Mouse
|
class Mouse
|
||||||
{
|
{
|
||||||
@@ -236,6 +245,8 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onSurfaceChanged(GL10 gl, int w, int h) {
|
public void onSurfaceChanged(GL10 gl, int w, int h) {
|
||||||
|
mWidth = w;
|
||||||
|
mHeight = h;
|
||||||
nativeResize(w, h, Globals.KeepAspectRatio ? 1 : 0);
|
nativeResize(w, h, Globals.KeepAspectRatio ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,10 +330,72 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
|||||||
context.runOnUiThread(cb);
|
context.runOnUiThread(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exitApp() {
|
public void exitApp()
|
||||||
|
{
|
||||||
nativeDone();
|
nativeDone();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private int PowerOf2(int i)
|
||||||
|
{
|
||||||
|
int value = 1;
|
||||||
|
while (value < i)
|
||||||
|
value <<= 1;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
public void DrawLogo(GL10 gl)
|
||||||
|
{
|
||||||
|
BitmapDrawable bmp = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bmp = new BitmapDrawable(context.getAssets().open("logo.png"));
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
bmp = new BitmapDrawable(context.getResources().openRawResource(R.drawable.publisherlogo));
|
||||||
|
}
|
||||||
|
int width = bmp.getBitmap().getWidth();
|
||||||
|
int height = bmp.getBitmap().getHeight();
|
||||||
|
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4 * width * height);
|
||||||
|
byteBuffer.order(ByteOrder.BIG_ENDIAN);
|
||||||
|
bmp.getBitmap().copyPixelsToBuffer(byteBuffer);
|
||||||
|
byteBuffer.position(0);
|
||||||
|
|
||||||
|
gl.glViewport(0, 0, mWidth, mHeight);
|
||||||
|
gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
|
||||||
|
gl.glColor4x(0x10000, 0x10000, 0x10000, 0x10000);
|
||||||
|
gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
gl.glEnable(GL10.GL_TEXTURE_2D);
|
||||||
|
int textureName = -1;
|
||||||
|
int mTextureNameWorkspace[] = new int[1];
|
||||||
|
int mCropWorkspace[] = new int[4];
|
||||||
|
gl.glGenTextures(1, mTextureNameWorkspace, 0);
|
||||||
|
textureName = mTextureNameWorkspace[0];
|
||||||
|
gl.glBindTexture(GL10.GL_TEXTURE_2D, textureName);
|
||||||
|
gl.glActiveTexture(textureName);
|
||||||
|
gl.glClientActiveTexture(textureName);
|
||||||
|
gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA,
|
||||||
|
PowerOf2(width), PowerOf2(height), 0,
|
||||||
|
GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, null);
|
||||||
|
gl.glTexSubImage2D(GL10.GL_TEXTURE_2D, 0, 0, 0,
|
||||||
|
width, height,
|
||||||
|
GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, byteBuffer);
|
||||||
|
mCropWorkspace[0] = 0; // u
|
||||||
|
mCropWorkspace[1] = height; // v
|
||||||
|
mCropWorkspace[2] = width;
|
||||||
|
mCropWorkspace[3] = -height;
|
||||||
|
((GL11) gl).glTexParameteriv(GL10.GL_TEXTURE_2D,
|
||||||
|
GL11Ext.GL_TEXTURE_CROP_RECT_OES, mCropWorkspace, 0);
|
||||||
|
((GL11Ext) gl).glDrawTexiOES(0, -mHeight, 0, mWidth, mHeight);
|
||||||
|
gl.glActiveTexture(0);
|
||||||
|
gl.glClientActiveTexture(0);
|
||||||
|
gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
|
||||||
|
gl.glDeleteTextures(1, mTextureNameWorkspace, 0);
|
||||||
|
|
||||||
|
gl.glFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private native void nativeInitJavaCallbacks();
|
private native void nativeInitJavaCallbacks();
|
||||||
private native void nativeInit(String CurrentPath, String CommandLine, int multiThreadedVideo);
|
private native void nativeInit(String CurrentPath, String CommandLine, int multiThreadedVideo);
|
||||||
private native void nativeResize(int w, int h, int keepAspectRatio);
|
private native void nativeResize(int w, int h, int keepAspectRatio);
|
||||||
@@ -343,6 +416,8 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
|||||||
public boolean mGlSurfaceCreated = false;
|
public boolean mGlSurfaceCreated = false;
|
||||||
public boolean mPaused = false;
|
public boolean mPaused = false;
|
||||||
private boolean mFirstTimeStart = true;
|
private boolean mFirstTimeStart = true;
|
||||||
|
public int mWidth = 0;
|
||||||
|
public int mHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||||
|
|||||||
Reference in New Issue
Block a user