Changing the ddsd.dwWidth to ddsd.lPitch worked. Now, tell my why? hehe.. I think I understand why, but anyway. That will fix 2 of the 7. I''ll see about messing with the buffer on the other ones.
Thanks for the info.
Dave
Tricks of the Windows Game Programming gurus question
Dave_________________There are three kinds of people in this world: Those who can count, and those who cant.
quote:
Original post by dashworth
Changing the ddsd.dwWidth to ddsd.lPitch worked. Now, tell my why? hehe.. I think I understand why, but anyway. That will fix 2 of the 7. I''ll see about messing with the buffer on the other ones.
Thanks for the info.
Dave
This is my understanding of it.
When you create a two dimensional array it is actually represented as a 1-D array in memory.
a 5x8 2-D array in memory
I F
XXXXXXXXXXXXXXXX (X = array element)
XXXXXXXXXXXXXXXX (0 = unallocated memory)
XXXXXXXX00000000
0000000000000000 and so on.
Pretend our system memory is 16 X''s (whatever our array element is)wide. The element under the I is array[0][0]. To move to array[1][0] (element under the f) we need only add the width of the array (8) times the element size (assume 1 for now) to the memory position of array[0][0].
A DirectDraw surface is a 2-D array of pixels. But when a surface gets created in video memory it does not get represented as a 1-D array.
a 5x8 ddraw surface in video memory
0000XXXXXXXX0000
0000XXXXXXXX0000
0000XXXXXXXX0000
0000XXXXXXXX0000
0000XXXXXXXX0000
0000000000000000
We see that one row of pixels belonging to a surface will not be immediatly followed (in memory) by the next row of pixels from that same surface. If fact to move from the memory position of array[0][0] to the memory position or array[1][0] we must add the actual width of the video memory (16).
When a surface is created in video memory lPitch is initialized to the width of video memory for the card installed on that computer. When a surface is created in system memory lPitch is initialized to dwWidth.
Once again this is my understanding of how this works from what I have read. If I have any of this wrong please let me know. Or if I''m dead on the money let me know so I can answer this question with a bit more confidence the next time the opportunity arrises.
L8r,
Murph
--------------------------------
Screw you guys! I''m going home.
--------------------------------Screw you guys! I'm going home.
Message board frigs up the spacing.
The F in the first "memory diagram" is supposed to be over the 9th X in the first row.
L8r,
Murph
--------------------------------
Screw you guys! I''m going home.
The F in the first "memory diagram" is supposed to be over the 9th X in the first row.
L8r,
Murph
--------------------------------
Screw you guys! I''m going home.
--------------------------------Screw you guys! I'm going home.
As far as I understand it the reason lPitch works where dwWidth doesnt is that dwWidth assumes that after dwWidth amount of pixels it starts on the next line which may or may not be correct. lPitch starts on the next line at the right place (or something like that). Something to do with linear memory addressing (i understand what im trying to say but cant explain it very well lol)
Just my thoughts take them as you will.
"People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
Just my thoughts take them as you will.
"People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
I''m down to the bitmaps not showing on the screen now. I''m going to check and make sure nothing is directly written to the display itself. My little aliens are walking happily across the screen. Ian Parberry has a simple game he is describing, so I may halt on Andre''s book until I can figure out how to fix the other errors. I''m still budding on this entire thing. (been doing this for about 4 months, but I''ve been a web programmer for 5 years or so (VB,ASP,SQL,PHOTOSHOP,FLASH,HTML,java-script,plus a few others).
It''s all coming quickly, but at the same time, I am a ways off. Thanks to everyone who has offered help.
Dave
It''s all coming quickly, but at the same time, I am a ways off. Thanks to everyone who has offered help.
Dave
Dave_________________There are three kinds of people in this world: Those who can count, and those who cant.
Well, I got example 7_10 working by applying the bitmap to the back buffer and flipping it to the front buffer just like it was suggested, so maybe that''s my way to go. On Andre''s Alien example, I got one of the aliens to move around with the keyboard (I know, big deal, but it''s good for me I''m going to try and move forward with Chapter 7 if all the other examples work as well. Thanks again for all the advice and help.
Dave
Dave
Dave_________________There are three kinds of people in this world: Those who can count, and those who cant.
I''ve also begun reading this book, but alas I''m stuck in Chapter 2. If anyone could offer some assistance, I would greatly appreciate it. The program I''m currently at is Demo2.cpp which just creates a window and displays it onto the screen. BTW, I''m using MS Visual C++ 6.0 on Windows ME with the DirectX 8.0 SDK loaded. I have some C++ experience, but this is my first jump into Visual C++ programming on Windows.
I am getting 3 compile errors in the Demo2.cpp.
1. The first compile error I get is "Error C2440: ''='' cannot convert from ''void *'' to ''struct HBRUSH__ *''
The line in question is (I think, I''m looking at a printout)...
winclass.hbrBackground = GetStockObject (BLACK_BRUSH)
2 and 3. I think I have these figured out. I spelled while with a capital ''W'' as in ''While'' which I''m sure will cause a problem.
If anyone can offer assistance to my first compile error, I would appreciate it. Thank you.
I am getting 3 compile errors in the Demo2.cpp.
1. The first compile error I get is "Error C2440: ''='' cannot convert from ''void *'' to ''struct HBRUSH__ *''
The line in question is (I think, I''m looking at a printout)...
winclass.hbrBackground = GetStockObject (BLACK_BRUSH)
2 and 3. I think I have these figured out. I spelled while with a capital ''W'' as in ''While'' which I''m sure will cause a problem.
If anyone can offer assistance to my first compile error, I would appreciate it. Thank you.
change the line to:
winclass.hbrBackground = (HBRUSH)GetStockObject (BLACK_BRUSH);
That should fix your problem. I had it too in chapter 4, so keep it in mind. When you get to chapter 7, you may run into the problems I did, so remember this post.
Dave
winclass.hbrBackground = (HBRUSH)GetStockObject (BLACK_BRUSH);
That should fix your problem. I had it too in chapter 4, so keep it in mind. When you get to chapter 7, you may run into the problems I did, so remember this post.
Dave
Dave_________________There are three kinds of people in this world: Those who can count, and those who cant.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement