Jump to content

world,context and window in other class


AggrorJorn
 Share

Recommended Posts

I am trying to create a new class that encapsulates the default creation of a window, context and world. However as soon as I try to add a camera, the program no longer works.

 

So the app.cpp looks like this:

bool App::Start()
{
game = new Game();
return true;
}
bool App::Loop()
{
game->Update();

return true;
}

 

The game.cpp looks like this (some code is removed to keep it clean):

Game::Game()
{
//Create a window
window = Leadwerks::Window::Create("Test 3");
//Create a context
context = Leadwerks::Context::Create(window);

//Create a world
world = Leadwerks::World::Create();


//Create a camera
//cam = Leadwerks::Camera::Create();
}
void Game::Update()
{
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync(false);
}

 

The program works, but as soon as I add a camera (removing the comments), the program crashes.

post-45-0-39109400-1367008582_thumb.jpg

Link to comment
Share on other sites

I get this same error when I run the default VS project. I can build and run the exe created from it just fine, but running from VS gives me the error on the same line as you Aggror. I didn't make any new filters or anything. App source files are in their source/header filters like they are by default. I even tried moving them to the root project filter and it didn't work either.

 

Yeah, this is very annoying. I can't debug a project :(

 

The only thing different is that my project isn't in the LE projects folder and instead of another drive in another folder. Maybe I'll have to change some paths in the project.

Link to comment
Share on other sites

I do have my located on another hard drive and that works okay for me. The only thing that seems to mess it up for me is either:

  • creating filters and store the app.h and app.cpp in these filters
  • Placing the app.cpp and app.h in a different or sub folder from its original location $project/Source/

Link to comment
Share on other sites

You're killing me Aggror smile.png. I have no idea why this is giving me this error then sad.png

 

What I find interesting is if I place the following line in the App::Start() right after the context gets created it doesn't error.

 

context->SetBlendMode(Blend::Alpha);

 

 

Also if I have this line before:

 

 

Time::Update();

world->Update();

world->Render();

 

 

it doesn't error. After and it errors. Strange.

Link to comment
Share on other sites

What I eventually did was create a new project on E:/. I didn't delete, change or moved any file, folder or setting, I just recreated the classes that I needed via Add->Class and then it finally worked. However as soon as I move the app.h or cpp in to another filter, things start to go down hill. Even if you place it back in the original state, it wont work again.

Link to comment
Share on other sites

It just happened again with a test project. I found the problem though. The project worked perfectly but after removing the suo file (of which git suggests that you put in the ignore file) , it no longer works. Problem now is that I have really deleted it from computer (it is not in the trash bin.) Rebuilding simply wont work anymore.

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...