   Making more place for the video card in gdi
  Hi people. Currently I''m making a space game using c++ and gdi. I know Gdi isn''t the perfect api for games, but it does the jobs and is slightler easyer than directx and opengl. All is going alwright in my game logic and all, but I have a simple probleme. My game takes too much place on the video buffer. I know that each time I make an HDC it takes more place on my video buffer. So here is my questions (An answer to any of them would be fine).1. Is there a way to transfer the place used on the video buffer to the system memmory like in direct draw2. How can I just draw the bitmap on the screen and take off the memory on the video buffer and not erase the bitmap.   Kevin 
  << 1. Is there a way to transfer the place used on the video buffer to the system memmory like in direct draw >>For speed, you want all your graphics blitted from video card memory to video card memory, and that is done only with DirectDraw (or D3D). But with GDI, its main memory not video card memory being blitted (if I understand right). For small 2D games, GDI should be fine though, speed will not be a problem on any machine over 500 Mhz.<< 2. How can I just draw the bitmap on the screen and take off the memory on the video buffer and not erase the bitmap. >>Not sure I understand this question, but you should need only 3 hdc (handles to device context): main_dc, back_dc, and bmp_dc. For GDI, main_dc represents your primary video buffer, back_dc is your back buffer (if you are using one) where you BitBlt all your game sprites, and bmp_dc is for your bitmaps (you only need one bmp_dc which can be used for all your bmps).Every frame of your game you erase your back_dc, then BitBlt all your sprites in their new positions to your back_dc, then BitBlt back_dc to main_dc all at once. At least that''s how I did my GDI games. Its not perfect but does remove a lot of flicker.VazGames.com  Phil P ;  Ohh sorry for my in comprhension. I already now the technique of double buffering, but I was asking can I delete de DC whitout deleting the image or can I just delete it''s mememory.   Kevin ;  << can I delete de DC whitout deleting the image or can I just delete it's mememory >>You delete/release pointers or handles. So any hdc should be released with DeleteDC (back) or ReleaseDC (primary), and any hbmp should be released with DeleteObject. I understood you to mean you were running out of memory with too many hdc or something....sorry. I can see French is your native language.Phil P   [edited by - PhilVaz on February 12, 2004 1:51:35 PM];I don''t remember the name of the GDI command... but I know there is one where you pass a ram memory pointer, the color format, dimensions, etc, and it blits the memory contents directly to the window client area.I don''t know what are you using for rendering, but if you''re using a plain ram memory buffer, I would suggest you to take a look at all the advanced GDI blit functions;  I see some misunderstanding here.First, DC stands for device context, and it works like a "handle" to any device that it''s attached to. You can use DC for bitmap on memory, you can use DC for printers, you can use DC for pen/drawing tool, you can use DC just about for anything else that Windows provides. Think DC as a pointer. It can have multiple copies, but it all points to one object.Second, you shouldn''t ever delete or release a DC that points to a bitmap in memory during the execution of the game. Once you attach a DC to a bitmap by calling SelectObject(), you are creating a bound that shouldn''t be deleted until your game terminates. Normally every DC you have should be paired with a bitmap. You can create copies of this DC, but you shouldn''t create copies of the bitmap it''s attached to. If you want to delete the copies (which you can), don''t delete the bitmap. Remember, it works like a pointer.Also, all blitting operations require only the DC, not the bitmap. So you should only has one bitmap in the memory of every bitmap files you use. So I don''t know how you could end up using all the memory, because such thing isn''t possible, unless you have a very big bitmap, or you are making copies of the bitmap (not the DC) which I suspect. 