fixed Android version (Sony Xperia Z3 Compact)

This commit is contained in:
Emil Kabirov 2018-11-09 07:39:08 +05:00
parent 77616bef24
commit 1d4b103f06
8 changed files with 165 additions and 104 deletions

View File

@ -1,15 +1,15 @@
precision lowp float; precision lowp float;
uniform sampler2D Texture; uniform sampler2D Texture;
uniform sampler2D NormalMap; //uniform sampler2D NormalMap;
uniform vec3 LightDirection; uniform vec3 LightDirection;
uniform float TimeOfDayCoef1; uniform float TimeOfDayCoef1;
uniform float TimeOfDayCoef2; uniform float TimeOfDayCoef2;
uniform float invCoef; //uniform float invCoef;
uniform vec3 TimeOfDayColor; uniform vec3 TimeOfDayColor;
varying vec2 texCoord;
varying vec3 camVec; varying vec2 texCoord;
varying vec3 normVec; varying vec3 normVec;
varying vec3 posVec; varying vec3 posVec;

View File

@ -1,15 +1,11 @@
attribute vec3 vPosition; attribute vec3 vPosition;
attribute vec3 Normal; attribute vec3 Normal;
attribute vec3 Tangent;
attribute vec3 Binormal;
attribute vec2 vTexCoord; attribute vec2 vTexCoord;
uniform mat4 ModelViewMatrix; //uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix; uniform mat4 ProjectionMatrix;
uniform vec3 CamPos;
varying vec2 texCoord; varying vec2 texCoord;
varying vec3 camVec;
varying vec3 normVec; varying vec3 normVec;
varying vec3 posVec; varying vec3 posVec;
@ -19,15 +15,6 @@ void main()
gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0); gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0);
texCoord = vTexCoord; texCoord = vTexCoord;
vec3 cVec = (CamPos - vPosition.xyz);
mat3 rot;
rot[0] = Tangent;
rot[1] = Binormal;
rot[2] = Normal;
camVec = cVec * rot;
normVec = Normal; normVec = Normal;
posVec = vPosition.xyz; posVec = vPosition.xyz;

14
jni/android_api.cpp Normal file → Executable file
View File

@ -26,13 +26,15 @@ JNIEXPORT void JNICALL Java_fishrungames_mountainwallpaper_JniWrapper_SetSnowPre
JNIEXPORT void JNICALL Java_fishrungames_mountainwallpaper_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height) JNIEXPORT void JNICALL Java_fishrungames_mountainwallpaper_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height)
{ {
auto app = JniInitApp<TAndroidApplication>(width, height, 800.f, 480.f);
Application = JniInitApp<TAndroidApplication>(width, height, 800.f, 480.f); if (app)
{
boost::get<TPanoramicCamera>(Renderer->Camera).SetAlpha((lastOffsetX) * pi / 180.f); Application = app;
Application->SkyTexShift = lastOffsetX*0.01f; }
boost::get<TPanoramicCamera>(Renderer->Camera).SetAlpha((lastOffsetX) * pi / 180.f);
Application->SkyTexShift = lastOffsetX*0.01f;
} }

View File

