Page 2 of 2 First 12
  • Jump to page:
    #16
  1. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    Originally posted by dog135
    I don't think the issue is the brush. It doesn't flicker off and on, it's a refresh type flicker, where the top with be animated in one frame, the the bottom animated in the next.
    I think there's a problem with terminology here, you should have explained yourself a little better. I think the problem you are experiencing is shearing - when an animation changes from one frame to the next, and gets 'caught' in the retrace, so you see a horizontal shear across the screen (which is usually most apparent during horizontal scrolling). Flickering, on the other hand, means to flicker - on and off. This is when you erase the animation frame with something, then redraw over this. It's an erase and then draw combinating that produces flickering. This is what I have been talking about, but I do not think this is the problem you are having.

    You cannot ask for anything specific from the hardware like where the retrace is in Windows. For that, you'll have to use DirectX, or wait for Windows Longhorn.
  2. #17
  3. Doggie
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2003
    Location
    Seattle, WA
    Posts
    751
    Rep Power
    13
    Oops! Sorry about the confusion. I thought I explained it in my first post, but I must have edited it out when I was rewording myself.

    I'm not looking for WHERE on the screen the refresh is, I just need to know when it's done or starting again.

    It's a method that's commonly used by other programmers, but usually it's done in VGA/DOS mode, not windows.
  4. #18
  5. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    Originally posted by dog135
    Oops! Sorry about the confusion. I thought I explained it in my first post, but I must have edited it out when I was rewording myself.
    Glad that we are on the same page now! :)

    Originally posted by dog135
    I'm not looking for WHERE on the screen the refresh is, I just need to know when it's done or starting again.
    Yes, I know. I should have been more clear in my last post. I meant that there is absolutely nothing about the retrace that can be determined from the win32 API. DirectX is the key if you wish to access that information. Windows Longhorn will allow applications to know when the retrace starts and ends, which will be great for animations.

    Originally posted by dog135
    It's a method that's commonly used by other programmers, but usually it's done in VGA/DOS mode, not windows.
    Yes, understood. I've incorporated it into almost every DOS graphics program I've ever made. ;)
    Last edited by Jason Doucette; July 19th, 2003 at 03:45 PM.
  6. #19
  7. Doggie
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2003
    Location
    Seattle, WA
    Posts
    751
    Rep Power
    13
    Ah, well, if those are my two choices, then I guess I'll just put up with it for now. :rolleyes:

    Thanks!
  8. #20
  9. No Profile Picture
    Offensive Member
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Location
    in the perfect world
    Posts
    622
    Rep Power
    27
    Try these things;

    look at the WM_ERASEBKGND msg.

    Ensure all drawing is compleated BEFORE you call a paint, remember that not all paint calls will result from actions IN your app. That is external actions may cause your app to need a re-paint. ie user passes messagebox over client area.
    If there is more than one BltBit() in your paint handler it will be too slow.

    Avoid StretchBlt() as its results are slow and unsatisfactory. If you have too use it ensure that all scaling is done with int multiples.

    One HDC is drawn on. All new images are constructed on this HDC. This is the 'back buffer'. It is never drawn to the screen.
    One HDC is drawn to the screen 'screen buffer'. After an image has been constructed in the back buffer the back buffer is copied to the screen buffer. In a paint msg the relevent area of the screen buffer is copied to the HDC returned by BeginPaint().

    NOTE: Any GDI objects (resources) created must be deleted. Any GDI objects 'Get' ed (GetDC() ) must be Release 'ed (ReleaseDC() ).
    Most CAN NOT be deleted while selected into a HDC!
    Thus dog's code snippet is a memory leak as the brush will not be deleted.

    Use GetUpdateRect() BEFORE BeginPaint() (which validates the area) to minimise the area re-drawn. If the rect is empty ( IsRectEmpty() ) use the client area. It should return the area called for painting in the InvalidateRect()

    Set the HDC's blit mode with SetStretchBltMode()
    For better drawing quality at lower speed set the HDC to HALFTONE. Look at other flags to improve speed at the cost of quality.
    The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

    Frank Zappa
  10. #21
  11. Doggie
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2003
    Location
    Seattle, WA
    Posts
    751
    Rep Power
    13
    Originally posted by TechNoFear
    Try these things;

    look at the WM_ERASEBKGND msg.
    I looked that up. It seems that it only fires when the window needs to be refreshed. I need an event for the vertical retrace.

    Originally posted by TechNoFear

    Ensure all drawing is compleated BEFORE you call a paint,
    ...
    In a paint msg the relevent area of the screen buffer is copied to the HDC returned by BeginPaint().
    Yeah, that's pretty much the same for Macs.

    Originally posted by TechNoFear

    NOTE: Any GDI objects (resources) created must be deleted. Any GDI objects 'Get' ed (GetDC() ) must be Release 'ed (ReleaseDC() ).
    Most CAN NOT be deleted while selected into a HDC!
    Thus dog's code snippet is a memory leak as the brush will not be deleted.
    That's basic memory management. Actually, I pieced together my snippet from a class I made for working with the graphics. The destructor of the class does delete the brush, I just forgot to piece it in. Here's some of the actual class functions:

    Code:
    gcross::gcross(HWND hWndo){
    	hPen=CreatePen(PS_SOLID,thickness,RGB(0,0,0));
    	hWnd=hWndo;
    	thickness=1;
    }
    
    gcross::~gcross(void){
    	DeleteObject(hPen);
    }
    
    void gcross::start(void){
    	hdc=BeginPaint(hWnd, &pstruct);
    	SelectObject(hdc, hPen);
    }
    
    void gcross::end(void){
    	EndPaint(hWnd, &pstruct );
    }
    
    void gcross::pix(long x, long y, int r, int g, int b){
    	SetPixelV(hdc,x,y,RGB(r,g,b));
    }
    Originally posted by TechNoFear

    Use GetUpdateRect() BEFORE BeginPaint() (which validates the area) to minimise the area re-drawn. If the rect is empty ( IsRectEmpty() ) use the client area. It should return the area called for painting in the InvalidateRect()

    Set the HDC's blit mode with SetStretchBltMode()
    For better drawing quality at lower speed set the HDC to HALFTONE. Look at other flags to improve speed at the cost of quality.
    Most of my projects involve animating an area large enough to require a refresh of the entire drawing area. One of my favorate things to play with are trying out different 3D methods like simulating fire or fireballs, hair, using splines to create cartoon objects in a 3D world, faster methods of ray tracing, etc. They're fun to play with, but they aren't smoothly animated because I don't know how to detect the vertical retrace.

    Speed really hasn't been an issue.

    Thanks for taking the time to reply to my post though! I appreciate it. :)
  12. #22
  13. No Profile Picture
    Offensive Member
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Location
    in the perfect world
    Posts
    622
    Rep Power
    27
    >>Most of my projects involve animating an area large enough to require a refresh of the entire drawing area.<<

    OK, but......it may not be your app that causes the repaint.

    PS: your class contains a GDI memory leak.
    The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

    Frank Zappa
  14. #23
  15. Doggie
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2003
    Location
    Seattle, WA
    Posts
    751
    Rep Power
    13
    Oh, thanks for pointing that out.

    I need to delete 'hdc' on the 'end' function, don't I?
  16. #24
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    272
    Rep Power
    19
    I think you need to save the result of the SelectObject call and do another SelectObject with that value as the parameter before the call to EndPaint. I'm not completely sure as it has been several years since I have worked on that sort of code.
    Last edited by 3dfxMM; July 23rd, 2003 at 11:33 PM.
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo