[DEV] correct sample

This commit is contained in:
Edouard DUPIN 2016-11-10 22:24:24 +01:00
parent 21c6ab2f80
commit 183a0020d7
7 changed files with 47 additions and 38 deletions

View File

@ -6,6 +6,8 @@
#include <ege/debug.hpp> #include <ege/debug.hpp>
#include <ege/widget/Scene.hpp> #include <ege/widget/Scene.hpp>
#include <echrono/Steady.hpp>
#include <echrono/Duration.hpp>
#include <cmath> #include <cmath>
#include <ege/debug.hpp> #include <ege/debug.hpp>
@ -66,7 +68,7 @@ void ege::widget::Scene::onRegenerateDisplay() {
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
#ifdef SCENE_DISPLAY_SPEED #ifdef SCENE_DISPLAY_SPEED
static int64_t g_startTime = 0; static echrono::Steady g_startTime;
static int32_t g_counterNbTimeDisplay = 0; static int32_t g_counterNbTimeDisplay = 0;
#endif #endif
@ -76,7 +78,7 @@ void ege::widget::Scene::onRegenerateDisplay() {
void ege::widget::Scene::onDraw() { void ege::widget::Scene::onDraw() {
#ifdef SCENE_DISPLAY_SPEED #ifdef SCENE_DISPLAY_SPEED
g_counterNbTimeDisplay++; g_counterNbTimeDisplay++;
g_startTime = ewol::getTime(); g_startTime = echrono::Steady::now();
#endif #endif
// draw constant object : // draw constant object :
@ -142,11 +144,11 @@ void ege::widget::Scene::onDraw() {
m_env->getParticuleEngine().draw(*camera); m_env->getParticuleEngine().draw(*camera);
} }
#ifdef SCENE_DISPLAY_SPEED #ifdef SCENE_DISPLAY_SPEED
float localTime = (float)(ewol::getTime() - g_startTime) / 1000.0f; echrono::Duration localTime = echrono::Steady::now() - g_startTime;
if (localTime>1) { if (localTime>1) {
EWOL_ERROR(" scene : " << localTime << "ms " << g_counterNbTimeDisplay); EWOL_ERROR(" scene : " << localTime << " " << g_counterNbTimeDisplay);
} else { } else {
EWOL_DEBUG(" scene : " << localTime << "ms " << g_counterNbTimeDisplay); EWOL_DEBUG(" scene : " << localTime << " " << g_counterNbTimeDisplay);
} }
#endif #endif
} }
@ -168,6 +170,7 @@ void ege::widget::Scene::systemDraw(const ewol::DrawProperty& _displayProp) {
#ifdef SCENE_BRUT_PERFO_TEST #ifdef SCENE_BRUT_PERFO_TEST
int64_t tmp___startTime0 = ewol::getTime(); int64_t tmp___startTime0 = ewol::getTime();
#endif #endif
//EGE_INFO("DRAW ...");
gale::openGL::bindBuffer(0); gale::openGL::bindBuffer(0);
gale::openGL::push(); gale::openGL::push();
// here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left // here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left

View File

@ -64,7 +64,7 @@ def configure(target, my_module):
'ege/Ray.cpp', 'ege/Ray.cpp',
]) ])
my_module.copy_path('data/ParticuleMesh.*') my_module.copy_path('data/ParticuleMesh.*')
my_module.add_depend(['ewol', 'bullet-physics']) my_module.add_depend(['ewol', 'bullet-physics', 'echrono'])
my_module.add_flag('c++', [ my_module.add_flag('c++', [
'-Wno-write-strings', '-Wno-write-strings',
'-Wmissing-field-initializers', '-Wmissing-field-initializers',

View File

@ -92,6 +92,7 @@ void appl::Windows::init() {
if (myMesh != nullptr) { if (myMesh != nullptr) {
m_env->addStaticMeshToDraw(myMesh); m_env->addStaticMeshToDraw(myMesh);
} }
m_env->propertyStatus.set(ege::gameStart);
} }

View File

@ -22,13 +22,15 @@
appl::Windows::Windows() { appl::Windows::Windows() {
addObjectType("appl::Windows"); addObjectType("appl::Windows");
propertyTitle.setDirectCheck("example ege : DoubleView"); propertyTitle.setDirectCheck("example ege : Collision");
} }
static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() { static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() {
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:texturedNoMaterial.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:texturedNoMaterial.prog");
if (out != nullptr) { if (out == nullptr) {
return out;
}
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>(); ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
// set the element material properties : // set the element material properties :
material->setAmbientFactor(vec4(1,1,1,1)); material->setAmbientFactor(vec4(1,1,1,1));
@ -44,7 +46,7 @@ static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() {
out->addMaterial("basics", material); out->addMaterial("basics", material);
//material->setImageSize(ivec2(size,size)); //material->setImageSize(ivec2(size,size));
egami::Image* myImage = material->get(); egami::Image* myImage = material->get();
if (nullptr == myImage) { if (myImage == nullptr) {
return out; return out;
} }
myImage->clear(etk::color::black); myImage->clear(etk::color::black);
@ -58,7 +60,6 @@ static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() {
out->createViewBox("basics", 1000/* distance */); out->createViewBox("basics", 1000/* distance */);
// generate the VBO // generate the VBO
out->generateVBO(); out->generateVBO();
}
return out; return out;
} }
@ -133,8 +134,8 @@ void appl::Windows::init() {
element->iaEnable(); element->iaEnable();
m_env->addElement(element); m_env->addElement(element);
} }
m_env->propertyStatus.set(ege::gameStart);
} }
namespace appl { namespace appl {
@ -171,6 +172,7 @@ bool appl::Windows::onEventInput(const ewol::event::Input& _event) {
element->setMass(20); element->setMass(20);
element->setLinearVelocity(ray.getDirection()*100); element->setLinearVelocity(ray.getDirection()*100);
m_env->addElement(element); m_env->addElement(element);
APPL_INFO("Create cube at position " << ray.getOrigin() << " velocity: " << ray.getDirection()*100);
} }
return true; return true;
} }

View File

@ -174,6 +174,7 @@ void appl::Windows::init() {
m_env->addElement(element); m_env->addElement(element);
} }
m_env->propertyStatus.set(ege::gameStart);
} }
bool appl::Windows::onEventInput(const ewol::event::Input& _event) { bool appl::Windows::onEventInput(const ewol::event::Input& _event) {

View File

@ -113,6 +113,7 @@ void appl::Windows::init() {
m_env->addElement(element); m_env->addElement(element);
} }
} }
m_env->propertyStatus.set(ege::gameStart);
} }

View File

@ -130,6 +130,7 @@ void appl::Windows::init() {
m_env->addElement(element); m_env->addElement(element);
} }
m_env->propertyStatus.set(ege::gameStart);
} }
bool appl::Windows::onEventInput(const ewol::event::Input& _event) { bool appl::Windows::onEventInput(const ewol::event::Input& _event) {