Jump to content
  • Advertisement

Archived

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

Possibility

How do you make a copy of a DirectDraw Buffer?

This topic is 6613 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

Currently in my game, everytime I render the frame, it re-calculates everything that needs to be draw and reblits them all the back buffer and then finally flips it to the primary buffer. But if I only move one small object, its inefficient to have to re-calculate and redraw everything. So how do i just do it once and store that in a seperate back buffer, then when I move a single unit, i make a copy of that primary backbuffer, blit the single image of moved unit to that copy, and then flip that to the primary buffer? I am working with VC++ and directX 7. Thanks for any help anyone can provide. Possibility

Share this post


Link to post
Share on other sites
Advertisement
I''m not sure that you can''t make a copy of a buffer with a single command, but I do know that you can just initialize an offscreen buffer with LPDIRECTDRAWSURFACE and just blit the entire back buffer to that offscreen buffer each frame. I''m not sure how fast that would be though.
Remember that when you make a copy of the back buffer and only draw little bits at a time to it you will also have to erase the pic of the object at its previous location. That could be tough, I would think. Also, you don''t necessarily have to do all the calculations each frame, but you will probably want to redraw all the pics each frame. Did that help at all?

Share this post


Link to post
Share on other sites
Aren''t Dirty Rectangles another way of speeding up drawing if you''re only changing like one thing in the scene? There is probably some documentation on this site somewhere. But what Dirty Rectangles essentially do is find the only place that changed in the scene and redraw only that. Dunno if that''s what you''re looking for.......

Share this post


Link to post
Share on other sites
What Possiblity wants definetly sounds like Dirty Rectangles. And that''s a whole different topic, try searching around for Dirty Rectangles.

-------------------------
-Now Working on Pokemon like Engine!

Share this post


Link to post
Share on other sites
I have no clue what dirty rectangles are, but that sounds like something for a 3D game, so maybe I should have stated I am not using 3D, but rather 2D directdraw. What I just want to do is make a copy of back buffer to another back buffer. I know you can have more then 1 back buffer, so how do you move the image from 1 to another?

here is the directX code to send an image to the back buffer:
lpDDSBack->BltFast (x_pos, y_pos, image_surf, &rct, DDBLTFAST_WAIT);

and then here is the code to flip the back buffer to the primary buffer, and this then gets sent to the computer monitor and you see it:
lpDDSPrimary->Flip (0, DDFLIP_WAIT);

but instead of sending the back buffer to the primary buffer, how can I instead make a copy of it to a secondary back buffer?

Possibility

Share this post


Link to post
Share on other sites
1) Dirty Rectangles Method is a 2D method that reduces the amount of blitting. A concrete example with tiles: You create an array of char that is the same as your map-tile array
TileInfo TileArray[maxcol][maxrow];
char TilesToBeFixed[maxcol][maxrow];// set all to zeros
Every object that exists covers up a certain number of tiles. You check the edges of it and in the char array change the Zero to a One. And rather than rebuilding the WHOLE set of tiles on the screen, you go through the array of chars and repaint only the ones that have been "spoiled"
reset to Zero when done the frame
It's more complex for none-tile situations but keeping track of what you've spoiled is the key.

2) But you're asking for something different.
Just make another surface with a different pointer. For example I have in my RPG a panel that gives someone's data. I set up a surface at the start of the game and put the basics on it background and labels. I also set up a Flag that keeps track of any changes to the panel. If the person changes from one member of the party to another, I set the Flag or If some of the player's data in the panel changes, I set the Flag. And during the PaintScreen Function, at each frame I do copy the panel from its surface to the backbuffer but before that I check the Flag and if it's set, I have a ReDoPanel() function first. It's the same for my background hextiles; I've a different surface for them as well. Take a look at the screen shot of my RPG it might be of some help.

You just create another surface and BltFast that to the BackBuffer. Also be careful of any printing or font engine you do. Make them flexible enough to print onto the BackBuffer surface or the panel surface.
ZoomBoy
A 2D RPG with skills, weapons, and adventure.
See my character editor, Tile editor and diary at
Check out my web-site


Edited by - ZoomBoy on 4/16/00 6:22:13 PM

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!