Jump to content
  • Advertisement
Sign in to follow this  
Evil Ozzy

Drawing a Pixel on a 32Bit Surface

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

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!