Jump to content

Getting rid of App class


Josh
 Share

Recommended Posts

I want to get rid of the C++ App class and modify all examples to work in the main function like this:

#include "Leadwerks.h"

 

using namespace Leadwerks;

 

int main(int argc, const char *argv[])

{

Leadwerks::Window* window = Window::Create();

Context* context = Context::Create(window);

World* world = World::Create();

Camera* camera = Camera::Create();

camera->SetRotation(35, 0, 0);

camera->Move(0, 0, -4);

Light* light = DirectionalLight::Create();

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

 

//Create a model

Model* model = Model::Box();

 

while (true)

{

if (window->Closed() || window->KeyDown(Key::Escape)) return false;

 

model->SetPosition(Math::Sin(Time::GetCurrent() / 10.0), 0, 0);

 

Leadwerks::Time::Update();

world->Update();

world->Render();

 

context->SetBlendMode(Blend::Alpha);

context->DrawText(model->GetPosition().ToString(), 2, 2);

 

context->Sync();

}

return 0;

}

 

Your existing projects that use App.cpp will still work and don't have to be changed.

  • Upvote 2

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

I think that is better than we have right now. Whenever I start a new project I have to get rid of the Start and Loop function and write it from scratch which looks similar to that.

 

Removing the App class does make you assume that there's only one application per run, which is a perfectly fine standpoint. I don't see anyone making two games in one executable. It's also good that there's less (perhaps unnecessary) overhead now, makes it easier to understand what's going on. In case people do want multiple applications in one executable then they can create their own App class.

 

I'd say do it.

Using Leadwerks Professional Edition (Beta), mainly using C++.

Windows 10 / Linux Mint, Visual Studio 2017. GPU: NVidia GeForce GTX970, CPU: Intel i7 7700K @ 4.20 GHz

Previously known as Evayr.

Link to comment
Share on other sites

The reason this was originally implemented is mobile, which is no longer relevant. If this is ever again pursued, threads can be used to control the program execution so that the Main loop still runs as expected.

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

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