@ -36,6 +36,8 @@ TPanoramicCamera mCamera;
const float cameraDistance = 100.f; const float cameraDistance = 100.f;
std::vector<int> iceIndexes; std::vector<int> iceIndexes;
TRenderPair water;
class LoadingQueueVisitor : public boost::static_visitor<void> class LoadingQueueVisitor : public boost::static_visitor<void>
{ {
public: public:
@ -249,7 +251,7 @@ void TAndroidApplication::DrawSceneWithoutWater(bool inv)
Renderer->TranslateMatrix(Vector3f(0, 0.0f, 0)); Renderer->TranslateMatrix(Vector3f(0, 0.0f, 0));
} }
Renderer->PushShader("SimplelightShader"); Renderer->PushShader("SimplelightShader");
@ -265,7 +267,7 @@ void TAndroidApplication::DrawSceneWithoutWater(bool inv)
RenderUniform1f("invCoef", 1.0f); RenderUniform1f("invCoef", 1.0f);
RenderUniform1f("extraSpace", 0.0f); RenderUniform1f("extraSpace", 0.0f);
} }
Vector3f dayColor = Vector3f(0,0,0); Vector3f dayColor = Vector3f(0,0,0);
Vector3f nightColor = Vector3f(0, 0.1f, 0.2f); Vector3f nightColor = Vector3f(0, 0.1f, 0.2f);
@ -290,7 +292,7 @@ void TAndroidApplication::DrawSceneWithoutWater(bool inv)
RenderUniform1f("TimeOfDayCoef2", 0.4f); RenderUniform1f("TimeOfDayCoef2", 0.4f);
} }
Renderer->PushPerspectiveProjectionMatrix(pi/6, Renderer->GetMatrixWidth() / Renderer->GetMatrixHeight(), 1.f, 450.f); Renderer->PushPerspectiveProjectionMatrix(pi/6, Renderer->GetMatrixWidth() / Renderer->GetMatrixHeight(), 1.f, 450.f);
//Renderer->PushMatrix(); //Renderer->PushMatrix();
//mCamera.SetCamView(); //mCamera.SetCamView();
@ -351,70 +353,85 @@ void TAndroidApplication::DrawSnow()
Renderer->PopProjectionMatrix(); Renderer->PopProjectionMatrix();
} }
void TAndroidApplication::DrawAllScene(bool toScreen) void TAndroidApplication::DrawAllScene(bool toScreen) {
{ //glClearColor(1.f, 0.f, 1.f, 1.0f);
//glClearColor(1.f, 0.f, 1.f, 1.0f); //glClearColor(0.9f, 0.9f, 1.f, 1.0f);
glClearColor(0.9f, 0.9f, 1.f, 1.0f); glClearColor(0.9f, 0.9f, 1.f, 1.0f);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
Renderer->PushMatrix(); Renderer->PushMatrix();
Renderer->SetGLCamView(); Renderer->SetGLCamView();
Renderer->PushShader("ClipShader"); Renderer->PushShader("ClipShader");
Renderer->SwitchToFrameBuffer("WaterFrame");
Renderer->SetGLCamView();
Renderer->ScaleMatrix(Vector3f(1, -1, 1));
Renderer->SwitchToFrameBuffer("WaterFrame"); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
Renderer->SetGLCamView();
Renderer->ScaleMatrix(Vector3f(1, -1, 1));
DrawSceneWithoutWater(true);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); Renderer->ScaleMatrix(Vector3f(1, -1, 1));
DrawSceneWithoutWater(true); if (toScreen) {
Renderer->SwitchToScreen();
} else {
Renderer->SwitchToFrameBuffer("ScreenshotFrame");
}
Renderer->ScaleMatrix(Vector3f(1, -1, 1)); Renderer->SetGLCamView();
if (toScreen) {
{ Renderer->PushShader("NormShader");
Renderer->SwitchToScreen();
}
else
{
Renderer->SwitchToFrameBuffer("ScreenshotFrame");
}
Renderer->SetGLCamView(); RenderUniform1f("Time", WaterTimer);
Renderer->PushShader("NormShader");
RenderUniform1f("Time", WaterTimer);
if (Renderer->GetScreenWidth() < 600)
{
RenderUniform1f("WaterScale", 0.7f);
}
else
{
RenderUniform1f("WaterScale", 1.f);
}
glActiveTexture(GL_TEXTURE0); // THIS IS A NORMAL MAP (UNIFORM IS SETTED BY ENGINE IN Renderer->PushShader() -> SetUnifroms())
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["water_nmap.png"]);
glActiveTexture(GL_TEXTURE1); // THIS IS A COLOR MAP (UNIFORM IS SETTED BY ENGINE IN Renderer->PushShader() -> SetUnifroms())
if (toScreen)
{
Renderer->SetFullScreenViewport();
}
else
{
Renderer->SetFrameViewport("ScreenshotFrame");
}
Renderer->DrawFramePartScreen("WaterFrame", Vector2f(0, 0), Vector2f(1.f, 0.55f)); if (Renderer->GetScreenWidth() < 600)
{
RenderUniform1f("WaterScale", 0.7f);
}
else
{
RenderUniform1f("WaterScale", 1.f);
}
// glActiveTexture(GL_TEXTURE0); // THIS IS A NORMAL MAP (UNIFORM IS SETTED BY ENGINE IN Renderer->PushShader() -> SetUnifroms())
// glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["water_nmap.png"]);
// glActiveTexture(GL_TEXTURE1); // THIS IS A COLOR MAP (UNIFORM IS SETTED BY ENGINE IN Renderer->PushShader() -> SetUnifroms())
if (toScreen)
{
Renderer->SetFullScreenViewport();
}
else
{
Renderer->SetFrameViewport("ScreenshotFrame");
}
// size_t texID = ResourceManager->FrameManager.GetFrameTexture("WaterFrame");
//
// if (texID != 0)
// {
Renderer->PushProjectionMatrix(1, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Renderer->LoadIdentity();
// glBindTexture(GL_TEXTURE_2D, texID);
TRenderParamsSetter setter(water.first);
Renderer->DrawTriangleList(water.second);
Renderer->PopProjectionMatrix();
//}
Renderer->PopShader();
}
glActiveTexture(GL_TEXTURE0); // return back glActiveTexture(GL_TEXTURE0); // return back
Renderer->PopShader();
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
@ -448,7 +465,7 @@ void TAndroidApplication::InnerInit()
GetConsole() << "Inner init go!\n"; GetConsole() << "Inner init go!\n";
#ifdef TARGET_ANDROID #ifdef TARGET_ANDROID
ResourceManager->PathToResources = ""; ST::PathToResources = "";
#endif #endif
#ifdef TARGET_WIN32 #ifdef TARGET_WIN32
ST::PathToResources = "../../assets/"; ST::PathToResources = "../../assets/";
@ -486,6 +503,10 @@ void TAndroidApplication::InnerInit()
CheckGlError(); CheckGlError();
water.first.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = "WaterFrame";
water.first.SamplerMap[CONST_STRING_NORMALMAP_UNIFORM] = "water_nmap.png";
water.second.Data = MakeDataTriangleList(Vector2f(0, 0), Vector2f(1.f, 0.55f), Vector4f(1, 1, 1, 1), 0, Vector2f(0, 0), Vector2f(1.f, 0.55f));
boost::get<TPanoramicCamera>(Renderer->Camera).MovePhi(pi / 360.f * 5); boost::get<TPanoramicCamera>(Renderer->Camera).MovePhi(pi / 360.f * 5);
mCamera.MovePhi(pi / 360.f * 5); mCamera.MovePhi(pi / 360.f * 5);
@ -522,7 +543,7 @@ void TAndroidApplication::InnerInit()
Renderer->PushPerspectiveProjectionMatrix(pi/6, Renderer->GetMatrixWidth() / Renderer->GetMatrixHeight(), 1.f, 400.f); Renderer->PushPerspectiveProjectionMatrix(pi/6, Renderer->GetMatrixWidth() / Renderer->GetMatrixHeight(), 1.f, 400.f);
GetConsole()<<"Inner init end!\n"; GetConsole() << "Inner init end!\n";
m2.unlock(); m2.unlock();
} }

