C++ w/ OpenGL Pixel Perfect Plot -


i need plot pixel on window, according position in pixels in integers, not floats. like, example, if plot 0, 0 top left corner of window, 1,1 1 pixel right of 0, 0, , 1 pixel below 0. guess need kind of grid. don't care if 0, 0 origin how is, need count pixels, not having 1 max , -1 min, or whatever.

things have tried: thought window width ^-1 * x plotting, , work, not time. anyways, how go doing this? have done x position / screen width, , works best, stops working every 10 or pixels.

first of all, opengl doesn't guarantee pixel perfect placement in cases. however, there common gotcha: center of each pixel not have integer coordinates if pixel coordinates.

here's diagram of bottom-left pixel in opengl viewport.

+y ^ |      +-----+ |     | |  o  | |     | +-----+---> +x 

if data transformed each pixel has width , height of 1 unit, center of pixel @ (0.5, 0.5). if draw gl_point @ pixel, coordinates should (0.5, 0.5). if draw rectangle, go (0,0) (1,1). if draw vertical line through it, line should have x-coordinate of 0.5.

et cetera.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -