Jump to content
  • Advertisement

Archived

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

cleves

pixel plotting

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

Hey all, The book i''m reading uses Plot8(100,20,26, (UCHAR *)ddsd.lpSurface,(int)ddsd.lPitch); to plot a pixle on the surface but this function dosen''t exsist in the directx 9 anymore. Is there any other function that does the same in directx 9? thanks

Share this post


Link to post
Share on other sites
Advertisement
Acquire a pointer to the surface by locking it. Adjust the pBits for the type of access you want i.e DWORD, BYTE etc... (don''t forget the pitch too) then simply calculate the position by: pitch * y + x and then set the colour on that pixel.
Release the surface and present the screen.
You can then create a function and call it Plot8 if you want.
However, I would recommend not making this a function as the call takes more time than actually placing the colour value itself.

____________________________________________________________
Try RealityRift at www.planetrift.com
Feel free to comment, object, laugh at or agree to this. I won''t engage in flaming because of what I have said.
I could be wrong or right but the ideas are mine.

Share this post


Link to post
Share on other sites
I build some functions myself and these are very fast

inline HRESULT D3DLockSurface(LPDIRECT3DSURFACE9 pD3DS, D3DLOCKED_RECT* D3DLockedRect)
{
return pD3DS->LockRect(D3DLockedRect,0,0);
}

inline HRESULT D3DUnlockSurface(LPDIRECT3DSURFACE9 pD3DS)
{
return pD3DS->UnlockRect();
}

inline void D3DPutPixel(D3DLOCKED_RECT D3DLockedRect, int x, int y, unsigned int rgb565)
{
int offset = (y*D3DLockedRect.Pitch + x*2);
unsigned char* szSurface = (unsigned char*)D3DLockedRect.pBits;
memcpy(szSurface + offset,&rgb565,2);
}

rgb565 can be done with:

#define RGB565(r,g,b) ((r << 11) | (g << 5) | b)

unsigned int color = RGB565(255,0,178)

Have fun

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!