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

Another pixel plotting problem

Started by james86 Feb 24, 2003 at 3:10 PM 1 replies 300+ views
Original Post
james86
james86
Hi, I have a simple asteroids like game that Im making and I''m trying to plot stars to the background. Its a full screen app running at 800*600*16. I locked the surface (lppdsback), got the line pitch (which I checked) and set a pointer equal to the surface desc. UCHAR *video_buffer; DDSURFACEDESC2 ddsd2; then I initialized ddsd2 and used it when I locked lpddsback. video_buffer = (UCHAR *)ddsd2.lpSurface; Then I try to plot the pixel with video_buffer[x + y*lpitch] = _RGB16BIT565(255,255,255); before the macro was defined as: #define _RGB16BIT565(r,g,b) ((b%32) + ((g%64) << 6) + ((r%32) << 11)) The I run the program and the pixel is in the correct location, but it is flickering and blue (sometimes changes to yellow). Does anyone have any idea what I did wrong? Thanks a lot. James
DarkPixel
DarkPixel
Well,

I may be wrong, but the line
video_buffer = (UCHAR *)ddsd2.lpSurface;
means that video_buffer is an array of unsigned chars, right ?

And, If i'm right, _RGB16BIT565(255,255,255) should return a
16-bit value, right ?

Is anything in the next line that sounds wrong ?
video_buffer[x + y*lpitch] = _RGB16BIT565(255,255,255);

(unsigned char = 1 byte)=(unsigned short = 2 bytes)=????

Try to change the 4th line to :
video_buffer = (USHORT *)ddsd2.lpSurface;

Right ? mm....mmmm...euh... I think !


[edited by - DarkPixel on February 24, 2003 4:22:42 PM]

There is no problem, only solutions...
brass_fish
brass_fish
shouldnt you be checking to see whether to use 565 or 555? im not really sure cuz ive never accually plotted a pixel in 16 bit color. but i did skim over a ddraw tutorial that had that in there.
extended waranty, how can I lose!

Topic Locked

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

Sign in to reply to this topic.