   How to resize ortho view?
  Hi, i'm creating a GUI for opengl and i can get the 3D scene behind it to resize but i can't get the gui to resize, so it gets messed up when i change resolutions. Maybe it is just a dumb mistake. My resize code isglViewport(x,y,resolution.width(),resolution.height());   glMatrixMode(GL_PROJECTION);    glLoadIdentity();gluPerspective(fov,(GLfloat)resolution.width()/(GLfloat)resolution.height(), z_near ,z_far);glMatrixMode(GL_MODELVIEW);  glLoadIdentity(); I'm using this to switch to ortho after i draw my 3DglViewport(x, y, resolution.width(), resolution.height());glMatrixMode(GL_PROJECTION);glLoadIdentity();gluOrtho2D(x, resolution.width(), y, resolution.height());glMatrixMode(GL_MODELVIEW);glLoadIdentity();    I am confused why are my ortho drawings not being resized?[edited by - clayasaurus on February 14, 2004 4:33:48 PM]
  I think your problem is that you don't fully undrestand orthographic/perspective projections. In an orthographic projection, the viewing volume is a box. When you use the dimensions of the window with glOrtho2D, you are getting a box the width and height of the window, with znear/zfar of -1.0 and 1.0. What this means is that (x,y) coordinates of (0,100) will be the same in a window that is 640x480 as they will in a window that is 800x600. You see, you have set up your projection so that you can treat it as a regular 2D framebuffer (think of blitting in DDraw).If you want your GUI objects to maintain dimensions relative to those of the window, then you need to derive the object's coordinates using the window dimensions. For example, a fullscreen GUI object that has its lower right corner at (640,480) in a 640x480 window will need to be adjusted to (800,600) in a window that is 800x600. So you need to be using that resolution.width & resolution.height to draw your GUI objects.You can really see what I mean if you play around with setting the ortho projection using values that are not the same as the window. For example, in an 800x600 window try setting the ortho projection using 400 for width and 300 for height and see what happens.EDIT: I just noticed you are using x,y variables in the gluOrtho2D call. My above assumption would be totally off if you are using any values other than 0 for those two variables. What *are* you using there?   Additionally, though it shouldn't hurt anything, there's no need to set the viewport each time you change projection modes. This only needs to be done once when the window is resized.   [edited by - aldacron on February 14, 2004 11:36:19 PM];  it would be easier to just use a fixed size for the projection like 1000 or 10000 and use relative coordinates. rounding errors might misplace some corner by one pixel, but youd have the same if you do it yourself and the textures will be a bigger problem anyway. make the default too small and high resolutions look bad, make it too big and lowresolutions are impossible to read. ;  The parameters are gluOrtho2D(left, right, bottom, top), which is not how you used it.   “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”    — Brian W. Kernighan (C programming language co-inventor);  yea my x & y values are just zero, but i keep them there if i ever want to change them for some bizzare reason.Fruny, so i don't call ortho like this? gluOrtho2D(0, 800, 0, 600); so i guess i use 0,800,600,0i got rid of the glViewport tooAldacron, so what you are saying is that i need to code the resizing of my GUI objects myself based on the current resolution? Well since it is all 2D i guess that shouldn't be too hard. Thx, bye.   [edited by - clayasaurus on February 15, 2004 6:03:47 AM];quote:Original post by clayasaurus  Aldacron, so what you are saying is that i need to code the resizing of my GUI objects myself based on the current resolution? Well since it is all 2D i guess that shouldn''t be too hard.just dont touch it and use the same for all resolutions. ortho takes world units and not pixels so just forget about your resolution or use your reference resolution.;quote:Original post by Trienco  just dont touch it and use the same for all resolutions. ortho takes world units and not pixels so just forget about your resolution or use your reference resolution.So your saying I should use the same world unit resolution  for every resolution, and if i do that the ortho drawings resize automatically. The only thing wrong is that my mouse coordinates become totally off on anything other than the reference resolution. ;  oops i didn''t mean to post anomonously oh well ;quote:Original post by Anonymous Poster  The only thing wrong is that my mouse coordinates become totally off on anything other than the reference resolution.  Then adjust the mouse coordinates to fit the reference resolution before feeding them into your GUI.;  i''ve tried to change the mouse coordinates by passing them to my gui likemouseX/(refRes/Res), mouseY/(refRes/res) where ref is reference and res is current resolution. This does not work for me however. Can anyone suggest a way i pass the mouse coordinates into my GUI? Thanks alot bye.  