View File

@ -1,7 +1,14 @@
cmake_minimum_required(VERSION 3.4.1) cmake_minimum_required(VERSION 3.4.1)
set(BOOST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../boost_1_67_0) #set( CMAKE_CXX_STANDARD 17 )
set(BOOST_GIL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/boost-gil-extension)
#add_definitions(-DEIGEN_HAS_CXX11_MATH=0)
#set(BOOST_GIL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/boost-gil-extension)
set(BOOST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../boost_1_68_0)
set(ZIP_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/julienr-libzip-android/jni) set(ZIP_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/julienr-libzip-android/jni)
set(LIBPNG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/libpng_1.4.1_android) set(LIBPNG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/libpng_1.4.1_android)
set(LIBJPEG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/jpeg-9) set(LIBJPEG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/jpeg-9)
@ -9,15 +16,17 @@ set(EIGEN_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../eigen)
set(SOL2_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../sol2) set(SOL2_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../sol2)
set(LUA_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/lua-5.3.4/src) set(LUA_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/lua-5.3.4/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../tes-engine) include_directories(${LIBJPEG_PATH}/vc10)
include_directories(${BOOST_PATH}) include_directories(${LUA_PATH})
include_directories(${EIGEN_PATH}) include_directories(${EIGEN_PATH})
include_directories(${SOL2_PATH}) include_directories(${SOL2_PATH})
include_directories(${LUA_PATH}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
include_directories(${BOOST_PATH})
include_directories(${LIBPNG_PATH}) include_directories(${LIBPNG_PATH})
include_directories(${LIBJPEG_PATH}) include_directories(${LIBJPEG_PATH})
include_directories(${ZIP_PATH}) include_directories(${ZIP_PATH})
include_directories(${BOOST_GIL_PATH}) include_directories(${BOOST_GIL_PATH})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../tes-engine)
add_definitions(-DTARGET_ANDROID) add_definitions(-DTARGET_ANDROID)

