🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

DirectDraw-stuff

Started by
0 comments, last by mr BiCEPS 24 years, 6 months ago
Hiya! I''m new to DirectX-stuff (Just got the SDK last week Now i''m wondering something... I just don''t seem to be able to find the answer anywhere... Well, here goes: Is there method similair to the GDI-funktion SetDIBits, but for use on a DirectDraw-surface? if not... What''s the fastest way of putting a pixel on that surface..? (I am running it a window with buffer blitting) I tried the Loch method (on the backsurface), and then writing direcly to that pointer... However, the computer jammed when I called the lock-API... /Grateful for any help
Advertisement
Hello warrior!

Hero you have a code slice from one of my games.
It draws a straight line.

void CDirect3drm::Draw_straight_line(int x1, int y1, int length,
int color, bool facing_x)
{
BYTE r, g, b;
int slut_punkt;

r = color >> 16;
r = r%256;

g = color >> 8;
g = g%256;

b = color;
b = b%256;

if(facing_x)
{
slut_punkt = x1+length;
}
else
{
slut_punkt = y1+length;
}

BYTE *pixels;
long lPitch;

memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);

backsurf->Lock(NULL,&ddsd,DDLOCK_SURFACEMEMORYPTR / DDLOCK_WAIT, NULL);
{
pixels = (BYTE *)ddsd.lpSurface;
pixels = &pixels[ddsd.lPitch*y1+3*x1];
lPitch = ddsd.lPitch;

if(facing_x)
for(int i=x1; i {
*pixels = b; pixels++;
*pixels = g; pixels++;
*pixels = r; pixels++;
}
else
for(int i=y1; i {
pixels[0] = b;
pixels[1] = g;
pixels[2] = r;
pixels+=lPitch;
}
}
backsurf->Unlock(pixels);
}

Gandalf the White
Gandalf the Black

This topic is closed to new replies.

Advertisement