First blood

This commit is contained in:
vladislav.khorev committed 2013-01-19 20:02:34 +00:00
1 parent 04f270f322
commit 5720f8322b
250 files changed
+33215

No files matched your search

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="C:/Workplace/Projects/Android/EngineWrapper/jar/EngineWrapper.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SLWP</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>
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1" android:versionName="1.0.0" package="fishrungames.wallpapertemplate">
<application android:label="@string/app_name" android:icon="@drawable/icon" >
<activity android:launchMode="standard" android:name="Prefs">
<intent-filter>
<category android:name="android.intent.category.PREFERENCE"></category>
<action android:name="android.intent.action.MAIN"></action>
</intent-filter>
</activity>
<service android:name="MainWallpaperService" android:enabled="true"
android:icon="@drawable/icon" android:label="@string/app_name"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter android:priority="1">
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data android:name="android.service.wallpaper"
android:resource="@xml/wallpaper" />
</service>
</application>
<uses-sdk android:minSdkVersion="8" />
<uses-feature android:glEsVersion="0x00020000"/>
</manifest>
Binary file not shown.

After

Width:  |  Height:  |  Size: 313 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 B

@@ -0,0 +1,10 @@
precision lowp float;
uniform sampler2D Texture;
varying vec2 texCoord;
void main()
{
vec4 texColor = texture2D(Texture,texCoord).rgba;
gl_FragColor = vec4(texColor.rgb, texColor.a);
}
@@ -0,0 +1,11 @@
attribute vec3 vPosition;
attribute vec2 vTexCoord;
varying vec2 texCoord;
uniform mat4 ProjectionMatrix;
void main()
{
//480x320
gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0);
texCoord = vTexCoord;
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,13 @@
# 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.
# Project target.
target=android-8
# Indicates whether an apk should be generated for each density.
split.density=false
@@ -0,0 +1,77 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LPATH := $(call my-dir)
ENGINE_PATH = $(SalmonEnginePathCygwin)
BOOST_PATH = $(LibsPathCygwin)/boost_1_47_0
OGG_PATH = $(LibsPathCygwin)/libogg-1.3.0
VORBIS_PATH = $(LibsPathCygwin)/libvorbis-1.3.2
SQUIRREL_PATH = $(LibsPathCygwin)/sqplus
LIBPNG_PATH = $(LibsPathCygwin)/libpng_1.4.1_android
ZIP_PATH = $(LibsPathCygwin)/julienr-libzip-android/jni
#====== ENGINE AND LIBS =====================
include $(ENGINE_PATH)/Android_Salmon_Engine.mk
#================= THE GAME =======================
LOCAL_PATH:= $(LPATH)
include $(CLEAR_VARS)
LOCAL_CFLAGS := -DTARGET_ANDROID -DNOSOUND -DTARGET_SALMON -std=gnu++11 --std=c++11
LOCAL_STATIC_LIBRARIES := boost
LOCAL_STATIC_LIBRARIES += squirrel
LOCAL_STATIC_LIBRARIES += png_lib
LOCAL_STATIC_LIBRARIES += zip
LOCAL_SHARED_LIBRARIES := SalmonEngine
LOCAL_SHARED_LIBRARIES += gnustl_shared
LOCAL_C_INCLUDES := $(ENGINE_PATH)
LOCAL_C_INCLUDES += $(BOOST_PATH)
LOCAL_C_INCLUDES += $(VORBIS_PATH)/include
LOCAL_C_INCLUDES += $(VORBIS_PATH)/include/vorbis
LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib
LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/books
LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/modes
LOCAL_C_INCLUDES += $(OGG_PATH)/include
LOCAL_C_INCLUDES += $(OGG_PATH)/include/ogg
LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/include
LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqplus
LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/squirrel
LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqstdlib
LOCAL_C_INCLUDES += $(LIBPNG_PATH)
LOCAL_C_INCLUDES += $(ZIP_PATH)
LOCAL_MODULE := SalmonWallpaper
LOCAL_SRC_FILES := main_code.cpp
LOCAL_SRC_FILES += android_api.cpp
LOCAL_LDLIBS := -lGLESv2
LOCAL_LDLIBS += -llog -Wl
#debug
#LOCAL_CFLAGS += -g -ggdb -O0
#LOCAL_LDLIBS += -g -ggdb
include $(BUILD_SHARED_LIBRARY)
@@ -0,0 +1,3 @@
APP_STL := gnustl_shared
APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -frtti
@@ -0,0 +1,119 @@
#include "android_api.h"
#include "main_code.h"
#include "boost\thread.hpp"
std::shared_ptr<TAndroidApplication> App(new TAndroidApplication);
boost::mutex RenderMutex;
float lastOffsetX = 0.5f;
bool OffsetChanged = false;
bool RedBkgPref = false;
JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height)
{
RenderMutex.lock();
try
{
if (App->IsInited())
{
App->OuterDeinit(); //Clean up what is left at previous launch (if applicable)
}
App->Width = width;
App->Height = height;
if (width > height)
{
App->OuterInit(width, height, 800.f, 480.f);
}
else
{
App->OuterInit(width, height, 480.f, 800.f);
}
Renderer->SetAlpha((lastOffsetX) * pi / 180.f);
App->Inited = true;
}
catch (...)
{
throw;
}
RenderMutex.unlock();
}
JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_Update(JNIEnv * env, jobject obj, long dt)
{
RenderMutex.unlock();
try
{
if (App->IsInited())
{
App->OuterDraw();
App->OuterUpdate(dt);
if (OffsetChanged)
{
Renderer->SetAlpha((lastOffsetX) * pi / 180.f);
}
}
}
catch (...)
{
throw;
}
RenderMutex.unlock();
}
JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, jfloat x, jfloat y)
{
try
{
if (App->IsInited())
{
vec2 offset = vec2(x*Renderer->GetMatrixWidth()/static_cast<float>(App->Width), y*Renderer->GetMatrixHeight()/static_cast<float>(App->Height));
App->OuterOnMove(offset);
}
}
catch (...)
{
throw;
}
}
JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetOffset(JNIEnv * env, jobject obj, jfloat offsetX, jfloat offsetY)
{
if (Renderer != NULL)
{
OffsetChanged = true;
lastOffsetX = offsetX;
}
}
JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetOrientation(JNIEnv * env, jobject obj, int isLandscape)
{
}
JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetRedBkgPref(JNIEnv * env, jobject obj, jboolean r)
{
RedBkgPref = r;
}
@@ -0,0 +1,31 @@
#ifndef ANDROID_API_H_INCLUDED
#define ANDROID_API_H_INCLUDED
#include <jni.h>
#include <android/log.h>
#include <GLES/gl.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include "boost/shared_ptr.hpp"
#include "main_code.h"
extern "C" {
JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height);
JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_Update(JNIEnv * env, jobject obj, long dt);
JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, jfloat x, jfloat y);
JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetOffset(JNIEnv * env, jobject obj, jfloat offsetX, jfloat offsetY);
JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetOrientation(JNIEnv * env, jobject obj, int isLandscape);
JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetRedBkgPref(JNIEnv * env, jobject obj, jboolean r);
};
#endif
@@ -0,0 +1,183 @@
#include "main_code.h"
#ifdef TARGET_ANDROID
#include "android_api.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include "include/Engine.h"
#include "main_code.h"
extern float lastOffsetX;
#ifdef TARGET_WIN32
bool RedBkgPref = true;
#else
extern bool RedBkgPref;
#endif
TAndroidApplication::TAndroidApplication()
: TApplication()
, Inited(false)
//, LiteModel(NULL)
{
}
void TAndroidApplication::LoadModels()
{
mat3 m(vec4(0,1*sin(pi/8 + pi/2),0,1*cos(pi/8 + pi/2)));
/*
LiteModel = new TLiteModel;
LiteModel->LoadModel("bt_box_yellow.lm1");
LiteModel->ScaleModel(10.0f);
LiteModel->RotateModel(m);
LiteModel->UpdateVBO();*/
FlexModel = ResourceManager->FlexModelManager.InstanciateModel("model.xml");
//FlexModel.MoveModel(vec3(1, -4, -4));
FlexModel.ScaleModel(1.5f);
FlexModel.RotateModel(m);
FlexModel.RefreshBuffer();
}
void TAndroidApplication::DrawAllScene()
{
glClearColor(0.f, 0.f, 0.f, 1.0f);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
Renderer->PushProjectionMatrix(1,1);
Renderer->LoadIdentity();
if (RedBkgPref)
{
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["bkg_red.png"]);
}
else
{
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["bkg_blue.png"]);
}
Renderer->DrawRect(vec2(0.0f, 0.f), vec2(1.f, 1.f), vec2(0.f, 0.f), vec2(1.f, 1.f));
Renderer->PopProjectionMatrix();
glClear(GL_DEPTH_BUFFER_BIT);
Renderer->SetGLCamView();
//LiteModel->DrawVBO();
FlexModel.Draw();
}
void TAndroidApplication::InnerInit()
{
RenderMutex.lock();
CheckGlError();
glEnable(GL_BLEND);
*Console<<"Inner init go!\n";
#ifdef TARGET_ANDROID
ResourceManager->PathToResources = "";
#endif
#ifdef TARGET_WIN32
ResourceManager->PathToResources = "../../assets/";
#endif
ResourceManager->ShaderManager.AddShader("DefaultShader", "gui_transparent.vertex", "gui_transparent.fragment");
Renderer->PushShader("DefaultShader");
ResourceManager->TexList.AddTexture("bkg_red.png");
ResourceManager->TexList.AddTexture("bkg_blue.png");
CheckGlError();
Renderer->MovePhi(pi/32);
//ResourceManager->ModelManager.AddLiteModel("bt_box_yellow.lm1");
ResourceManager->TexList.AddTexture("bt_box_yellow.bmp");
ResourceManager->FlexModelManager.LoadModelFromXml("model.xml");
LoadModels();
if (Width > Height)
{
Renderer->MoveDist(30.f);
}
else
{
Renderer->MoveDist(45.f);
}
CheckGlError();
Renderer->SetPerspectiveFullScreenViewport();
*Console<<"Inner init end!\n";
RenderMutex.unlock();
}
void TAndroidApplication::InnerDeinit()
{
RenderMutex.lock();
Inited = false;
/*
if (LiteModel != NULL)
{
LiteModel->FreeModel();
delete LiteModel;
LiteModel = NULL;
}*/
RenderMutex.unlock();
}
void TAndroidApplication::InnerDraw()
{
RenderMutex.lock();
DrawAllScene();
RenderMutex.unlock();
}
void TAndroidApplication::InnerUpdate(cardinal dt)
{
}
void TAndroidApplication::InnerOnMove(vec2 shift)
{
Renderer->MoveAlpha(-pi*shift.v[0]*0.1f);
}
void TAndroidApplication::OnMouseDown(TMouseState& mouseState)
{
}
@@ -0,0 +1,67 @@
#ifndef GL_CODE_H_INCLUDED
#define GL_CODE_H_INCLUDED
#ifdef TARGET_ANDROID
//#include "android_api.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#ifdef TARGET_ANDROID
#include <GLES/gl.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#endif
#include "boost/shared_ptr.hpp"
#include "boost/thread/thread.hpp"
#include "boost/asio.hpp"
#include "boost/signal.hpp"
#include "boost/assign.hpp"
#include "boost/variant.hpp"
#include "boost/function.hpp"
#include "boost/bind.hpp"
#include "include/Engine.h"
using namespace SE;
class TAndroidApplication : public TApplication
{
protected:
void LoadModels();
public:
bool Inited;
boost::mutex RenderMutex;
//TLiteModel* LiteModel;
TFlexModel FlexModel;
TAndroidApplication();
virtual void InnerInit();
virtual void InnerDeinit();
virtual void InnerDraw();
virtual void InnerUpdate(cardinal dt);
virtual void InnerOnMove(vec2 shift);
virtual void OnMouseDown(TMouseState& mouseState);
bool IsInited() { return Inited; }
void DrawAllScene();
};
#endif
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

