Android work in progress changes
This commit is contained in:
parent
1e800d9551
commit
f4c25ac3fa
14 changed files with 94 additions and 300 deletions
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.sfml"
|
||||
package="org.sfmldev.android"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
|||
android:icon="@drawable/sfml_logo"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize">
|
||||
|
||||
<meta-data android:name="android.app.lib_name" android:value="sfml-activity" />
|
||||
<meta-data android:name="android.app.lib_name" android:value="sfml-activity-d" />
|
||||
<meta-data android:name="sfml.app.lib_name" android:value="sfml-example" />
|
||||
|
||||
<intent-filter>
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := sfml-example
|
||||
|
||||
LOCAL_SRC_FILES := main.cpp
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := sfml-system
|
||||
LOCAL_SHARED_LIBRARIES += sfml-window
|
||||
LOCAL_SHARED_LIBRARIES += sfml-graphics
|
||||
LOCAL_SHARED_LIBRARIES += sfml-audio
|
||||
LOCAL_SHARED_LIBRARIES += sfml-network
|
||||
LOCAL_SHARED_LIBRARIES += sfml-activity
|
||||
LOCAL_SHARED_LIBRARIES += openal
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := sfml-main
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
$(call import-module,sfml)
|
|
@ -1,5 +0,0 @@
|
|||
NDK_TOOLCHAIN_VERSION := 4.9
|
||||
APP_PLATFORM := android-14
|
||||
APP_STL := stlport_shared
|
||||
APP_ABI := armeabi-v7a
|
||||
APP_MODULES := sfml-activity sfml-example
|
20
examples/android/app/src/main/jni/Android.mk
Normal file
20
examples/android/app/src/main/jni/Android.mk
Normal file
|
@ -0,0 +1,20 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := sfml-example
|
||||
|
||||
LOCAL_SRC_FILES := main.cpp
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := sfml-system-d
|
||||
LOCAL_SHARED_LIBRARIES += sfml-window-d
|
||||
LOCAL_SHARED_LIBRARIES += sfml-graphics-d
|
||||
LOCAL_SHARED_LIBRARIES += sfml-audio-d
|
||||
LOCAL_SHARED_LIBRARIES += sfml-network-d
|
||||
LOCAL_SHARED_LIBRARIES += sfml-activity-d
|
||||
LOCAL_SHARED_LIBRARIES += openal
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := sfml-main-d
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
$(call import-module,third_party/sfml)
|
8
examples/android/app/src/main/jni/Application.mk
Normal file
8
examples/android/app/src/main/jni/Application.mk
Normal file
|
@ -0,0 +1,8 @@
|
|||
NDK_TOOLCHAIN_VERSION := 4.9
|
||||
APP_PLATFORM := android-14
|
||||
# APP_STL has to match CMAKE_ANDROID_STL_TYPE
|
||||
APP_STL := c++_static
|
||||
APP_ABI := armeabi-v7a
|
||||
APP_MODULES := sfml-activity-d sfml-example
|
||||
APP_OPTIM := debug
|
||||
APP_CFLAG := -g -ggdb -O0
|
|
@ -76,40 +76,79 @@ int vibrate(sf::Time duration)
|
|||
// ('vibrate()' in this example; undefine 'USE_JNI' above to disable it)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "");
|
||||
sf::VideoMode screen(sf::VideoMode::getDesktopMode());
|
||||
|
||||
sf::RenderWindow window(screen, "");
|
||||
window.setFramerateLimit(30);
|
||||
|
||||
sf::Texture texture;
|
||||
if(!texture.loadFromFile("image.png"))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
sf::Sprite image(texture);
|
||||
image.setPosition(0, 0);
|
||||
image.setPosition(screen.width / 2, screen.height / 2);
|
||||
image.setOrigin(texture.getSize().x/2, texture.getSize().y/2);
|
||||
|
||||
sf::Music music;
|
||||
sf::Font font;
|
||||
if (!font.loadFromFile("sansation.ttf"))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
sf::Text text("Tap anywhere to move the logo.", font, 64);
|
||||
text.setFillColor(sf::Color::Black);
|
||||
text.setPosition(10, 10);
|
||||
|
||||
// Loading canary.wav fails for me for now; haven't had time to test why
|
||||
|
||||
/*sf::Music music;
|
||||
if(!music.openFromFile("canary.wav"))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
music.play();
|
||||
music.play();*/
|
||||
|
||||
sf::View view = window.getDefaultView();
|
||||
|
||||
sf::Color background = sf::Color::White;
|
||||
|
||||
// We shouldn't try drawing to the screen while in background
|
||||
// so we'll have to track that. You can do minor background
|
||||
// work, but keep battery life in mind.
|
||||
bool active = true;
|
||||
|
||||
while (window.isOpen())
|
||||
{
|
||||
sf::Event event;
|
||||
|
||||
while (window.pollEvent(event))
|
||||
while (active ? window.pollEvent(event) : window.waitEvent(event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case sf::Event::Closed:
|
||||
window.close();
|
||||
break;
|
||||
case sf::Event::KeyPressed:
|
||||
if (event.key.code == sf::Keyboard::Escape)
|
||||
window.close();
|
||||
break;
|
||||
case sf::Event::Resized:
|
||||
view.setSize(event.size.width, event.size.height);
|
||||
view.setCenter(event.size.width/2, event.size.height/2);
|
||||
window.setView(view);
|
||||
break;
|
||||
case sf::Event::LostFocus:
|
||||
background = sf::Color::Black;
|
||||
break;
|
||||
case sf::Event::GainedFocus:
|
||||
background = sf::Color::White;
|
||||
break;
|
||||
|
||||
// On Android MouseLeft/MouseEntered are (for now) triggered,
|
||||
// whenever the app loses or gains focus.
|
||||
case sf::Event::MouseLeft:
|
||||
active = false;
|
||||
break;
|
||||
case sf::Event::MouseEntered:
|
||||
active = true;
|
||||
break;
|
||||
case sf::Event::TouchBegan:
|
||||
if (event.touch.finger == 0)
|
||||
{
|
||||
|
@ -122,8 +161,15 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
window.clear(sf::Color::White);
|
||||
window.draw(image);
|
||||
window.display();
|
||||
if (active)
|
||||
{
|
||||
window.clear(background);
|
||||
window.draw(image);
|
||||
window.draw(text);
|
||||
window.display();
|
||||
}
|
||||
else {
|
||||
sf::sleep(sf::milliseconds(100));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue