First blood
8
.classpath
Normal file
@ -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>
|
33
.project
Normal file
@ -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>
|
26
AndroidManifest.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="fishrungames.mountainwallpaper" android:versionCode="1" android:versionName="1.0.0">
|
||||
<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="MountainWallpaperService" 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>
|
BIN
assets/console_bkg.bmp
Normal file
After Width: | Height: | Size: 102 B |
BIN
assets/file.bmp
Normal file
After Width: | Height: | Size: 768 KiB |
BIN
assets/final_cloud.png
Normal file
After Width: | Height: | Size: 89 KiB |
10
assets/gui_transparent.fragment
Normal file
@ -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);
|
||||
}
|
11
assets/gui_transparent.vertex
Normal file
@ -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;
|
||||
}
|
13
assets/gui_transparent_clip.fragment
Normal file
@ -0,0 +1,13 @@
|
||||
precision lowp float;
|
||||
|
||||
uniform sampler2D Texture;
|
||||
varying vec2 texCoord;
|
||||
varying vec3 vertexPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texColor = texture2D(Texture,texCoord).rgba;
|
||||
|
||||
gl_FragColor = vec4(texColor.rgb, texColor.a); //day
|
||||
|
||||
}
|
13
assets/gui_transparent_clip.vertex
Normal file
@ -0,0 +1,13 @@
|
||||
attribute vec3 vPosition;
|
||||
attribute vec2 vTexCoord;
|
||||
varying vec2 texCoord;
|
||||
varying vec3 vertexPos;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
|
||||
void main()
|
||||
{
|
||||
//480x320
|
||||
gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0);
|
||||
vertexPos = vPosition.xyz;
|
||||
texCoord = vTexCoord;
|
||||
}
|
BIN
assets/ice1.lm1
Normal file
BIN
assets/ice1.png
Normal file
After Width: | Height: | Size: 131 KiB |
BIN
assets/ice2.lm1
Normal file
BIN
assets/ice2.png
Normal file
After Width: | Height: | Size: 147 KiB |
BIN
assets/ice3.lm1
Normal file
BIN
assets/ice3.png
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
assets/ice4.lm1
Normal file
BIN
assets/ice5.lm1
Normal file
BIN
assets/ice6.lm1
Normal file
29
assets/ices.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<Ices>
|
||||
|
||||
<Ice><ModelName>ice1.lm1</ModelName><PosX>0.0</PosX><PosZ>13.0</PosZ><Angle>110</Angle><Scale>2.0</Scale></Ice>
|
||||
<Ice><ModelName>ice2.lm1</ModelName><PosX>-3.0</PosX><PosZ>14.0</PosZ><Angle>70</Angle></Ice>
|
||||
<Ice><ModelName>ice3.lm1</ModelName><PosX>-4.0</PosX><PosZ>15.0</PosZ><Angle>160</Angle><Scale>2.0</Scale></Ice>
|
||||
<Ice><ModelName>ice6.lm1</ModelName><PosX>7.0</PosX><PosZ>13.5</PosZ><Angle>240</Angle></Ice>
|
||||
<Ice><ModelName>ice4.lm1</ModelName><PosX>4.0</PosX><PosZ>15.0</PosZ><Scale>1.4</Scale></Ice>
|
||||
<Ice><ModelName>ice5.lm1</ModelName><PosX>-6.0</PosX><PosZ>14.0</PosZ><Angle>60</Angle></Ice>
|
||||
<Ice><ModelName>ice6.lm1</ModelName><PosX>-1.0</PosX><PosZ>14.0</PosZ></Ice>
|
||||
<Ice><ModelName>ice1.lm1</ModelName><PosX>5.0</PosX><PosZ>13.0</PosZ><Scale>1.3</Scale></Ice>
|
||||
<Ice><ModelName>ice3.lm1</ModelName><PosX>-5.0</PosX><PosZ>15.0</PosZ><Angle>30</Angle></Ice>
|
||||
|
||||
|
||||
<Ice><ModelName>ice6.lm1</ModelName><PosX>9.0</PosX><PosZ>12.0</PosZ></Ice>
|
||||
<Ice><ModelName>ice4.lm1</ModelName><PosX>11.0</PosX><PosZ>11.0</PosZ><Angle>130</Angle><Scale>2.1</Scale></Ice>
|
||||
|
||||
|
||||
<Ice><ModelName>ice4.lm1</ModelName><PosX>13.0</PosX><PosZ>10.0</PosZ><Angle>240</Angle><Scale>1.5</Scale></Ice>
|
||||
|
||||
<Ice><ModelName>ice1.lm1</ModelName><PosX>14.0</PosX><PosZ>6.0</PosZ></Ice>
|
||||
<Ice><ModelName>ice2.lm1</ModelName><PosX>16.0</PosX><PosZ>4.5</PosZ><Scale>1.8</Scale></Ice>
|
||||
<Ice><ModelName>ice3.lm1</ModelName><PosX>18.0</PosX><PosZ>2.0</PosZ><Angle>340</Angle></Ice>
|
||||
|
||||
<Ice><ModelName>ice4.lm1</ModelName><PosX>17.0</PosX><PosZ>2.0</PosZ><Scale>2.0</Scale></Ice>
|
||||
<Ice><ModelName>ice2.lm1</ModelName><PosX>18.0</PosX><PosZ>-1.5</PosZ><Angle>60</Angle><Scale>1.5</Scale></Ice>
|
||||
<Ice><ModelName>ice1.lm1</ModelName><PosX>15.0</PosX><PosZ>-5.5</PosZ><Angle>130</Angle><Scale>2.0</Scale></Ice>
|
||||
<Ice><ModelName>ice5.lm1</ModelName><PosX>12.0</PosX><PosZ>-8.0</PosZ><Angle>160</Angle></Ice>
|
||||
|
||||
</Ices>
|
BIN
assets/mountain.lm1
Normal file
BIN
assets/mountain.png
Normal file
After Width: | Height: | Size: 1.2 MiB |
BIN
assets/sky.png
Normal file
After Width: | Height: | Size: 385 KiB |
BIN
assets/sky_night.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
assets/snow.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
56
assets/test_norm.fragment
Normal file
@ -0,0 +1,56 @@
|
||||
precision lowp float;
|
||||
|
||||
uniform sampler2D Texture;
|
||||
uniform sampler2D NormalMap;
|
||||
uniform vec3 CamPos;
|
||||
uniform float WaterScale;
|
||||
varying vec2 texCoord;
|
||||
uniform float Time;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
vec2 localTexCoord = texCoord;
|
||||
|
||||
vec3 camVec = CamPos.xyz;
|
||||
float len = length(camVec);
|
||||
float squeeze = 0.5*(len / CamPos.y );
|
||||
|
||||
squeeze = min(squeeze, 4.0);
|
||||
|
||||
//if (squeeze>15.0) squeeze = 15.0;
|
||||
|
||||
vec3 v3 = vec3(0.0,1.0,0.0);
|
||||
vec3 v2 = vec3(1.0,0.0,0.0);
|
||||
vec3 v1 = vec3(0.0,0.0,1.0);
|
||||
|
||||
mat3 rot;
|
||||
|
||||
rot[0] = v1;
|
||||
rot[1] = v2;
|
||||
rot[2] = v3;
|
||||
|
||||
float sinx = 0.025*sin(Time+localTexCoord.x*2.0);
|
||||
|
||||
vec3 NVec1 = texture2D(NormalMap, vec2(-Time*0.04 + localTexCoord.x*WaterScale + sinx, -Time*0.04 + squeeze*localTexCoord.y*WaterScale - sinx)).rgb;
|
||||
vec3 NVec2 = texture2D(NormalMap, vec2( Time*0.04 + squeeze*localTexCoord.y*WaterScale - sinx, -Time*0.04 + (1.0-localTexCoord.x)*WaterScale + sinx)).rgb;
|
||||
|
||||
NVec1 = (NVec1 -0.5) * 2.0;
|
||||
NVec2 = (NVec2 -0.5) * 2.0;
|
||||
|
||||
|
||||
vec3 NVec = 0.5*NVec1 + 0.5*NVec2;
|
||||
NVec = rot * NVec;
|
||||
|
||||
float d = 1.0/(len+0.05);
|
||||
|
||||
d = min(d, 2.0);
|
||||
|
||||
localTexCoord.x = max(min(localTexCoord.x + d * NVec.x, 1.0), 0.0);
|
||||
localTexCoord.y = max(min(localTexCoord.y - d * NVec.z, 1.0), 0.0);
|
||||
|
||||
vec4 specular = vec4(0.8, 0.8, 0.8, 1.0)* (1.0-pow(max(dot(vec3(0.0,1.0,0.0), normalize(NVec)),0.0),2.0));
|
||||
|
||||
|
||||
gl_FragColor = texture2D(Texture, localTexCoord).rgba + specular + vec4(0.0, 0.05, 0.1, 0.0);
|
||||
}
|
12
assets/test_norm.vertex
Normal file
@ -0,0 +1,12 @@
|
||||
attribute vec3 vPosition;
|
||||
attribute vec3 Normal;
|
||||
attribute vec2 vTexCoord;
|
||||
varying vec2 texCoord;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
|
||||
void main()
|
||||
{
|
||||
//480x320
|
||||
gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0);
|
||||
texCoord = vTexCoord;
|
||||
}
|
34
assets/test_parallax.fragment
Normal file
@ -0,0 +1,34 @@
|
||||
precision lowp float;
|
||||
|
||||
uniform sampler2D Texture;
|
||||
uniform sampler2D NormalMap;
|
||||
uniform vec3 LightDirection;
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 camVec;
|
||||
varying vec3 normVec;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
vec3 cVec = normalize(camVec);
|
||||
|
||||
float parallax = 0.035;
|
||||
|
||||
//double refinement
|
||||
float height = texture2D(NormalMap, texCoord.xy).a;
|
||||
float offset = parallax * (2.0 * height - 1.0);
|
||||
vec2 parallaxTexCoord = texCoord.xy + offset * cVec.xy;
|
||||
height += texture2D(NormalMap, parallaxTexCoord).a;
|
||||
|
||||
offset = parallax * (height - 1.0);
|
||||
|
||||
parallaxTexCoord = texCoord.xy + offset * cVec.xy;
|
||||
|
||||
vec3 nvec = normalize(normVec);
|
||||
|
||||
|
||||
float cosf = max(0.0, dot(nvec, -LightDirection));
|
||||
|
||||
gl_FragColor = vec4((texture2D(Texture, parallaxTexCoord).rgb * (cosf * 0.75 + 0.25)), 1.0);
|
||||
}
|
30
assets/test_parallax.vertex
Normal file
@ -0,0 +1,30 @@
|
||||
attribute vec3 vPosition;
|
||||
attribute vec3 Normal;
|
||||
attribute vec3 Tangent;
|
||||
attribute vec3 Binormal;
|
||||
attribute vec2 vTexCoord;
|
||||
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform vec3 CamPos;
|
||||
|
||||
varying vec2 texCoord;
|
||||
varying vec3 camVec;
|
||||
varying vec3 normVec;
|
||||
|
||||
void main()
|
||||
{
|
||||
//480x320
|
||||
gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0);
|
||||
texCoord = vTexCoord;
|
||||
|
||||
vec3 cVec = (CamPos - vPosition.xyz);
|
||||
|
||||
mat3 rot;
|
||||
rot[0] = Tangent;
|
||||
rot[1] = Binormal;
|
||||
rot[2] = Normal;
|
||||
|
||||
camVec = cVec * rot;
|
||||
|
||||
normVec = Normal;
|
||||
}
|
26
assets/test_simplelight.fragment
Normal file
@ -0,0 +1,26 @@
|
||||
precision lowp float;
|
||||
|
||||
uniform sampler2D Texture;
|
||||
uniform sampler2D NormalMap;
|
||||
uniform vec3 LightDirection;
|
||||
uniform float TimeOfDayCoef1;
|
||||
uniform float TimeOfDayCoef2;
|
||||
uniform vec3 TimeOfDayColor;
|
||||
varying vec2 texCoord;
|
||||
|
||||
varying vec3 camVec;
|
||||
varying vec3 normVec;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
vec3 nvec = normalize(normVec);
|
||||
|
||||
float cosf = max(0.0, dot(nvec, -LightDirection));
|
||||
|
||||
//gl_FragColor = vec4((texture2D(Texture, texCoord).rgb * (cosf * 0.75 + 0.25)), 1.0); //day
|
||||
//gl_FragColor = vec4((texture2D(Texture, texCoord).rgb * (cosf * 0.5 + 0.25)), 1.0); //twilight
|
||||
//gl_FragColor = vec4(((texture2D(Texture, texCoord).rgb + vec3(0.0, 0.1, 0.2)) * (0.4)), 1.0);
|
||||
|
||||
gl_FragColor = vec4(((texture2D(Texture, texCoord).rgb + TimeOfDayColor) * (cosf * TimeOfDayCoef1 + TimeOfDayCoef2)), 1.0);
|
||||
}
|
30
assets/test_simplelight.vertex
Normal file
@ -0,0 +1,30 @@
|
||||
attribute vec3 vPosition;
|
||||
attribute vec3 Normal;
|
||||
attribute vec3 Tangent;
|
||||
attribute vec3 Binormal;
|
||||
attribute vec2 vTexCoord;
|
||||
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform vec3 CamPos;
|
||||
|
||||
varying vec2 texCoord;
|
||||
varying vec3 camVec;
|
||||
varying vec3 normVec;
|
||||
|
||||
void main()
|
||||
{
|
||||
//480x320
|
||||
gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0);
|
||||
texCoord = vTexCoord;
|
||||
|
||||
vec3 cVec = (CamPos - vPosition.xyz);
|
||||
|
||||
mat3 rot;
|
||||
rot[0] = Tangent;
|
||||
rot[1] = Binormal;
|
||||
rot[2] = Normal;
|
||||
|
||||
camVec = cVec * rot;
|
||||
|
||||
normVec = Normal;
|
||||
}
|
BIN
assets/water_nmap.png
Normal file
After Width: | Height: | Size: 126 KiB |
77
jni/Android.mk
Normal file
@ -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_52_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 -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)
|
3
jni/Application.mk
Normal file
@ -0,0 +1,3 @@
|
||||
APP_STL := gnustl_shared
|
||||
APP_CPPFLAGS += -fexceptions
|
||||
APP_CPPFLAGS += -frtti
|
49
jni/android_api.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
#include "android_api.h"
|
||||
|
||||
#include "main_code.h"
|
||||
#include "boost\thread.hpp"
|
||||
|
||||
TAndroidApplication* Application = NULL;
|
||||
|
||||
|
||||
float lastOffsetX = 0.5f;
|
||||
|
||||
const float CONST_ANGLE_SHIFT = 45.f;
|
||||
|
||||
int TimeOfDayPref = 0;
|
||||
bool SnowPref = false;
|
||||
|
||||
bool OffsetChanged = false;
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_mountainwallpaper_JniWrapper_SetTimeOfDayPref(JNIEnv * env, jobject obj, jint timeofday)
|
||||
{
|
||||
TimeOfDayPref = timeofday;
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_fishrungames_mountainwallpaper_JniWrapper_SetSnowPref(JNIEnv * env, jobject obj, jboolean snow)
|
||||
{
|
||||
SnowPref = snow;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_mountainwallpaper_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height)
|
||||
{
|
||||
|
||||
Application = JniInitApp<TAndroidApplication>(width, height, 800.f, 480.f);
|
||||
|
||||
boost::get<TPanoramicCamera>(Renderer->Camera).SetAlpha((lastOffsetX) * pi / 180.f);
|
||||
Application->SkyTexShift = lastOffsetX*0.01f;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_mountainwallpaper_JniWrapper_SetOffset(JNIEnv * env, jobject obj, jfloat offsetX, jfloat offsetY)
|
||||
{
|
||||
|
||||
if (Renderer != NULL)
|
||||
{
|
||||
OffsetChanged = true;
|
||||
Application->SkyTexShift = offsetX*0.01f;
|
||||
lastOffsetX = offsetX;
|
||||
boost::get<TPanoramicCamera>(Renderer->Camera).SetAlpha((lastOffsetX) * pi / 180.f);
|
||||
}
|
||||
}
|
30
jni/android_api.h
Normal file
@ -0,0 +1,30 @@
|
||||
#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"
|
||||
|
||||
using namespace SE;
|
||||
|
||||
extern "C" {
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_mountainwallpaper_JniWrapper_SetTimeOfDayPref(JNIEnv * env, jobject obj, jint timeofday);
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_mountainwallpaper_JniWrapper_SetSnowPref(JNIEnv * env, jobject obj, jboolean snow);
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_mountainwallpaper_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height);
|
||||
|
||||
JNIEXPORT void JNICALL Java_fishrungames_mountainwallpaper_JniWrapper_SetOffset(JNIEnv * env, jobject obj, jfloat offsetX, jfloat offsetY);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
550
jni/main_code.cpp
Normal file
@ -0,0 +1,550 @@
|
||||
#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"
|
||||
|
||||
bool makeShot = true;
|
||||
|
||||
|
||||
extern int TimeOfDayPref;
|
||||
extern bool SnowPref;
|
||||
|
||||
extern float lastOffsetX;
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
int TimeOfDayPref = 0;
|
||||
bool SnowPref = false;
|
||||
|
||||
#else
|
||||
extern int TimeOfDayPref;
|
||||
extern bool SnowPref;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
boost::mutex m2;
|
||||
|
||||
|
||||
class LoadingQueueVisitor : public boost::static_visitor<void>
|
||||
{
|
||||
public:
|
||||
void operator()(boost::function<cardinal()> f) const
|
||||
{
|
||||
f();
|
||||
}
|
||||
|
||||
void operator()(boost::function<bool()> f) const
|
||||
{
|
||||
f();
|
||||
}
|
||||
|
||||
void operator()(boost::function<void()> f) const
|
||||
{
|
||||
f();
|
||||
}
|
||||
};
|
||||
|
||||
TAndroidApplication::TAndroidApplication()
|
||||
: TApplication()
|
||||
, Inited(false)
|
||||
, Loaded(false)
|
||||
, LiteModel(NULL)
|
||||
, WaterTimer(0)
|
||||
, SnowTimer(0)
|
||||
, CloudTimer(0)
|
||||
, SkyTexShift(0)
|
||||
, WaveDir(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TAndroidApplication::Serialize(boost::property_tree::ptree& propertyTree)
|
||||
{
|
||||
BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree.get_child("Ices"))
|
||||
{
|
||||
|
||||
std::string modelName = v.second.get<std::string>("ModelName");
|
||||
float posx = v.second.get<float>("PosX");
|
||||
float posz = v.second.get<float>("PosZ");
|
||||
|
||||
float angle = v.second.get<float>("Angle", 0.f);
|
||||
float scale = v.second.get<float>("Scale", 1.f);
|
||||
|
||||
mat3 m(vec4(0, cos(angle*pi/360.f), 0, sin(angle*pi/360.f)));
|
||||
|
||||
IceModel.push_back(TLiteModel());
|
||||
IceModel[IceModel.size()-1].LoadModel(modelName);
|
||||
IceModel[IceModel.size()-1].RotateModel(m);
|
||||
IceModel[IceModel.size()-1].ScaleModel(scale);
|
||||
IceModel[IceModel.size()-1].MoveModel(vec3(posx, 0, posz));
|
||||
|
||||
|
||||
IceModel[IceModel.size()-1].UpdateVBO();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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("mountain.lm1");
|
||||
LiteModel->ScaleModel(0.5f);
|
||||
LiteModel->RotateModel(m);
|
||||
LiteModel->MoveModel(vec3(0, 0, 0));
|
||||
LiteModel->UpdateVBO();
|
||||
|
||||
std::shared_ptr<boost::property_tree::ptree> p = FileToPropertyTree("ices.xml");
|
||||
|
||||
Serialize(*p);
|
||||
|
||||
}
|
||||
|
||||
void TAndroidApplication::AddFrameBuffers()
|
||||
{
|
||||
ResourceManager->FrameManager.AddFrameRenderBuffer("WaterFrame", 256, 256);
|
||||
ResourceManager->FrameManager.AddFrameRenderBuffer("ScreenshotFrame", 512, 512);
|
||||
|
||||
}
|
||||
|
||||
void TAndroidApplication::DrawSceneWithoutWater(bool inv)
|
||||
{
|
||||
|
||||
|
||||
Renderer->PushProjectionMatrix(1,1);
|
||||
Renderer->LoadIdentity();
|
||||
|
||||
if (inv)
|
||||
{
|
||||
|
||||
|
||||
if (TimeOfDayPref == 2)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["sky_night.png"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["sky.png"]);
|
||||
}
|
||||
Renderer->DrawRect(vec2(0.0f, 0.56f), vec2(1.f, 0.f), vec2(0.5f + SkyTexShift, 0.f), vec2(1.f + SkyTexShift, 1.f));
|
||||
|
||||
if (TimeOfDayPref == 1)
|
||||
{
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["final_cloud.png"]);
|
||||
Renderer->DrawRect(vec2(0.0f, 0.56f), vec2(4.f, 0.f), vec2(0.0f + SkyTexShift + CloudTimer, 0.f), vec2(1.f + SkyTexShift + CloudTimer, 0.5f));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TimeOfDayPref == 2)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["sky_night.png"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["sky.png"]);
|
||||
}
|
||||
Renderer->DrawRect(vec2(0.0f, 0.54f), vec2(1.f, 1.f), vec2(0.5f + SkyTexShift, 0.f), vec2(1.f + SkyTexShift, 1.f));
|
||||
|
||||
if (TimeOfDayPref == 1)
|
||||
{
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["final_cloud.png"]);
|
||||
Renderer->DrawRect(vec2(0.0f, 0.54f), vec2(4.f, 1.f), vec2(0.0f + SkyTexShift + CloudTimer, 0.f), vec2(1.f + SkyTexShift + CloudTimer, 0.5f));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Renderer->PopProjectionMatrix();
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
Renderer->SetGLCamView();
|
||||
|
||||
if (inv)
|
||||
{
|
||||
Renderer->TranslateMatrix(vec3(0,0.1f,0));
|
||||
Renderer->ScaleMatrix(vec3(1, -1, 1));
|
||||
}
|
||||
|
||||
Renderer->PushShader("SimplelightShader");
|
||||
|
||||
vec3 dayColor = vec3(0,0,0);
|
||||
vec3 nightColor = vec3(0, 0.1f, 0.2f);
|
||||
|
||||
if (TimeOfDayPref == 0)
|
||||
{
|
||||
RenderUniform3fv("TimeOfDayColor", dayColor.v);
|
||||
RenderUniform1f("TimeOfDayCoef1", 0.75f);
|
||||
RenderUniform1f("TimeOfDayCoef2", 0.25f);
|
||||
}
|
||||
else
|
||||
if (TimeOfDayPref == 1)
|
||||
{
|
||||
RenderUniform3fv("TimeOfDayColor", dayColor.v);
|
||||
RenderUniform1f("TimeOfDayCoef1", 0.5f);
|
||||
RenderUniform1f("TimeOfDayCoef2", 0.25f);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderUniform3fv("TimeOfDayColor", nightColor.v);
|
||||
RenderUniform1f("TimeOfDayCoef1", 0.0f);
|
||||
RenderUniform1f("TimeOfDayCoef2", 0.4f);
|
||||
}
|
||||
|
||||
|
||||
Renderer->PushPerspectiveProjectionMatrix(pi/6, Renderer->GetMatrixWidth() / Renderer->GetMatrixHeight(), 1.f, 450.f);
|
||||
|
||||
LiteModel->DrawVBO();
|
||||
|
||||
for (int i=0; i<IceModel.size(); i++)
|
||||
{
|
||||
IceModel[i].DrawVBO();
|
||||
}
|
||||
|
||||
Renderer->PopProjectionMatrix();
|
||||
|
||||
Renderer->PopShader();
|
||||
}
|
||||
|
||||
void TAndroidApplication::DrawSnow()
|
||||
{
|
||||
|
||||
Renderer->PushProjectionMatrix(1,1);
|
||||
|
||||
Renderer->LoadIdentity();
|
||||
|
||||
const float multiply_x = 4;
|
||||
const float multiply_y = 2;
|
||||
|
||||
Renderer->DrawRect(vec2(0, 0), vec2(1.f, 1.f), vec2(-SkyTexShift, SnowTimer), vec2(multiply_x - SkyTexShift, multiply_y + SnowTimer));
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
Renderer->DrawRect(vec2(0, 0), vec2(1.f, 1.f), vec2(SnowTimer*0.7f+0.3f - SkyTexShift, SnowTimer+0.7f), vec2(multiply_x - SkyTexShift + SnowTimer*0.7f+0.3f, multiply_y + SnowTimer+0.7f));
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
Renderer->DrawRect(vec2(0, 0), vec2(1.f, 1.f), vec2(SnowTimer*0.4f+0.7f - SkyTexShift, SnowTimer+0.3f), vec2(multiply_x - SkyTexShift + SnowTimer*0.4f+0.7f, multiply_y + SnowTimer+0.3f));
|
||||
|
||||
Renderer->PopProjectionMatrix();
|
||||
}
|
||||
|
||||
void TAndroidApplication::DrawAllScene(bool toScreen)
|
||||
{
|
||||
glClearColor(0.f, 0.f, 0.f, 1.0f);
|
||||
//glClearColor(1.f, 1.f, 1.f, 1.0f);
|
||||
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||
|
||||
Renderer->PushMatrix();
|
||||
Renderer->SetGLCamView();
|
||||
|
||||
Renderer->PushShader("ClipShader");
|
||||
|
||||
|
||||
Renderer->SwitchToFrameBuffer("WaterFrame");
|
||||
Renderer->SetGLCamView();
|
||||
Renderer->ScaleMatrix(vec3(1, -1, 1));
|
||||
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||
|
||||
DrawSceneWithoutWater(true);
|
||||
|
||||
Renderer->ScaleMatrix(vec3(1, -1, 1));
|
||||
|
||||
if (toScreen)
|
||||
{
|
||||
Renderer->SwitchToScreen();
|
||||
}
|
||||
else
|
||||
{
|
||||
Renderer->SwitchToFrameBuffer("ScreenshotFrame");
|
||||
}
|
||||
|
||||
Renderer->SetGLCamView();
|
||||
|
||||
Renderer->PushShader("NormShader");
|
||||
RenderUniform1f("Time", WaterTimer);
|
||||
if (Renderer->GetScreenWidth() < 600)
|
||||
{
|
||||
RenderUniform1f("WaterScale", 0.7f);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderUniform1f("WaterScale", 1.f);
|
||||
}
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["water_nmap.png"]);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
if (toScreen)
|
||||
{
|
||||
Renderer->SetFullScreenViewport();
|
||||
}
|
||||
else
|
||||
{
|
||||
Renderer->SetFrameViewport("ScreenshotFrame");
|
||||
}
|
||||
Renderer->DrawFramePartScreen("WaterFrame", vec2(0, 0), vec2(1.f, 0.54f));
|
||||
Renderer->PopShader();
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
Renderer->SetGLCamView();
|
||||
|
||||
|
||||
DrawSceneWithoutWater(false);
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["snow.png"]);
|
||||
|
||||
if (SnowPref)
|
||||
{
|
||||
DrawSnow();
|
||||
}
|
||||
|
||||
Renderer->PopShader();
|
||||
|
||||
Renderer->PopMatrix();
|
||||
}
|
||||
|
||||
void TAndroidApplication::InnerInit()
|
||||
{
|
||||
m2.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");
|
||||
|
||||
LoadingQueue.push_back(boost::function<bool()>(boost::bind(&TShaderManager::AddShader, &(ResourceManager->ShaderManager), "ClipShader", "gui_transparent_clip.vertex", "gui_transparent_clip.fragment")));
|
||||
LoadingQueue.push_back(boost::function<bool()>(boost::bind(&TShaderManager::AddShader, &(ResourceManager->ShaderManager), "NormShader", "test_norm.vertex", "test_norm.fragment")));
|
||||
LoadingQueue.push_back(boost::function<bool()>(boost::bind(&TShaderManager::AddShader, &(ResourceManager->ShaderManager), "ParallaxShader", "test_parallax.vertex", "test_parallax.fragment")));
|
||||
LoadingQueue.push_back(boost::function<bool()>(boost::bind(&TShaderManager::AddShader, &(ResourceManager->ShaderManager), "SimplelightShader", "test_simplelight.vertex", "test_simplelight.fragment")));
|
||||
|
||||
if (IsFileExistsInUserData("file.bmp"))
|
||||
{
|
||||
ResourceManager->TexList.AddTextureFromUserdata("file.bmp", "ScreenshotTexture");
|
||||
}
|
||||
else
|
||||
{
|
||||
ResourceManager->TexList.AddTexture("file.bmp", "ScreenshotTexture");
|
||||
}
|
||||
|
||||
LoadingQueue.push_back(boost::function<cardinal()>(boost::bind(&TTextureListClass::AddTexture, &(ResourceManager->TexList), "console_bkg.bmp", "")));
|
||||
LoadingQueue.push_back(boost::function<cardinal()>(boost::bind(&TTextureListClass::AddTexture, &(ResourceManager->TexList), "water_nmap.png", "")));
|
||||
LoadingQueue.push_back(boost::function<cardinal()>(boost::bind(&TTextureListClass::AddTexture, &(ResourceManager->TexList), "sky.png", "")));
|
||||
LoadingQueue.push_back(boost::function<cardinal()>(boost::bind(&TTextureListClass::AddTexture, &(ResourceManager->TexList), "sky_night.png", "")));
|
||||
LoadingQueue.push_back(boost::function<cardinal()>(boost::bind(&TTextureListClass::AddTexture, &(ResourceManager->TexList), "snow.png", "")));
|
||||
LoadingQueue.push_back(boost::function<cardinal()>(boost::bind(&TTextureListClass::AddTexture, &(ResourceManager->TexList), "final_cloud.png", "")));
|
||||
|
||||
|
||||
LoadingQueue.push_back(boost::function<bool()>(boost::bind(&TModelManager::AddLiteModel, &(ResourceManager->ModelManager), "mountain.lm1", "")));
|
||||
LoadingQueue.push_back(boost::function<bool()>(boost::bind(&TModelManager::AddLiteModel, &(ResourceManager->ModelManager), "ice1.lm1", "")));
|
||||
LoadingQueue.push_back(boost::function<bool()>(boost::bind(&TModelManager::AddLiteModel, &(ResourceManager->ModelManager), "ice2.lm1", "")));
|
||||
LoadingQueue.push_back(boost::function<bool()>(boost::bind(&TModelManager::AddLiteModel, &(ResourceManager->ModelManager), "ice3.lm1", "")));
|
||||
LoadingQueue.push_back(boost::function<bool()>(boost::bind(&TModelManager::AddLiteModel, &(ResourceManager->ModelManager), "ice4.lm1", "")));
|
||||
LoadingQueue.push_back(boost::function<bool()>(boost::bind(&TModelManager::AddLiteModel, &(ResourceManager->ModelManager), "ice5.lm1", "")));
|
||||
LoadingQueue.push_back(boost::function<bool()>(boost::bind(&TModelManager::AddLiteModel, &(ResourceManager->ModelManager), "ice6.lm1", "")));
|
||||
|
||||
LoadingQueue.push_back(boost::function<void()>(boost::bind(&TAndroidApplication::LoadModels, this)));
|
||||
LoadingQueue.push_back(boost::function<void()>(boost::bind(&TAndroidApplication::AddFrameBuffers, this)));
|
||||
|
||||
|
||||
|
||||
//LoadModels();
|
||||
|
||||
CheckGlError();
|
||||
|
||||
|
||||
boost::get<TPanoramicCamera>(Renderer->Camera).MovePhi(pi/32);
|
||||
|
||||
|
||||
if (Renderer->GetScreenWidth() > Renderer->GetScreenHeight())
|
||||
{
|
||||
boost::get<TPanoramicCamera>(Renderer->Camera).MoveDist(30.f);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
boost::get<TPanoramicCamera>(Renderer->Camera).MoveDist(45.f);
|
||||
}
|
||||
|
||||
boost::get<TPanoramicCamera>(Renderer->Camera).CalcCamVec();
|
||||
|
||||
CheckGlError();
|
||||
|
||||
ResourceManager->LightManager.SetLightOn();
|
||||
|
||||
ResourceManager->LightManager.SetLightDirection(vec3(1, -1, 0));
|
||||
|
||||
//AddFrameBuffers();
|
||||
|
||||
//Renderer->SetPerspectiveFullScreenViewport();
|
||||
|
||||
if (Renderer->GetScreenWidth() < Renderer->GetScreenHeight())
|
||||
{
|
||||
Renderer->SetMatrixWidth(480);
|
||||
Renderer->SetMatrixHeight(800);
|
||||
}
|
||||
|
||||
Renderer->PushPerspectiveProjectionMatrix(pi/6, Renderer->GetMatrixWidth() / Renderer->GetMatrixHeight(), 1.f, 400.f);
|
||||
|
||||
*Console<<"Inner init end!\n";
|
||||
|
||||
m2.unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TAndroidApplication::InnerDeinit()
|
||||
{
|
||||
m2.lock();
|
||||
Inited = false;
|
||||
Loaded = false;
|
||||
|
||||
makeShot = true;
|
||||
LoadingQueue.clear();
|
||||
|
||||
if (LiteModel != NULL)
|
||||
{
|
||||
LiteModel->FreeModel();
|
||||
delete LiteModel;
|
||||
LiteModel = NULL;
|
||||
}
|
||||
|
||||
IceModel.clear();
|
||||
|
||||
SimpleLand = std::shared_ptr<TSimpleLandClass>();
|
||||
SimpleLandInv = std::shared_ptr<TSimpleLandClass>();
|
||||
m2.unlock();
|
||||
}
|
||||
|
||||
|
||||
void TAndroidApplication::InnerDraw()
|
||||
{
|
||||
m2.lock();
|
||||
if (!Loaded)
|
||||
{
|
||||
glClearColor(0.f, 0.f, 0.f, 1.0f);
|
||||
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["ScreenshotTexture"]);
|
||||
Renderer->PushProjectionMatrix(1,1);
|
||||
Renderer->LoadIdentity();
|
||||
Renderer->DrawRect(vec2(0, 0), vec2(1.f, 1.f));
|
||||
Renderer->PopProjectionMatrix();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
DrawAllScene(true);
|
||||
|
||||
if (makeShot)
|
||||
{
|
||||
makeShot = false;
|
||||
|
||||
Renderer->SwitchToFrameBuffer("ScreenshotFrame");
|
||||
|
||||
DrawAllScene(false);
|
||||
|
||||
ResourceManager->TexList.SaveTexDataToPlainBmpToUserData("file.bmp", ResourceManager->FrameManager.ReadFromBufferToTexData("ScreenshotFrame"));
|
||||
|
||||
Renderer->SwitchToScreen();
|
||||
|
||||
}
|
||||
}
|
||||
m2.unlock();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TAndroidApplication::InnerUpdate(cardinal dt)
|
||||
{
|
||||
|
||||
if (!Loaded)
|
||||
{
|
||||
|
||||
boost::apply_visitor( LoadingQueueVisitor(), *LoadingQueue.begin() );
|
||||
LoadingQueue.erase(LoadingQueue.begin());
|
||||
|
||||
if (LoadingQueue.size() == 0)
|
||||
{
|
||||
Loaded = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
if (WaveDir)
|
||||
{
|
||||
WaterTimer += dt/1000.f;
|
||||
if (WaterTimer >= 10 * pi)
|
||||
{
|
||||
WaveDir = false;
|
||||
WaterTimer = 10 * pi;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WaterTimer -= dt/1000.f;
|
||||
if (WaterTimer < 0)
|
||||
{
|
||||
WaveDir = true;
|
||||
WaterTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
CloudTimer += dt / 60000.f;
|
||||
|
||||
while (CloudTimer >= 1.f)
|
||||
{
|
||||
CloudTimer -= 1.f;
|
||||
}
|
||||
|
||||
|
||||
SnowTimer += dt/3000.f;
|
||||
|
||||
while (SnowTimer > 10.f)
|
||||
{
|
||||
SnowTimer -= 10.f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TAndroidApplication::InnerOnMove(vec2 shift)
|
||||
{
|
||||
|
||||
shift = vec2(shift.v[0]*Renderer->GetMatrixWidth()/static_cast<float>(Renderer->GetScreenWidth()), shift.v[1]*Renderer->GetMatrixHeight()/static_cast<float>(Renderer->GetScreenHeight()));
|
||||
|
||||
boost::get<TPanoramicCamera>(Renderer->Camera).MoveAlpha(-pi*shift.v[0]*0.1f);
|
||||
}
|
||||
|
||||
void TAndroidApplication::OnMouseDown(TMouseState& mouseState)
|
||||
{
|
||||
|
||||
}
|
90
jni/main_code.h
Normal file
@ -0,0 +1,90 @@
|
||||
#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, public TSerializeInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
void LoadModels();
|
||||
void AddFrameBuffers();
|
||||
|
||||
public:
|
||||
bool Inited;
|
||||
bool Loaded;
|
||||
|
||||
std::vector<boost::variant<boost::function<cardinal()>, boost::function<bool()>, boost::function<void()> > > LoadingQueue;
|
||||
|
||||
TLiteModel* LiteModel;
|
||||
|
||||
float WaterTimer;
|
||||
float SnowTimer;
|
||||
float CloudTimer;
|
||||
float SkyTexShift;
|
||||
bool WaveDir;
|
||||
|
||||
std::vector<TLiteModel> IceModel;
|
||||
|
||||
std::shared_ptr<TSimpleLandClass> SimpleLand;
|
||||
|
||||
std::shared_ptr<TSimpleLandClass> SimpleLandInv;
|
||||
|
||||
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 DrawSceneWithoutWater(bool inv);
|
||||
void DrawSnow();
|
||||
void DrawAllScene(bool toScreen);
|
||||
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
|
||||
//void DrawSceneWithoutWaterFrame();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
//static void checkGlError(const std::string& op);
|
||||
|
||||
|
||||
#endif
|
BIN
res/drawable-hdpi/icon.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
res/drawable-ldpi/icon.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
res/drawable-mdpi/icon.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
res/drawable/notificon.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
res/drawable/thumb.jpg
Normal file
After Width: | Height: | Size: 28 KiB |
7
res/layout/main.xml
Normal file
@ -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>
|
10
res/layout/prefliste.xml
Normal file
@ -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>
|
22
res/values-cs/strings.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Horská odražené</string>
|
||||
<string name="description">Horská odráží ve vodě, s účinkem sněhu</string>
|
||||
<string name="feedback">Pokud dojde k chybě aplikace, prosím, kontaktujte mě: mephi1984@gmail.com</string>
|
||||
|
||||
<string name="p_snow">Sněžení</string>
|
||||
<string name="p_snow_on">Sněžení je zapnuta</string>
|
||||
<string name="p_snow_off">Sněžení je vypnutý</string>
|
||||
|
||||
<string name="p_timeofday">Denní čas</string>
|
||||
<string name="p_stimeofday">Vyberte si čas dne</string>
|
||||
|
||||
|
||||
<string-array name="timeofday_id">
|
||||
<item>Den</item>
|
||||
<item>Přeháňky den</item>
|
||||
<item>Noc</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
22
res/values-de/strings.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Reflektierte Berg</string>
|
||||
<string name="description">Berg spiegelt sich im Wasser, mit dem Effekt der Schnee</string>
|
||||
<string name="feedback">Wenn die Anwendung abstürzt, bitte kontaktieren Sie mich: mephi1984@gmail.com</string>
|
||||
|
||||
<string name="p_snow">Schneefall</string>
|
||||
<string name="p_snow_on">Schneefall ist eingeschaltet</string>
|
||||
<string name="p_snow_off">Schneefall ausgeschaltet</string>
|
||||
|
||||
<string name="p_timeofday">Zeit des Tages</string>
|
||||
<string name="p_stimeofday">Wählen Sie die Zeit des Tages</string>
|
||||
|
||||
<string-array name="timeofday_id">
|
||||
<item>Day</item>
|
||||
<item>Bewölkten Day</item>
|
||||
<item>Night</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
</resources>
|
||||
|
23
res/values-es/strings.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Montaña que se refleja</string>
|
||||
<string name="description">Montaña que se refleja en el agua con efectos nevada</string>
|
||||
<string name="feedback">Si la aplicación se bloquea, por favor póngase en contacto conmigo: mephi1984@gmail.com</string>
|
||||
|
||||
<string name="p_snow">Las nevadas</string>
|
||||
<string name="p_snow_on">Las nevadas se enciende</string>
|
||||
<string name="p_snow_off">Las nevadas se apaga</string>
|
||||
|
||||
<string name="p_timeofday">La hora del día</string>
|
||||
<string name="p_stimeofday">Elija la hora del día</string>
|
||||
|
||||
|
||||
<string-array name="timeofday_id">
|
||||
<item>Día</item>
|
||||
<item>Día nublado</item>
|
||||
<item>Noche</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
</resources>
|
||||
|
22
res/values-fr/strings.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Montagne réfléchie</string>
|
||||
<string name="description">Montagne reflète dans l\'eau avec des effets des chutes de neige</string>
|
||||
<string name="feedback">Si l\'application se bloque, s\'il vous plaît contactez-moi : mephi1984@gmail.com</string>
|
||||
|
||||
<string name="p_snow">Chutes de neige</string>
|
||||
<string name="p_snow_on">Chutes de neige est en marche</string>
|
||||
<string name="p_snow_off">Chutes de neige est éteint</string>
|
||||
|
||||
<string name="p_timeofday">L\'heure du jour</string>
|
||||
<string name="p_stimeofday">Choisissez le moment de la journée</string>
|
||||
|
||||
<string-array name="timeofday_id">
|
||||
<item>Jour</item>
|
||||
<item>Temps nuageux</item>
|
||||
<item>Nuit</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
</resources>
|
||||
|
30
res/values-it/strings.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Montagna riflessa</string>
|
||||
<string name="description">Montagna riflessa nell\'acqua, con l\'effetto di neve</string>
|
||||
<string name="feedback">Se l\'applicazione si blocca, si prega di contattare me: mephi1984@gmail.com</string>
|
||||
|
||||
<string name="p_snow">Nevicate</string>
|
||||
<string name="p_snow_on">Nevicate si accende</string>
|
||||
<string name="p_snow_off">Nevicata è spento</string>
|
||||
|
||||
<string name="p_timeofday">Il momento della giornata</string>
|
||||
<string name="p_stimeofday">Scegliere il momento della giornata</string>
|
||||
|
||||
|
||||
|
||||
<string-array name="timeofday_id">
|
||||
<item>Giorno</item>
|
||||
<item>Giornata nuvolosa</item>
|
||||
<item>Notte</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<string-array name="timeofday_value">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
22
res/values-nl/strings.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Reflected berg</string>
|
||||
<string name="description">Mountain weerspiegeld in het water met sneeuwval effecten</string>
|
||||
<string name="feedback">Als de toepassing crasht, neem dan contact met mij op: mephi1984@gmail.com</string>
|
||||
|
||||
<string name="p_snow">Sneeuwval</string>
|
||||
<string name="p_snow_on">Sneeuwval is ingeschakeld</string>
|
||||
<string name="p_snow_off">Sneeuwval is uitgeschakeld</string>
|
||||
|
||||
<string name="p_timeofday">Tijd van de dag</string>
|
||||
<string name="p_stimeofday">Kies de tijd van de dag</string>
|
||||
|
||||
<string-array name="timeofday_id">
|
||||
<item>Dag</item>
|
||||
<item>Bewolkte dag</item>
|
||||
<item>Nacht</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
</resources>
|
||||
|
23
res/values-pt/strings.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Montanha refletidas</string>
|
||||
<string name="description">Montanha refletida na água com efeitos queda de neve</string>
|
||||
<string name="feedback">Se o aplicativo falha, por favor contacte-me: mephi1984@gmail.com</string>
|
||||
|
||||
<string name="p_snow">Queda de neve</string>
|
||||
<string name="p_snow_on">Neve está ligado</string>
|
||||
<string name="p_snow_off">Neve está desligado</string>
|
||||
|
||||
<string name="p_timeofday">Hora do dia</string>
|
||||
<string name="p_stimeofday">Escolha a hora do dia</string>
|
||||
|
||||
|
||||
<string-array name="timeofday_id">
|
||||
<item>Dia</item>
|
||||
<item>Dia nublado</item>
|
||||
<item>Noite</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
</resources>
|
||||
|
23
res/values-ru/strings.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Отраженная гора</string>
|
||||
<string name="description">Гора, отраженная в воде, с эффектом снегопада</string>
|
||||
<string name="feedback">Если приложение падает, пожалуйста, свяжитесь со мною: mephi1984@gmail.com</string>
|
||||
|
||||
<string name="p_snow">Снегопад</string>
|
||||
<string name="p_snow_on">Снегопад включен</string>
|
||||
<string name="p_snow_off">Снегопад выключен</string>
|
||||
|
||||
<string name="p_timeofday">Время суток</string>
|
||||
<string name="p_stimeofday">Выберите время суток</string>
|
||||
|
||||
|
||||
<string-array name="timeofday_id">
|
||||
<item>День</item>
|
||||
<item>Облачный день</item>
|
||||
<item>Ночь</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
</resources>
|
||||
|
43
res/values/strings.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Reflected mountain</string>
|
||||
<string name="description">Mountain reflected in the water with snow effects</string>
|
||||
<string name="feedback">If wallpaper crashes or something else goes wrong, please, contact with me: mephi1984@gmail.com</string>
|
||||
|
||||
<string name="p_snow">Snow</string>
|
||||
<string name="p_snow_on">Snow is on</string>
|
||||
<string name="p_snow_off">Snow is off</string>
|
||||
|
||||
<string name="p_timeofday">Time of day</string>
|
||||
<string name="p_stimeofday">Choose time of day to display</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>
|
||||
|
||||
|
||||
<string-array name="timeofday_id">
|
||||
<item>Day</item>
|
||||
<item>Cloudy day</item>
|
||||
<item>Night</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<string-array name="timeofday_value">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
13
res/xml/preferences.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen android:title="Main"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<ListPreference
|
||||
android:key="Timeofday" android:summary="@string/p_stimeofday"
|
||||
android:title="@string/p_timeofday" android:entries="@array/timeofday_id"
|
||||
android:entryValues="@array/timeofday_value" android:defaultValue="0"/>
|
||||
<CheckBoxPreference android:summaryOn="@string/p_snow_on"
|
||||
android:key="Snow" android:title="@string/p_snow"
|
||||
android:summaryOff="@string/p_snow_off" android:defaultValue="false" />
|
||||
|
||||
</PreferenceScreen>
|
6
res/xml/wallpaper.xml
Normal file
@ -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.mountainwallpaper.Prefs"/>
|
960
src/fishrungames/mountainwallpaper/GLWallpaperService.java
Normal file
@ -0,0 +1,960 @@
|
||||
package fishrungames.mountainwallpaper;
|
||||
|
||||
|
||||
import fishrungames.mountainwallpaper.BaseConfigChooser.ComponentSizeChooser;
|
||||
import fishrungames.mountainwallpaper.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;
|
||||
|
||||
import fishrungames.engine.EngineWrapper;
|
||||
|
||||
|
||||
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();
|
||||
|
||||
EngineWrapper.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;
|
||||
}
|
||||
}
|
||||
}
|
27
src/fishrungames/mountainwallpaper/JniWrapper.java
Normal file
@ -0,0 +1,27 @@
|
||||
package fishrungames.mountainwallpaper;
|
||||
|
||||
public class JniWrapper
|
||||
{
|
||||
|
||||
static
|
||||
{
|
||||
System.loadLibrary("SalmonWallpaper");
|
||||
}
|
||||
|
||||
public static void LoadLibrary()
|
||||
{
|
||||
//To force loading libraries
|
||||
}
|
||||
|
||||
public static native void SetTimeOfDayPref(int timeofday);
|
||||
|
||||
public static native void SetSnowPref(boolean snow);
|
||||
|
||||
|
||||
public static native void Init(int width, int height);
|
||||
|
||||
public static native void SetOffset(float offsetX, float offsetY);
|
||||
|
||||
public static native void SetOrientation(int isLandscape);
|
||||
|
||||
}
|
233
src/fishrungames/mountainwallpaper/MountainWallpaperService.java
Normal file
@ -0,0 +1,233 @@
|
||||
package fishrungames.mountainwallpaper;
|
||||
|
||||
|
||||
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.EngineWrapper;
|
||||
|
||||
public class MountainWallpaperService extends GLWallpaperService implements
|
||||
OnSharedPreferenceChangeListener {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see android.app.Service#onLowMemory()
|
||||
*/
|
||||
static
|
||||
{
|
||||
EngineWrapper.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.mountainwallpaper.FOREGROUND";
|
||||
static final String ACTION_BACKGROUND = "fishrungames.mountainwallpaper.BACKGROUND";
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onCreate();
|
||||
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
EngineWrapper.SetActivityInstance(this);
|
||||
EngineWrapper.SetupEnviroment();
|
||||
|
||||
String apkFilePath = null;
|
||||
ApplicationInfo appInfo = null;
|
||||
PackageManager packMgmr = this.getPackageManager();
|
||||
try {
|
||||
appInfo = packMgmr.getApplicationInfo("fishrungames.mountainwallpaper", 0);
|
||||
} catch (NameNotFoundException e) {
|
||||
|
||||
|
||||
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Unable to locate assets, aborting...");
|
||||
}
|
||||
apkFilePath = appInfo.sourceDir;
|
||||
|
||||
EngineWrapper.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("Timeofday") == 0)
|
||||
{
|
||||
int time = Integer.parseInt(sharedPreferences.getString("Timeofday", "0"));
|
||||
JniWrapper.SetTimeOfDayPref(time);
|
||||
}
|
||||
|
||||
if (key.compareToIgnoreCase("Snow") == 0) {
|
||||
|
||||
JniWrapper.SetSnowPref(sharedPreferences.getBoolean("Snow", 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);
|
||||
MountainWallpaperService.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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
72
src/fishrungames/mountainwallpaper/Prefs.java
Normal file
@ -0,0 +1,72 @@
|
||||
package fishrungames.mountainwallpaper;
|
||||
|
||||
import fishrungames.mountainwallpaper.R;
|
||||
import fishrungames.mountainwallpaper.JniWrapper;
|
||||
|
||||
|
||||
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 snowPref;
|
||||
private ListPreference timeOfDayPref;
|
||||
|
||||
|
||||
public static Uri currImageURI;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.prefliste);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
|
||||
|
||||
snowPref = (CheckBoxPreference)this.getPreferenceManager().findPreference("Snow");
|
||||
timeOfDayPref = (ListPreference) findPreference("Timeofday");
|
||||
|
||||
if (timeOfDayPref.getKey().compareToIgnoreCase("Timeofday") == 0)
|
||||
{
|
||||
JniWrapper.SetTimeOfDayPref(Integer.parseInt((String) timeOfDayPref.getValue()));
|
||||
|
||||
}
|
||||
|
||||
if (snowPref.getKey().compareToIgnoreCase("Snow") == 0) {
|
||||
if (!snowPref.isChecked())
|
||||
{
|
||||
JniWrapper.SetSnowPref(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
JniWrapper.SetSnowPref(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
|
||||
}
|
||||
|
||||
}
|
5
windows/Readme.txt
Normal file
@ -0,0 +1,5 @@
|
||||
Для создания своего проекта на основе этого шаблона нужно:
|
||||
1) Счекаутить движок с svn куда-нибудь, например C:\Work\Salmon Engine\
|
||||
1) Указать в системе переменную окружения SalmonEnginePath с путем к движку, например c:\Work\Salmon Engine\
|
||||
2) Скопировать содержимое шаблона в какой-нибудь каталог
|
||||
3) Запустить Template.sln в Visual C++ 2010
|
34
windows/Template.sln
Normal file
@ -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
|
90
windows/Template/Template.vcxproj
Normal file
@ -0,0 +1,90 @@
|
||||
<?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;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;DEBUG</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4503</DisableSpecificWarnings>
|
||||
</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;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;NDEBUG</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4503</DisableSpecificWarnings>
|
||||
</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>
|
30
windows/Template/main.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include "main.h"
|
||||
|
||||
#include "main_code.h"
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst,
|
||||
LPSTR lpszCmdLine, int nCmdShow)
|
||||
{
|
||||
|
||||
int width = 800;
|
||||
int height = 480;
|
||||
|
||||
if (CreateEngine(width, height))
|
||||
{
|
||||
|
||||
//MyApplication scope
|
||||
{
|
||||
TAndroidApplication Application;
|
||||
|
||||
Application.OuterInit(width, height, width, height);
|
||||
|
||||
MainLoop(&Application);
|
||||
|
||||
Application.OuterDeinit();
|
||||
}
|
||||
|
||||
DestroyEngine();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
6
windows/Template/main.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
/* Path to the engine */
|
||||
#include "include/Engine.h"
|
||||
|
||||
#include "main_code.h"
|