View File

@ -1,25 +1,41 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest
package="fishrungames.mountainwallpaper" android:versionCode="1" android:versionName="1.0.0"> xmlns:android="http://schemas.android.com/apk/res/android"
<application android:label="@string/app_name" android:icon="@drawable/icon" > package="fishrungames.mountainwallpaper"
<activity android:launchMode="standard" android:name=".Prefs"> android:versionCode="1"
android:versionName="1.0.0">
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:label="@string/app_name"
android:icon="@drawable/icon" >
<activity
android:name=".Prefs">
<intent-filter> <intent-filter>
<category android:name="android.intent.category.PREFERENCE"/>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<service android:name="MountainWallpaperService" android:enabled="true" <service
android:icon="@drawable/icon" android:label="@string/app_name" android:name=".MountainWallpaperService"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:permission="android.permission.BIND_WALLPAPER"> android:permission="android.permission.BIND_WALLPAPER">
<intent-filter android:priority="1"> <intent-filter android:priority="1">
<action android:name="android.service.wallpaper.WallpaperService" /> <action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter> </intent-filter>
<meta-data android:name="android.service.wallpaper" <meta-data
android:resource="@xml/wallpaper" /> android:name="android.service.wallpaper"
android:resource="@xml/wallpaper"/>
</service> </service>
</application> </application>
<uses-feature android:glEsVersion="0x00020000"/>
</manifest> </manifest>

View File

@ -31,17 +31,17 @@ public class Prefs extends PreferenceActivity implements
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.prefliste); setContentView(R.layout.prefliste);
addPreferencesFromResource(R.xml.preferences); addPreferencesFromResource(R.xml.preferences);
snowPref = (CheckBoxPreference)this.getPreferenceManager().findPreference("Snow"); snowPref = (CheckBoxPreference)this.getPreferenceManager().findPreference("Snow");
timeOfDayPref = (ListPreference) findPreference("Timeofday"); timeOfDayPref = (ListPreference) findPreference("Timeofday");
if (timeOfDayPref.getKey().compareToIgnoreCase("Timeofday") == 0) if (timeOfDayPref.getKey().compareToIgnoreCase("Timeofday") == 0)
{ {
JniWrapper.SetTimeOfDayPref(Integer.parseInt((String) timeOfDayPref.getValue())); JniWrapper.SetTimeOfDayPref(Integer.parseInt((String) timeOfDayPref.getValue()));
} }
if (snowPref.getKey().compareToIgnoreCase("Snow") == 0) { if (snowPref.getKey().compareToIgnoreCase("Snow") == 0) {
if (!snowPref.isChecked()) if (!snowPref.isChecked())
{ {
@ -51,7 +51,7 @@ public class Prefs extends PreferenceActivity implements
{ {
JniWrapper.SetSnowPref(true); JniWrapper.SetSnowPref(true);
} }
} }
} }

View File

@ -1,10 +1,36 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent"> 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> <RelativeLayout
<ListView android:layout_width="fill_parent" android:id="@+id/android_list" android:layout_height="wrap_content"></ListView> android:id="@+id/LinearLayout01"
<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> 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="@android:id/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> </LinearLayout>