Jump to content
  • entries
    943
  • comments
    5,899
  • views
    923,763

Map Viewer available to subscribers


Josh

2,043 views

 Share

A map viewer application is now available for beta subscribers. This program will load any Leadwerks map and let you fly around in it, so you can see the performance difference the new renderer makes. I will be curious to hear what kind of results you see with this:

Program is not tested with all hardware yet, and functionality is limited.

  • Like 3
  • Confused 1
 Share

5 Comments


Recommended Comments

Great work!  I haven't any of my own maps to test with as my game is programmed entirely in C++.  Curious though as to if you have any ideas when we might get Turbo ready for C++ use?

Link to comment
5 hours ago, SpiderPig said:

Great work!  I haven't any of my own maps to test with as my game is programmed entirely in C++.  Curious though as to if you have any ideas when we might get Turbo ready for C++ use?

I’ll have a new library available soon. I want to make sure this is working first.

  • Upvote 1
Link to comment

This is what the main.cpp file looks like in this program:

#include "Leadwerks.h"

using namespace Leadwerks;

int main(int argc, const char *argv[])
{
	//Create a window
	auto window = CreateWindow("MyGame", 0, 0, 1280, 720);
	
	//Create a rendering context
	auto context = CreateContext(window);

	//Create the world
	auto world = CreateWorld();

	//Load a map
	auto map = LoadMap(world, "Maps/start.map");

	//Find a camera
	shared_ptr<Camera> camera;
	for (auto entity : map->entities)
	{
		if (dynamic_pointer_cast<Light>(entity) == nullptr)
		{
			camera = dynamic_pointer_cast<Camera>(entity);
			if (camera != nullptr) break;
		}
	}

	//Create a camera if one was not found
	if (camera == nullptr) camera = CreateCamera(world);

	//Enable camera free look
	camera->SetFreeLookMode(true);
	window->HideMouse();

	while (window->KeyHit(KEY_ESCAPE) == false and window->Closed() == false)
	{
		//Camera movement
		if (window->KeyDown(KEY_A)) camera->Move(-0.1, 0, 0);
		if (window->KeyDown(KEY_D)) camera->Move(0.1, 0, 0);
		if (window->KeyDown(KEY_W)) camera->Move(0, 0, 0.1);
		if (window->KeyDown(KEY_S)) camera->Move(0, 0, -0.1);

		//Update the world
		world->Update();

		//Render the world
		world->Render(context);
	}
	
	//Clean up the library
	Shutdown();
	return 0;
}

 

  • Upvote 1
Link to comment

I don't remember the conversation on this before but are you required to use auto or can you still use Context*, Window*, etc?

Link to comment
4 hours ago, gamecreator said:

I don't remember the conversation on this before but are you required to use auto or can you still use Context*, Window*, etc?

Use of the "auto" keyword is optional. The full declaration of these variables would be like this:

shared_ptr<Window> window = CreateWindow(...
shared_prr<Context> context = CreateContext(...

So you can see why I prefer "auto". The new engine uses shared pointers only. Raw pointers are never exposed in the API. This is wonderful because it means your game can never have an invalid pointer. The worst thing that can happen is a slow memory leak.

In Lua it is still just a variable:

local window = CreateWindow(...
local context = CreateContext(...

 

  • Upvote 1
Link to comment
Guest
Add a comment...

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

×
×
  • Create New...