View unanswered posts | View active topics It is currently Sat Nov 01, 2014 7:24 am



Reply to topic  [ 5 posts ] 
 question about ddsd.lPitch & ddsd.lpSurface 
Author Message

Joined: Sun Sep 14, 2003 7:01 am
Posts: 11
Post question about ddsd.lPitch & ddsd.lpSurface
alright here is the quetion i have. I am reading TOTWGPG and im on chp 6 and im trying to understand the array lpSurface[x + y * lPitch];

i know that lPitch is the number of bytes per line so for a 640x480x8 resolution would it be 8 bits since the color is 8 bits, 1 byte since its 8 bits , or 640 cause that is how many bytes per line there is. so hence would it be

lpSurface[20+30*8]
lpSurface[20+30*1]
lpSurface[20+30*640]

and once the array is set up say its like lpSurface[400] where do that point to does it go2 the the 400th point on the screen and take that and plot the point there?


Sat Apr 17, 2004 11:33 am
Profile

Joined: Thu Nov 30, 2000 8:01 am
Posts: 25
Location: Williamsport, PA
Post question about ddsd.lPitch & ddsd.lpSurface
Sorry, I should have read this the first time I saw it on the board. You are corrent that the pitch is the number of bytes per row (or line). So, in a common video card running 640x480x8 you'll have a minimum pitch of 640 (but it will still probably be 1024 - a power of 2). You can then multiply Y by the pitch to write to the surface.

point x,y = surface[x + (y * pitch)];

I can't remember if 32bit color would then have a pitch of 1024 or 4096 (I would expect 4096).

I'm also not entirely sure why video card manufacturers use this pitch approach, I'm sure its some hardware issue with allowing higher resolutions. So, it may be faster when copying an entire screen (or clearing) to allocate a buffer of height*pitch instead of the actual screen size of width*height.

Does this answer your question? It was a little hard to understand what your question was?


Sun Apr 18, 2004 4:04 pm
Profile

Joined: Sun Sep 14, 2003 7:01 am
Posts: 11
Post question about ddsd.lPitch & ddsd.lpSurface
so when the array is created like Surface[(say 600)600] is the array pointing to the 600th pixel on the surface? or say it was 20,000 or u get what im saying


Sun Apr 18, 2004 8:44 pm
Profile

Joined: Thu Apr 11, 2002 7:01 am
Posts: 7
Post question about ddsd.lPitch & ddsd.lpSurface
The Pitch MAY be 640. And it may not. even in an 8bit mode the pitch may be greater than 640, hence the need for DirectX to provide that information.

<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote
Quote:
and once the array is set up say its like lpSurface[400] where do that point to does it go2 the the 400th point on the screen and take that and plot the point there?


it goes to [400 + 0*Pitch], or the 400th pixel from the left, and the first pixel from the top. (assuming no pointer arithmetic has been performed on lpSurface.)

[ April 18, 2004: Message edited by: Xanth ]</p>


Sun Apr 18, 2004 10:13 pm
Profile

Joined: Sun Sep 14, 2003 7:01 am
Posts: 11
Post question about ddsd.lPitch & ddsd.lpSurface
so if its y it goes x it goes like 400 pixels to the left but say x was 400 and y was 150 would it go 400 pixels to the left and 150 pixels down?


Mon Apr 19, 2004 12:10 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware.