Coder Noob
June 29th, 2007, 09:29 PM
Hi. I'm making a 2D map editor and trying to update the window that shows the map. Anyway, the way I have it now works good, but there is a lot of flicker because I clear the screen to a white color and then update it. This is how I do it now.
Pseudocode
begin
Create Device Context
Create Memory Device Context
begin
Clear map window
Select tileset into memory device context
for(short x = 0; x < map width; x++)
begin
for(short y = 0; y < map height; y++)
begin
Update tile[x][y]
end
end
end
release device contexts
end
So as you can see, I use 2 device contexts. Then I use 2 for(;;) loops to update the map 1 tile at a time. This leaves a problem though. Since I am selecting a tileset into the backbuffer and drawing to the main DC, I can't just blit the complete picture to update the map. The tiles need to be drawn 1 at a time.
So I was thinking maybe I use 3 device contexts. Select the tileset into a memory device context, then draw to the other memory device context. Finally, blit everything to the main device context. Could this work? I've tried it before, but I had to replace my old files as it got seriously screwed up. Any source/pseudocode would be appreciated as would other ideas as to how I could handle this. Thank you.
Pseudocode
begin
Create Device Context
Create Memory Device Context
begin
Clear map window
Select tileset into memory device context
for(short x = 0; x < map width; x++)
begin
for(short y = 0; y < map height; y++)
begin
Update tile[x][y]
end
end
end
release device contexts
end
So as you can see, I use 2 device contexts. Then I use 2 for(;;) loops to update the map 1 tile at a time. This leaves a problem though. Since I am selecting a tileset into the backbuffer and drawing to the main DC, I can't just blit the complete picture to update the map. The tiles need to be drawn 1 at a time.
So I was thinking maybe I use 3 device contexts. Select the tileset into a memory device context, then draw to the other memory device context. Finally, blit everything to the main device context. Could this work? I've tried it before, but I had to replace my old files as it got seriously screwed up. Any source/pseudocode would be appreciated as would other ideas as to how I could handle this. Thank you.