Skip to main content
GameDev.net gamedev.net
🔒 Locked

pixel plotting in DirectDraw

Started by Real World Sep 19, 2002 at 1:54 PM 6 replies 200+ views
Original Post
Real World
Real World
OK I have a large array with COLORREF values. I want to display these colours to the screen unless its black. The problem I have is plotting these pixels to the screen. I found a tutorial on gamedev for depth buffer independant pixel plotting but it uses indexed colour and i need to just grab a colour from a array and put it on screen so I don''t think its what I want. Can anyone point me in the right direction? Planetblaze.com - www.planetblaze.com - As METAL as it gets!
Tooko
Tooko
To draw an individual pixel to a LPDIRECTDRAWSURFACE you need to do the following code: (I wrote an easy to use function)

void PutPixel(int x, int y, COLORREF color)
{
HDC dc;
lpDDS->GetDC(&dc);
SettPixel(dc, x, y, color);
lpDDS->ReleaseDC(dc);
}
Please note that lpDDS is your secondary buffer. If not using double buffering, use your primary surface. And remember to flip surfaces after drawing. I forgot once

Mike
the future is just like the past, just later. - TANSTAAFL
Real World
Real World
Thats the GDI set pixel code isn''t that slow or something?
I was hoping to find some DirectDraw8 code

Planetblaze.com - www.planetblaze.com - As METAL as it gets!
Hyatus
Hyatus
Well, it would help if you were a little more specific.
What''s your bpp?
And I''m assuming DX8?
You''re plotting on the screen, correct?(as opposed to a texture
on a triangle/polygon/etc...)

I know how to do it in DDraw7, which seems to be the best choice
for 2d from an ease-of-use standpoint. Haven''t mugged around in
DX8Graphics, tho...

-Hyatus
"da da da"
Real World
Real World
I thought I had already answered all those questions.

What''s your bpp?
- I want bit depth independant pixel plotting
And I''m assuming DX8?
- Yes thats correct
You''re plotting on the screen, correct?(as opposed to a texture
on a triangle/polygon/etc...)
- My entire game is 2D so I have been using traingles which are textured and displayed in the scene. As a result there are no LPDIRECTSURFACE8 references anywhere which is causing problems so far with the tutorials I have encountered.

And yeah I know DX7 is better for 2D but I have 8.1 now and I can''t and dont want to go back

Any help?

Planetblaze.com - www.planetblaze.com - As METAL as it gets!
digitec devil
digitec devil
you can still use DirectX7 functions, so theres no problem with learning DirectX7''s direct draw
Real World
Real World
really? I thought they had all been replaced

Planetblaze.com - www.planetblaze.com - As METAL as it gets!
Hyatus
Hyatus
Actually, they can't replace it.
It's part of the DX interface.

You can bring up any version of a DX component you want.

For the DX8->DX7 conversion, you'd have to change your display
format a tad. DX7 is a seperate entity from DX8.

However, there are some advantages you might want to consider
with DX8. If you plan on using a lot of effects like
translucent objects, you might want to stay with it.

[edited for bad, less sensible grammar and lack of sleep]

-Hyatus
"da da da"

[edited by - hyatus on September 29, 2002 2:42:05 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.