By (5, 5) I mean exactly the fifth row and fifth column.
I found it very hard to draw things using screen coordinates, all the coordinates in OpenGL is relative, and usually ranging from -1.0 to 1.0. Why it is so serious to prevent programmers from using screen coordinates / window coordinates?
Determine the Location of the Pixel Region Rectangle To determine the current location of the pixel region in the target image, you can use the pixel information given at the bottom of the tool. This information includes the x- and y-coordinates of pixels in the target image coordinate system.
The pixel coordinate is a number that identifies the location of a pixel in the image array.
Pictures are made up of little pixels, laid out on an (x,y) grid. Each pixel contains a color. Each color has a red part, a green part, and a blue part. Each color part is actually a number between 0 and 255.
The simplest way is probably to set the projection to match the pixel dimensions of the rendering space via glOrtho. Then vertices can be in pixel coordinates. The downside is that resizing the window could cause problems and you're mostly wasting the accelerated transforms.
Assuming a window that is 640x480:
// You can reverse the 0,480 arguments depending on you Y-axis
// direction preference
glOrtho(0, 640, 0, 480, -1, 1);
Frame buffer objects and textures are another avenue but you'll have to create your own rasterization routines (draw line, circle, bitmap, etc). There are problaby libs for this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With