News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Spinning cube flickering problem

Started by r0ger, August 27, 2022, 06:22:56 AM

Previous topic - Next topic

r0ger

Hi guys,

does anyone know how do i insert another device context for the cube without flickering that much and to make it play more smooth ?
i tried many times to make another one even with PatBlt and doesn't work in any way..

thanks.
r0ger // PRF

jj2007

Hi R0ger,

I've no time to study your code right now: do you paint to a memory DC? I.e. double buffering etc?

r0ger

i've painted the cube to the main device context (the hdc one from the WM_INITDIALOG).
r0ger // PRF

fearless

I would double buffer everything.

       
  • Paint background color
  • Paint cube points for rotating cube
  • Paint text at x position for scrolling text with specific font and color
  • Then BitBlt that to the main dc
It is an ideal candidate for a custom control, so could create a custom control and have specific 'properties' to set, back color, text color, cube color, speed of animation, animation direction? speed of text scrolling, direction of text scroll: left to right (centered), down to up (centered), or possible others, etc.

HSE

Reading code, there is double buffering.

Perhaps must be invalidate instead of redraw?

Capture background erase?
Equations in Assembly: SmplMath

Greenhorn

invoke SetTimer, hWnd, 1, 10, NULL
invoke SetTimer, hWnd, 2, 15, NULL


So, every 30ms the window gets redrawn. 30ms, because of the invoke Sleep, 20 in the WM_PAINT.
Maybe here is the root of the evil ... ?

Quote from: HSE on August 27, 2022, 09:04:03 AM
Capture background erase?
This could also be the cause (and more likely).
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

jj2007

The Sleep 20 seems to be necessary to make the image rotate.

Yours are valid reasons, HSE & Greenhorn, but sometimes there is one more reason: painting is slow. Check the Coloured rounded buttons example. It's double-buffered, but especially the controls on the left (using images) tend to flicker. And if you resize the whole thing, it becomes obvious that cpu and gpu have to work hard... if you have an example where a dialog with many controls can be flicker-free resized, I'd be curious to see it :cool:

fearless

Quote from: jj2007 on August 27, 2022, 06:42:50 PM
if you have an example where a dialog with many controls can be flicker-free resized

I normally would set wc.style to 0 or drop shadow style and make sure no CS_HREDRAW or CS_VREDRAW is used:

mov wc.style, CS_DROPSHADOWAnd set WS_CLIPCHILDREN with the dialog style
That seems to allow flicker free resizing of dialog with child controls.

jj2007

Quote from: fearless on August 27, 2022, 10:53:18 PMI normally would set wc.style to 0 or drop shadow style and make sure no CS_HREDRAW or CS_VREDRAW is used:

mov wc.style, CS_DROPSHADOWAnd set WS_CLIPCHILDREN with the dialog style
That seems to allow flicker free resizing of dialog with child controls.

Sure. That's what I do. Show me a flicker-free example of a resizable dialog with many resizable controls. Seriously, I am curious - maybe I am really doing something wrong.

hutch--

JJ,

    style = CS_BYTEALIGNCLIENT or CS_BYTEALIGNWINDOW

    and

    mrm wc.hbrBackground,  0

Give it a whirl.

hutch--

Roger,

I had a quick look at the code you posted and its a dialog, not a CreateWindowEx and I don't know if you can set the styles in a dialog as well as a full window. I would be inclined to set the display in a window where you have the WNDCLASSEX styles that you can set.

avcaballero

I have seen the code and I have not understand anything. It seems to be some kind of unassembly product.

jj2007

Quote from: hutch-- on August 28, 2022, 12:47:14 AM
JJ,

    style = CS_BYTEALIGNCLIENT or CS_BYTEALIGNWINDOW

    and

    mrm wc.hbrBackground,  0

Give it a whirl.

No difference. Btw and wc.hbrBackground, 0 is shorter ;-)

r0ger

well i have reviewed all your answers.
tried removing the RedrawWindow and starts to overdraw all the cube lines. :P
my concept of this aboutbox is to create a text scroller to draw altogether with the cube animation without flickering or overdrawing on the black background.
r0ger // PRF

r0ger

#14
well it seems like there is nothing to do with this cube. i've got to say that i will be giving up continuing to fix the Gdi problem. whenever i try to fix every device context value to this cube it kept getting worse for odd reasons.
r0ger // PRF