Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify loaddocument sample to take model path as param #453

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Samples/basic/loaddocument/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@
#if defined RMLUI_PLATFORM_WIN32
#include <RmlUi_Include_Windows.h>
int APIENTRY WinMain(HINSTANCE /*instance_handle*/, HINSTANCE /*previous_instance_handle*/, char* /*command_line*/, int /*command_show*/)
{
auto argc = __argc;
auto argv = __argv;
#else
int main(int /*argc*/, char** /*argv*/)
#endif
int main(int argc, char** argv)
{
#endif
const int window_width = 1024;
const int window_height = 768;

Expand Down Expand Up @@ -75,9 +78,18 @@ int main(int /*argc*/, char** /*argv*/)
// Fonts should be loaded before any documents are loaded.
Shell::LoadFonts();

// Load and show the demo document.
if (Rml::ElementDocument* document = context->LoadDocument("assets/demo.rml"))
// Load and show the document.
Rml::String path = "assets/demo.rml";
if (argc >= 2)
path = argv[1];

if (Rml::ElementDocument* document = context->LoadDocument(path))
document->Show();
else
{
Rml::Log::Message(Rml::Log::Type::LT_ERROR, "Document could not be loaded: %s. Exiting.", path.c_str());
return -1;
}

bool running = true;
while (running)
Expand Down