@@ -0,0 +1,7 @@
<?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"
>
</LinearLayout>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent">
<RelativeLayout android:id="@+id/LinearLayout01" android:layout_height="wrap_content" android:layout_width="fill_parent"><ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon" android:layout_alignParentLeft="true" android:layout_marginLeft="3dp"></ImageView>
</RelativeLayout>
<ListView android:layout_width="fill_parent" android:id="@+id/android:list" android:layout_height="wrap_content"></ListView>
<TextView android:layout_width="fill_parent" android:id="@+id/android:text_feedback" android:padding="20px" android:text="@string/feedback" android:layout_height="wrap_content"></TextView>
</LinearLayout>
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Salmon Engine Wallpaper Template</string>
<string name="description">Salmon Engine Wallpaper Template</string>
<string name="feedback">This template made by fishrungames.com</string>
<string name="p_red_background">Background color</string>
<string name="p_red_background_on">Red background</string>
<string name="p_red_background_off">Blue background</string>
<declare-styleable name="Wallpaper">
<!--
Component name of an activity that allows the user to modify the
current settings for this wallpaper.
-->
<attr name="settingsActivity" format="reference" />
<!-- Reference to a the wallpaper's thumbnail bitmap. -->
<attr name="thumbnail" format="reference" />
<!-- Name of the author of this component, e.g. Google. -->
<attr name="author" format="reference" />
<!-- Short description of the component's purpose or behavior. -->
<attr name="description" format="reference" />
</declare-styleable>
</resources>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen android:title="Main"
xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference android:summaryOn="@string/p_red_background_on"
android:key="RedBackground" android:title="@string/p_red_background"
android:summaryOff="@string/p_red_background_off" android:defaultValue="false" />
</PreferenceScreen>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<wallpaper
xmlns:android="http://schemas.android.com/apk/res/android"
android:thumbnail="@drawable/thumb"
android:description="@string/description"
android:settingsActivity="fishrungames.wallpapertemplate.Prefs"/>
@@ -0,0 +1,958 @@
package fishrungames.wallpapertemplate;
import fishrungames.wallpapertemplate.BaseConfigChooser.ComponentSizeChooser;
import fishrungames.wallpapertemplate.BaseConfigChooser.SimpleEGLConfigChooser;
import java.util.ArrayList;
import java.util.Calendar;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
import android.service.wallpaper.WallpaperService;
import android.util.Log;
import android.view.SurfaceHolder;
public class GLWallpaperService extends WallpaperService {
private static final String TAG = "GLWallpaperService";
@Override
public Engine onCreateEngine() {
return new GLEngine();
}
public class GLEngine extends Engine {
public final static int RENDERMODE_WHEN_DIRTY = 0;
public final static int RENDERMODE_CONTINUOUSLY = 1;
private GLThread mGLThread;
private EGLConfigChooser mEGLConfigChooser;
private EGLContextFactory mEGLContextFactory;
private EGLWindowSurfaceFactory mEGLWindowSurfaceFactory;
private int mDebugFlags;
public GLEngine() {
super();
}
@Override
public void onVisibilityChanged(boolean visible) {
if (visible) {
onResume();
} else {
onPause();
}
super.onVisibilityChanged(visible);
}
@Override
public void onCreate(SurfaceHolder surfaceHolder) {
super.onCreate(surfaceHolder);
// Log.d(TAG, "GLEngine.onCreate()");
}
@Override
public void onDestroy() {
super.onDestroy();
// Log.d(TAG, "GLEngine.onDestroy()");
mGLThread.requestExitAndWait();
}
@Override
public void onSurfaceChanged(SurfaceHolder holder, int format,
int width, int height) {
// Log.d(TAG, "onSurfaceChanged()");
mGLThread.onWindowResize(width, height);
super.onSurfaceChanged(holder, format, width, height);
}
@Override
public void onSurfaceCreated(SurfaceHolder holder) {
Log.d(TAG, "onSurfaceCreated()");
mGLThread.surfaceCreated(holder);
super.onSurfaceCreated(holder);
}
@Override
public void onSurfaceDestroyed(SurfaceHolder holder) {
Log.d(TAG, "onSurfaceDestroyed()");
mGLThread.surfaceDestroyed();
super.onSurfaceDestroyed(holder);
}
public void setDebugFlags(int debugFlags) {
mDebugFlags = debugFlags;
}
public int getDebugFlags() {
return mDebugFlags;
}
public void setRenderer() {
checkRenderThreadState();
if (mEGLConfigChooser == null) {
mEGLConfigChooser = new SimpleEGLConfigChooser(true);
}
if (mEGLContextFactory == null) {
//mEGLContextFactory = new DefaultContextFactory();
mEGLContextFactory = new ES20ContextFactory();
}
if (mEGLWindowSurfaceFactory == null) {
mEGLWindowSurfaceFactory = new DefaultWindowSurfaceFactory();
}
mGLThread = new GLThread(mEGLConfigChooser,
mEGLContextFactory, mEGLWindowSurfaceFactory);
mGLThread.start();
}
public void setEGLContextFactory(EGLContextFactory factory) {
checkRenderThreadState();
mEGLContextFactory = factory;
}
public void setEGLWindowSurfaceFactory(EGLWindowSurfaceFactory factory) {
checkRenderThreadState();
mEGLWindowSurfaceFactory = factory;
}
public void setEGLConfigChooser(EGLConfigChooser configChooser) {
checkRenderThreadState();
mEGLConfigChooser = configChooser;
}
public void setEGLConfigChooser(boolean needDepth) {
setEGLConfigChooser(new SimpleEGLConfigChooser(needDepth));
}
public void setEGLConfigChooser(int redSize, int greenSize,
int blueSize, int alphaSize, int depthSize, int stencilSize) {
setEGLConfigChooser(new ComponentSizeChooser(redSize, greenSize,
blueSize, alphaSize, depthSize, stencilSize));
}
public void setRenderMode(int renderMode) {
mGLThread.setRenderMode(renderMode);
}
public int getRenderMode() {
return mGLThread.getRenderMode();
}
public void requestRender() {
mGLThread.requestRender();
}
public void onPause() {
mGLThread.onPause();
}
public void onResume() {
mGLThread.onResume();
}
public void queueEvent(Runnable r) {
mGLThread.queueEvent(r);
}
private void checkRenderThreadState() {
if (mGLThread != null) {
throw new IllegalStateException(
"setRenderer has already been called for this instance.");
}
}
}
}
// ----------------------------------------------------------------------
/**
* An interface for customizing the eglCreateContext and eglDestroyContext
* calls.
*
*
* This interface must be implemented by clients wishing to call
* {@link GLWallpaperService#setEGLContextFactory(EGLContextFactory)}
*/
interface EGLContextFactory {
EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig);
void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context);
}
class DefaultContextFactory implements EGLContextFactory {
public EGLContext createContext(EGL10 egl, EGLDisplay display,
EGLConfig config) {
return egl
.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT, null);
}
public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
egl.eglDestroyContext(display, context);
}
}
class ES20ContextFactory implements EGLContextFactory {
private static int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
public EGLContext createContext(EGL10 egl, EGLDisplay display,
EGLConfig config) {
int[] attrib_list =
{ EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
return egl
.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT, attrib_list);
}
public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
egl.eglDestroyContext(display, context);
}
}
/**
* An interface for customizing the eglCreateWindowSurface and eglDestroySurface
* calls.
*
*
* This interface must be implemented by clients wishing to call
* {@link GLWallpaperService#setEGLWindowSurfaceFactory(EGLWindowSurfaceFactory)}
*/
interface EGLWindowSurfaceFactory {
EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
EGLConfig config, Object nativeWindow);
void destroySurface(EGL10 egl, EGLDisplay display, EGLSurface surface);
}
class DefaultWindowSurfaceFactory implements EGLWindowSurfaceFactory {
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
EGLConfig config, Object nativeWindow) {
// this is a bit of a hack to work around Droid init problems - if you
// don't have this, it'll get hung up on orientation changes
EGLSurface eglSurface = null;
while (eglSurface == null) {
try {
eglSurface = egl.eglCreateWindowSurface(display, config,
nativeWindow, null);
} catch (Throwable t) {
} finally {
if (eglSurface == null) {
try {
Thread.sleep(10);
} catch (InterruptedException t) {
}
}
}
}
return eglSurface;
}
public void destroySurface(EGL10 egl, EGLDisplay display, EGLSurface surface) {
egl.eglDestroySurface(display, surface);
}
}
class EglHelper {
private EGL10 mEgl;
private EGLDisplay mEglDisplay;
private EGLSurface mEglSurface;
private EGLContext mEglContext;
EGLConfig mEglConfig;
private EGLConfigChooser mEGLConfigChooser;
private EGLContextFactory mEGLContextFactory;
private EGLWindowSurfaceFactory mEGLWindowSurfaceFactory;
public EglHelper(EGLConfigChooser chooser,
EGLContextFactory contextFactory,
EGLWindowSurfaceFactory surfaceFactory) {
this.mEGLConfigChooser = chooser;
this.mEGLContextFactory = contextFactory;
this.mEGLWindowSurfaceFactory = surfaceFactory;
}
/**
* Initialize EGL for a given configuration spec.
*
* @param configSpec
*/
public void start() {
String instanceId = "";
Log.d("EglHelper" + instanceId, "start()");
if (mEgl == null) {
Log.d("EglHelper" + instanceId, "getting new EGL");
/*
* Get an EGL instance
*/
mEgl = (EGL10) EGLContext.getEGL();
} else {
Log.d("EglHelper" + instanceId, "reusing EGL");
}
if (mEglDisplay == null) {
Log.d("EglHelper" + instanceId, "getting new display");
/*
* Get to the default display.
*/
mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
} else {
Log.d("EglHelper" + instanceId, "reusing display");
}
if (mEglConfig == null) {
Log.d("EglHelper" + instanceId, "getting new config");
/*
* We can now initialize EGL for that display
*/
int[] version = new int[2];
mEgl.eglInitialize(mEglDisplay, version);
mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);
} else {
Log.d("EglHelper" + instanceId, "reusing config");
}
if (mEglContext == null) {
Log.d("EglHelper" + instanceId, "creating new context");
/*
* Create an OpenGL ES context. This must be done only once, an
* OpenGL context is a somewhat heavy object.
*/
mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay,
mEglConfig);
if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
throw new RuntimeException("createContext failed");
}
} else {
Log.d("EglHelper" + instanceId, "reusing context");
}
mEglSurface = null;
}
/*
* React to the creation of a new surface by creating and returning an
* OpenGL interface that renders to that surface.
*/
public void createSurface(SurfaceHolder holder) {
if (mEglSurface != null && mEglSurface != EGL10.EGL_NO_SURFACE) {
mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE,
EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
mEGLWindowSurfaceFactory.destroySurface(mEgl, mEglDisplay,
mEglSurface);
}
mEglSurface = mEGLWindowSurfaceFactory.createWindowSurface(mEgl,
mEglDisplay, mEglConfig, holder);
if (mEglSurface == null || mEglSurface == EGL10.EGL_NO_SURFACE) {
throw new RuntimeException("createWindowSurface failed");
}
if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
mEglContext)) {
//throw new RuntimeException("eglMakeCurrent failed.");
}
}
/**
* Display the current render surface.
*
* @return false if the context has been lost.
*/
public boolean swap() {
try {
mEgl.eglSwapBuffers(mEglDisplay, mEglSurface);
} catch (Exception e) {
return false;
}
return true;
/*
* Always check for EGL_CONTEXT_LOST, which means the context and all
* associated data were lost (For instance because the device went to
* sleep). We need to sleep until we get a new surface.
*/
}
public void destroySurface() {
if (mEglSurface != null && mEglSurface != EGL10.EGL_NO_SURFACE) {
mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE,
EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
mEGLWindowSurfaceFactory.destroySurface(mEgl, mEglDisplay,
mEglSurface);
mEglSurface = null;
}
}
public void finish() {
if (mEglContext != null) {
mEGLContextFactory.destroyContext(mEgl, mEglDisplay, mEglContext);
mEglContext = null;
}
if (mEglDisplay != null) {
mEgl.eglTerminate(mEglDisplay);
mEglDisplay = null;
}
}
}
class GLThread extends Thread {
private final static boolean LOG_THREADS = false;
public final static int DEBUG_CHECK_GL_ERROR = 1;
public final static int DEBUG_LOG_GL_CALLS = 2;
private final GLThreadManager sGLThreadManager = new GLThreadManager();
private GLThread mEglOwner;
private EGLConfigChooser mEGLConfigChooser;
private EGLContextFactory mEGLContextFactory;
private EGLWindowSurfaceFactory mEGLWindowSurfaceFactory;
public SurfaceHolder mHolder;
private boolean mSizeChanged = true;
// Once the thread is started, all accesses to the following member
// variables are protected by the sGLThreadManager monitor
public boolean mDone;
private boolean mPaused;
private boolean mHasSurface;
private boolean mWaitingForSurface;
private boolean mHaveEgl;
private int mWidth;
private int mHeight;
private int mRenderMode;
private boolean mRequestRender;
private boolean mEventsWaiting;
// End of member variables protected by the sGLThreadManager monitor.
//private GLWallpaperService.Renderer mRenderer;
private ArrayList mEventQueue = new ArrayList();
private EglHelper mEglHelper;
static long lastTimeStamp;
static boolean gameIsInited = false;
GLThread(EGLConfigChooser chooser,
EGLContextFactory contextFactory,
EGLWindowSurfaceFactory surfaceFactory) {
super();
mDone = false;
mWidth = 0;
mHeight = 0;
mRequestRender = true;
mRenderMode = GLWallpaperService.GLEngine.RENDERMODE_CONTINUOUSLY;
this.mEGLConfigChooser = chooser;
this.mEGLContextFactory = contextFactory;
this.mEGLWindowSurfaceFactory = surfaceFactory;
Calendar c = Calendar.getInstance();
lastTimeStamp = c.getTimeInMillis();
gameIsInited = true;
}
@Override
public void run() {
setName("GLThread " + getId());
if (LOG_THREADS) {
Log.i("GLThread", "starting tid=" + getId());
}
try {
guardedRun();
} catch (InterruptedException e) {
// fall thru and exit normally
} finally {
sGLThreadManager.threadExiting(this);
}
}
/*
* This private method should only be called inside a
* synchronized(sGLThreadManager) block.
*/
private void stopEglLocked() {
if (mHaveEgl) {
mHaveEgl = false;
mEglHelper.destroySurface();
sGLThreadManager.releaseEglSurface(this);
}
}
private void guardedRun() throws InterruptedException {
mEglHelper = new EglHelper(mEGLConfigChooser, mEGLContextFactory,
mEGLWindowSurfaceFactory/*, mGLWrapper*/);
try {
boolean tellRendererSurfaceCreated = true;
boolean tellRendererSurfaceChanged = true;
/*
* This is our main activity thread's loop, we go until asked to
* quit.
*/
while (!isDone()) {
/*
* Update the asynchronous state (window size)
*/
int w = 0;
int h = 0;
boolean changed = false;
boolean needStart = false;
boolean eventsWaiting = false;
synchronized (sGLThreadManager) {
while (true) {
// Manage acquiring and releasing the SurfaceView
// surface and the EGL surface.
if (mPaused) {
stopEglLocked();
}
if (!mHasSurface) {
if (!mWaitingForSurface) {
stopEglLocked();
mWaitingForSurface = true;
sGLThreadManager.notifyAll();
}
} else {
if (!mHaveEgl) {
if (sGLThreadManager.tryAcquireEglSurface(this)) {
mHaveEgl = true;
mEglHelper.start();
mRequestRender = true;
needStart = true;
}
}
}
// Check if we need to wait. If not, update any state
// that needs to be updated, copy any state that
// needs to be copied, and use "break" to exit the
// wait loop.
if (mDone) {
return;
}
if (mEventsWaiting) {
eventsWaiting = true;
mEventsWaiting = false;
break;
}
if ((!mPaused)
&& mHasSurface
&& mHaveEgl
&& (mWidth > 0)
&& (mHeight > 0)
&& (mRequestRender || (mRenderMode == GLWallpaperService.GLEngine.RENDERMODE_CONTINUOUSLY))) {
changed = mSizeChanged;
w = mWidth;
h = mHeight;
mSizeChanged = false;
mRequestRender = false;
if (mHasSurface && mWaitingForSurface) {
changed = true;
mWaitingForSurface = false;
sGLThreadManager.notifyAll();
}
break;
}
// By design, this is the only place where we wait().
if (LOG_THREADS) {
Log.i("GLThread", "waiting tid=" + getId());
}
sGLThreadManager.wait();
}
} // end of synchronized(sGLThreadManager)
/*
* Handle queued events
*/
if (eventsWaiting) {
Runnable r;
while ((r = getEvent()) != null) {
r.run();
if (isDone()) {
return;
}
}
// Go back and see if we need to wait to render.
continue;
}
if (needStart) {
tellRendererSurfaceCreated = true;
changed = true;
}
if (changed) {
mEglHelper.createSurface(mHolder);
tellRendererSurfaceChanged = true;
}
if (tellRendererSurfaceCreated) {
tellRendererSurfaceCreated = false;
}
if (tellRendererSurfaceChanged) {
//Xperimental -- VLAD KHOREV
JniWrapper.Init(w, h);
tellRendererSurfaceChanged = false;
}
if ((w > 0) && (h > 0)) {
/* draw a frame here */
if (gameIsInited)
{
Calendar c = Calendar.getInstance();
long currentTimeStamp = c.getTimeInMillis();
JniWrapper.Update(currentTimeStamp - lastTimeStamp);
lastTimeStamp = currentTimeStamp;
}
/*
* Once we're done with GL, we need to call swapBuffers() to
* instruct the system to display the rendered frame
*/
mEglHelper.swap();
}
}
} finally {
/*
* clean-up everything...
*/
synchronized (sGLThreadManager) {
stopEglLocked();
mEglHelper.finish();
}
}
}
private boolean isDone() {
synchronized (sGLThreadManager) {
return mDone;
}
}
public void setRenderMode(int renderMode) {
if (!((GLWallpaperService.GLEngine.RENDERMODE_WHEN_DIRTY <= renderMode) && (renderMode <= GLWallpaperService.GLEngine.RENDERMODE_CONTINUOUSLY))) {
throw new IllegalArgumentException("renderMode");
}
synchronized (sGLThreadManager) {
mRenderMode = renderMode;
if (renderMode == GLWallpaperService.GLEngine.RENDERMODE_CONTINUOUSLY) {
sGLThreadManager.notifyAll();
}
}
}
public int getRenderMode() {
synchronized (sGLThreadManager) {
return mRenderMode;
}
}
public void requestRender() {
synchronized (sGLThreadManager) {
mRequestRender = true;
sGLThreadManager.notifyAll();
}
}
public void surfaceCreated(SurfaceHolder holder) {
mHolder = holder;
synchronized (sGLThreadManager) {
if (LOG_THREADS) {
Log.i("GLThread", "surfaceCreated tid=" + getId());
}
mHasSurface = true;
sGLThreadManager.notifyAll();
}
}
public void surfaceDestroyed() {
synchronized (sGLThreadManager) {
if (LOG_THREADS) {
Log.i("GLThread", "surfaceDestroyed tid=" + getId());
}
mHasSurface = false;
sGLThreadManager.notifyAll();
while (!mWaitingForSurface && isAlive() && !mDone) {
try {
sGLThreadManager.wait();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
}
public void onPause() {
synchronized (sGLThreadManager) {
mPaused = true;
sGLThreadManager.notifyAll();
}
}
public void onResume() {
synchronized (sGLThreadManager) {
mPaused = false;
mRequestRender = true;
sGLThreadManager.notifyAll();
}
}
public void onWindowResize(int w, int h) {
synchronized (sGLThreadManager) {
mWidth = w;
mHeight = h;
mSizeChanged = true;
sGLThreadManager.notifyAll();
}
}
public void requestExitAndWait() {
// don't call this from GLThread thread or it is a guaranteed
// deadlock!
synchronized (sGLThreadManager) {
mDone = true;
sGLThreadManager.notifyAll();
}
try {
join();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
/**
* Queue an "event" to be run on the GL rendering thread.
*
* @param r
* the runnable to be run on the GL rendering thread.
*/
public void queueEvent(Runnable r) {
synchronized (this) {
mEventQueue.add(r);
synchronized (sGLThreadManager) {
mEventsWaiting = true;
sGLThreadManager.notifyAll();
}
}
}
private Runnable getEvent() {
synchronized (this) {
if (mEventQueue.size() > 0) {
return (Runnable) mEventQueue.remove(0);
}
}
return null;
}
private class GLThreadManager {
public synchronized void threadExiting(GLThread thread) {
if (LOG_THREADS) {
Log.i("GLThread", "exiting tid=" + thread.getId());
}
thread.mDone = true;
if (mEglOwner == thread) {
mEglOwner = null;
}
notifyAll();
}
/*
* Tries once to acquire the right to use an EGL surface. Does not
* block.
*
* @return true if the right to use an EGL surface was acquired.
*/
public synchronized boolean tryAcquireEglSurface(GLThread thread) {
if (mEglOwner == thread || mEglOwner == null) {
mEglOwner = thread;
notifyAll();
return true;
}
return false;
}
public synchronized void releaseEglSurface(GLThread thread) {
if (mEglOwner == thread) {
mEglOwner = null;
}
notifyAll();
}
}
}
interface EGLConfigChooser {
EGLConfig chooseConfig(EGL10 egl, EGLDisplay display);
}
abstract class BaseConfigChooser implements EGLConfigChooser {
public BaseConfigChooser(int[] configSpec) {
mConfigSpec = configSpec;
}
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
int[] num_config = new int[1];
egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config);
int numConfigs = num_config[0];
if (numConfigs <= 0) {
throw new IllegalArgumentException("No configs match configSpec");
}
EGLConfig[] configs = new EGLConfig[numConfigs];
egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs,
num_config);
EGLConfig config = chooseConfig(egl, display, configs);
if (config == null) {
throw new IllegalArgumentException("No config chosen");
}
return config;
}
abstract EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
EGLConfig[] configs);
protected int[] mConfigSpec;
public static class ComponentSizeChooser extends BaseConfigChooser {
public ComponentSizeChooser(int redSize, int greenSize, int blueSize,
int alphaSize, int depthSize, int stencilSize) {
super(new int[] { EGL10.EGL_RED_SIZE, redSize,
EGL10.EGL_GREEN_SIZE, greenSize, EGL10.EGL_BLUE_SIZE,
blueSize, EGL10.EGL_ALPHA_SIZE, alphaSize,
EGL10.EGL_DEPTH_SIZE, depthSize, EGL10.EGL_STENCIL_SIZE,
stencilSize, EGL10.EGL_NONE });
mValue = new int[1];
mRedSize = redSize;
mGreenSize = greenSize;
mBlueSize = blueSize;
mAlphaSize = alphaSize;
mDepthSize = depthSize;
mStencilSize = stencilSize;
}
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
EGLConfig[] configs) {
EGLConfig closestConfig = null;
int closestDistance = 1000;
for (EGLConfig config : configs) {
int d = findConfigAttrib(egl, display, config,
EGL10.EGL_DEPTH_SIZE, 0);
int s = findConfigAttrib(egl, display, config,
EGL10.EGL_STENCIL_SIZE, 0);
if (d >= mDepthSize && s >= mStencilSize) {
int r = findConfigAttrib(egl, display, config,
EGL10.EGL_RED_SIZE, 0);
int g = findConfigAttrib(egl, display, config,
EGL10.EGL_GREEN_SIZE, 0);
int b = findConfigAttrib(egl, display, config,
EGL10.EGL_BLUE_SIZE, 0);
int a = findConfigAttrib(egl, display, config,
EGL10.EGL_ALPHA_SIZE, 0);
int distance = Math.abs(r - mRedSize)
+ Math.abs(g - mGreenSize)
+ Math.abs(b - mBlueSize)
+ Math.abs(a - mAlphaSize);
if (distance < closestDistance) {
closestDistance = distance;
closestConfig = config;
}
}
}
return closestConfig;
}
private int findConfigAttrib(EGL10 egl, EGLDisplay display,
EGLConfig config, int attribute, int defaultValue) {
if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
return mValue[0];
}
return defaultValue;
}
private int[] mValue;
// Subclasses can adjust these values:
protected int mRedSize;
protected int mGreenSize;
protected int mBlueSize;
protected int mAlphaSize;
protected int mDepthSize;
protected int mStencilSize;
}
/**
* This class will choose a supported surface as close to RGB565 as
* possible, with or without a depth buffer.
*
*/
public static class SimpleEGLConfigChooser extends ComponentSizeChooser {
public SimpleEGLConfigChooser(boolean withDepthBuffer) {
super(4, 4, 4, 0, withDepthBuffer ? 16 : 0, 0);
// Adjust target values. This way we'll accept a 4444 or
// 555 buffer if there's no 565 buffer available.
mRedSize = 5;
mGreenSize = 6;
mBlueSize = 5;
}
}
}
@@ -0,0 +1,29 @@
package fishrungames.wallpapertemplate;
public class JniWrapper
{
static
{
System.loadLibrary("SalmonWallpaper");
}
public static void LoadLibrary()
{
//To force loading libraries
}
public static native void SetRedBkgPref(boolean r);
public static native void Init(int width, int height);
public static native void Update(long dt);
public static native void OnTapMove(float x, float y);
public static native void SetOffset(float offsetX, float offsetY);
public static native void SetOrientation(int isLandscape);
}
@@ -0,0 +1,227 @@
package fishrungames.wallpapertemplate;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.ConnectivityManager;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
//import com.seb.SLWP.SLWP.GlEngine.DownloadTask;
import fishrungames.engine.FileWrapper;
public class MainWallpaperService extends GLWallpaperService implements
OnSharedPreferenceChangeListener {
/*
* (non-Javadoc)
*
* @see android.app.Service#onLowMemory()
*/
static
{
FileWrapper.LoadSalmonEngineLibrary();
JniWrapper.LoadLibrary();
}
public static final long SLEEPTIME = 1000 * 60 * 30; // 30 minutes
private GlEngine mGle;
public static Context mContext;
public static boolean ShowClouds;
public static boolean TouchRot;
public static int Bg;
public static boolean Usebg;
public static int Tex;
static long Synctime;
public boolean Slidedir;
public boolean Slideplanet;
public boolean Syncrot;
public static boolean Randomtex = true;
public static boolean visible = false;
public static boolean useCropper = true;
public static int Cropaspect;
public static boolean loading = false;
public static final Handler mHandler = new Handler();
public static final int RNDMAP = -1;
public static boolean destroyed;
public static String bgfile;
public ConnectivityManager cm;
public boolean needresume;
public boolean fstart;
public static String[] randlist;
public int curtexidx = -99;
static final String ACTION_FOREGROUND = "fishrungames.wallpapertemplate.FOREGROUND";
static final String ACTION_BACKGROUND = "fishrungames.wallpapertemplate.BACKGROUND";
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
FileWrapper.SetActivityInstance(this);
FileWrapper.SetupEnviroment();
String apkFilePath = null;
ApplicationInfo appInfo = null;
PackageManager packMgmr = this.getPackageManager();
try {
appInfo = packMgmr.getApplicationInfo("fishrungames.wallpapertemplate", 0);
} catch (NameNotFoundException e) {
e.printStackTrace();
throw new RuntimeException("Unable to locate assets, aborting...");
}
apkFilePath = appInfo.sourceDir;
FileWrapper.SetupApkFilePath(apkFilePath);
Init();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// handleCommand(intent);
// We want this service to continue running until it is explicitly
// stopped, so return sticky.
return START_STICKY;
}
private void Init() {
try {
mContext = this;
cm = (ConnectivityManager) mContext
.getSystemService(Context.CONNECTIVITY_SERVICE);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
if (key.compareToIgnoreCase("RedBackground") == 0) {
JniWrapper.SetRedBkgPref(sharedPreferences.getBoolean("RedBackground", false));
}
}
@Override
public Engine onCreateEngine() {
if (mGle != null) {
mGle = null;
}
try {
mGle = new GlEngine();
} catch (Exception e) {
return null;
}
return mGle;
}
class GlEngine extends GLEngine {
public Handler mHandler = new Handler();
long NOW;
@Override
public void onCreate(SurfaceHolder surfaceHolder) {
super.onCreate(surfaceHolder);
try {
this.setTouchEventsEnabled(true);
fstart = true;
setRenderer();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onTouchEvent(MotionEvent e) {
return;
}
@Override
public void onOffsetsChanged(float xOffset, float yOffset,
float xOffsetStep, float yOffsetStep, int xPixelOffset,
int yPixelOffset) {
super.onOffsetsChanged(xOffset, yOffset, xOffsetStep, yOffsetStep,
xPixelOffset, yPixelOffset);
JniWrapper.SetOffset(xPixelOffset*xOffsetStep, yPixelOffset*yOffsetStep);
}
@Override
public void onVisibilityChanged(boolean visible) {
// TODO Auto-generated method stub
super.onVisibilityChanged(visible);
MainWallpaperService.visible = visible;
if (visible) {
} else {
}
}
@Override
public void onPause() {
super.onPause();
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onSurfaceChanged(SurfaceHolder holder, int format,
int width, int height) {
// TODO Auto-generated method stub
super.onSurfaceChanged(holder, format, width, height);
fstart = true;
}
}
}
@@ -0,0 +1,63 @@
package fishrungames.wallpapertemplate;
import fishrungames.wallpapertemplate.JniWrapper;
import fishrungames.wallpapertemplate.R;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.Preference.OnPreferenceChangeListener;
public class Prefs extends PreferenceActivity implements
OnPreferenceChangeListener {
private CheckBoxPreference redBkgPref;
public static Uri currImageURI;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.prefliste);
addPreferencesFromResource(R.xml.preferences);
redBkgPref = (CheckBoxPreference)this.getPreferenceManager().findPreference("RedBackground");
if (redBkgPref.getKey().compareToIgnoreCase("RedBackground") == 0) {
if (!redBkgPref.isChecked())
{
JniWrapper.SetRedBkgPref(false);
}
else
{
JniWrapper.SetRedBkgPref(true);
}
}
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
return true;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
}
}
@@ -0,0 +1,34 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C++ Express 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Template", "Template\Template.vcxproj", "{0080A3E1-DFBF-4557-B198-E6D5D7724393}"
ProjectSection(ProjectDependencies) = postProject
{48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20} = {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Salmon Engine", "..\..\..\Engine\Salmon Engine\Salmon Engine.vcxproj", "{48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug_nosound|Win32 = Debug_nosound|Win32
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug_nosound|Win32.ActiveCfg = Debug|Win32
{0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug_nosound|Win32.Build.0 = Debug|Win32
{0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug|Win32.ActiveCfg = Debug|Win32
{0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug|Win32.Build.0 = Debug|Win32
{0080A3E1-DFBF-4557-B198-E6D5D7724393}.Release|Win32.ActiveCfg = Release|Win32
{0080A3E1-DFBF-4557-B198-E6D5D7724393}.Release|Win32.Build.0 = Release|Win32
{48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug_nosound|Win32.ActiveCfg = Debug_nosound|Win32
{48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug_nosound|Win32.Build.0 = Debug_nosound|Win32
{48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug|Win32.ActiveCfg = Debug|Win32
{48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug|Win32.Build.0 = Debug|Win32
{48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Release|Win32.ActiveCfg = Release|Win32
{48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{0080A3E1-DFBF-4557-B198-E6D5D7724393}</ProjectGuid>
<RootNamespace>Template</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)include</IncludePath>
<LibraryPath>$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)include</IncludePath>
<LibraryPath>$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510;..\..\jni</AdditionalIncludeDirectories>
<PreprocessorDefinitions>TARGET_WIN32;TARGET_SALMON;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;opengl32.lib;glu32.lib;Salmon Engine.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;zlib.lib;libpng15.lib;sqplusD.lib;squirrelD.lib;sqdbglibD.lib;sqstdlibD.lib;dsound.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(LibsPath)\boost_1_52_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\libogg-1.3.0\win32\VS2010\Win32\$(Configuration);$(LibsPath)\libvorbis-1.3.2\win32\VS2010\Win32\$(Configuration);$(LibsPath)\sqplus\lib;$(LibsPath)\DirectXsdk\Lib\x86;$(LibsPath)\lpng1510\projects\vstudio\Debug Library</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510;..\..\jni</AdditionalIncludeDirectories>
<PreprocessorDefinitions>TARGET_WIN32;TARGET_SALMON;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;opengl32.lib;glu32.lib;Salmon Engine.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;zlib.lib;libpng15.lib;sqplus.lib;squirrel.lib;sqdbglib.lib;sqstdlib.lib;dsound.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(LibsPath)\boost_1_52_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\libogg-1.3.0\win32\VS2010\Win32\$(Configuration);$(LibsPath)\libvorbis-1.3.2\win32\VS2010\Win32\$(Configuration);$(LibsPath)\sqplus\lib;$(LibsPath)\DirectXsdk\Lib\x86;$(LibsPath)\lpng1510\projects\vstudio\Release Library</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\jni\main_code.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\jni\main_code.h" />
<ClInclude Include="main.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,15 @@
#include "main.h"
int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst,
LPSTR lpszCmdLine, int nCmdShow)
{
//Create application
TAndroidApplication Application;
Application.Width = 800;
Application.Height = 480;
//Start application
return MainLoop(Application);
}
@@ -0,0 +1,8 @@
#pragma once
/* Path to the engine */
#include "include/Engine.h"
#include "main_code.h"
using namespace SE;