Window dimension in world coordinate

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

Share on other sites
top-left -1, 1, 0
top-right 1, 1, 0

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

Share this post

Share on other sites
Quote:
 Original post by Molle85top-left -1, 1, 0top-right 1, 1, 0bottom-left -1, -1, 0bottom-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

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

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

Share on other sites
Quote:
 Original post by datalurkurIt 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

Share on other sites
Quote:
Original post by Molle85
Quote:
 Original post by datalurkurIt 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

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;}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

• Forum Statistics

• Total Topics
628275
• Total Posts
2981740

• 10
• 11
• 17
• 10
• 9