restored deleted files
This commit is contained in:
parent
9d4e34bbc3
commit
648e7119ba
8
.classpath
Normal file
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
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>
|
77
jni/Android.mk
Normal file
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
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
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
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
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
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
|
Loading…
Reference in New Issue
Block a user