• 12
• 12
• 9
• 10
• 13

# Window dimension in world coordinate

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

## 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 on other sites
top-left -1, 1, 0
top-right 1, 1, 0

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

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

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