🔒 Locked
win32 double buffering???
Advertisement
Original Post
Brannon: Don't forget GDI+.
baddrizz: (Assuming you're using GDI)
At every WM_PAINT event, do:
1. Create an bitmap with CreateCompatibleBitmap()
2. Create an off-screen DC with CreateCompatibleDC()
3. Select the bitmap into the off-screen DC with SelectObject()
4. Do all your drawing on the off-screen DC
5. Blit the off-screen DC onto your window's DC with BitBlt()
6. Deselect the bitmap from the off-screen DC (SelectObject())
7. Delete the off-screen DC (DeleteDC())
8. Delete the bitmap (DeleteObject())
This is a pretty slow method, though. To optimize, you might want to create the bitmap and off-screen DC at startup (re-creating them on window resize) and delete them on shutdown.
If you're not using GDI, feel free ignore this post
.
Edited by - LNK2001 on January 16, 2002 3:25:04 AM
baddrizz: (Assuming you're using GDI)
At every WM_PAINT event, do:
1. Create an bitmap with CreateCompatibleBitmap()
2. Create an off-screen DC with CreateCompatibleDC()
3. Select the bitmap into the off-screen DC with SelectObject()
4. Do all your drawing on the off-screen DC
5. Blit the off-screen DC onto your window's DC with BitBlt()
6. Deselect the bitmap from the off-screen DC (SelectObject())
7. Delete the off-screen DC (DeleteDC())
8. Delete the bitmap (DeleteObject())
This is a pretty slow method, though. To optimize, you might want to create the bitmap and off-screen DC at startup (re-creating them on window resize) and delete them on shutdown.
If you're not using GDI, feel free ignore this post
Edited by - LNK2001 on January 16, 2002 3:25:04 AM
I, too, assume you r using GDI.
Create the bitmap and the off-screen HDC at startup. THis is analogous on your side to a D3D/DDraw backbuffer. Draw everything to the off-screen DC, then draw the entire off-screen DC to the on-screen DC.
For whatever reason, this tends to fail absolutely in VB. Not sure why. (something to do with AutoRedraw and other such VB drawing settings, not completely sure.)
Create the bitmap and the off-screen HDC at startup. THis is analogous on your side to a D3D/DDraw backbuffer. Draw everything to the off-screen DC, then draw the entire off-screen DC to the on-screen DC.
For whatever reason, this tends to fail absolutely in VB. Not sure why. (something to do with AutoRedraw and other such VB drawing settings, not completely sure.)
Or you could do it using Get Set and ChoosePixelFormat...
look them up in MSDN and youll see what you need.
look them up in MSDN and youll see what you need.
thx for your replys sorry forgot to say i''m using the GDI i tried using PIXELFORMATDESCRIPOR(think its spelled right) here is how i set it up and i didn''t work 
and then called SwitchBuffer(hdc); after all the drawing was done and it didn''t change anythingi''m going to try the other idea''s right now.....
thx again
PIXELFORMATDESCRIPTOR pfd;
memset(&pfd, 0, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_GDI | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
UINT pixelformat = ChoosePixelFormat(hdc, &pfd);
SetPixelFormat(hdc, pixelformat, &pfd);
and then called SwitchBuffer(hdc); after all the drawing was done and it didn''t change anythingi''m going to try the other idea''s right now.....
thx again
quote:
Original post by Brannon
What are you using to draw with?
DirectDraw?
GDI?
OpenGL?
Something else? (what else is there?)
-Brannon
Can I access graphics memory directly with OpenGL, like
with dds->Lock() in DDraw? (pixels)
I''m sorry to get off topic, but does your user name represent bad me? Like, BadDrizzt.
Or just drizz in some way.
Just wondering.
------------------------------
Simple DirectMedia Layer:
Main Site - (www.libsdl.org)
Cone3D Tutorials- (cone3D.gamedev.net)
GameDev.net''s Tutorials - (Here)
OpenGL:
Main Site - (www.opengl.org)
NeHe Tutorials - (nehe.gamedev.net)
Online Books - (Red Book) (Blue Book)
Or just drizz in some way.
Just wondering.
------------------------------
Simple DirectMedia Layer:
Main Site - (www.libsdl.org)
Cone3D Tutorials- (cone3D.gamedev.net)
GameDev.net''s Tutorials - (Here)
OpenGL:
Main Site - (www.opengl.org)
NeHe Tutorials - (nehe.gamedev.net)
Online Books - (Red Book) (Blue Book)
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement