I’m trying to just draw a single pixel in an opengl view… I’ve tried the following code but not seen anything but the black background…what else is needed?
You need to setup the modelview transformation, the default “camera” in OpenGL is located at 0,0,0 looking along Z axis and you would probably need to change that to make your point visible, take a look at a tutorial on OpenGL, you can just do a glTranslate( 0, 0, distance_from_origin) or use gluLookAt() to change the “camera”
Yeah, the problem is I have be able to draw a pixel in the right spot in a view…
I’m required for a class to write the code to draw a line and to convert from world coordinates to screen coordinates. Once in screen coordinates, I’m supposedly able to use this code:
void Pixel::drawPixel(int xPixel, int yPixel)
{
//convert from pixel to world projected coordinates and plot one pixel
double xCanonical;
double yCanonical;
How far can you stretch the assignment? You can make the conversion trivial, but I expect that will break the rules…
Use glOrtho or gluOrtho2D to create a scene with the xmax and ymax set to the window’s width and height, and xmin and ymin set to 0. This should give a one-to-one correspondence between your drawing space and the pixels on the screen.
Hint for the future: instead of adding together values in the glClear call, bitwise OR them (use | instead of +). If you ever typo and include the same value twice, this will save a lot of head-scratching.