I am having a bit of an issue with the position of things on the screen when I, or my users, are running in different resolutions. I generally run in 1024x768 (or another 4:3 ratio mode) but I recently got a widescreen monitor and decided to move my resolution to 1280x768 (which I believe is a 16:9 ratio) and I have noticed that some things are not where I'd expect them to be.
This was not unexpected, but I'm not sure about how to get them back to the place I want them - regardless of what resolution is being used by my users. Here are two .jpg images (100K each I'm afraid) that illustrate what I'm talking about. In the code, I set the X location of the Singer Images going down the left hand side as a constant value - they are placed at -0.6 on the X after I have translated to -2 on the Z. They are also a constant size (W = 0.41601 and H = 0.13541) and in any 4:3 resolution (800x600, 1024x768, 1600x1200) they appear on screen as I had intended... at the left, the size they are supposed to be - the picture illustrates:
When I change to a widescreen resolution, though, my Singer Images are still obviously been told to go to -0.6 on the X - but there are more pixels than there were previously... so they are closer to the centre of X, i.e. 0 - the picture illustrates:
You will notice that all the text is in the right place - as I'm doing that in orthographic mode obviously. My question is... when using gluPerspective (45,Screen.Width / Screen.Height,1,100); how can I understand what the OpenGL unit limits of my screen actually are when running in different resolutions? I am translating to -2 on the Z plane, if I have, say, a 1280x768 screen what OpenGL unit would be close to the left edge of the screen? Likewise in 1920x1200 and other resolutions. I obviously know how many pixels I have to play with 1024 or 1280 in this case... but I don't yet know how to work out my OpenGL limits. I understand that I won't be able to survive with a constant value of X, i.e. -0.6, for the X position of my Singer Images any more - now that widescreen screens and resolutions are becoming more and more prominent.
Registriert: Mo Sep 02, 2002 15:41 Beiträge: 867 Wohnort: nahe Stuttgart
OK, I don't know whether my ideas work or whether you've tried them already, but I've got a few words to say:
1. 1280x768 is 5:4, 1280x720 would be 16:9
The second parameter is the aspect ratio, so you could try to simply replace the screen dimensions with "4/3".
3. To answer your actual question, I think if you multiply the Projection matrix with the vector you're displaying, you can tell where on the screen it actually is (at least I hope the result is in the range 0..1 or -1..1 or something like that).
4. Another idea that just came to my mind: You could divide your position (maybe only X?) by 4/3 and then multiply it with Screen.Width/Screen.Height. Could be pretty much the same effect as 2.
Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast
Du darfst keine neuen Themen in diesem Forum erstellen. Du darfst keine Antworten zu Themen in diesem Forum erstellen. Du darfst deine Beiträge in diesem Forum nicht ändern. Du darfst deine Beiträge in diesem Forum nicht löschen. Du darfst keine Dateianhänge in diesem Forum erstellen.