Skip to content

Commit

Permalink
Fixed the android backend, fixed some bugs and etc
Browse files Browse the repository at this point in the history
  • Loading branch information
scooterman committed Sep 6, 2011
1 parent a9040c3 commit 323b580
Show file tree
Hide file tree
Showing 42 changed files with 605 additions and 99 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
*~
include/
build/
bin/
gen/
libs/
6 changes: 4 additions & 2 deletions src/backends/gdx-cpp-backend-android/AndroidGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ bool gdx_cpp::backends::android::AndroidGraphics::isGL20Available()
}

bool gdx_cpp::backends::android::AndroidGraphics::setDisplayMode(gdx_cpp::Graphics::DisplayMode displayMode)
{
{
if (!supportsDisplayModeChange())
return false;
}
Expand Down Expand Up @@ -219,7 +219,8 @@ bool gdx_cpp::backends::android::AndroidGraphics::setDisplayMode(int width, int
{
this->width = width;
this->height = height;


this->lastTime = Gdx::system->nanoTime();
glCommon->glViewport(0, 0, width, height);
}

Expand All @@ -231,6 +232,7 @@ void backends::android::AndroidGraphics::resize(int width, int height)
{
this->width = width;
this->height = height;
this->lastTime = Gdx::system->nanoTime();
glCommon->glViewport(0, 0, width, height);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin"/>
</classpath>
33 changes: 33 additions & 0 deletions src/backends/gdx-cpp-backend-android/android_support/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ACTIVITY_ENTRY_NAME</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aevumlab.libgdxcpp"
android:versionCode="1"
android:versionName="1.0">
<application android:label="@string/app_name" android:icon="@drawable/icon">
<activity android:name="ACTIVITY_ENTRY_NAME"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked in Version Control Systems, as it is
# integral to the build system of your project.

# This file is only used by the Ant script.

# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.

# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.

79 changes: 79 additions & 0 deletions src/backends/gdx-cpp-backend-android/android_support/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="GdxCppAndroidSupport" default="help">

<!-- The local.properties file is created and updated by the 'android'
tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />

<!-- The build.properties file can be created by you and is never touched
by the 'android' tool. This is the place to change some of the
default property values used by the Ant rules.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="build.properties" />

<!-- The default.properties file is created and updated by the 'android'
tool, as well as ADT.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<property file="default.properties" />


<!-- Required pre-setup import -->
<import file="${sdk.dir}/tools/ant/pre_setup.xml" />


<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
<!--
<target name="-pre-build">
</target>
<target name="-pre-compile">
</target>
[This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir}]
<target name="-post-compile">
</target>
-->

<!-- Execute the Android Setup task that will setup some properties
specific to the target, and import the build rules files.
The rules file is imported from
<SDK>/tools/ant/
Depending on the project type it can be either:
- main_rules.xml
- lib_rules.xml
- test_rules.xml
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<setup> task.
- customize it to your needs.
- Customize the whole script.
- copy/paste the content of the rules files (minus the top node)
into this file, *after* the <setup> task
- disable the import of the rules by changing the setup task
below to <setup import="false" />.
- customize to your needs.
-->
<setup />

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

android.library=true
# Project target.
target=Google Inc.:Google APIs:9
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked in Version Control Systems,
# as it contains information specific to your local configuration.

# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=/home/victor/applications/android-sdk-linux_x86
36 changes: 36 additions & 0 deletions src/backends/gdx-cpp-backend-android/android_support/proguard.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, ACTIVITY_ENTRY_NAME"
/>
</LinearLayout>

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">ACTIVITY_ENTRY_NAME</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package com.aevumlab.gdxcpp;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.app.Activity;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.view.Display;

public class ApplicationManager {
static native void nativeInitSystem();

static native void nativeInitialize(int width, int height);

static native void nativeCreate();

static native void nativeUpdate();

static native void nativePause();

static native void nativeResume();

static native void nativeResize(int widht, int height);

Activity activity;

class NativeSurfaceRenderer implements GLSurfaceView.Renderer {

@Override
public void onDrawFrame(GL10 gl) {
ApplicationManager.nativeUpdate();
}

@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
ApplicationManager.nativeResize(width, height);
ApplicationManager.nativeCreate();
}

@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {

Display display = activity.getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();

ApplicationManager.nativeInitialize(width, height);
}
}

class NativeSurfaceView extends GLSurfaceView {

public NativeSurfaceView(Context context) {
super(context);
setFocusable(true);
setFocusableInTouchMode(true);
setRenderer(new NativeSurfaceRenderer());
}

// @Override
// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
// {
// final int width = View.MeasureSpec.getSize(widthMeasureSpec);
// final int height = View.MeasureSpec.getSize(heightMeasureSpec);
//
// setMeasuredDimension( width, height);
// }
}

public GLSurfaceView createView(Context context) {
return new NativeSurfaceView(context);
}

public void initializeWithSharedLib(String library) {
System.loadLibrary(library);
nativeInitSystem();
}

public void initialize(Activity activity) {
this.activity = activity;
System.loadLibrary("gdx-cpp");
}

public void update() {
}

public void pause() {
nativePause();
}

public void resume() {
nativeResume();
}

public void unload() {

}
}
6 changes: 4 additions & 2 deletions src/backends/gdx-cpp-backend-linux/LinuxApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ void LinuxApplication::error(const std::string& tag, const char* format, ...)
{
va_list list;
va_start(list, format);
std::string newTag = tag + ":" + format;
std::string newTag = tag + ":" + format + "\n";

vfprintf(stderr, newTag.c_str(), list);
fflush(stderr);
#if DEBUG
assert(false);
#endif
Expand Down Expand Up @@ -151,9 +152,10 @@ void LinuxApplication::log(const std::string& tag, const char* format, ...)

va_list list;
va_start(list, format);
std::string newTag = tag + ":" + format;
std::string newTag = tag + ":" + format + "\n";

vfprintf(stdout, newTag.c_str(), list);
fflush(stdout);
}

int gdx_cpp::backends::nix::LinuxApplication::getVersion()
Expand Down
Loading

0 comments on commit 323b580

Please sign in to comment.