Jump to content
  • Advertisement

Archived

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

QBRADQ

Line drawing and pixel setting in DX7

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

How do I draw a line of a specified color and set a pixel of a specified color in DX7? I can''t seem to find this. I am doing a pong game just for kicks, and have never had to draw lines before. I COULD do it by abussing the streaching capablities of the Blt(), but I REALY don''t want to

Share this post


Link to post
Share on other sites
Advertisement
I am doing nearly the same project now, but use sdl http://www.libsdl.org which has a function for drawing filled rects which fits perfectly in drawing for pong style paddles.
But I don''t know if that is also available in directx.
If not use the blit stuff a pong style game is not that resource hungry, so you shouldn''t have to worry about speed, you probably have to slow it even down

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

Direct Draw has no line drawing functions. You have to:

1. Write your own line drawer.
2. Use a library.
3. Abuss the streaching capablities of the Blt().
4. Abuse the stretching capabilities of Blt().


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Its better to use a blit. It´s faster if you cant asm.

Share this post


Link to post
Share on other sites
This is from the DirectX7 SDK.

DirectDrawSurface7.DrawLine

The DirectDrawSurface7.DrawLine method draws a line on the surface.

object.DrawLine( _
x1 As Long, _
y1 As Long, _
x2 As Long, _
y2 As Long)

Parameters
object
Object expression that resolves to a DirectDrawSurface7 object.
x1, y1, x2, y2
End points of the line to be drawn.
Error Codes
If the method fails, it raises an error, and Err.Number is set.

Remarks
The default draw style is a solid line; this can be changed with a call to DirectDrawSurface7.SetDrawStyle



For plotting pixels you have to lock the surface and then use this.

DirectDrawSurface7.SetLockedPixel

The DirectDrawSurface7.SetLockedPixel method sets a single pixel to the specified color and updates the locked surface.

object.SetLockedPixel( _
x As Long, _
y As Long, _
col As Long)

Parameters
object
Object expression that resolves to a DirectDrawSurface7 object.
x and y
Coordinates of the pixel to set.
col
RGB value for the set pixel.
Error Codes
If the method fails, it raises an error, and Err.Number is set.

Remarks
You must first lock the surface with a call to DirectDrawSurface7.Lock.

The above method is very slow unless you are plotting only a few pixels per frame.

Good luck

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!