Archived

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

CopySurfaceToSurface()

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

ok, so i need to copy a surface to another surface, i think i got it, as long as the data for a pixel is a DWORD, but anyways, i have a book that im reading to help me, and well, it keeps referring to the PITCH, what is it? thanx; wow i ended a sentence wit ha semicolon, too much c++ :-/ [edited by - Ademan555 on November 30, 2003 4:24:02 PM]

Share this post


Link to post
Share on other sites
The book you said you are using, "The Zen of Direct3D Game Programming", explains it in the beginning of the first Direct3D chapter. And, again, that book isn''t very good...

Share this post


Link to post
Share on other sites
"pitch" is the distance between the first pixel of each scanline. Often, the "pitch" is the same as "sizeof(pixel)*width", but not always. For example, when using less than 4-byte pixels, pitch is often rounded up to a multiple of 4 for efficiency reasons. Also, if you have a larger image, and refer to some subset of that image that''s narrower than the full image, the pitch of the subset is still the same as the pitch of the big image.

Another way to say it:

To move a (char) pointer one pixel over, add sizeof(pixel).
To move a (char) pointer one scanline over, add pitch.

Share this post


Link to post
Share on other sites
Yeah, I'm 16... age doesn't really matter.

I don't know what to recomment, but here is what is wrong with it:

1. He starts off explaining things really well, but as the book goes on, he explains things less and less and less.

2. There are tons of typos, even in the math section.

3.He programs terribly. I am still getting better myself, but he brags in the beginning that his code is great. His code is extremely messy, and almost everything is global, which, once you start making more complicated stuff, makes things really hard to modify and deal with. Plus, he just does stupid things. He Releases and recreates the back buffer every frame at one point in the book (which, in case you didn't know, is a super slow and you don't have to), and in his DirectInput section, he Polls the entire keyboard every time he checks for a single key.

3. At one point he makes a function (ValidateDevice) that works for where he is in the book, and the forgets about it, adds new stuff to the program, and then the function stops working.

4. If someone starts at the 3D section, he says "Here are the functions I have made so far, in case you are just starting here" and leaves out a bunch of them that he still uses in the functions he shows. He even says in the beginning of the book that it would be no problem starting at any chapter in the book.

5. He spends too much time explaining specific things (like making a console), and leaves out a ton of D3D's features.

[edited by - PlayGGY on November 30, 2003 4:45:49 PM]

[edited by - PlayGGY on November 30, 2003 4:46:26 PM]

[edited by - PlayGGY on November 30, 2003 4:54:23 PM]

Share this post


Link to post
Share on other sites
On the topic of "Zen"-bashing.. I can''t believe that anyone who''s been programming for a while would publish his book. If you look at his source code, it''s all in one header and one source file. It just gives headaches; if you try to cut and paste one class that he''s written to your own project, you find that it has a million dependencies on previous classes/functions.

As for what books I recommend.. there''s a bunch of good reviews on this site, and I''ve heard that Programming RPG Games for DirectX is an awesome book. I''ve only skimmed through it at a bookstore, though.

Share this post


Link to post
Share on other sites
yah, ive looked at that for a split second, but anyways, i seem to have some across yet another difference between dx9 and dx8, there seems to be no copy rects function, unless it isnt a member of the device, which is very possible considering what you guys seem to think of this author. anyways ill look for it in msdn, but if anyone has a quick solution, thatd be cool

Share this post


Link to post
Share on other sites
I beleive Beginning Direct3D is better, but I only looked at it for a few minutes, and I have heard some bad things about it, too. I have heard the RPG book that the guy before me mentioned is good, but I haven''t ever looked at it.

But again, the code in Zen is extremely messy . I can''t even describe it, so pop in the CD, close the installition page, browse the CD in a folder, go to Examples->Final Zen Base and open it up. Look at the header file. Wow.

Share this post


Link to post
Share on other sites
quote:
Original post by Ademan555
yah, ive looked at that for a split second, but anyways, i seem to have some across yet another difference between dx9 and dx8, there seems to be no copy rects function, unless it isnt a member of the device, which is very possible considering what you guys seem to think of this author. anyways ill look for it in msdn, but if anyone has a quick solution, thatd be cool


Yeah, I had the same problems you did. I went on MSDN, found the function for creating a surface in DX9, looked for a new CopyRects function, didn''t find one, and then switched over to texture quads.

Share this post


Link to post
Share on other sites
damn, looks like im gonna hafta home brew one? oh well, shouldnt be too hard, i just dont want a memory leak :-D, i need ta move to actual 3d space b4 i can really utilize textured quads correct?

Share this post


Link to post
Share on other sites
quote:
Original post by Ademan555
damn, looks like im gonna hafta home brew one? oh well, shouldnt be too hard, i just dont want a memory leak :-D, i need ta move to actual 3d space b4 i can really utilize textured quads correct?



Heh... how the hell did you find that!?


Either way, texture quads are faster. And you don''t have to do any 3D math either. There is an article on this site about it, but is also isn''t very good. You could see how easy it is from the tutorial though, but just read the comments people made about the tutorial before putting in your game.

Share this post


Link to post
Share on other sites