Hooking up SpriteBatch to vertex buffer?

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.
Post Reply
perrako
Prole
Posts: 5
Joined: Sat Mar 31, 2012 9:59 pm

Hooking up SpriteBatch to vertex buffer?

Post by perrako »

Howdy folks! I'm hooking up LiquidFun to Lua/Love2D with LuaBridge and having trouble with rendering. Most of the work getting the two to talk is already done, but I'm having a spot of bother rendering it. LiquidFun stores its liquid particle positions in a contiguous buffer in memory to make calling things like glVertexPointer the efficient way to render them. The closest equivalent to glVertexPointer in Love2D would be SpriteBatch, but I can't figure out how to give SpriteBatch a pointer to the positions buffer.

Is there a good way to do this without modifying and recompiling Love? I could rewrite or modify SpriteBatch itself, but I'd love to make it easier to distribute my LiquidFun bindings.
User avatar
slime
Solid Snayke
Posts: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Hooking up SpriteBatch to vertex buffer?

Post by slime »

[wiki]Mesh[/wiki]es are the closest thing to Vertex Buffers in LÖVE, currently.

[wiki]Mesh:setVertices[/wiki] can also accept a [wiki]Data[/wiki] object as of 0.10.0 (although I haven't documented that on the wiki yet), and you can copy bytes to a Data object with the FFI by using [wiki]Data:getPointer[/wiki] and [wiki]Data:getSize[/wiki] with ffi.copy.
perrako
Prole
Posts: 5
Joined: Sat Mar 31, 2012 9:59 pm

Re: Hooking up SpriteBatch to vertex buffer?

Post by perrako »

Ah, good idea. I'm able to get that about 50% working, but I can't seem to get Mesh to render Point Sprites. I can get it rendering uniform squares taken from one texture coordinate, but nothing like this. Before I go about writing a vertex shader to transform the point into a quad, is there something I'm missing inside of Mesh that would do what I want?
User avatar
slime
Solid Snayke
Posts: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Hooking up SpriteBatch to vertex buffer?

Post by slime »

LÖVE doesn't provide a way to enable/use point-sprite rendering.
perrako
Prole
Posts: 5
Joined: Sat Mar 31, 2012 9:59 pm

Re: Hooking up SpriteBatch to vertex buffer?

Post by perrako »

Gotcha. Alright, I'll use SpriteBatch until performance seems to be a non-starter, then write a fragment shader to try and make it work.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 8 guests