2013-01-19 20:02:34 +00:00
|
|
|
#include "main_code.h"
|
|
|
|
#ifdef TARGET_ANDROID
|
|
|
|
#include "android_api.h"
|
|
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include "include/Engine.h"
|
|
|
|
|
|
|
|
#include "main_code.h"
|
|
|
|
|
|
|
|
extern float lastOffsetX;
|
|
|
|
|
|
|
|
#ifdef TARGET_WIN32
|
|
|
|
bool RedBkgPref = true;
|
|
|
|
|
|
|
|
#else
|
|
|
|
extern bool RedBkgPref;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TAndroidApplication::TAndroidApplication()
|
|
|
|
: TApplication()
|
|
|
|
, Inited(false)
|
|
|
|
//, LiteModel(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TAndroidApplication::LoadModels()
|
|
|
|
{
|
|
|
|
|
|
|
|
mat3 m(vec4(0,1*sin(pi/8 + pi/2),0,1*cos(pi/8 + pi/2)));
|
|
|
|
/*
|
|
|
|
LiteModel = new TLiteModel;
|
|
|
|
LiteModel->LoadModel("bt_box_yellow.lm1");
|
|
|
|
LiteModel->ScaleModel(10.0f);
|
|
|
|
LiteModel->RotateModel(m);
|
|
|
|
LiteModel->UpdateVBO();*/
|
|
|
|
|
|
|
|
FlexModel = ResourceManager->FlexModelManager.InstanciateModel("model.xml");
|
|
|
|
|
|
|
|
//FlexModel.MoveModel(vec3(1, -4, -4));
|
|
|
|
FlexModel.ScaleModel(1.5f);
|
|
|
|
FlexModel.RotateModel(m);
|
|
|
|
FlexModel.RefreshBuffer();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TAndroidApplication::DrawAllScene()
|
|
|
|
{
|
|
|
|
glClearColor(0.f, 0.f, 0.f, 1.0f);
|
|
|
|
|
|
|
|
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
|
|
Renderer->PushProjectionMatrix(1,1);
|
|
|
|
Renderer->LoadIdentity();
|
|
|
|
|
|
|
|
if (RedBkgPref)
|
|
|
|
{
|
|
|
|
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["bkg_red.png"]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["bkg_blue.png"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
Renderer->DrawRect(vec2(0.0f, 0.f), vec2(1.f, 1.f), vec2(0.f, 0.f), vec2(1.f, 1.f));
|
|
|
|
|
|
|
|
Renderer->PopProjectionMatrix();
|
|
|
|
|
|
|
|
glClear(GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
Renderer->SetGLCamView();
|
|
|
|
|
|
|
|
//LiteModel->DrawVBO();
|
|
|
|
FlexModel.Draw();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void TAndroidApplication::InnerInit()
|
|
|
|
{
|
|
|
|
RenderMutex.lock();
|
|
|
|
|
|
|
|
CheckGlError();
|
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
|
|
|
*Console<<"Inner init go!\n";
|
|
|
|
|
|
|
|
#ifdef TARGET_ANDROID
|
|
|
|
ResourceManager->PathToResources = "";
|
|
|
|
#endif
|
|
|
|
#ifdef TARGET_WIN32
|
|
|
|
ResourceManager->PathToResources = "../../assets/";
|
|
|
|
#endif
|
|
|
|
ResourceManager->ShaderManager.AddShader("DefaultShader", "gui_transparent.vertex", "gui_transparent.fragment");
|
|
|
|
Renderer->PushShader("DefaultShader");
|
|
|
|
|
|
|
|
ResourceManager->TexList.AddTexture("bkg_red.png");
|
|
|
|
ResourceManager->TexList.AddTexture("bkg_blue.png");
|
|
|
|
|
|
|
|
CheckGlError();
|
|
|
|
|
2013-02-10 12:47:51 +00:00
|
|
|
boost::get<TPanoramicCamera>(Renderer->Camera).MovePhi(pi/32);
|
2013-01-19 20:02:34 +00:00
|
|
|
|
|
|
|
//ResourceManager->ModelManager.AddLiteModel("bt_box_yellow.lm1");
|
|
|
|
|
|
|
|
|
|
|
|
ResourceManager->TexList.AddTexture("bt_box_yellow.bmp");
|
|
|
|
ResourceManager->FlexModelManager.LoadModelFromXml("model.xml");
|
|
|
|
|
|
|
|
|
|
|
|
LoadModels();
|
|
|
|
|
2013-02-10 12:47:51 +00:00
|
|
|
if (Renderer->GetScreenWidth() > Renderer->GetScreenHeight())
|
2013-01-19 20:02:34 +00:00
|
|
|
{
|
2013-02-10 12:47:51 +00:00
|
|
|
boost::get<TPanoramicCamera>(Renderer->Camera).MoveDist(30.f);
|
2013-01-19 20:02:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
2013-02-10 12:47:51 +00:00
|
|
|
boost::get<TPanoramicCamera>(Renderer->Camera).MoveDist(45.f);
|
2013-01-19 20:02:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CheckGlError();
|
|
|
|
|
2013-02-10 12:47:51 +00:00
|
|
|
glViewport(0, 0, Renderer->GetScreenWidth(), Renderer->GetScreenHeight());
|
|
|
|
|
|
|
|
Renderer->SetPerspectiveProjection(pi / 6.f, 1.0f, 100.0f);
|
2013-01-19 20:02:34 +00:00
|
|
|
|
|
|
|
*Console<<"Inner init end!\n";
|
|
|
|
|
|
|
|
RenderMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TAndroidApplication::InnerDeinit()
|
|
|
|
{
|
|
|
|
RenderMutex.lock();
|
|
|
|
Inited = false;
|
|
|
|
/*
|
|
|
|
if (LiteModel != NULL)
|
|
|
|
{
|
|
|
|
LiteModel->FreeModel();
|
|
|
|
delete LiteModel;
|
|
|
|
LiteModel = NULL;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
RenderMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TAndroidApplication::InnerDraw()
|
|
|
|
{
|
|
|
|
RenderMutex.lock();
|
|
|
|
|
|
|
|
DrawAllScene();
|
|
|
|
|
|
|
|
RenderMutex.unlock();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TAndroidApplication::InnerUpdate(cardinal dt)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void TAndroidApplication::InnerOnMove(vec2 shift)
|
|
|
|
{
|
2013-02-10 12:47:51 +00:00
|
|
|
boost::get<TPanoramicCamera>(Renderer->Camera).MoveAlpha(-pi*shift.v[0]*0.1f);
|
2013-01-19 20:02:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TAndroidApplication::OnMouseDown(TMouseState& mouseState)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|