Sign in to follow this  
Evil Ozzy

Drawing a Pixel on a 32Bit Surface

Recommended Posts

Evil Ozzy    127
Hi guys, I am clearly having a dumb day today... I have a primary and a back buffer, i compose my 2D scene on the backbuffer and flip as usual, in certain circumstances I want to blur the contents of the backbuffer before the flip (I have a general blur algorithm). But for some reason I cannot manage to draw a pixel to the backbuffer surface once I've locked it...it's driving me insane, I am obviously doing something wrong, but can't see the wood for the trees... Can someone put me out of my misery and post me the code to write pixels to a 32bit surface... Cheers James

Share this post


Link to post
Share on other sites
Evil Ozzy    127
Hi Guys,

Yes sorry, school boy error in not giving you all the facts, ok let me try again...

Am using DirectX7, and C/C++. So all I am trying to do is build my scene on the backbuffer, then blur it, the perform the flip.

But for the time being I will settle just for plotting some pixels on the screen. I can get the odd one pixel, but it flickers, but most of the time no pixels show at all, so my math must be wrong or my pointers messed up...

Hopefully someone can put me right and out of my misery....

Cheers peeps :o)

void render func1()
{
render_some_stuff(backbuffer);

blurSurface(backbuffer);

primarysurface->Flip(); // screen res 1024x768
}

#define RGB24(r, g, b) ((((r) << 16) | ((g) << 8) | (b)))

void blurSurface(LPDIRECTDRAWSURFACE7 lpDDS)
{
DDSURFACEDESC2 ddsd;
UINT32* LockedSurfaceMemory;
UINT32 SurfacePoint;

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

lpDDS->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);

LockedSurfaceMemory = (UINT*) ddsd.lpSurface;

//my blur routine will sit here one day....

//calculate the surface address and draw a few pixels...
for(UINT ix = 0; ix < 100; ix++)
{
SurfacePoint = ix + 600 * ddsd.lPitch; // x + y * pitch
LockedSurfaceMemory[SurfacePoint] = RGB24(0, 255, 0);
}

lpDDS->Unlock(NULL);
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this