george68 Posted January 19, 2016 Share Posted January 19, 2016 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? Quote Link to comment Share on other sites More sharing options...
reepblue Posted January 19, 2016 Share Posted January 19, 2016 When the camera is released, the last frame gets stuck. You can draw a black rectangle whenever there is no active camera being used. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
george68 Posted January 19, 2016 Author Share Posted January 19, 2016 In this case I have to draw all the 2D stuff again Quote Link to comment Share on other sites More sharing options...
Josh Posted January 19, 2016 Share Posted January 19, 2016 Just call context->Clear() after deleting the camera. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
george68 Posted January 19, 2016 Author Share Posted January 19, 2016 It didn't cross my mind. I am new to the Leadwerks That makes the job simple. Thanks Quote Link to comment Share on other sites More sharing options...
george68 Posted January 19, 2016 Author Share Posted January 19, 2016 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 Quote Link to comment Share on other sites More sharing options...
Josh Posted January 19, 2016 Share Posted January 19, 2016 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; } 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
george68 Posted January 19, 2016 Author Share Posted January 19, 2016 It works. Thanks Josh Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.