PDA

View Full Version : about diferent screen resolutions



Xception
11-10-2000, 12:09 AM
I'm am having some trouble for example using the mouse coordinates because the coords I get are relative to he window upper left corner and they vary from 0 to the screen resolution, and in gl I'm usng floats that are much lower values than those I get from the mouse.

I converted the mouse coords so tha they vary from -1 to 1

But rounding many times makes the calculation become inprecise sometimes.
Is'nt there an easyer way for getting the mouse coords in "gl mode" if know what I mean.

ipo
11-11-2000, 09:56 AM
I am not sure what you have in mind. If you're looking for a way of mapping window coordinates to object coordinates and vice-versa, check gluProject & gluUnProject()

RandyU
11-12-2000, 02:05 PM
If you mean mapping windows coordinates to GL coordinates try this formula:
xgl = (xw-winx/2.)/(winx/2.)*XT
where xw - x in window coordinates
winx- window's width
XT - most left GL coordinate on desired depth
I think accuracy of this is enough for any purpose

Xception
11-13-2000, 12:01 AM
I think I am doing some sort of calculations very similar to those but what happens is that when I change the screen resolution I work In something happens so that mouse coords stop working has they wore.

The problem I think that I have is that I want to map the coords of the mouse to a plane that doesent exists but that if it existed it would ocuppie the Intire screen, and the so called XT vaiable is the value more to the left in gl coords, so how do I know the value of XT??I've used several "random" values and I got to 1.33 that was the current aspect ratio. I think that with the equation you posted here i'll solve my problem , thx for everything

Xception
11-13-2000, 12:03 AM
Sorry about the big mess of words up there, its early in the mornign and I'm kind of asleep

RandyU
11-13-2000, 02:19 PM
If i have no mistake,
YT = dist*tg(fovy/2)
XT = YT*aspectratio
where fovy is a field of view ( in raidans)
dist - distance to needed plane
aspectration - WINX/WINY