quick SetPixel() example?

I've looked everywhere but cannot seem to find a good example usage of SetPixel()... could someone please post an example of this function using valid parameters?

When I try to use it with the following code

1
2
3
4
#include <windows.h>
int main() {
   SetPixel(NULL, 0, 0, RGB(255, 255, 255));
}


I get an error:

1
2
[Linker error] undefined reference to `SetPixel@16'
ld returned 1 exit status 
Last edited on
It works fine on MSVC++, what compiler are you using? [or maybe your windows.h file is corrupt]
Are you linking to the right libraries?
Im using Dev-C++. Its possible that my windows.h is corrupt. ive had several linking problems like this.

I noticed that I do not have Gdi32.lib in my lib/ directory. Do I need this?
Last edited on
You need to add -lgdi32 to the linker flags.
that worked! no errors. thanks!
It's worth noting that:

1) SetPixelV is faster than SetPixel

2) SetPixelV is still dreadfully slow.

For faster per-pixel drawing, look up SetDIBits or CreateDIBSection
Topic archived. No new replies allowed.