Jan 1, 2010 at 9:18pm UTC
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 Jan 1, 2010 at 9:24pm UTC
Jan 1, 2010 at 9:45pm UTC
It works fine on MSVC++, what compiler are you using? [or maybe your windows.h file is corrupt]
Jan 1, 2010 at 9:51pm UTC
Are you linking to the right libraries?
Jan 1, 2010 at 10:23pm UTC
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 Jan 1, 2010 at 10:25pm UTC
Jan 1, 2010 at 10:31pm UTC
You need to add -lgdi32 to the linker flags.
Jan 1, 2010 at 10:39pm UTC
that worked! no errors. thanks!
Jan 2, 2010 at 1:08am UTC
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