how can determine(this isn't right term use know) that, every position of mouse in window space
, gets converted ogl space
(-1, 1). in case, user moves mouse fast, assume all of previous positions converted ogl coordinates. trying that...is common cpu fast enough (to track previous events) if c++ ogl coordinates converter
computational expensive? lets put time consuming loops in there? or.. fast method()
. how can assure no ogl coordinates skipped out if move mouse fast enough? i'm not jumping conclusion here or assuming else might think.
edit:
my program main loop this(pseudocode):
void pollevents() { everyt_obj in { if not collide() { move(x, y) // } } } void mousepos() { mouse.pos = to_ogl_coord2f() }
these separate threads executed (but not real thread) suppose mouse.pos = (0, 0)
moved mouse fast enough make new mouse.pos
(10, 10). in single execution of loop, mouse position changed far before. now, how can tell program, implementing bresenham's line algorithm
mentioned christian rau, values generated algorithm(not being tracked) have been crossed mouse. add loop step positions?
how can assure no ogl coordinates skipped out if move mouse fast enough?
that's not possible, since there no way let os generate mouse events each , every point mouse move have crossed when tracked theoretically infinite precision.
the way ensure fill missing points between 2 (possibly far away) mouse positions yourself. if want draw point each position mosue moved on (maybe using opengl), draw line instead.
if on other hand need intermediary mouse positions further computations, won't around computing them using common line rasterization algorithm (like bresenham algorithm, the school book algorithm line rasterization). compute each point on discrete grid line 1 point have crossed (similar graphics card when converting line discrete pixels), generate each discrete mouse position virtual mouse path has crossed (ignoring non-linear mouse movement between measurement points).
edit: if don't need discrete line proper equal-width characteristics easier way messing line rasterization work floating point positions , simple linear interpolation of end points, datenwolf writes in comment. give better timing precision discrete mouse positions. depends on want mouse positions (and way tell us).
edit: updated question looks need mouse positions @ high granularity in order compute collision of mouse objects. in case don't need intermediary points @ all. take line current mouse position previous 1 (represented pair of points, or whatever theoretical line representation) , compute collision of objects line instead of individual points.
Comments
Post a Comment