Search found 245 matches

by RNavega
Tue Apr 16, 2024 1:44 pm
Forum: Libraries and Tools
Topic: Rasterizing polygons into images
Replies: 3
Views: 404

Rasterizing polygons into images

This is an example script of rasterizing a polygon into a grayscale image (R8 format). So, starting from SVG data, you generate an Image object from it then draw that Image as needed. Depending on the shape and its size, it's a bit lighter to have it described as SVG data than as a PNG file in your ...
by RNavega
Fri Apr 05, 2024 11:04 am
Forum: Support and Development
Topic: Avoid table overhead by using Data when creating a mesh
Replies: 6
Views: 363

Re: Avoid table overhead by using Data when creating a mesh

Wow, you're right. Thanks for the correction. I don't know why I said all of that, when a few days ago I had read the Löve source code and seen how it differentiates the possible uniform types (int, float etc), and used int in a shader myself... The OpenGL wiki does list more types that should be av...
by RNavega
Thu Apr 04, 2024 9:12 pm
Forum: Support and Development
Topic: 2D Array
Replies: 6
Views: 427

Re: 2D Array

Code: Select all

function FallingSand:update(dt)
	print(FallingSand:withinCols(5))
end
Try self:withinCols(5) so the sugar becomes FallingSand.withinCols(self, 5).

The colon syntax is explained in here (the entire PIL e-book is useful btw): https://www.lua.org/pil/16.html
by RNavega
Thu Apr 04, 2024 10:18 am
Forum: Support and Development
Topic: Avoid table overhead by using Data when creating a mesh
Replies: 6
Views: 363

Re: Avoid table overhead by using Data when creating a mesh

Unorm16: according to this answer , on older OpenGL versions all data types are mapped to floats. So in your case, it would be a vec2 indeed. In the OpenGL wiki it says that there are other GLSL data types like int, uint, ivecn, uvecn and dvecn, so I think that after some GLSL version those new typ...
by RNavega
Wed Apr 03, 2024 8:36 am
Forum: Support and Development
Topic: Different ways to adjust audio
Replies: 4
Views: 331

Re: Different ways to adjust audio

I'm in the same boat, in that I haven't tried the Löve audio system yet. What I'd do is make a folder with a main.lua inside it and treat it like a sandbox, testing all kinds of stuff. You mentioned that Banjo Kazooie style of speech, I think there are only two ways: playing the same source over and...
by RNavega
Wed Apr 03, 2024 7:57 am
Forum: Support and Development
Topic: Avoid table overhead by using Data when creating a mesh
Replies: 6
Views: 363

Re: Avoid table overhead by using Data when creating a mesh

Using a flat array of attributes set by pointer index timed a bit faster than using an array of structs. But using structs leads to less cumbersome code, as instead of "myAttributes[vertexOffset + attributeOffset] = value", you'd do "myVertex.attribute = value". So unfortunately ...
by RNavega
Mon Mar 25, 2024 12:00 pm
Forum: Libraries and Tools
Topic: Fast 2D point-in-polygon test
Replies: 13
Views: 11787

Re: Fast 2D point-in-polygon test

I'm not too surprised. In LuaJIT, external function calls via standard Lua (as opposed to via FFI) either prevent compilation, or require trace stitching (meaning, switch to interpreter mode, run the function, switch back to compiled mode and resume), both of which are slow. I already got caught by...
by RNavega
Sun Mar 24, 2024 1:33 pm
Forum: Libraries and Tools
Topic: Fast 2D point-in-polygon test
Replies: 13
Views: 11787

Re: Fast 2D point-in-polygon test

Ehhh, here's something weird. From my tests, that Lua-based method in the OP is slightly faster than the Box2D one. Point for LuaJIT I guess, it's probably optimizing that function amazingly. I honestly thought the C++ one would be faster. point-in-polygon_benchmark.png The code I'm using is this (t...
by RNavega
Sun Mar 24, 2024 3:42 am
Forum: Support and Development
Topic: Weird Mobile Screensize Behavior
Replies: 2
Views: 1144

Re: Weird Mobile Screensize Behavior

Also check love.graphics.getWidth() and love.graphics.getPixelWidth(), in the Window section of the graphics page:
https://love2d.org/wiki/love.graphics#Window
by RNavega
Sun Mar 24, 2024 3:20 am
Forum: Libraries and Tools
Topic: Fast 2D point-in-polygon test
Replies: 13
Views: 11787

Re: Fast 2D point-in-polygon test

Yes, this: https://love2d.org/wiki/Shape:testPoint That's cool dusoft, nice tip. That will rely on the fast C++ Box2D implementation. The testing code seems to be this: https://github.com/love2d/love/blob/main/src/libraries/box2d/collision/b2_polygon_shape.cpp#L250 They're using a facingness test b...