Added GLES2 support, and support for 24bpp and 32bpp - NOT TESTED,
it's only for OpenGL and for pure SW mode, HW SDL surfaces won't work
This commit is contained in:
@@ -95,36 +95,6 @@ if [ -n "$AppDataDownloadUrl1" ] ; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$SdlVideoResize" -o -z "$AUTO" ]; then
|
|
||||||
echo
|
|
||||||
echo "Application window should be resized to fit into native device screen (480x320 or 800x480) (y) or (n) ($SdlVideoResize): "
|
|
||||||
read var
|
|
||||||
if [ -n "$var" ] ; then
|
|
||||||
SdlVideoResize="$var"
|
|
||||||
CHANGED=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$SdlVideoResizeKeepAspect" -o -z "$AUTO" ]; then
|
|
||||||
echo
|
|
||||||
echo -n "Application resizing should use 4:3 aspect ratio, creating black bars (y) or (n) ($SdlVideoResizeKeepAspect): "
|
|
||||||
read var
|
|
||||||
if [ -n "$var" ] ; then
|
|
||||||
SdlVideoResizeKeepAspect="$var"
|
|
||||||
CHANGED=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$NeedDepthBuffer" -o -z "$AUTO" ]; then
|
|
||||||
echo
|
|
||||||
echo -n "Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n) ($NeedDepthBuffer): "
|
|
||||||
read var
|
|
||||||
if [ -n "$var" ] ; then
|
|
||||||
NeedDepthBuffer="$var"
|
|
||||||
CHANGED=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$LibSdlVersion" = "1.2" ]; then
|
if [ "$LibSdlVersion" = "1.2" ]; then
|
||||||
if [ -z "$CompatibilityHacks" -o -z "$AUTO" ]; then
|
if [ -z "$CompatibilityHacks" -o -z "$AUTO" ]; then
|
||||||
echo
|
echo
|
||||||
@@ -154,6 +124,76 @@ else
|
|||||||
SwVideoMode=n
|
SwVideoMode=n
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$VideoDepthBpp" -o -z "$AUTO" ]; then
|
||||||
|
echo
|
||||||
|
echo "Video color depth - 16 BPP is the fastest, other modes are not supported"
|
||||||
|
echo -n "if you're using SDL_HWSURFACE (16)/(24)/(32) ($VideoDepthBpp): "
|
||||||
|
read var
|
||||||
|
if [ -n "$var" ] ; then
|
||||||
|
VideoDepthBpp="$var"
|
||||||
|
CHANGED=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$SwVideoMode" = "y" ]; then
|
||||||
|
NeedDepthBuffer=n
|
||||||
|
NeedStencilBuffer=n
|
||||||
|
NeedGles2=n
|
||||||
|
else
|
||||||
|
|
||||||
|
if [ -z "$NeedDepthBuffer" -o -z "$AUTO" ]; then
|
||||||
|
echo
|
||||||
|
echo -n "Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n) ($NeedDepthBuffer): "
|
||||||
|
read var
|
||||||
|
if [ -n "$var" ] ; then
|
||||||
|
NeedDepthBuffer="$var"
|
||||||
|
CHANGED=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$NeedStencilBuffer" -o -z "$AUTO" ]; then
|
||||||
|
echo
|
||||||
|
echo -n "Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n) ($NeedDepthBuffer): "
|
||||||
|
read var
|
||||||
|
if [ -n "$var" ] ; then
|
||||||
|
NeedStencilBuffer="$var"
|
||||||
|
CHANGED=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$NeedGles2" -o -z "$AUTO" ]; then
|
||||||
|
echo
|
||||||
|
echo "Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device"
|
||||||
|
ecno -n "you need this option only if you're developing 3-d app (y) or (n) ($NeedGles2): "
|
||||||
|
read var
|
||||||
|
if [ -n "$var" ] ; then
|
||||||
|
NeedGles2="$var"
|
||||||
|
CHANGED=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$SdlVideoResize" -o -z "$AUTO" ]; then
|
||||||
|
echo
|
||||||
|
echo "Application window should be resized to fit into native device screen (480x320 or 800x480) (y) or (n) ($SdlVideoResize): "
|
||||||
|
read var
|
||||||
|
if [ -n "$var" ] ; then
|
||||||
|
SdlVideoResize="$var"
|
||||||
|
CHANGED=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$SdlVideoResizeKeepAspect" -o -z "$AUTO" ]; then
|
||||||
|
echo
|
||||||
|
echo -n "Application resizing should use 4:3 aspect ratio, creating black bars (y) or (n) ($SdlVideoResizeKeepAspect): "
|
||||||
|
read var
|
||||||
|
if [ -n "$var" ] ; then
|
||||||
|
SdlVideoResizeKeepAspect="$var"
|
||||||
|
CHANGED=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$AppUsesMouse" -o -z "$AUTO" ]; then
|
if [ -z "$AppUsesMouse" -o -z "$AUTO" ]; then
|
||||||
echo
|
echo
|
||||||
echo -n "Application uses mouse (y) or (n) ($AppUsesMouse): "
|
echo -n "Application uses mouse (y) or (n) ($AppUsesMouse): "
|
||||||
@@ -476,10 +516,13 @@ echo AppFullName=$AppFullName >> AndroidAppSettings.cfg
|
|||||||
echo ScreenOrientation=$ScreenOrientation >> AndroidAppSettings.cfg
|
echo ScreenOrientation=$ScreenOrientation >> AndroidAppSettings.cfg
|
||||||
echo InhibitSuspend=$InhibitSuspend >> AndroidAppSettings.cfg
|
echo InhibitSuspend=$InhibitSuspend >> AndroidAppSettings.cfg
|
||||||
echo AppDataDownloadUrl=\"$AppDataDownloadUrl\" >> AndroidAppSettings.cfg
|
echo AppDataDownloadUrl=\"$AppDataDownloadUrl\" >> AndroidAppSettings.cfg
|
||||||
|
echo VideoDepthBpp=$VideoDepthBpp >> AndroidAppSettings.cfg
|
||||||
|
echo NeedDepthBuffer=$NeedDepthBuffer >> AndroidAppSettings.cfg
|
||||||
|
echo NeedStencilBuffer=$NeedStencilBuffer >> AndroidAppSettings.cfg
|
||||||
|
echo NeedGles2=$NeedGles2 >> AndroidAppSettings.cfg
|
||||||
|
echo SwVideoMode=$SwVideoMode >> AndroidAppSettings.cfg
|
||||||
echo SdlVideoResize=$SdlVideoResize >> AndroidAppSettings.cfg
|
echo SdlVideoResize=$SdlVideoResize >> AndroidAppSettings.cfg
|
||||||
echo SdlVideoResizeKeepAspect=$SdlVideoResizeKeepAspect >> AndroidAppSettings.cfg
|
echo SdlVideoResizeKeepAspect=$SdlVideoResizeKeepAspect >> AndroidAppSettings.cfg
|
||||||
echo NeedDepthBuffer=$NeedDepthBuffer >> AndroidAppSettings.cfg
|
|
||||||
echo SwVideoMode=$SwVideoMode >> AndroidAppSettings.cfg
|
|
||||||
echo CompatibilityHacks=$CompatibilityHacks >> AndroidAppSettings.cfg
|
echo CompatibilityHacks=$CompatibilityHacks >> AndroidAppSettings.cfg
|
||||||
echo AppUsesMouse=$AppUsesMouse >> AndroidAppSettings.cfg
|
echo AppUsesMouse=$AppUsesMouse >> AndroidAppSettings.cfg
|
||||||
echo AppNeedsTwoButtonMouse=$AppNeedsTwoButtonMouse >> AndroidAppSettings.cfg
|
echo AppNeedsTwoButtonMouse=$AppNeedsTwoButtonMouse >> AndroidAppSettings.cfg
|
||||||
@@ -551,6 +594,18 @@ else
|
|||||||
NeedDepthBuffer=false
|
NeedDepthBuffer=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$NeedStencilBuffer" = "y" ] ; then
|
||||||
|
NeedStencilBuffer=true
|
||||||
|
else
|
||||||
|
NeedStencilBuffer=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$NeedGles2" = "y" ] ; then
|
||||||
|
NeedGles2=true
|
||||||
|
else
|
||||||
|
NeedGles2=false
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$SwVideoMode" = "y" ] ; then
|
if [ "$SwVideoMode" = "y" ] ; then
|
||||||
SwVideoMode=true
|
SwVideoMode=true
|
||||||
else
|
else
|
||||||
@@ -678,8 +733,11 @@ cat project/src/Globals.java | \
|
|||||||
sed "s/public static String ApplicationName = .*;/public static String ApplicationName = \"$AppShortName\";/" | \
|
sed "s/public static String ApplicationName = .*;/public static String ApplicationName = \"$AppShortName\";/" | \
|
||||||
sed "s/public static final boolean Using_SDL_1_3 = .*;/public static final boolean Using_SDL_1_3 = $UsingSdl13;/" | \
|
sed "s/public static final boolean Using_SDL_1_3 = .*;/public static final boolean Using_SDL_1_3 = $UsingSdl13;/" | \
|
||||||
sed "s@public static String DataDownloadUrl = .*@public static String DataDownloadUrl = \"$AppDataDownloadUrl1\";@" | \
|
sed "s@public static String DataDownloadUrl = .*@public static String DataDownloadUrl = \"$AppDataDownloadUrl1\";@" | \
|
||||||
sed "s/public static boolean NeedDepthBuffer = .*;/public static boolean NeedDepthBuffer = $NeedDepthBuffer;/" | \
|
|
||||||
sed "s/public static boolean SwVideoMode = .*;/public static boolean SwVideoMode = $SwVideoMode;/" | \
|
sed "s/public static boolean SwVideoMode = .*;/public static boolean SwVideoMode = $SwVideoMode;/" | \
|
||||||
|
sed "s/public static int VideoDepthBpp = .*;/public static int VideoDepthBpp = $VideoDepthBpp;/" | \
|
||||||
|
sed "s/public static boolean NeedDepthBuffer = .*;/public static boolean NeedDepthBuffer = $NeedDepthBuffer;/" | \
|
||||||
|
sed "s/public static boolean NeedStencilBuffer = .*;/public static boolean NeedStencilBuffer = $NeedStencilBuffer;/" | \
|
||||||
|
sed "s/public static boolean NeedGles2 = .*;/public static boolean NeedGles2 = $NeedGles2;/" | \
|
||||||
sed "s/public static boolean CompatibilityHacks = .*;/public static boolean CompatibilityHacks = $CompatibilityHacks;/" | \
|
sed "s/public static boolean CompatibilityHacks = .*;/public static boolean CompatibilityHacks = $CompatibilityHacks;/" | \
|
||||||
sed "s/public static boolean HorizontalOrientation = .*;/public static boolean HorizontalOrientation = $HorizontalOrientation;/" | \
|
sed "s/public static boolean HorizontalOrientation = .*;/public static boolean HorizontalOrientation = $HorizontalOrientation;/" | \
|
||||||
sed "s/public static boolean InhibitSuspend = .*;/public static boolean InhibitSuspend = $InhibitSuspend;/" | \
|
sed "s/public static boolean InhibitSuspend = .*;/public static boolean InhibitSuspend = $InhibitSuspend;/" | \
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
"setRenderer has already been called for this instance.");
|
"setRenderer has already been called for this instance.");
|
||||||
}
|
}
|
||||||
if (mEGLConfigChooser == null) {
|
if (mEGLConfigChooser == null) {
|
||||||
mEGLConfigChooser = new SimpleEGLConfigChooser(true);
|
mEGLConfigChooser = getEglConfigChooser(16, false, false, false);
|
||||||
}
|
}
|
||||||
mGLThread = new GLThread(renderer);
|
mGLThread = new GLThread(renderer);
|
||||||
mGLThread.start();
|
mGLThread.start();
|
||||||
@@ -319,8 +319,8 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
*
|
*
|
||||||
* @param needDepth
|
* @param needDepth
|
||||||
*/
|
*/
|
||||||
public void setEGLConfigChooser(boolean needDepth) {
|
public void setEGLConfigChooser(int bpp, boolean needDepth, boolean stencil, boolean gles2) {
|
||||||
setEGLConfigChooser(new SimpleEGLConfigChooser(needDepth));
|
setEGLConfigChooser(getEglConfigChooser(bpp, needDepth, stencil, gles2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -337,9 +337,9 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setEGLConfigChooser(int redSize, int greenSize, int blueSize,
|
public void setEGLConfigChooser(int redSize, int greenSize, int blueSize,
|
||||||
int alphaSize, int depthSize, int stencilSize) {
|
int alphaSize, int depthSize, int stencilSize, boolean gles2) {
|
||||||
setEGLConfigChooser(new ComponentSizeChooser(redSize, greenSize,
|
setEGLConfigChooser(new ComponentSizeChooser(redSize, greenSize,
|
||||||
blueSize, alphaSize, depthSize, stencilSize));
|
blueSize, alphaSize, depthSize, stencilSize, gles2));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Set the rendering mode. When renderMode is
|
* Set the rendering mode. When renderMode is
|
||||||
@@ -619,6 +619,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* @return the chosen configuration.
|
* @return the chosen configuration.
|
||||||
*/
|
*/
|
||||||
EGLConfig chooseConfig(EGL10 egl, EGLDisplay display);
|
EGLConfig chooseConfig(EGL10 egl, EGLDisplay display);
|
||||||
|
public boolean isGles2Required();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static abstract class BaseConfigChooser
|
private static abstract class BaseConfigChooser
|
||||||
@@ -655,7 +656,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
|
|
||||||
private static class ComponentSizeChooser extends BaseConfigChooser {
|
private static class ComponentSizeChooser extends BaseConfigChooser {
|
||||||
public ComponentSizeChooser(int redSize, int greenSize, int blueSize,
|
public ComponentSizeChooser(int redSize, int greenSize, int blueSize,
|
||||||
int alphaSize, int depthSize, int stencilSize) {
|
int alphaSize, int depthSize, int stencilSize, boolean isGles2) {
|
||||||
super(new int[] {
|
super(new int[] {
|
||||||
EGL10.EGL_RED_SIZE, redSize,
|
EGL10.EGL_RED_SIZE, redSize,
|
||||||
EGL10.EGL_GREEN_SIZE, greenSize,
|
EGL10.EGL_GREEN_SIZE, greenSize,
|
||||||
@@ -663,6 +664,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
EGL10.EGL_ALPHA_SIZE, alphaSize,
|
EGL10.EGL_ALPHA_SIZE, alphaSize,
|
||||||
EGL10.EGL_DEPTH_SIZE, depthSize,
|
EGL10.EGL_DEPTH_SIZE, depthSize,
|
||||||
EGL10.EGL_STENCIL_SIZE, stencilSize,
|
EGL10.EGL_STENCIL_SIZE, stencilSize,
|
||||||
|
EGL10.EGL_RENDERABLE_TYPE, isGles2 ? EGL_OPENGL_ES2_BIT : 0,
|
||||||
EGL10.EGL_NONE});
|
EGL10.EGL_NONE});
|
||||||
mValue = new int[1];
|
mValue = new int[1];
|
||||||
mRedSize = redSize;
|
mRedSize = redSize;
|
||||||
@@ -671,6 +673,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
mAlphaSize = alphaSize;
|
mAlphaSize = alphaSize;
|
||||||
mDepthSize = depthSize;
|
mDepthSize = depthSize;
|
||||||
mStencilSize = stencilSize;
|
mStencilSize = stencilSize;
|
||||||
|
this.isGles2 = isGles2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -691,10 +694,13 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
EGL10.EGL_DEPTH_SIZE, 0);
|
EGL10.EGL_DEPTH_SIZE, 0);
|
||||||
int s = findConfigAttrib(egl, display, config,
|
int s = findConfigAttrib(egl, display, config,
|
||||||
EGL10.EGL_STENCIL_SIZE, 0);
|
EGL10.EGL_STENCIL_SIZE, 0);
|
||||||
|
boolean gles2 = (findConfigAttrib(egl, display, config,
|
||||||
|
EGL10.EGL_RENDERABLE_TYPE, 0) & EGL_OPENGL_ES2_BIT) != 0;
|
||||||
int distance = Math.abs(r - mRedSize)
|
int distance = Math.abs(r - mRedSize)
|
||||||
+ Math.abs(g - mGreenSize)
|
+ Math.abs(g - mGreenSize)
|
||||||
+ Math.abs(b - mBlueSize) + Math.abs(a - mAlphaSize)
|
+ Math.abs(b - mBlueSize) + Math.abs(a - mAlphaSize)
|
||||||
+ Math.abs(d - mDepthSize) + Math.abs(s - mStencilSize);
|
+ Math.abs(d - mDepthSize) + Math.abs(s - mStencilSize)
|
||||||
|
+ (gles2 == isGles2 ? 0 : 17);
|
||||||
if (distance < closestDistance) {
|
if (distance < closestDistance) {
|
||||||
closestDistance = distance;
|
closestDistance = distance;
|
||||||
closestConfig = config;
|
closestConfig = config;
|
||||||
@@ -712,6 +718,11 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isGles2Required()
|
||||||
|
{
|
||||||
|
return isGles2;
|
||||||
|
}
|
||||||
|
|
||||||
private int[] mValue;
|
private int[] mValue;
|
||||||
// Subclasses can adjust these values:
|
// Subclasses can adjust these values:
|
||||||
protected int mRedSize;
|
protected int mRedSize;
|
||||||
@@ -720,6 +731,9 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
protected int mAlphaSize;
|
protected int mAlphaSize;
|
||||||
protected int mDepthSize;
|
protected int mDepthSize;
|
||||||
protected int mStencilSize;
|
protected int mStencilSize;
|
||||||
|
public boolean isGles2 = false;
|
||||||
|
|
||||||
|
public static final int EGL_OPENGL_ES2_BIT = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -727,9 +741,9 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* RGB565 as possible, with or without a depth buffer.
|
* RGB565 as possible, with or without a depth buffer.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static class SimpleEGLConfigChooser extends ComponentSizeChooser {
|
private static class SimpleEGLConfigChooser16 extends ComponentSizeChooser {
|
||||||
public SimpleEGLConfigChooser(boolean withDepthBuffer) {
|
public SimpleEGLConfigChooser16(boolean withDepthBuffer, boolean stencil, boolean gles2) {
|
||||||
super(4, 4, 4, 0, withDepthBuffer ? 16 : 0, 0);
|
super(4, 4, 4, 0, withDepthBuffer ? 16 : 0, stencil ? 8 : 0, gles2);
|
||||||
// Adjust target values. This way we'll accept a 4444 or
|
// Adjust target values. This way we'll accept a 4444 or
|
||||||
// 555 buffer if there's no 565 buffer available.
|
// 555 buffer if there's no 565 buffer available.
|
||||||
mRedSize = 5;
|
mRedSize = 5;
|
||||||
@@ -738,6 +752,34 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class SimpleEGLConfigChooser24 extends ComponentSizeChooser {
|
||||||
|
public SimpleEGLConfigChooser24(boolean withDepthBuffer, boolean stencil, boolean gles2) {
|
||||||
|
super(8, 8, 8, 0, withDepthBuffer ? 16 : 0, stencil ? 8 : 0, gles2);
|
||||||
|
mRedSize = 8;
|
||||||
|
mGreenSize = 8;
|
||||||
|
mBlueSize = 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SimpleEGLConfigChooser32 extends ComponentSizeChooser {
|
||||||
|
public SimpleEGLConfigChooser32(boolean withDepthBuffer, boolean stencil, boolean gles2) {
|
||||||
|
super(8, 8, 8, 8, withDepthBuffer ? 16 : 0, stencil ? 8 : 0, gles2);
|
||||||
|
mRedSize = 8;
|
||||||
|
mGreenSize = 8;
|
||||||
|
mBlueSize = 8;
|
||||||
|
mAlphaSize = 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static ComponentSizeChooser getEglConfigChooser(int videoDepthBpp, boolean withDepthBuffer, boolean stencil, boolean gles2) {
|
||||||
|
if(videoDepthBpp == 16)
|
||||||
|
return new SimpleEGLConfigChooser16(withDepthBuffer, stencil, gles2);
|
||||||
|
if(videoDepthBpp == 24)
|
||||||
|
return new SimpleEGLConfigChooser24(withDepthBuffer, stencil, gles2);
|
||||||
|
if(videoDepthBpp == 32)
|
||||||
|
return new SimpleEGLConfigChooser32(withDepthBuffer, stencil, gles2);
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An EGL helper class.
|
* An EGL helper class.
|
||||||
*/
|
*/
|
||||||
@@ -775,8 +817,11 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* Create an OpenGL ES context. This must be done only once, an
|
* Create an OpenGL ES context. This must be done only once, an
|
||||||
* OpenGL context is a somewhat heavy object.
|
* OpenGL context is a somewhat heavy object.
|
||||||
*/
|
*/
|
||||||
|
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,
|
mEglContext = mEgl.eglCreateContext(mEglDisplay, mEglConfig,
|
||||||
EGL10.EGL_NO_CONTEXT, null);
|
EGL10.EGL_NO_CONTEXT, mEGLConfigChooser.isGles2Required() ? gles2_attrib_list : null );
|
||||||
|
|
||||||
mEglSurface = null;
|
mEglSurface = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,11 @@ class Globals {
|
|||||||
public static String AppLibraries[] = { "sdl-1.2", };
|
public static String AppLibraries[] = { "sdl-1.2", };
|
||||||
public static final boolean Using_SDL_1_3 = false;
|
public static final boolean Using_SDL_1_3 = false;
|
||||||
public static String DataDownloadUrl = "Data files are 2 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-data.zip/download^High-quality GFX and music - 40 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-hqp.zip/download";
|
public static String DataDownloadUrl = "Data files are 2 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-data.zip/download^High-quality GFX and music - 40 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-hqp.zip/download";
|
||||||
public static boolean NeedDepthBuffer = false;
|
public static int VideoDepthBpp = 16;
|
||||||
public static boolean SwVideoMode = false;
|
public static boolean SwVideoMode = false;
|
||||||
|
public static boolean NeedDepthBuffer = false;
|
||||||
|
public static boolean NeedStencilBuffer = false;
|
||||||
|
public static boolean NeedGles2 = false;
|
||||||
public static boolean CompatibilityHacks = false;
|
public static boolean CompatibilityHacks = false;
|
||||||
public static boolean HorizontalOrientation = true;
|
public static boolean HorizontalOrientation = true;
|
||||||
public static boolean InhibitSuspend = false;
|
public static boolean InhibitSuspend = false;
|
||||||
|
|||||||
@@ -2356,6 +2356,7 @@ class Settings
|
|||||||
|
|
||||||
static void Apply(Activity p)
|
static void Apply(Activity p)
|
||||||
{
|
{
|
||||||
|
nativeSetVideoDepth(Globals.VideoDepthBpp);
|
||||||
if(Globals.SmoothVideo)
|
if(Globals.SmoothVideo)
|
||||||
nativeSetSmoothVideo();
|
nativeSetSmoothVideo();
|
||||||
if( Globals.CompatibilityHacks )
|
if( Globals.CompatibilityHacks )
|
||||||
@@ -2488,6 +2489,7 @@ class Settings
|
|||||||
private static native void nativeSetMultitouchUsed();
|
private static native void nativeSetMultitouchUsed();
|
||||||
private static native void nativeSetTouchscreenKeyboardUsed();
|
private static native void nativeSetTouchscreenKeyboardUsed();
|
||||||
private static native void nativeSetSmoothVideo();
|
private static native void nativeSetSmoothVideo();
|
||||||
|
private static native void nativeSetVideoDepth(int bpp);
|
||||||
private static native void nativeSetCompatibilityHacks();
|
private static native void nativeSetCompatibilityHacks();
|
||||||
private static native void nativeSetVideoMultithreaded();
|
private static native void nativeSetVideoMultithreaded();
|
||||||
private static native void nativeSetupScreenKeyboard(int size, int drawsize, int theme, int nbuttonsAutoFire, int transparency);
|
private static native void nativeSetupScreenKeyboard(int size, int drawsize, int theme, int nbuttonsAutoFire, int transparency);
|
||||||
|
|||||||
@@ -444,7 +444,7 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
|||||||
super(context);
|
super(context);
|
||||||
mParent = context;
|
mParent = context;
|
||||||
touchInput = DifferentTouchInput.getInstance();
|
touchInput = DifferentTouchInput.getInstance();
|
||||||
setEGLConfigChooser(Globals.NeedDepthBuffer);
|
setEGLConfigChooser(Globals.VideoDepthBpp, Globals.NeedDepthBuffer, Globals.NeedStencilBuffer, Globals.NeedGles2);
|
||||||
mRenderer = new DemoRenderer(context);
|
mRenderer = new DemoRenderer(context);
|
||||||
setRenderer(mRenderer);
|
setRenderer(mRenderer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,13 @@ AppFullName=net.sourceforge.clonekeenplus
|
|||||||
ScreenOrientation=h
|
ScreenOrientation=h
|
||||||
InhibitSuspend=n
|
InhibitSuspend=n
|
||||||
AppDataDownloadUrl="!Data files|data.zip^High-quality GFX and music - 40 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-hqp-1.8.zip/download"
|
AppDataDownloadUrl="!Data files|data.zip^High-quality GFX and music - 40 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-hqp-1.8.zip/download"
|
||||||
|
VideoDepthBpp=16
|
||||||
|
NeedDepthBuffer=n
|
||||||
|
NeedStencilBuffer=n
|
||||||
|
NeedGles2=n
|
||||||
|
SwVideoMode=y
|
||||||
SdlVideoResize=y
|
SdlVideoResize=y
|
||||||
SdlVideoResizeKeepAspect=n
|
SdlVideoResizeKeepAspect=n
|
||||||
NeedDepthBuffer=n
|
|
||||||
SwVideoMode=y
|
|
||||||
CompatibilityHacks=n
|
CompatibilityHacks=n
|
||||||
AppUsesMouse=n
|
AppUsesMouse=n
|
||||||
AppNeedsTwoButtonMouse=n
|
AppNeedsTwoButtonMouse=n
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ static void ANDROID_VideoQuitMT(_THIS);
|
|||||||
static void ANDROID_UpdateRectsMT(_THIS, int numrects, SDL_Rect *rects);
|
static void ANDROID_UpdateRectsMT(_THIS, int numrects, SDL_Rect *rects);
|
||||||
static int ANDROID_FlipHWSurfaceMT(_THIS, SDL_Surface *surface);
|
static int ANDROID_FlipHWSurfaceMT(_THIS, SDL_Surface *surface);
|
||||||
static int ANDROID_ToggleFullScreen(_THIS, int fullscreen);
|
static int ANDROID_ToggleFullScreen(_THIS, int fullscreen);
|
||||||
|
static Uint32 PixelFormatEnum = SDL_PIXELFORMAT_RGB565;
|
||||||
|
static Uint32 PixelFormatEnumAlpha = SDL_PIXELFORMAT_RGBA4444;
|
||||||
|
static Uint32 PixelFormatEnumColorkey = SDL_PIXELFORMAT_RGBA5551;
|
||||||
|
|
||||||
|
|
||||||
// Stubs to get rid of crashing in OpenGL mode
|
// Stubs to get rid of crashing in OpenGL mode
|
||||||
@@ -117,7 +120,6 @@ static SDL_Rect *SDL_modelist[SDL_NUMMODES+1];
|
|||||||
|
|
||||||
//#define SDL_modelist (this->hidden->SDL_modelist)
|
//#define SDL_modelist (this->hidden->SDL_modelist)
|
||||||
|
|
||||||
enum { ANDROID_BYTESPERPIXEL = 2, ANDROID_BITSPERPIXEL = 16 };
|
|
||||||
typedef struct SDL_Texture private_hwdata;
|
typedef struct SDL_Texture private_hwdata;
|
||||||
|
|
||||||
// Pointer to in-memory video surface
|
// Pointer to in-memory video surface
|
||||||
@@ -212,21 +214,32 @@ int ANDROID_VideoInit(_THIS, SDL_PixelFormat *vformat)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
static SDL_PixelFormat alphaFormat;
|
static SDL_PixelFormat alphaFormat;
|
||||||
|
int bpp;
|
||||||
|
|
||||||
/* Determine the screen depth (use default 16-bit depth) */
|
/* Determine the screen depth (use default 16-bit depth) */
|
||||||
/* we change this during the SDL_SetVideoMode implementation... */
|
/* we change this during the SDL_SetVideoMode implementation... */
|
||||||
if( vformat ) {
|
if( vformat ) {
|
||||||
vformat->BitsPerPixel = ANDROID_BITSPERPIXEL;
|
vformat->BitsPerPixel = SDL_ANDROID_BITSPERPIXEL;
|
||||||
vformat->BytesPerPixel = ANDROID_BYTESPERPIXEL;
|
vformat->BytesPerPixel = SDL_ANDROID_BYTESPERPIXEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( SDL_ANDROID_BITSPERPIXEL == 24 )
|
||||||
|
PixelFormatEnum = SDL_PIXELFORMAT_RGB24;
|
||||||
|
if( SDL_ANDROID_BITSPERPIXEL == 32 )
|
||||||
|
PixelFormatEnum = SDL_PIXELFORMAT_RGBA8888;
|
||||||
|
|
||||||
|
if( SDL_ANDROID_BITSPERPIXEL >= 24 )
|
||||||
|
{
|
||||||
|
PixelFormatEnumAlpha = SDL_PIXELFORMAT_RGBA8888;
|
||||||
|
PixelFormatEnumColorkey = SDL_PIXELFORMAT_RGBA8888;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bpp;
|
|
||||||
SDL_memset(&alphaFormat, 0, sizeof(alphaFormat));
|
SDL_memset(&alphaFormat, 0, sizeof(alphaFormat));
|
||||||
SDL_PixelFormatEnumToMasks( SDL_PIXELFORMAT_RGBA4444, &bpp,
|
SDL_PixelFormatEnumToMasks( PixelFormatEnumAlpha, &bpp,
|
||||||
&alphaFormat.Rmask, &alphaFormat.Gmask,
|
&alphaFormat.Rmask, &alphaFormat.Gmask,
|
||||||
&alphaFormat.Bmask, &alphaFormat.Amask );
|
&alphaFormat.Bmask, &alphaFormat.Amask );
|
||||||
alphaFormat.BitsPerPixel = ANDROID_BITSPERPIXEL;
|
alphaFormat.BitsPerPixel = SDL_ANDROID_BITSPERPIXEL;
|
||||||
alphaFormat.BytesPerPixel = ANDROID_BYTESPERPIXEL;
|
alphaFormat.BytesPerPixel = SDL_ANDROID_BYTESPERPIXEL;
|
||||||
this->displayformatalphapixel = &alphaFormat;
|
this->displayformatalphapixel = &alphaFormat;
|
||||||
|
|
||||||
this->info.hw_available = 1;
|
this->info.hw_available = 1;
|
||||||
@@ -269,7 +282,7 @@ int ANDROID_VideoInit(_THIS, SDL_PixelFormat *vformat)
|
|||||||
|
|
||||||
SDL_Rect **ANDROID_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
|
SDL_Rect **ANDROID_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
|
||||||
{
|
{
|
||||||
if(format->BitsPerPixel != ANDROID_BITSPERPIXEL)
|
if(format->BitsPerPixel != SDL_ANDROID_BITSPERPIXEL)
|
||||||
return NULL;
|
return NULL;
|
||||||
return SDL_modelist;
|
return SDL_modelist;
|
||||||
}
|
}
|
||||||
@@ -280,7 +293,7 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
|
|||||||
SDL_PixelFormat format;
|
SDL_PixelFormat format;
|
||||||
int bpp1;
|
int bpp1;
|
||||||
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_SetVideoMode(): application requested mode %dx%d OpenGL %d HW %d", width, height, flags & SDL_OPENGL, flags & SDL_HWSURFACE);
|
__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_SetVideoMode(): application requested mode %dx%d OpenGL %d HW %d BPP %d", width, height, flags & SDL_OPENGL, flags & SDL_HWSURFACE, SDL_ANDROID_BITSPERPIXEL);
|
||||||
if( ! SDL_ANDROID_InsideVideoThread() )
|
if( ! SDL_ANDROID_InsideVideoThread() )
|
||||||
{
|
{
|
||||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
|
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
|
||||||
@@ -295,7 +308,7 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
|
|||||||
current->flags = (flags & SDL_FULLSCREEN) | (flags & SDL_OPENGL) | SDL_DOUBLEBUF | ( flags & SDL_HWSURFACE );
|
current->flags = (flags & SDL_FULLSCREEN) | (flags & SDL_OPENGL) | SDL_DOUBLEBUF | ( flags & SDL_HWSURFACE );
|
||||||
current->w = width;
|
current->w = width;
|
||||||
current->h = height;
|
current->h = height;
|
||||||
current->pitch = SDL_ANDROID_sFakeWindowWidth * ANDROID_BYTESPERPIXEL;
|
current->pitch = SDL_ANDROID_sFakeWindowWidth * SDL_ANDROID_BYTESPERPIXEL;
|
||||||
current->pixels = NULL;
|
current->pixels = NULL;
|
||||||
current->hwdata = NULL;
|
current->hwdata = NULL;
|
||||||
|
|
||||||
@@ -312,7 +325,7 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
|
|||||||
SDL_VideoWindow = SDL_CreateWindow("", 0, 0, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL);
|
SDL_VideoWindow = SDL_CreateWindow("", 0, 0, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL);
|
||||||
|
|
||||||
SDL_memset(&mode, 0, sizeof(mode));
|
SDL_memset(&mode, 0, sizeof(mode));
|
||||||
mode.format = SDL_PIXELFORMAT_RGB565;
|
mode.format = PixelFormatEnum;
|
||||||
SDL_SetWindowDisplayMode(SDL_VideoWindow, &mode);
|
SDL_SetWindowDisplayMode(SDL_VideoWindow, &mode);
|
||||||
|
|
||||||
if (SDL_CreateRenderer(SDL_VideoWindow, -1, 0) < 0) {
|
if (SDL_CreateRenderer(SDL_VideoWindow, -1, 0) < 0) {
|
||||||
@@ -324,14 +337,14 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
|
|||||||
current->hwdata = NULL;
|
current->hwdata = NULL;
|
||||||
if( ! (flags & SDL_HWSURFACE) )
|
if( ! (flags & SDL_HWSURFACE) )
|
||||||
{
|
{
|
||||||
current->pixels = SDL_malloc(width * height * ANDROID_BYTESPERPIXEL);
|
current->pixels = SDL_malloc(width * height * SDL_ANDROID_BYTESPERPIXEL);
|
||||||
if ( ! current->pixels ) {
|
if ( ! current->pixels ) {
|
||||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate buffer for requested mode");
|
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate buffer for requested mode");
|
||||||
SDL_SetError("Couldn't allocate buffer for requested mode");
|
SDL_SetError("Couldn't allocate buffer for requested mode");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
SDL_memset(current->pixels, 0, width * height * ANDROID_BYTESPERPIXEL);
|
SDL_memset(current->pixels, 0, width * height * SDL_ANDROID_BYTESPERPIXEL);
|
||||||
current->hwdata = (struct private_hwdata *)SDL_CreateTexture(SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STATIC, width, height);
|
current->hwdata = (struct private_hwdata *)SDL_CreateTexture(PixelFormatEnum, SDL_TEXTUREACCESS_STATIC, width, height);
|
||||||
if( !current->hwdata ) {
|
if( !current->hwdata ) {
|
||||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate texture for SDL_CurrentVideoSurface");
|
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate texture for SDL_CurrentVideoSurface");
|
||||||
SDL_free(current->pixels);
|
SDL_free(current->pixels);
|
||||||
@@ -354,13 +367,13 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
|
|||||||
|
|
||||||
/* Allocate the new pixel format for the screen */
|
/* Allocate the new pixel format for the screen */
|
||||||
SDL_memset(&format, 0, sizeof(format));
|
SDL_memset(&format, 0, sizeof(format));
|
||||||
SDL_PixelFormatEnumToMasks( SDL_PIXELFORMAT_RGB565, &bpp1,
|
SDL_PixelFormatEnumToMasks( PixelFormatEnum, &bpp1,
|
||||||
&format.Rmask, &format.Gmask,
|
&format.Rmask, &format.Gmask,
|
||||||
&format.Bmask, &format.Amask );
|
&format.Bmask, &format.Amask );
|
||||||
format.BitsPerPixel = bpp1;
|
format.BitsPerPixel = bpp1;
|
||||||
format.BytesPerPixel = ANDROID_BYTESPERPIXEL;
|
format.BytesPerPixel = SDL_ANDROID_BYTESPERPIXEL;
|
||||||
|
|
||||||
if ( ! SDL_ReallocFormat(current, ANDROID_BITSPERPIXEL, format.Rmask, format.Gmask, format.Bmask, format.Amask) ) {
|
if ( ! SDL_ReallocFormat(current, SDL_ANDROID_BITSPERPIXEL, format.Rmask, format.Gmask, format.Bmask, format.Amask) ) {
|
||||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate new pixel format for requested mode");
|
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate new pixel format for requested mode");
|
||||||
SDL_SetError("Couldn't allocate new pixel format for requested mode");
|
SDL_SetError("Couldn't allocate new pixel format for requested mode");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@@ -437,14 +450,13 @@ static int ANDROID_AllocHWSurface(_THIS, SDL_Surface *surface)
|
|||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
DEBUGOUT("ANDROID_AllocHWSurface() surface %p w %d h %d", surface, surface->w, surface->h);
|
DEBUGOUT("ANDROID_AllocHWSurface() surface %p w %d h %d", surface, surface->w, surface->h);
|
||||||
Uint32 format = SDL_PIXELFORMAT_RGBA5551; // 1-bit alpha for color key, every surface will have colorkey so it's easier for us
|
Uint32 format = PixelFormatEnumColorkey; // 1-bit alpha for color key, every surface will have colorkey so it's easier for us
|
||||||
if( surface->format->Amask )
|
if( surface->format->Amask )
|
||||||
{
|
{
|
||||||
SDL_PixelFormat format1;
|
SDL_PixelFormat format1;
|
||||||
int bpp;
|
int bpp;
|
||||||
format = SDL_PIXELFORMAT_RGBA4444;
|
format = PixelFormatEnumAlpha;
|
||||||
DEBUGOUT("ANDROID_AllocHWSurface() SDL_PIXELFORMAT_RGBA4444");
|
SDL_memset(&format1, 0, sizeof(format1));
|
||||||
SDL_memset(&format1, 0, sizeof(format1));
|
|
||||||
SDL_PixelFormatEnumToMasks( format, &bpp,
|
SDL_PixelFormatEnumToMasks( format, &bpp,
|
||||||
&format1.Rmask, &format1.Gmask,
|
&format1.Rmask, &format1.Gmask,
|
||||||
&format1.Bmask, &format1.Amask );
|
&format1.Bmask, &format1.Amask );
|
||||||
@@ -457,7 +469,6 @@ static int ANDROID_AllocHWSurface(_THIS, SDL_Surface *surface)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUGOUT("ANDROID_AllocHWSurface() SDL_PIXELFORMAT_RGBA5551");
|
|
||||||
// HW-accel surface should be RGB565
|
// HW-accel surface should be RGB565
|
||||||
if( !( SDL_CurrentVideoSurface->format->BitsPerPixel == surface->format->BitsPerPixel &&
|
if( !( SDL_CurrentVideoSurface->format->BitsPerPixel == surface->format->BitsPerPixel &&
|
||||||
SDL_CurrentVideoSurface->format->Rmask == surface->format->Rmask &&
|
SDL_CurrentVideoSurface->format->Rmask == surface->format->Rmask &&
|
||||||
@@ -557,7 +568,7 @@ static int ANDROID_LockHWSurface(_THIS, SDL_Surface *surface)
|
|||||||
if( ! SDL_CurrentVideoSurface->pixels )
|
if( ! SDL_CurrentVideoSurface->pixels )
|
||||||
{
|
{
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||||
SDL_CurrentVideoSurface->pixels = SDL_malloc(SDL_ANDROID_sFakeWindowWidth * SDL_ANDROID_sFakeWindowHeight * ANDROID_BYTESPERPIXEL);
|
SDL_CurrentVideoSurface->pixels = SDL_malloc(SDL_ANDROID_sFakeWindowWidth * SDL_ANDROID_sFakeWindowHeight * SDL_ANDROID_BYTESPERPIXEL);
|
||||||
if ( ! SDL_CurrentVideoSurface->pixels ) {
|
if ( ! SDL_CurrentVideoSurface->pixels ) {
|
||||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate buffer for SDL_CurrentVideoSurface");
|
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate buffer for SDL_CurrentVideoSurface");
|
||||||
SDL_SetError("Couldn't allocate buffer for SDL_CurrentVideoSurface");
|
SDL_SetError("Couldn't allocate buffer for SDL_CurrentVideoSurface");
|
||||||
@@ -566,7 +577,7 @@ static int ANDROID_LockHWSurface(_THIS, SDL_Surface *surface)
|
|||||||
}
|
}
|
||||||
if( ! SDL_CurrentVideoSurface->hwdata )
|
if( ! SDL_CurrentVideoSurface->hwdata )
|
||||||
{
|
{
|
||||||
SDL_CurrentVideoSurface->hwdata = (struct private_hwdata *)SDL_CreateTexture(SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STATIC, SDL_ANDROID_sFakeWindowWidth, SDL_ANDROID_sFakeWindowHeight);
|
SDL_CurrentVideoSurface->hwdata = (struct private_hwdata *)SDL_CreateTexture(PixelFormatEnum, SDL_TEXTUREACCESS_STATIC, SDL_ANDROID_sFakeWindowWidth, SDL_ANDROID_sFakeWindowHeight);
|
||||||
if( !SDL_CurrentVideoSurface->hwdata ) {
|
if( !SDL_CurrentVideoSurface->hwdata ) {
|
||||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate texture for SDL_CurrentVideoSurface");
|
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate texture for SDL_CurrentVideoSurface");
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
@@ -585,6 +596,7 @@ static int ANDROID_LockHWSurface(_THIS, SDL_Surface *surface)
|
|||||||
|
|
||||||
for(y=0; y<fakeH; y++)
|
for(y=0; y<fakeH; y++)
|
||||||
{
|
{
|
||||||
|
// TODO: support 24bpp and 32bpp
|
||||||
glReadPixels(0, realH - 1 - (realH * y / fakeH),
|
glReadPixels(0, realH - 1 - (realH * y / fakeH),
|
||||||
realW, 1, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, row);
|
realW, 1, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, row);
|
||||||
for(x=0; x<fakeW; x++)
|
for(x=0; x<fakeW; x++)
|
||||||
@@ -621,7 +633,7 @@ static int ANDROID_LockHWSurface(_THIS, SDL_Surface *surface)
|
|||||||
static void ANDROID_UnlockHWSurface(_THIS, SDL_Surface *surface)
|
static void ANDROID_UnlockHWSurface(_THIS, SDL_Surface *surface)
|
||||||
{
|
{
|
||||||
SDL_PixelFormat format;
|
SDL_PixelFormat format;
|
||||||
Uint32 hwformat = SDL_PIXELFORMAT_RGBA5551;
|
Uint32 hwformat = PixelFormatEnumColorkey;
|
||||||
int bpp;
|
int bpp;
|
||||||
SDL_Surface * converted = NULL;
|
SDL_Surface * converted = NULL;
|
||||||
|
|
||||||
@@ -635,26 +647,26 @@ static void ANDROID_UnlockHWSurface(_THIS, SDL_Surface *surface)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if( surface->format->Amask )
|
if( surface->format->Amask )
|
||||||
hwformat = SDL_PIXELFORMAT_RGBA4444;
|
hwformat = PixelFormatEnumAlpha;
|
||||||
|
|
||||||
if( surface == SDL_CurrentVideoSurface ) // Special case
|
if( surface == SDL_CurrentVideoSurface ) // Special case
|
||||||
hwformat = SDL_PIXELFORMAT_RGB565;
|
hwformat = PixelFormatEnum;
|
||||||
|
|
||||||
/* Allocate the new pixel format for the screen */
|
/* Allocate the new pixel format for the screen */
|
||||||
SDL_memset(&format, 0, sizeof(format));
|
SDL_memset(&format, 0, sizeof(format));
|
||||||
SDL_PixelFormatEnumToMasks( hwformat, &bpp,
|
SDL_PixelFormatEnumToMasks( hwformat, &bpp,
|
||||||
&format.Rmask, &format.Gmask,
|
&format.Rmask, &format.Gmask,
|
||||||
&format.Bmask, &format.Amask );
|
&format.Bmask, &format.Amask );
|
||||||
format.BytesPerPixel = ANDROID_BYTESPERPIXEL;
|
format.BytesPerPixel = SDL_ANDROID_BYTESPERPIXEL;
|
||||||
format.BitsPerPixel = bpp;
|
format.BitsPerPixel = bpp;
|
||||||
|
|
||||||
|
// TODO: support 24bpp and 32bpp
|
||||||
if( format.BitsPerPixel == surface->format->BitsPerPixel &&
|
if( format.BitsPerPixel == surface->format->BitsPerPixel &&
|
||||||
format.Rmask == surface->format->Rmask &&
|
format.Rmask == surface->format->Rmask &&
|
||||||
format.Gmask == surface->format->Gmask &&
|
format.Gmask == surface->format->Gmask &&
|
||||||
format.Bmask == surface->format->Bmask &&
|
format.Bmask == surface->format->Bmask &&
|
||||||
format.Amask == surface->format->Amask )
|
format.Amask == surface->format->Amask )
|
||||||
{
|
{
|
||||||
DEBUGOUT("ANDROID_UnlockHWSurface() no conversion");
|
|
||||||
converted = surface; // No need for conversion
|
converted = surface; // No need for conversion
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -963,11 +975,11 @@ void SDL_ANDROID_VideoContextRecreated()
|
|||||||
for( i = 0; i < HwSurfaceCount; i++ )
|
for( i = 0; i < HwSurfaceCount; i++ )
|
||||||
{
|
{
|
||||||
// Allocate HW texture
|
// Allocate HW texture
|
||||||
Uint32 format = SDL_PIXELFORMAT_RGBA5551; // 1-bit alpha for color key, every surface will have colorkey so it's easier for us
|
Uint32 format = PixelFormatEnumColorkey; // 1-bit alpha for color key, every surface will have colorkey so it's easier for us
|
||||||
if( HwSurfaceList[i]->format->Amask )
|
if( HwSurfaceList[i]->format->Amask )
|
||||||
format = SDL_PIXELFORMAT_RGBA4444;
|
format = PixelFormatEnumAlpha;
|
||||||
if( HwSurfaceList[i] == SDL_CurrentVideoSurface )
|
if( HwSurfaceList[i] == SDL_CurrentVideoSurface )
|
||||||
format = SDL_PIXELFORMAT_RGB565;
|
format = PixelFormatEnum;
|
||||||
HwSurfaceList[i]->hwdata = (struct private_hwdata *)SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, HwSurfaceList[i]->w, HwSurfaceList[i]->h);
|
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 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -133,8 +133,7 @@ SDL_RenderDriver GL_ES_RenderDriver = {
|
|||||||
SDL_PIXELFORMAT_RGBA5551,
|
SDL_PIXELFORMAT_RGBA5551,
|
||||||
SDL_PIXELFORMAT_RGB565,
|
SDL_PIXELFORMAT_RGB565,
|
||||||
SDL_PIXELFORMAT_RGB24,
|
SDL_PIXELFORMAT_RGB24,
|
||||||
SDL_PIXELFORMAT_BGR888,
|
SDL_PIXELFORMAT_RGBA8888},
|
||||||
SDL_PIXELFORMAT_ABGR8888},
|
|
||||||
0,
|
0,
|
||||||
0}
|
0}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -68,6 +68,9 @@ static int showScreenKeyboardSendBackspace = 0;
|
|||||||
int SDL_ANDROID_SmoothVideo = 0;
|
int SDL_ANDROID_SmoothVideo = 0;
|
||||||
int SDL_ANDROID_VideoMultithreaded = 0;
|
int SDL_ANDROID_VideoMultithreaded = 0;
|
||||||
int SDL_ANDROID_CompatibilityHacks = 0;
|
int SDL_ANDROID_CompatibilityHacks = 0;
|
||||||
|
int SDL_ANDROID_BYTESPERPIXEL = 2;
|
||||||
|
int SDL_ANDROID_BITSPERPIXEL = 16;
|
||||||
|
|
||||||
|
|
||||||
static void appPutToBackgroundCallbackDefault(void)
|
static void appPutToBackgroundCallbackDefault(void)
|
||||||
{
|
{
|
||||||
@@ -306,3 +309,10 @@ JAVA_EXPORT_NAME(Settings_nativeSetCompatibilityHacks) (JNIEnv* env, jobject thi
|
|||||||
{
|
{
|
||||||
SDL_ANDROID_CompatibilityHacks = 1;
|
SDL_ANDROID_CompatibilityHacks = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL
|
||||||
|
JAVA_EXPORT_NAME(Settings_nativeSetVideoDepth) (JNIEnv* env, jobject thiz, jint bpp)
|
||||||
|
{
|
||||||
|
SDL_ANDROID_BITSPERPIXEL = bpp;
|
||||||
|
SDL_ANDROID_BYTESPERPIXEL = SDL_ANDROID_BITSPERPIXEL / 8;
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ extern int SDL_ANDROID_TouchscreenCalibrationY;
|
|||||||
extern int SDL_ANDROID_SmoothVideo;
|
extern int SDL_ANDROID_SmoothVideo;
|
||||||
extern int SDL_ANDROID_VideoMultithreaded;
|
extern int SDL_ANDROID_VideoMultithreaded;
|
||||||
extern int SDL_ANDROID_CompatibilityHacks;
|
extern int SDL_ANDROID_CompatibilityHacks;
|
||||||
|
extern int SDL_ANDROID_BYTESPERPIXEL;
|
||||||
|
extern int SDL_ANDROID_BITSPERPIXEL;
|
||||||
extern void SDL_ANDROID_TextInputInit(char * buffer, int len);
|
extern void SDL_ANDROID_TextInputInit(char * buffer, int len);
|
||||||
extern void SDL_ANDROID_TextInputFinished();
|
extern void SDL_ANDROID_TextInputFinished();
|
||||||
extern SDL_Surface *SDL_CurrentVideoSurface;
|
extern SDL_Surface *SDL_CurrentVideoSurface;
|
||||||
|
|||||||
12
readme.txt
12
readme.txt
@@ -52,13 +52,12 @@ You may find quick Android game porting manual at http://anddev.at.ua/src/portin
|
|||||||
|
|
||||||
If you're porting existing app which uses SDL 1.2 please always use SW mode:
|
If you're porting existing app which uses SDL 1.2 please always use SW mode:
|
||||||
neither SDL_SetVideoMode() call nor SDL_CreateRGBSurface() etc functions shall contain SDL_HWSURFACE flags.
|
neither SDL_SetVideoMode() call nor SDL_CreateRGBSurface() etc functions shall contain SDL_HWSURFACE flags.
|
||||||
The BPP in SDL_SetVideoMode() shall be set to 16, and audio format - to AUDIO_S8 or AUDIO_S16.
|
The BPP in SDL_SetVideoMode() shall be set to the same value you've specified in ChangeAppSettings.sh,
|
||||||
|
and audio format - to AUDIO_S8 or AUDIO_S16.
|
||||||
|
|
||||||
The native Android pixel format is RGB_565, even for OpenGL, not BGR_565 as all other OpenGL implementations have.
|
The native Android 16-bit pixel format is RGB_565, even for OpenGL, not BGR_565 as all other OpenGL implementations have.
|
||||||
|
|
||||||
Colorkey images are supported using RGBA_5551 pixelformat with 1-bit alpha -
|
Colorkey surfaces and alpha surfaces are supported, SDL_RLEACCEL is not supported.
|
||||||
SDL does conversion internally, for you they are just RGB_565 surfaces.
|
|
||||||
Alpha surfaces have RGBA_4444 format. SDL_RLEACCEL is not supported.
|
|
||||||
|
|
||||||
To compile your own app, put your app sources into project/jni/application dir (or create symlink to them),
|
To compile your own app, put your app sources into project/jni/application dir (or create symlink to them),
|
||||||
and change symlink "src" to point to your app:
|
and change symlink "src" to point to your app:
|
||||||
@@ -98,7 +97,8 @@ SDL_ListModes()[0] will always return native screen resolution.
|
|||||||
Also make sure that your HW textures are not wider than 1024 pixels, or it will fail to allocate such
|
Also make sure that your HW textures are not wider than 1024 pixels, or it will fail to allocate such
|
||||||
texture on HTC G1, and other low-end devices. Software surfaces may be of any size of course.
|
texture on HTC G1, and other low-end devices. Software surfaces may be of any size of course.
|
||||||
|
|
||||||
If you want HW acceleration there are some limitations:
|
If you want HW acceleration - just use OpenGL, the HW acceleration by SDL has some limitations:
|
||||||
|
You should use 16-bit color depth.
|
||||||
You cannot blit SW surface to screen, it should be only HW surface.
|
You cannot blit SW surface to screen, it should be only HW surface.
|
||||||
You can use colorkey, per-surface alpha and per-pixel alpha with HW surfaces.
|
You can use colorkey, per-surface alpha and per-pixel alpha with HW surfaces.
|
||||||
If you're using SDL 1.3 always use SDL_Texture, if you'll be using SDL_Surface with SDL 1.3 it will switch to SW mode.
|
If you're using SDL 1.3 always use SDL_Texture, if you'll be using SDL_Surface with SDL 1.3 it will switch to SW mode.
|
||||||
|
|||||||
Reference in New Issue
Block a user