How to draw a single pixel

Dear Programmers,

I want to write a program, which needs two points, and draws a line between these two points. The problem I'm facing now, is how to draw a single pixel?
I know that there are several functions to draw a line, but i can't use them, because my job is to make a program, which demonstrates the drawing method. So i want to ask two points from the user, and then i want to draw the line between the two coordinates from pixel to pixel. I have 7 days to finish this and send to my teacher.
So I just want to know, how to draw a single pixel easily.

Best wishes:
Ray
What graphics library are you using?
The other question, that which library is the easiest, to draw a pixel?
I was about to use OpenGL, but couldn't figure out, how to use it.
I just want to know, how to draw a pixel in any graphics library.
As soon as I can draw a single pixel, i can draw a line, right? This is what I think.
you can use the function 'SetPixel()' by including <windows.h> and <wingdi.h> and link the 'gdi32' lib in your project.
@Rayy, Drawing a single pixel is different than drawing text, or drawing a line, because a line can be diagonal. Unless you want to develop your graphic engine from scratch, you should use some graphic library like Irrlicht, SDL, or plain OpenGL (See here for nice tutorials (Outdated, take care) : http://nehe.gamedev.net/tutorial/lessons_01__05/22004/
or plain DirectX. Just letting you know, if you make a line only of plain dots, it's using more CPU than making a line from premade functions. Why?
Because let's say you make a horizontal line like this:
1
2
3
4
5
void line(Position begin, Position end)
{
	for(int x = begin.x; x < end.x; x++)
		DrawPixel(x,begin.y);
}

Your CPU will handle your DrawPixel many times.
If you draw a plain Line with Hardware Accelerated Graphics, your GPU will handle that, and your CPU will handle a DrawLine only once.
@EssGeEich, Thanks for the advice, I know, that you're right, but I don't have to care about the speed of the program.

@Vins3Xtreme, Thanks foe the SetPixel(), it works great.

Another question: i want to get datas from the user, but not in the console window. I can write into my window with the TextOut() function. How can I get datas from the keyboard?

Thanks,
Ray
you may want to see something like this... http://www.cplusplus.com/forum/lounge/65208/
Topic archived. No new replies allowed.