Page 78 of 91

Re: "Questions that don't deserve their own thread" thread

Posted: Sat Nov 05, 2016 10:30 pm
by Dudenheit
Hello!
I have a question, that don't deserve a own thread :-)
If you have some objects in your game, and each draws an image in your virtual world, there is always a chance that not all images are on the screen.
Like, the player is walking away from a npc and the npc is drifted out of the screen.

Actually I have to include some sort of z-sorting and stumble over the question to check first, if the object is on screen. And after this successful check, the z of the object is sorted. So I stumbled over the question if you have to check the "on-screen"-property of objects for drawing, too to improve the performance of the love.draw-function.
Do you check, if the world-position is on screen before drawing the image? Does this improve the performance?

Re: "Questions that don't deserve their own thread" thread

Posted: Sun Nov 06, 2016 3:31 am
by raidho36
If you frustum cull every individual object, with modern GPUs that results in bottlenecking the CPU and framerate drops just as well. E.g. if you use sprite batches, it's not slower to render all sprites in the scene indiscriminately compared to only rendering the specific ones in the view until amount of off-screen sprites gets absolutely ridiculous. It's a tradeoff between GPU performance and CPU performance and you need to strike the right balance, and it will hinge at its own particular point for each hardware configuration.

Having that said, modern GPUs render very fast but are starting to render slow, so if setup time is significant compared to render time (e.g. rendering 2-poly individual sprites vs. 2 million polygon batches) then minimizing amount of calls to the GPU is a sure way to improve rendering times. In most practical cases, arranging your render order so that GPU doesn't need to change current texture and current shader will improve performance miles better than camera frustum culling.

Re: "Questions that don't deserve their own thread" thread

Posted: Mon Nov 14, 2016 4:22 pm
by megalukes
Quick question. I have an image of 100x100 pixels and I want to draw it in an area of 128x128 pixels (I want to stretch it to that exact size). What would be the easier way to do it?

Re: "Questions that don't deserve their own thread" thread

Posted: Mon Nov 14, 2016 4:36 pm
by Nixola
[wiki]love.graphics.draw[/wiki]([wiki]Image[/wiki], x, y, 0, 128/[wiki](Image):getWidth[/wiki](), 128/[wiki](Image):getHeight[/wiki]())

Re: "Questions that don't deserve their own thread" thread

Posted: Mon Nov 14, 2016 4:57 pm
by s-ol
Nixola wrote:[wiki]love.graphics.draw[/wiki]([wiki]Image[/wiki], x, y, 0, 128/[wiki](Image):getWidth[/wiki](), 128/[wiki](Image):getHeight[/wiki]())
you got my vote for most well-linked answer of 2016

Re: "Questions that don't deserve their own thread" thread

Posted: Mon Nov 14, 2016 5:01 pm
by megalukes
Nixola wrote:[wiki]love.graphics.draw[/wiki]([wiki]Image[/wiki], x, y, 0, 128/[wiki](Image):getWidth[/wiki](), 128/[wiki](Image):getHeight[/wiki]())
Man, thanks. I haven't thought about using this division.
s-ol wrote:
Nixola wrote:[wiki]love.graphics.draw[/wiki]([wiki]Image[/wiki], x, y, 0, 128/[wiki](Image):getWidth[/wiki](), 128/[wiki](Image):getHeight[/wiki]())
you got my vote for most well-linked answer of 2016
He's got my vote too.

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Nov 16, 2016 9:46 am
by RadioactiveGears
Dudenheit wrote:Hello!
I have a question, that don't deserve a own thread :-)
If you have some objects in your game, and each draws an image in your virtual world, there is always a chance that not all images are on the screen.
Like, the player is walking away from a npc and the npc is drifted out of the screen.

Actually I have to include some sort of z-sorting and stumble over the question to check first, if the object is on screen. And after this successful check, the z of the object is sorted. So I stumbled over the question if you have to check the "on-screen"-property of objects for drawing, too to improve the performance of the love.draw-function.
Do you check, if the world-position is on screen before drawing the image? Does this improve the performance?
Yes it does improve performance. If you have no checks for this kind of thing then you give the GPU too many draw calls, because then it has to process EVERYTHING that is in your map at once.
I suggest you do the checks in a function that runs in love.update and have a variable like "draw = false" and use that variable in the draw function. If you do the complete check in the draw function then it is better than nothing but still slow.
I think this was what you asked at least.

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Nov 16, 2016 6:24 pm
by parallax7d
Are the screen, canvases and pixel shaders the only possible render destinations for love.graphics calls such as rectangle?

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Nov 16, 2016 8:45 pm
by D0NM
parallax7d wrote:Are the screen, canvases and pixel shaders the only possible render destinations for love.graphics calls such as rectangle?
Yes. For any graphics such as text, shapes, rectangles etc.

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Nov 16, 2016 9:10 pm
by Remscar
I've been having trouble getting an external console to show up on windows.

I've tried modifying conf.lua as such:
conf.lua

Code: Select all

function love.conf(t)
	t.console = true
end
I've also tried running the game with the latest version of love using the lovec.exe
I've also tried running the game with --console in the command line.

In case it's relevant, I do have a custom love.run function, and I'm using Windows 10.

Has anyone else had similar problems? I can provide code as necessary.
Any help would be appreciated, this has been a really annoying problem for me.

Edit
After doing more digging i'm thinking that the console output is getting sent back to Atom (Text editor I use and I launch the game from). Is there a way to force Love2d to make a console window and send the output there instead?

Edit 2
Solved it. Thanks bartbes, you sent me down the right path.