diff --git a/assets/test_simplelight.fragment b/assets/test_simplelight.fragment index 398d02b..0e94b96 100644 --- a/assets/test_simplelight.fragment +++ b/assets/test_simplelight.fragment @@ -1,15 +1,15 @@ precision lowp float; uniform sampler2D Texture; -uniform sampler2D NormalMap; +//uniform sampler2D NormalMap; + uniform vec3 LightDirection; uniform float TimeOfDayCoef1; uniform float TimeOfDayCoef2; -uniform float invCoef; +//uniform float invCoef; uniform vec3 TimeOfDayColor; -varying vec2 texCoord; -varying vec3 camVec; +varying vec2 texCoord; varying vec3 normVec; varying vec3 posVec; diff --git a/assets/test_simplelight.vertex b/assets/test_simplelight.vertex index 8b4d05a..71fe8da 100644 --- a/assets/test_simplelight.vertex +++ b/assets/test_simplelight.vertex @@ -1,15 +1,11 @@ attribute vec3 vPosition; attribute vec3 Normal; -attribute vec3 Tangent; -attribute vec3 Binormal; attribute vec2 vTexCoord; -uniform mat4 ModelViewMatrix; +//uniform mat4 ModelViewMatrix; uniform mat4 ProjectionMatrix; -uniform vec3 CamPos; varying vec2 texCoord; -varying vec3 camVec; varying vec3 normVec; varying vec3 posVec; @@ -19,15 +15,6 @@ void main() 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; posVec = vPosition.xyz; diff --git a/jni/android_api.cpp b/jni/android_api.cpp old mode 100644 new mode 100755 index e154036..898b2e3 --- a/jni/android_api.cpp +++ b/jni/android_api.cpp @@ -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) { + auto app = JniInitApp(width, height, 800.f, 480.f); - Application = JniInitApp(width, height, 800.f, 480.f); - - boost::get(Renderer->Camera).SetAlpha((lastOffsetX) * pi / 180.f); - Application->SkyTexShift = lastOffsetX*0.01f; - - + if (app) + { + Application = app; + } + + boost::get(Renderer->Camera).SetAlpha((lastOffsetX) * pi / 180.f); + Application->SkyTexShift = lastOffsetX*0.01f; } diff --git a/jni/main_code.cpp b/jni/main_code.cpp index 63c0a29..82139f3 100755 --- a/jni/main_code.cpp +++ b/jni/main_code.cpp @@ -36,6 +36,8 @@ TPanoramicCamera mCamera; const float cameraDistance = 100.f; std::vector iceIndexes; +TRenderPair water; + class LoadingQueueVisitor : public boost::static_visitor { public: @@ -249,7 +251,7 @@ void TAndroidApplication::DrawSceneWithoutWater(bool inv) Renderer->TranslateMatrix(Vector3f(0, 0.0f, 0)); } - + Renderer->PushShader("SimplelightShader"); @@ -265,7 +267,7 @@ void TAndroidApplication::DrawSceneWithoutWater(bool inv) RenderUniform1f("invCoef", 1.0f); RenderUniform1f("extraSpace", 0.0f); } - + Vector3f dayColor = Vector3f(0,0,0); Vector3f nightColor = Vector3f(0, 0.1f, 0.2f); @@ -290,7 +292,7 @@ void TAndroidApplication::DrawSceneWithoutWater(bool inv) RenderUniform1f("TimeOfDayCoef2", 0.4f); } - + Renderer->PushPerspectiveProjectionMatrix(pi/6, Renderer->GetMatrixWidth() / Renderer->GetMatrixHeight(), 1.f, 450.f); //Renderer->PushMatrix(); //mCamera.SetCamView(); @@ -351,70 +353,85 @@ void TAndroidApplication::DrawSnow() Renderer->PopProjectionMatrix(); } -void TAndroidApplication::DrawAllScene(bool toScreen) -{ - //glClearColor(1.f, 0.f, 1.f, 1.0f); - glClearColor(0.9f, 0.9f, 1.f, 1.0f); - glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); +void TAndroidApplication::DrawAllScene(bool toScreen) { + //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); + glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - Renderer->PushMatrix(); - Renderer->SetGLCamView(); + Renderer->PushMatrix(); + Renderer->SetGLCamView(); - Renderer->PushShader("ClipShader"); + Renderer->PushShader("ClipShader"); + Renderer->SwitchToFrameBuffer("WaterFrame"); + Renderer->SetGLCamView(); + Renderer->ScaleMatrix(Vector3f(1, -1, 1)); - Renderer->SwitchToFrameBuffer("WaterFrame"); - Renderer->SetGLCamView(); - Renderer->ScaleMatrix(Vector3f(1, -1, 1)); + glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + 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->SwitchToScreen(); - } - else - { - Renderer->SwitchToFrameBuffer("ScreenshotFrame"); - } + { + Renderer->PushShader("NormShader"); - Renderer->SetGLCamView(); - - 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"); - } + RenderUniform1f("Time", WaterTimer); - 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 - Renderer->PopShader(); - glClear(GL_DEPTH_BUFFER_BIT); @@ -448,7 +465,7 @@ void TAndroidApplication::InnerInit() GetConsole() << "Inner init go!\n"; #ifdef TARGET_ANDROID - ResourceManager->PathToResources = ""; + ST::PathToResources = ""; #endif #ifdef TARGET_WIN32 ST::PathToResources = "../../assets/"; @@ -486,6 +503,10 @@ void TAndroidApplication::InnerInit() 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(Renderer->Camera).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); - GetConsole()<<"Inner init end!\n"; + GetConsole() << "Inner init end!\n"; m2.unlock(); } diff --git a/proj.android-studio/app/CMakeLists.txt b/proj.android-studio/app/CMakeLists.txt index 252d8a7..1659b89 100755 --- a/proj.android-studio/app/CMakeLists.txt +++ b/proj.android-studio/app/CMakeLists.txt @@ -1,7 +1,14 @@ cmake_minimum_required(VERSION 3.4.1) -set(BOOST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../boost_1_67_0) -set(BOOST_GIL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/boost-gil-extension) +#set( CMAKE_CXX_STANDARD 17 ) + + +#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(LIBPNG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/libpng_1.4.1_android) 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(LUA_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/lua-5.3.4/src) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../tes-engine) -include_directories(${BOOST_PATH}) +include_directories(${LIBJPEG_PATH}/vc10) +include_directories(${LUA_PATH}) include_directories(${EIGEN_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(${LIBJPEG_PATH}) include_directories(${ZIP_PATH}) include_directories(${BOOST_GIL_PATH}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../tes-engine) add_definitions(-DTARGET_ANDROID) diff --git a/proj.android-studio/app/src/main/AndroidManifest.xml b/proj.android-studio/app/src/main/AndroidManifest.xml index 6062ef6..42e214a 100755 --- a/proj.android-studio/app/src/main/AndroidManifest.xml +++ b/proj.android-studio/app/src/main/AndroidManifest.xml @@ -1,25 +1,41 @@ - - - + + + + + + + - + + - - + + - \ No newline at end of file diff --git a/proj.android-studio/app/src/main/java/fishrungames/mountainwallpaper/Prefs.java b/proj.android-studio/app/src/main/java/fishrungames/mountainwallpaper/Prefs.java old mode 100644 new mode 100755 index 0e0c578..79c7c3e --- a/proj.android-studio/app/src/main/java/fishrungames/mountainwallpaper/Prefs.java +++ b/proj.android-studio/app/src/main/java/fishrungames/mountainwallpaper/Prefs.java @@ -31,17 +31,17 @@ public class Prefs extends PreferenceActivity implements 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()) { @@ -51,7 +51,7 @@ public class Prefs extends PreferenceActivity implements { JniWrapper.SetSnowPref(true); } - } + } } diff --git a/proj.android-studio/app/src/main/res/layout/prefliste.xml b/proj.android-studio/app/src/main/res/layout/prefliste.xml index db4d4e5..3c2ad7c 100755 --- a/proj.android-studio/app/src/main/res/layout/prefliste.xml +++ b/proj.android-studio/app/src/main/res/layout/prefliste.xml @@ -1,10 +1,36 @@ - - - - + xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent"> + + + + + + + + + + + + +