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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Locked
Dudenheit
Prole
Posts: 5
Joined: Wed Dec 17, 2014 7:40 am

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

Post 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?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

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

Post 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.
User avatar
megalukes
Citizen
Posts: 94
Joined: Fri Jun 27, 2014 11:29 pm
Location: Brazil

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

Post 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?
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

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

Post by Nixola »

[wiki]love.graphics.draw[/wiki]([wiki]Image[/wiki], x, y, 0, 128/[wiki](Image):getWidth[/wiki](), 128/[wiki](Image):getHeight[/wiki]())
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

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

Post 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

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
megalukes
Citizen
Posts: 94
Joined: Fri Jun 27, 2014 11:29 pm
Location: Brazil

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

Post 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.
User avatar
RadioactiveGears
Prole
Posts: 6
Joined: Sun Oct 23, 2016 8:16 pm
Location: Denmark
Contact:

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

Post 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.
User avatar
parallax7d
Citizen
Posts: 82
Joined: Wed Jul 02, 2014 11:44 pm

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

Post by parallax7d »

Are the screen, canvases and pixel shaders the only possible render destinations for love.graphics calls such as rectangle?
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

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

Post 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.
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
User avatar
Remscar
Prole
Posts: 1
Joined: Wed Nov 16, 2016 9:04 pm

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

Post 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.
Last edited by Remscar on Wed Nov 16, 2016 11:02 pm, edited 1 time in total.
Locked

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot] and 9 guests