Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

dragon9

Video sync in GDI

This topic is 5573 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am writing a game using just GDI functions (yes, I have a reason for not using DX/OGL.) I am having trouble synchronizing the WM_PAINT updates with the vsync refresh, resulting in interference anomalies. Does anyone know of a mechanism to do high speed animation using the GDI/Paint functions that is video refresh synchronized? Thanks...

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
try looking into the DrawDib set of functions. i''m not sure if these auto-sync or not, but they''re faster than GDI.

Share this post


Link to post
Share on other sites
Though I have a lot of experience with DirectX animation, I have very little with GDI programming. My problem is that I''m invalidating the window client area and redrawing about 60 times a second, I assume the redraw is out of sync with the video refresh.

How does one use a backbuffer with the GDI?

Share this post


Link to post
Share on other sites
To create a Back Buffer, you have to create a compatible HDC, then draw anything to this HDC and at the end of the frame, BitBlt this HDC to your window DC, if you dont do this you will see how the pixels are drawn.

-----------------------------------------------------------------
If God with me, Who against me?
Digital Moon Studio...

[edited by - NeonGE on June 18, 2003 7:28:56 PM]

Share this post


Link to post
Share on other sites
In the function InvalidateRect,
BOOL InvalidateRect(
HWND hWnd, // handle to window
CONST RECT* lpRect, // rectangle coordinates
BOOL bErase // erase state
);
set bErase to false if u do not need the system to redraw the background for you. It might dramatically speed ur game.

Hope it helps!

Share this post


Link to post
Share on other sites
"set bErase to false if u do not need the system to redraw the background for you. It might dramatically speed ur game"

That won't make any difference if you are using a backbuffer. There is no background as far as windows in concerned, so it never trys to draw one.

(note, when you register your windows class hbrBackground should be set to NULL)


My Website: ai-junkie.com | My Book: AI Techniques for Game Programming



[edited by - fup on June 19, 2003 1:38:17 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by fup
"set bErase to false if u do not need the system to redraw the background for you. It might dramatically speed ur game"

That won't make any difference if you are using a backbuffer. There is no background as far as windows in concerned, so it never trys to draw one.

(note, when you register your windows class hbrBackground should be set to NULL)


My Website: ai-junkie.com | My Book: AI Techniques for Game Programming




Setting hbrBackground to NULL might solve the problem, but if it's not set to NULL then bErase should be set to FALSE. I had the problem by the past. Because sometimes i needed to clean the window and redraw everything, but sometimes i needed windows to draw the background for me.



[edited by - remi on June 19, 2003 5:09:11 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!