Forumchem - Forum with AI(ALICE BOT & HAL9000) and TTS

More dificult for us, more easy for you
It is currently Fri Apr 19, 2024 10:07 pm

All times are UTC





Post new topic Reply to topic  Page 1 of 1
 [ 1 post ] 
Author Message
 Post subject: c++ - opengl coordinate system is not at -1 to 1 - stack ove
PostPosted: Thu Nov 07, 2013 3:03 pm 
Offline
User avatar

Joined: Fri Apr 03, 2009 1:31 am
Posts: 1357
c++ - opengl coordinate system is not at -1 to 1 - stack overflow

If you arent going to be dynamically changing your projection matrix, the easiest thing to do would be to call



glScalef(.63f,.63f,1);



on your projection matrix.



You can then restrict movement based on these values.



To compute the world space coordinates at any time you should make use of gluUnProject.
assuming x and y are the width and height of your window respectively (the values you pass gluPerspective) you can find the world space coordinates like so:



double world_llx,world_lly,world_llz;
//world coordinates of lower left corner of window
gluUnProject(0, 0, 0, view_mat, proj_mat, viewport,&world_llx,&world_lly,&world_llz);
//world coordinate of upper right corner of window
double world_urx,world_ury,world_urz;
gluUnProject(x,y,0,view_mat,proj_mat,viewport,&world_urx,&world_ury,&world_urz);


view_mat is your view matrix. proj_mat is your projection matrix. You can get both of these using glGetDouble* with GL_MODELVIEW_MATRIX and GL_PROJECTION_MATRIX.



The viewport parameter will probably have the same dimensions as your window. In any event, this is what you set with glViewport.



This assumes your XZ plane is at z == 0.






Source



Top
 Profile      
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  Page 1 of 1
 [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: fukgolmuetoeg4 and 8 guests


 
Search for:
 
Jump to:  

cron
Click me:
Powered by phpBB © 2000, 2002, 2005, 2007, 2008, 2009 phpBB Group
Chronicles phpBB3 theme by Jakob Persson. Stone textures by Patty Herford.
With special thanks to RuneVillage

This site have 4 type of tecnology in order to convert text to speech. By default you use the vozme tecnology. In order to know the other you need to sign for.


- Privacy Policy -