News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Scrolling text flickers?

Started by hfheatherfox07, May 18, 2011, 09:04:04 PM

Previous topic - Next topic

hfheatherfox07

Hi,
When I tried to add Scrolling text to star-filed or star-burst the scrolling text flickers...any ideas why?

I tried both vertical and horizontal text scrolls , as well as with a static and with out....

P.S

I have lots of scrolling text examples but I still can't get the "Start trek"  effect were the scrolling text goes into space (comes to one point).... If anybody has an example like that ...I would appropriate it...   :bg

qWord

write the text to the back buffer hmainDC after the stars has been drawn.
FPU in a trice: SmplMath
It's that simple!

hfheatherfox07

Quote from: qWord on May 18, 2011, 09:13:31 PM
write the text to the back buffer hmainDC after the stars has been drawn.


I am not so sure that I understand , but I will give it a try...

dedndave

http://www.masm32.com/board/index.php?topic=16066.0

there are a number of forum threads that cover this
search for "flicker" or "CreateCompatibleDC"

hfheatherfox07

Thanks,
It looks like "Flicker" is a common problem  :lol
I came a cross 4 pages on this issue

I also came across this for back buffer:
http://www.madwizard.org/programming/tutorials/mosaic/7

I will give these things a try....

qWord

Quote from: hfheatherfox07 on May 22, 2011, 01:28:08 AMIt looks like "Flicker" is a common problem  :lol
...
I also came across this for back buffer:
exactly this technique is used by the program YOU have shown in your first post in this thread! All you need to change is the order of drawing, so that the text is drawn after the 'stars' has been drawn (to the back buffer hmainDC).
FPU in a trice: SmplMath
It's that simple!

hfheatherfox07

I understand what you are saying but I think I have 2 Problems that I do not know how to solve:

1. There are 2 "SetTimer" , even though they are written different I still can not get them to separate, the timing for the stars is faster than the scrolling text.... How can I separate the two? what I mean is if I erase one of them the whole thing still works??? If I erase the faster timer for the stars than both the stars and the text run at the slower speed of the scrolling text and vise versa ...

SetTimer for text:
mov TimerID,FUNC(SetTimer,hWnd,IDC_TIMER,SCROLLSPEED,NULL)

SetTimer for Stars:

invoke SetTimer, hWnd, TIMER1, 10, NULL

see : attempts  of starfield with dialog rsrc & Scroll Text.zip

2. here is the original text scroll that I used for this,  in line 201:
invoke FillRect,hmainDC,ADDR rScroll,rv(GetStockObject,TRANSPARENT) ; OPAQUE VS BLACK_BRUSH VS TRANSPARENT

I took out the black brush so you can see that the text does not copy transparent onto the screen ... how do I fix that....????

in line 171 of starfield2.asm I can fix that by changing "mov hdc,FUNC(GetDC,hWnd)"  to " mov chdc,FUNC(GetDC,hWnd)"  but than the scrolling text hits the top of the window and scrolls right back down ....  :dazzled:

Ahh

qWord

there are several methods of solving your problem. However, in the attachment you will find the best solution (IMO) for displaying different animations in one graphic: it creates three memory DCs, where one is used for drawing the text and one for drawing the stars (=this is our background). This two layers are merged in the third DC using Alpha/Transparent blt. This DC is then copyed to the screen. Using this technique allows to quickly combine differently timed animations - However, as you surly can see, it need more system resources (not really hard for nowadays systems/graphic-cards)
FPU in a trice: SmplMath
It's that simple!

hfheatherfox07

Thanks I will take it apart tonight.... it seems to have the same problem too fast of a scroll and stars have the speed of the scroll, but I have not assembled it yet so That might be changeable ....

I was toying with the idea of creating a thread proc for the text like in the horizontal text scroll example that I posted

hfheatherfox07

Any ideas how to fix the  Scroll Text Up Example_2a.zip   :(...just the scroll example?

qWord

- erase hmainDC with some color and not with an hollow brush!
- invoke SetBkMode,hmainDC,TRANSPARENT
- draw the text and Blt it to the screen
- you are the owner of hmainDC: there is no need to endless reselect the font - the same applies for settings like the BkMode/Color
FPU in a trice: SmplMath
It's that simple!

hfheatherfox07

Quote from: qWord on May 23, 2011, 12:55:54 AM
- erase hmainDC with some color and not with an hollow brush!
- invoke SetBkMode,hmainDC,TRANSPARENT
- draw the text and Blt it to the screen
- you are the owner of hmainDC: there is no need to endless reselect the font - the same applies for settings like the BkMode/Color


I will give that a try , buy I purposely put Null brush instead of some color(so you can see the error), If you take that example and use "BLACK_BRUSH" every thing looks perfect , but when you add a picture to the background , you get that black (or what ever color was used to erase the background) scrolling on top of the picture (the text is not transparent on top of the picture)
I don't think I understated "- draw the text and Blt it to the screen"
isn't that what is done here:

BitBlt,hdc,0,0,WindowRect.right,WindowRect.bottom,hmainDC,0,0,SRCCOPY
invoke EndPaint,hWnd,addr ps


I am not clear with what you mean but I will mess with it tonight

qWord

for me it works:
invoke SelectObject,hmainDC,rv(GetStockObject,BLACK_BRUSH)
.....
.elseif uMsg == WM_PAINT
invoke BeginPaint,hWnd,addr ps
mov hdc,eax
; erase DC
invoke BitBlt,hmainDC,0,0,WindowRect.right,WindowRect.bottom,hmainDC,0,0,PATCOPY

; draw something for testing purpose
invoke DrawFrameControl,hmainDC,ADDR WindowRect,DFC_BUTTON,DFCS_BUTTONPUSH
invoke SetTextColor,hmainDC,0ffh
invoke SetBkColor,hmainDC,0
invoke SetBkMode,hmainDC,TRANSPARENT
invoke DrawText,hmainDC,ADDR szWindowMsg,-1,ADDR rScroll,DT_CENTER + DT_TOP + DT_NOPREFIX + DT_NOCLIP 
invoke BitBlt,hdc,0,0,WindowRect.right,WindowRect.bottom,hmainDC,0,0,SRCCOPY
invoke EndPaint,hWnd,addr ps
FPU in a trice: SmplMath
It's that simple!

hfheatherfox07

Sorry about the late reply, yes you are right it works amazing .....( I did it a little different) :U

I also managed messing with the speeds of the scrolling text that you posted, that worked amazing too....

Thank you for all your help  :bg


hfheatherfox07

Hi qWord,

Any Idea how to make my scrolling text example that I posted in this thread  "Scroll Text Up Example_2a.zip"  do this:

http://www.megaupload.com/?d=5KJFUP0X

just click on the .HTML to view the video  :P

....and that assembly  you are right about it does crashes... I downloaded it the same day , and on this computer it worked...How ever when I got home on my computer it did not... Strange.... This computer on which it works is an XP as well , however  I have no admin privilege here I am a guest... I wonder if that makes a difference?

Appreciate all your help ....


Later on I plan on adding a moon an the star ship Enterprise to it all, so far I can not get the stars to go over the bitmaps, even if I use WM_PAINT to add the images.... :U