# Window dimension in world coordinate

This topic is 3827 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...

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

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634046
• Total Posts
3015224
×