Jump to content

Recommended Posts

Posted

Please consider this piece of code:

#include "App.h"

App::App() : window(NULL), context(NULL), world(NULL), camera(NULL)
{
}

App::~App()
{
   delete world;
   delete window;
}

Leadwerks::Model *model = NULL;

bool App::Start()
{
   window = Leadwerks::Window::Create();
   context = Leadwerks::Context::Create(window);
   world = Leadwerks::World::Create();
   camera = Leadwerks::Camera::Create();
   camera->Move(0, 0, -3);

   Leadwerks::Light *light = Leadwerks::DirectionalLight::Create();

   light->SetRotation(35, 35, 0);
   model = Leadwerks::Model::Box();
   model->SetColor(0.0, 0.0, 1.0);
   return true;
}

bool App::Loop()
{
   if (window->Closed() || window->KeyDown(Leadwerks::Key::Escape))
       return false;
   if (camera)
       if (window->KeyDown(Leadwerks::Key::Space))
       {
           camera->Release(); // or camera->Hide()
           camera = NULL;
       }
   model->Turn(0, Leadwerks::Time::GetSpeed(), 0);
   Leadwerks::Time::Update();
   world->Update();
   world->Render();
   context->Sync();
   return true;
}

After pressing the space key, only a blank black screen should be visible. But strangely the cube is still visible, without rotating.

How I can have the 3D world invisible when the camera is deleted?

Posted

hmmm... strange

I call the Clear() method:

bool App::Loop()
{
   if (window->Closed() || window->KeyDown(Leadwerks::Key::Escape))
       return false;
   if (camera)
   {
       if (window->KeyDown(Leadwerks::Key::Space))
       {
           camera->Release();
           camera = NULL;
           context->Clear();
       }
   }
   model->Turn(0, Leadwerks::Time::GetSpeed(), 0);
   Leadwerks::Time::Update();
   world->Update();
   world->Render();
   context->Sync();
   return true;
}

but the screen is flashing

Posted
bool App::Loop()
{
       if (window->Closed() || window->KeyDown(Leadwerks::Key::Escape))
               return false;
       if (camera)
       {
               if (window->KeyDown(Leadwerks::Key::Space))
               {
                       camera->Release();
                       camera = NULL;
               }
       }
       model->Turn(0, Leadwerks::Time::GetSpeed(), 0);
       Leadwerks::Time::Update();
       world->Update();
       if (camera)
       {
               world->Render();
       }
       else
       {
               context->Clear();
       }
       context->Sync();
       return true;
}

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...