Jump to content

[Solved] Model Created at Runtime Not Visible


Aaron Symons
 Share

Recommended Posts

Hi all,

 

I've just started getting back into C++ and Leadwerks and I'm having an issue with a simple task: displaying a model created in code at runtime. The model doesn't display, and all I see is a black screen.

 

If anyone could offer any advice on how to look for the problem I would be very grateful!

 

App.h

#pragma once

 

#include "Leadwerks.h"

 

#undef GetFileType

 

using namespace Leadwerks;

 

class App

{

public:

Leadwerks::Window* window;

Context* context;

World* world;

Camera* camera;

Light* light;

 

Model* box;

 

App();

virtual ~App();

 

bool Start();

bool Loop();

};

 

App.cpp

#include "App.h"

 

using namespace Leadwerks;

 

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

 

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

 

bool App::Start()

{

// Create main window

window = Window::Create("Hello there!", 100, 100, 1024, 768, Window::Titlebar);

 

// Create context

context = Context::Create(window);

 

// Create the world

world = World::Create();

 

// Create camera

camera = Camera::Create();

camera->Move(Vec3(0, 2, -5));

 

// Create a light

light = DirectionalLight::Create();

light->SetRotation(45, 45, 0);

 

// Create a box

box = Model::Box();

box->SetPosition(-4, 0, 0);

 

 

 

return true;

}

 

bool App::Loop()

{

// Close window on 'exit button' or ESC key is pressed

if (window->Closed() || window->KeyHit(Key::Escape))

{

return false;

}

 

Time::Update();

world->Update();

world->Render();

 

return true;

}

 

Many thanks!

Win7 64-bit | Intel i7-3770 3.40GHz | NVIDIA GeForce GTX 660

Link to comment
Share on other sites

You are missing

 

context->Sync(false)

 

right between the render call and the return of the loop.

This call is important, as everything is only rendered to the backbuffer and the buffer is never switched to become front-buffer

 

Thanks!

 

Can't believe I forgot about that one! huh.png

  • Upvote 1

Win7 64-bit | Intel i7-3770 3.40GHz | NVIDIA GeForce GTX 660

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...