Results 1 to 3 of 3

Thread: Mixed projections

  1. #1
    Junior Member Newbie
    Join Date
    May 2001
    Posts
    21

    Mixed projections

    Hi,

    is it possible to first draw objects in perspective mode, and then switch this view with gluOrtho2D and draw other objects, like controlbars etc..

    in my RenderScene procedure, after drawing 3D, i would switch like this:

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    gluOrtho2D(0, viewWidth, viewHeight, 0);
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();
    glPushAttrib(GL_ENABLE_BIT);
    glDisable(GL_LIGHTING);
    glDisable(GL_DEPTH_TEST);
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_SCISSOR_TEST);

    // i write my drawing code here

    glDisable(GL_TEXTURE_2D);
    glPopAttrib();
    glPopMatrix();
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    why doesn't this work?

    anybody?

  2. #2
    Senior Member Regular Contributor
    Join Date
    May 2000
    Location
    Oxford, England
    Posts
    472

    Re: Mixed projections

    wang the stuff to switch between them in some display lists (I'm using Persp & Ortho). Do this when your window is resized

    {
    glDeleteLists(Persp,1);
    glDeleteLists(Ortho,1);
    Persp = glGenLists(1);
    Ortho = glGenLists(1);
    if( h==0 ) h = 1;
    glNewList(Persp,GL_COMPILE);
    glViewport(0, (GLsizei) 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(55.0, w/h , 0.01, 500 );
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glEndList();

    glNewList(Ortho,GL_COMPILE);
    glViewport(0, (GLsizei) 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, w, h, 0, -1, 1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glEndList();
    }

    Once thats done, your display func should be something of the form..

    {
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
    glLoadIdentity()
    glCallList(Persp);

    //draw 3d stuff

    glCallList(Ortho);

    //draw 2d gubbins

    }

  3. #3
    Junior Member Newbie
    Join Date
    May 2001
    Posts
    21

    Re: Mixed projections

    thanx a lot!

Similar Threads

  1. Replies: 0
    Last Post: 08-09-2013, 10:35 AM
  2. Replies: 1
    Last Post: 09-13-2012, 07:33 AM
  3. Color mixed with texture
    By shawn619 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 07-26-2012, 06:42 AM
  4. EGL mixed rendering of 2d/3d on Brew
    By OpenGL_newbie in forum EGL
    Replies: 2
    Last Post: 01-20-2010, 09:49 PM
  5. FBO with mixed format texture
    By delfare in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 09-14-2008, 08:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean