A brand new game
for Windows, Linux, Mac, HTML5, 3DS Homebrew and more
every week,
unless exhausted!
About Games Music Pixelart Poetry Home Patreon Scores JNKPlat Levels
  9th June, 2018
Maybe I'm coding this wrong, but I swear I'm doing everything the way I'm supposed to!!


So, I spent the past couple of hours implementing Voxels, and managed to get the framerate of my JNKPlat test from 50fps with my own code, down to about 30fps with the Voxel code.
With the extra chunkiness of the voxels, came a heck of a lot more drawing, and I quickly realised it wasn't going to work out.

I scrapped that, and did some reading of the sf2d code.
Seems that they're using GPU_TRIANGLE_STRIP, where I'm just drawing a GPU_TRIANGLE_ARRAY.

At first I thought "Well, that's a bit silly, as that's more drawing calls per frame".. Since their code calls a "Drawing Strip" for each object, whilst I buffer my objects into an array and draw in one single call.
But the more I thought about it, the more sense it made..

Instead of using 6 vertex points for two triangles, you instead only set 4 vertex points, and so you're only doing 66% of the original drawing..

The 6 co-ords are for the two triangles that make up a square sprite. Top left, top right, bottom right... and then Top left, bottom right, bottom left. The two halves making up a whole.
But if you request a Strip, you only need to create 4 points, as it "knows" you mean to make 2 triangles.

So, I took a leaf out of their book, and rewrote most of my drawing code to be 4-co-ordinate Strips instead of 6-co-ordinate Arrays.

And the result..?

The same 30fps that the broken Voxel attempt gave me, earlier.


I'm back to my own code.
My own code works better.

It could still do with some kind of optimisation, though. I'm really at a loss as to why a relatively simple screen full of sprites would reduce the overall speed to 50fps.

.. Hmmm..

Views 30, Upvotes 10
2018 Framework , 3ds Homebrew
Site credits : PHP script, Site design, Blog posts, Games, Music, Pixelart, Poems and More : Jayenkai
(c) Jayenkai 2017 and onwards. RSS feed
Blog - Hmmmmm... - AGameAWeek