sdxsdx Posted June 20, 2023 Share Posted June 20, 2023 How to show FPS inside the game and how to increase the distance for shadow shading? Many thanks for any help. Quote Link to comment Share on other sites More sharing options...
sdxsdx Posted June 20, 2023 Author Share Posted June 20, 2023 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. Quote Link to comment Share on other sites More sharing options...
sdxsdx Posted June 20, 2023 Author Share Posted June 20, 2023 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. Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted June 20, 2023 Solution Share Posted June 20, 2023 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. Quote 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 More sharing options...
sdxsdx Posted June 20, 2023 Author Share Posted June 20, 2023 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. Quote Link to comment Share on other sites More sharing options...
Josh Posted June 20, 2023 Share Posted June 20, 2023 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. 1 Quote 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 More sharing options...
sdxsdx Posted June 20, 2023 Author Share Posted June 20, 2023 Hope the shadow function works soon. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.