2
0

HelloPolycodeApp.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "HelloPolycodeApp.h"
  2. HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) : EventHandler() {
  3. #ifdef __APPLE__
  4. core = new CocoaCore(view, 640,480,false,false,0,0,90);
  5. #else
  6. core = new SDLCore(view, 640,480,false,false,0,0,90);
  7. #endif
  8. CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
  9. CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);
  10. CoreServices::getInstance()->getResourceManager()->addDirResource("Resources", false);
  11. Scene *scene = new Scene();
  12. ScenePrimitive *ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 5,5);
  13. ground->setMaterialByName("GroundMaterial");
  14. scene->addEntity(ground);
  15. ScenePrimitive *box = new ScenePrimitive(ScenePrimitive::TYPE_TORUS, 0.8,0.3,30,20);
  16. box->setMaterialByName("CubeMaterial");
  17. box->setPosition(0.0, 0.5, 0.0);
  18. scene->addEntity(box);
  19. SceneLight *light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  20. light->setPosition(1,2,1);
  21. scene->addLight(light);
  22. scene->getDefaultCamera()->setPosition(7,7,7);
  23. scene->getDefaultCamera()->lookAt(Vector3(0,0,0));
  24. }
  25. HelloPolycodeApp::~HelloPolycodeApp() {
  26. }
  27. bool HelloPolycodeApp::Update() {
  28. return core->Update();
  29. }