filling a pixel... sure, SOUNDS easy.

Started by
2 comments, last by xProwler 24 years, 8 months ago
I'll write you an example, what median? (Dos, Windows, etc.)
Advertisement
Funkymunky sounds like a nice chap
could you do a quick DDraw example?
the SDK is giving me a freakin headache...

just a fullscreen 640*480 or sumthing with lots of comments and how to put a single pixel. Thanks on beforehand.

Now that I have that info, I still can't get the book for another 4 or 5 weeks. I have to buy some pics from my sisters wedding and get new shoes, a new wallet, some other things, and I really need a TNT2 ultra if I get the $ :P Anyway, I'm gonna try and get the book before the TNT2 and after the rest if I have the $ on that paycheck.. but if i go from $0 to $260 then the TNT2U it is :p Even if I get it ASAP, I have a dilemma. I have like weeks to kill before then. I love C++, I have learned tons about it, but can't use it really without any kind of graphics. I want to start writing my own game - can someone help me with a way, using basic C++ and VC++6 standard edition, to fill a pixel? I was told at first I could just write to a000:0000, but then they said that I couldn't, they being some friends of mine, and I don't know how to write to a specific location like that anyway. (sigh). If you can help me I would greatly appreciate it.

xProwler

Doughtnut ph33r me because I'm beautiful.
OK, sure, here's an example of putting a pixel to the primary buffer (the screen that you see). I hope this helps.

I won't cover any windows that is not completely necessary, because it is a pain in the ass.

// Include DirectDraw thrash#include // * Gasp! global variables! *LPDIRECTDRAW lpdd;LPDIRECTDRAWSURFACE primary;// Later down in the code, in the main loop// (i'm assuming you put this stuff in a// separate function // Create Direct Draw Objectif(DirectDrawCreate(NULL,&lpdd,NULL)!=DD_OK)    return(0);// Now set cooperative levelif(lpdd->SetCooperativeLevel(window_handle, DDSCL_FULLSCREEN | DDSCL_EXLCUSIVE | DDSCL_ALLOWREBOOT)!=DD_OK)    return(0);// Now set the display modeif(lpdd->SetDisplayMode(640,480,16)!=DD_OK)    return(0);// Now set up the primary surfaceDDSURFACEDESC ddsd;// Fill the big happy house to 0memset(&ddsd,0,sizeof(DDSURFACEDESC));// Set data fieldsddsd.dwSize=sizeof(ddsd);ddsd.dwFlags=DDSD_CAPS;ddsd.ddsCaps=dwCaps=DDSCAPS_PRIMARYSURFACE;// create the primary surfaceif(lpdd->CreateSurface(&ddsd,&primary,NULL)!=DD_OK)    return(0);// Now get the video pointerUSHORT *vidmem_ptr;// Lock the primary surfaceprimary->Lock(NULL,&ddsd,DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);// Now get the address of the memory and stuff it into the pointervidmem_ptr=(USHORT *)ddsd.lpSurface;// Now set up where you want the pixel to goint x=320,y=240,col=40;// Now plot the pixelvidmem_ptr[x+(y*ddsd.lPitch >> 1)] =col;// Unlock the display memoryprimary->Unlock(NULL);Whew! Now here's how to shut down DirectX:lpdd->Release();primary->Release();Hope that helps!------------------That's how you do it, but that's just the opinion of a MADMAN!!! BWAHAHAAHAHA! :D :D :D

That's how you do it, but that's just the opinion of a MADMAN!!! BWAHAHAAHAHA! :D :D :D

This topic is closed to new replies.

Advertisement