Advertisement
Ember

new

Mar 19th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. // Application initialization ---------------------------------------------------------
  2. bool Game::Initialize()
  3. {
  4.     bool result;
  5.  
  6.     // Initialize R3D
  7.     R3D::Initialize();
  8.  
  9.     // Set the frame time
  10.     mFrameTime = floor(1000 / 60); // 60 FPS target (66.6 fps lol)
  11.  
  12.     Window::Description windowDesc;
  13.     // Setup the window
  14.     windowDesc.Width = 960;
  15.     windowDesc.Height = 640;
  16.     windowDesc.Flags.Format = Texture::Format::RGB10A2UNorm;
  17.  
  18.     // Create a window and begin initialization
  19.     result = mWindow.Create(windowDesc);
  20.     if(!result) { return false; }
  21.  
  22.     // Create the Resource and Scene managers here and store them somewhere, idk where yet
  23.  
  24.     // Prepare the resource manager
  25.     Resource::Manager* resourceManager = Resource::Manager::Singleton;
  26.     resourceManager->AddResourceLocation("/Resources/");
  27.     resourceManager->InitializeResources();
  28.  
  29.     // Prepare the scene manager
  30.     Scene::Manager* sceneManager = Scene::Manager::Singleton;
  31.     sceneManager->Initialize();
  32.  
  33.     // Create a floor and a box
  34.     Resource::Model floor, box;
  35.     floor = resourceManager->GetModel("R3D/Plane");
  36.     floor.Material = resourceManager->GetMaterial("Materials/Dirt");
  37.     box = resourceManager->GetModel("R3D/Box");
  38.     box.Material = resourceManager->GetMaterial("Materials/Brick");
  39.  
  40.     // Now place the box on top of the plane
  41.     // Create a scene node and attach the models to it
  42.     Scene::NodeID floorNode = sceneManager->CreateNode();
  43.     floorNode->AddModel(floor);
  44.     //--//
  45.     Scene::NodeID boxNode = sceneManager->CreateNode();
  46.     boxNode->AddModel(box);
  47.     //--//
  48.     floorNode->SetScale(10.0f, 10.0f, 10.0f);
  49.     //--//
  50.     boxNode->Translate(0.0f, 0.0f, -2.5f);
  51.     boxNode->SetScale(5.0f, 5.0f, 5.0f);
  52.  
  53.     return true;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement