Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Double buffering — Gideros Forum

Double buffering

hgy29hgy29 Maintainer
edited March 2015 in Suggestions & requests
Hi folks,

I was playing around with animated Shape objects with overlapping geometries. Think of dice faces with large white rectangle and blacks circles (dots) over. The issue is that the rendering looks horrible (on the player at least), dots keep flickering. I think this is because we see the actual rendering taking place on screen one shape after the other, and perhaps double buffering would be a nice addition to gideros ?
+1 -1 (+1 / -0 )Share on Facebook

Comments

  • In that case, do we need vector draw plugin?
    https://github.com/memononen/nanovg

    (Maybe i did not fully understand @hgy29 suggestion but it is nice to have vector drawing shape in gideros!)

    Likes: hgy29, pie

    Coming soon
    +1 -1 (+2 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    @vitalitymobile: nanovg looks very nice indeed! By double buffering, I was meaning the fact that gideros could draw the stage in an off-screen buffer, then make this buffer appear on screen in a single shot, thus hiding drawing artifacts that I suppose I am seeing.
    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    @pie, it may well be, indeed!

    Likes: pie

    +1 -1 (+1 / -0 )Share on Facebook
  • You could possibly render to texture then render that texture as the full screen.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • hgy29hgy29 Maintainer
    @SinisterSoft, this would be a pretty good workaround, but I since double buffering is a very common way to solve those rendering issues and it is handled at graphic toolkit level, and seems to me that it would be more effective to use it if appropriate, i.e. application:enableDoubleBuffering(true) for example
  • hgy29hgy29 Maintainer
    Ok so I've been digging into gideros code to see how this could be implemented, and discovered that it was already done at least for Android and iOS (this is default behavior). So my flicker effect is probably caused by something else.
  • How is it implimented? It could be that it's done on a timer that operates on a different interrupt than the stage refresh event. In which case most of your sprites could be updated whilst others not - if you have a lot of sprites then the last few might stagger to th next frame.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • hgy29hgy29 Maintainer
    Problem understood and solved :) I forgot to mention that I was working on a 3D demo, and what I was experiencing where issues due to depth buffer testing, since my several shape fragments where aliased to the same Z location, drawing order was not clearly defined. Translating slightly dots shape in respect to dice faces prevents aliasing and then rendering is now correct.

    @SinisterSoft, As far as I understood, every sprite is drawn in every frame such that time spent in drawing the frame limits the fps. However is time spent rendering is short enough, frame rate is then limited to configured fps rate by sleeping between frame draws.
    Dice demo.png
    380 x 428 - 27K
  • SinisterSoftSinisterSoft Maintainer
    edited March 2015
    With the 3D extensions is it possible to use the Z location to stagger draw order - even though it's a flat 2D game?

    What I mean is does Z affect the size of the drawn shape or can it be set so Z doesn't affect the size and can be used for draw ordering?

    What I want to do is sort my sprites based on Y position on the screen, using Z to do this would be a nice cheat - no need to use Lua to sort.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • hgy29hgy29 Maintainer
    In order to keep compat with 2D games, I arranged so that it is still possible to use ortho projection (not perspective). In fact it is the default. In that case you can use Z coordinate to change draw ordering but for this trick to work your Z ordered shapes will have to be child of 3D mesh (possibly empty). I imposed this in order to avoid breaking not Z aware 2D.

    Hopefully @ar2rsawseen will be able to prepare a beta version with 3D support when he have time.

    Likes: SinisterSoft, pie

    +1 -1 (+2 / -0 )Share on Facebook
  • If the Z is the same, then is the order not the normal child order or will be be virtually random?

    If it is the child order then not setting the Z will mean that existing programs are compatible - so it could then be a child of sprite/stage?
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • hgy29hgy29 Maintainer
    Well for compatibility reasons drawing order is kept the same as usual for all sprites, Z makes no difference on drawing order.
    However, if (and only if) your sprite is either a 3D mesh or a child of a 3D mesh, then additional depth testing is enabled on OpenGL. Depth testing dictates that pixels are drawn only if they are nearer than previously drawn pixels with depth testing enabled.

    If you'd like to play around with upcoming 3D stuff, I have an AndroidPlayer apk that support it.
  • Thanks for the offer but I rolled my own custom android player that has some controller and advert stuff in it - hopefully Arturs will include your stuff in a new official build.

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • I know this is an odd question, but does the screen 'stutter' for you if you are constantly moving your finger on the screen?
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
Sign In or Register to comment.