Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 27

Thread: Ortho Setup

  1. #11
    Join Date
    Sep 2004
    Location
    Denmark
    Posts
    763
    Try using gluOrtho2D() like this:

    gluOrtho2D(0, width, height, 0);
    I didn't mean to do it.

  2. #12
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    877
    didn't work either! screen is black... man it feels like I'll never get this working properly...

    "That makes me a saaaad panda"

    Edit: Ow, no, wait, never mind... I think I get it... so that's what you meant with the aspect ratio...?

    It has to be the scale 4:3 (or 1.33:1)..., but since it's based on units and not on pixels you should enter a low value... I tried the argumments (-4,4,-3,3) and it looked perfect!

    Using a grater value makes it look more distant, using a lower value makes it looks less distant.

    "It's based on units and not on pixels..."
    -You mean if I enter 4; 4 units fits onto the screen! 'glVertex2f(4.0f, 0.0f)' would be the end of the screen!

    Did I get it? Huh? Huh? Did I?

    Edit: But the resolution WAS 4:3... and yet that didn't work... aw nuts! I don't got it...
    Edit again: no, wait... maybe I do...? one time it did work, but the object looked distant... -that's because I used a high value... and the reason it got displayed in the left-bottom corner is because I used 0 as the first and third argumments...

    Well... am I on the right track? I don't remember when it did and did not work...
    Last edited by EvilCookie; 08-10-2006 at 09:15 AM.

  3. #13
    Join Date
    Jan 2003
    Location
    Cookie Jar
    Posts
    971
    If you want you can look at my SNARE source code, I have a working quad viewport setup, 3 of which are orthographic, one is perspective, there are two versions, SDL and Win32.
    Attached Files Attached Files

  4. #14
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    877

    Confirm!

    Well, thanks, but I think I got it!

    Could you look at the PNG and just confirm my thoughts?
    It all makes sense - I'm pritty sure this thread is "solved".

    Thanks!
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	glOrtho.PNG 
Views:	63 
Size:	36.6 KB 
ID:	51771  
    Last edited by EvilCookie; 08-10-2006 at 10:17 AM.

  5. #15
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    877

    hurrays it works! why won't it stop working? it works too well!

    Aww, man... Now that it works I'm having trouble disabling Ortho!
    -I want to regain the 3d-drawin'... but instead everything is ortho... which looks quite wierd...

    This is the code I use at the beginning of the program:
    Code:
    glViewport(0, 0, width, height);
    glDepthFunc(GL_LESS);
    glEnable(GL_DEPTH_TEST);
    glShadeModel(GL_SMOOTH);
    glMatrixMode(GL_PROJECTION);
    gluPerspective(45.0f, (GLfloat)width/(GLfloat)height, 0.1f, 100.0f);
    glMatrixMode(GL_MODELVIEW);
    and this is the code I use to enable the ortho graphics:
    Code:
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-50, 50, -37.5, 37.5, 0, 100);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    What's the code I should use to "regain" 3d?
    I've tried tons of stuff, moving, adding, and removing code, but the result is that either nothing's displayed, only the ortho is displayed, or both the 2d and 3d is displayed as 2d (in ortho).

    ...what exactly does GL_PROJECTION and GL_MODELVIEW (in 'glMatrixMode') do anyway?

    Thanks.

  6. #16
    Join Date
    Jan 2003
    Location
    Cookie Jar
    Posts
    971
    By 3D I assume you mean perspective? Ortho is "3d" as well but everything is perfectly parallel to the camera and is the same size regardless of distance from the camera. Perspective simply makes things in the distance smaller as they appear in real life.

    You dont "Disable" ortho, you can probably just call gluPerspective when you want a perspective mode as well as switching matrix modes at the right time.

    My code shows you what you are looking for (download at the bottom): http://www.armorycore.com/ac3/index....ject&projid=41

    GL Projection and Model view info I found with a quick google search: http://www.storkyak.com/2005/11/open...modelview.html

  7. #17
    Join Date
    Sep 2004
    Location
    Denmark
    Posts
    763
    Right, I have made this function for my projection changes - it is quite handy.

    I'm utilizing glu calls though - I dont think you will have any troubles understanding it.
    Code:
    GLvoid CRRenderer::SetProjectionMatrix(GLbitfield mask) {
    	// temp vars
    	GLsizei width = GetWidth();
    	GLsizei height = GetHeight();
    
    	glViewport(0, 0, width, height );
    
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
    	
    	if ( mask & RND_PERSPECTIVE ) {
    		gluPerspective(45.0f, 1.0 * width / height, 0.1f, 200.0f);
    	} else if (mask & RND_ORTHO ) {
          gluOrtho2D(0, width, height, 0);
    	}
    }
    At first I get the height and width (800x600, or whatever)

    With glMatrixMode() you choose which matrix you will be doing modification to - here, since its some kind of projection modifcation, you'll have to choose projection.

    I guess you know what glLoadIdentity() does.

    I know the mask this could just as well be some enum or things like that, but I have chosen to do it like this so I can expand with more arguments passed to the function.
    I didn't mean to do it.

  8. #18
    Join Date
    Sep 2004
    Location
    Denmark
    Posts
    763
    Quote Originally Posted by MVP
    My code shows you what you are looking for (download at the bottom): http://www.armorycore.com/ac3/index....ject&projid=41

    Somehow I think you know about LAME - the mp3 codec
    I didn't mean to do it.

  9. #19
    Join Date
    Jan 2003
    Location
    Cookie Jar
    Posts
    971
    Quote Originally Posted by rev'en
    Somehow I think you know about LAME - the mp3 codec
    Acually thats not the only one: http://en.wikipedia.org/wiki/Recursive_acronym

  10. #20
    Join Date
    Sep 2004
    Location
    Denmark
    Posts
    763
    I see. Oh well, back to topic of the thread.
    I didn't mean to do it.

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •