Jump to content

How to show FPS in game and how to increase the distance for shadow shading?


Go to solution Solved by Josh,

Recommended Posts

Posted

 

I have found:

auto font = LoadFont("Fonts/arial.ttf");
    auto sprite = CreateSprite(world, font, "", 18);
    sprite->SetRenderLayers(128);
    sprite->SetPosition(2, framebuffer->size.y - font->GetHeight(18) - 2, 0);

    //Main loop
    while (window->Closed() == false)
    {
        //Display the feamerate
        sprite->SetText("FPS: " + String(world->renderstats.framerate));

        world->Update();
        world->Render(framebuffer);
    }

 

but I still can't see the fps.

 

Posted

 

auto sprite = CreateSprite(world, font, "FPS", 18);
    sprite->SetRenderLayers(128);
    sprite->SetPosition(2, framebuffer->size.y - font->GetHeight(18) - 2, 0);
    sprite->SetRenderLayers(2);
    world->RecordStats();

    auto uicam = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
    uicam->SetClearMode(CLEAR_DEPTH);
    uicam->SetRenderLayers(2);
    uicam->SetPosition(framebuffer->size.x / 2, framebuffer->size.y / 2);

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        sprite->SetText("FPS:" + (String)world->renderstats.framerate);
        while (PeekEvent()) {
            ui->ProcessEvent(WaitEvent());
        }
        world->Update();
        world->Render(framebuffer);
    }

 

 

I modified some lines and this works for fps showing.

 

The second question is still not answered.

 

  • Solution
Posted

In the default main.lua script there is some code that shows stats and FPS.

	--Render statistics
	context:SetBlendMode(Blend.Alpha)
	if DEBUG then
		context:SetColor(1,0,0,1)
		context:DrawText("Debug Mode",2,2)
		context:SetColor(1,1,1,1)
		context:DrawStats(2,22)
		context:SetBlendMode(Blend.Solid)
	else
		--Toggle statistics on and off
		if (window:KeyHit(Key.F11)) then showstats = not showstats end
		if showstats then
			context:SetColor(1,1,1,1)
			context:DrawText("FPS: "..Math:Round(Time:UPS()),2,2)
		end
	end

I usually use a third-party tool like FRAPS because it ensures consistency across all programs.

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted
3 hours ago, Josh said:

In the default main.lua script there is some code that shows stats and FPS.

	--Render statistics
	context:SetBlendMode(Blend.Alpha)
	if DEBUG then
		context:SetColor(1,0,0,1)
		context:DrawText("Debug Mode",2,2)
		context:SetColor(1,1,1,1)
		context:DrawStats(2,22)
		context:SetBlendMode(Blend.Solid)
	else
		--Toggle statistics on and off
		if (window:KeyHit(Key.F11)) then showstats = not showstats end
		if showstats then
			context:SetColor(1,1,1,1)
			context:DrawText("FPS: "..Math:Round(Time:UPS()),2,2)
		end
	end

I usually use a third-party tool like FRAPS because it ensures consistency across all programs.

Thanks you, how could I increase the shadow rendering distance? I have tired  world->SetLightQuality(2) or light->SetRange(10000) or     light->SetRange(-10000,10000), it doesn't work.

   

Posted

Other than setting the light quality, you don't have that much control over directional lights. They can only cover a limited area.

In Ultra I plan to have a command like Light:SetShadowDistance(range, stage) to provide more control over this.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

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.

×
×
  • Create New...