Jump to content
  • Advertisement
Sign in to follow this  
enigmagame

Window dimension in world coordinate

This topic is 3617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I've a window of length 1280 and height 800. I've setup the projection matrix and the modelview matrix, is possible to know the dimension of the window in world coordinate? I would know the coordinate of the up-left corner etc. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Molle85
top-left -1, 1, 0
top-right 1, 1, 0

bottom-left -1, -1, 0
bottom-right 1, -1, 0

I'm confused, if I place a point in (-1, 1, 0), I can't see this point, is out of the camera frustum. In order to have this dimension, how I must set the projection and the modelview matrix?

Share this post


Link to post
Share on other sites
That is in view projection space, so if you set the world matrix to inverse of the view projection you will have it in that space

Share this post


Link to post
Share on other sites
It might be a good exercise - if you want to know more about OpenGL, anyway - to read up on matrix math. Using graphics is one thing, but understanding how it works fundamentally is another entirely.

If you check on opengl.org, you can probably find something helpful.

Share this post


Link to post
Share on other sites
Quote:
Original post by datalurkur
It might be a good exercise - if you want to know more about OpenGL, anyway - to read up on matrix math. Using graphics is one thing, but understanding how it works fundamentally is another entirely.

If you check on opengl.org, you can probably find something helpful.


he never mentioned that he was using opengl, and wiki has probably more information about matrix math

Share this post


Link to post
Share on other sites
Quote:
Original post by Molle85
Quote:
Original post by datalurkur
It might be a good exercise - if you want to know more about OpenGL, anyway - to read up on matrix math. Using graphics is one thing, but understanding how it works fundamentally is another entirely.

If you check on opengl.org, you can probably find something helpful.


he never mentioned that he was using opengl, and wiki has probably more information about matrix math


Well, this IS the OpenGL forum, you know...

Share this post


Link to post
Share on other sites
I found this quite useful, mentioned in another old thread. I'm having trouble finding good info on how gluUnProject works though. Because it seems to exaggerate the movements I make with the mouse with the projected coordinates even though I've set up all matrices to work with 1280x720.



Vector3 Unproject( int x, int y )
{
Vector3 coords; //Something to store our return value in
GLfloat wx, wy, wz; //Window coordinates
GLdouble cx, cy, cz; //Object coordinates

GLdouble mv[16]; //Modelview matrix
GLdouble proj[16]; //Projection matrix
GLint vp[4]; //Viewport

glGetDoublev( GL_MODELVIEW_MATRIX, mv );
glGetDoublev( GL_PROJECTION_MATRIX, proj );
glGetIntegerv( GL_VIEWPORT, vp );

//re-enable various settings we may have turned off
glEnable(GL_DEPTH_TEST); //Re-enable depth testing and masking
glDepthMask(GL_TRUE);
glDepthRange(0.0f,1.0f);
wx = ( float ) x;
wy = ( float ) vp[3] - ( float ) y; //To invert the y


glReadPixels( x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &wz );

gluUnProject( wx, wy, wz, mv, proj, vp, &cx, &cy, &cz );

coords = Vector3( cx, cy, cz );

return coords;
}



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!