Search found 2058 matches

by raidho36
Tue Mar 03, 2020 5:08 am
Forum: Support and Development
Topic: [SOLVED] Lua math.cos issue
Replies: 8
Views: 3905

Re: [SOLVED] Lua math.cos issue

Lua uses C standard library (by design) and it usually provides fairly good scientific functions, horrendously slow though. LuaJIT uses hardware acceleration whenever available (by design) and hardware accelerated floating point math tends to not be very accurate, particularly the transcendental fun...
by raidho36
Tue Mar 03, 2020 1:55 am
Forum: Support and Development
Topic: [SOLVED] Lua math.cos issue
Replies: 8
Views: 3905

Re: [SOLVED] Lua math.cos issue

pgimeno wrote:
Mon Mar 02, 2020 11:40 pm
This is exactly the reason. The value returned is the cosine of that approximation. Something similar happens with math.sin(math.pi).
Nevermind that math.cos function itself only returns approximate cosine values (and of not particularly great accuracy, FYI).
by raidho36
Mon Mar 02, 2020 9:24 pm
Forum: Support and Development
Topic: [SOLVED] Lua math.cos issue
Replies: 8
Views: 3905

Re: [SOLVED] Lua math.cos issue

Welcome to the world of floating point numbers. It patently sucks but it's the best we have.
by raidho36
Mon Mar 02, 2020 1:08 am
Forum: General
Topic: Can you give me advice?
Replies: 3
Views: 2997

Re: Can you give me advice?

A game doesn't need to have pretty source code, it just needs to work. Metatables are your go-to syntax sugar for calling methods on objects. Doing it the C way is faster but that's C way, so not ideal. What __index does is, basically, hooks up another table to your existing table as a backup. It's ...
by raidho36
Fri Feb 28, 2020 7:09 pm
Forum: Support and Development
Topic: How do I efficiently update an image?
Replies: 16
Views: 5623

Re: How do I efficiently update an image?

I'm giving you PC architecture lesson because you fail to understand limitations of the hardware. There's no way to shovel large amounts of data over PCI bus without it being crazy-slow (compared to RAM-to-RAM anyway), particularly when GPU is involved because it's heavily bottlenecked by driver's t...
by raidho36
Fri Feb 28, 2020 7:01 pm
Forum: Support and Development
Topic: How do I efficiently update an image?
Replies: 16
Views: 5623

Re: How do I efficiently update an image?

You don't. You need to push the contents to the GPU before they can be rendered. GPU is a physically separate extension board, remember? You push data to it, and you push commands to it, and it executes your commands on your data, and then you can fetch the results (by default it outputs results to ...
by raidho36
Fri Feb 28, 2020 6:54 pm
Forum: Support and Development
Topic: How do I efficiently update an image?
Replies: 16
Views: 5623

Re: How do I efficiently update an image?

You changed the data that sits in RAM, of course this does nothing about the data that sits on the GPU. In case it's not clear, they're physically separate.
by raidho36
Fri Feb 28, 2020 6:43 pm
Forum: Support and Development
Topic: How do I efficiently update an image?
Replies: 16
Views: 5623

Re: How do I efficiently update an image?

ImageData holds information in RAM. In order to render anything, it needs to be on the GPU. You see my point?
by raidho36
Tue Feb 25, 2020 12:33 am
Forum: Support and Development
Topic: Any way to get canvases to be more efficient?
Replies: 38
Views: 12180

Re: Any way to get canvases to be more efficient?

480 draw calls eating 12% of the GPU power sounds about right, in by book that's pretty generous actually. Batching will reduce the amount of draw calls. If you were using version 11 or later there should be autobatching enabled; check the output of love.graphics.getStats.
by raidho36
Mon Feb 24, 2020 11:24 pm
Forum: Support and Development
Topic: Any way to get canvases to be more efficient?
Replies: 38
Views: 12180

Re: Any way to get canvases to be more efficient?

You just shove your entire map into a spritebatch, in the order in which each tile would be rendered, accounting for layers and all. Particularly gigantic maps may need splitting into chunks but yours are very small. You can break up the batch if your effects necessitate a shader switch (or uniform ...