Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: So Jul 13, 2025 17:10

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 2 Beiträge ] 
Autor Nachricht
BeitragVerfasst: So Sep 23, 2007 11:11 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
Hi,

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:

http://www.hmusiccentre.org.uk/forumimages/1024x768.jpg

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:

http://www.hmusiccentre.org.uk/forumimages/1280x768.jpg

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.

// Edit Lossy: Images as links

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: So Sep 23, 2007 16:42 
Offline
DGL Member
Benutzeravatar

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

2.
Zitat:
gluPerspective (45,Screen.Width / Screen.Height,1,100);

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).

You can find the actually created matrix here: gluPerspective. That matrix is multiplied with the identity matrix via glMultMatrix (no idea how it's done exactly), maybe you should check Google/whatever/the Specs: http://www.opengl.org/registry/doc/glspec21.20061201.pdf
If you multiply your matrix with your vector just like here (first picture below the heading "Anwendung der Matrix...":
http://wiki.delphigl.com/index.php/Tutorial_Nachsitzen#Anwendung_der_Matrix_auf_einen_Vektor
you should have its position on the screen.

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.


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 2 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

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.

Suche nach:
Gehe zu:  
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.010s | 17 Queries | GZIP : On ]