Skip to main content
GameDev.net gamedev.net
🔒 Locked

glViewPort

Started by mbanghart Jul 17, 2008 at 2:12 PM 1 replies 600+ views
Original Post
mbanghart
mbanghart
Hi I am trying to create a viewport in a window (which will be slighly smaller in x and y than the window. When my project starts it seems to create the viewport but then switches to the default viewport (entire window) shortly after. Also, all my callbacks are in the init() function. Any ideas?

 //Create 2D Map Window
    glutInitWindowSize(300, 300);        
    glutInitWindowPosition(610,1);     
    windowMap = glutCreateWindow("2D Map Window");       
    init();    
    glViewport(50, 50, 249, 249);  
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(worldxBegin,worldxEnd,worldyBegin,worldyEnd,10,-10);
    glMatrixMode(GL_MODELVIEW);   
    glutDisplayFunc(displayA);
Here is my display function:

//Function that creates 2D Map
void displayMap()
{     
     glutSetWindow(windowMap);
     glClearColor(wc1, wc2, wc3, 0.0);      //Set ground color
     glClear(GL_COLOR_BUFFER_BIT);      
     drawObjects();                         //Draw objects   
     //Draw white arrow
     glPushAttrib(GL_ALL_ATTRIB_BITS);                                                                      
     glPushMatrix();     
       glColor3f(1,1,1);      
       glTranslatef(-Aposx,-Aposy,0);                  
       glRotatef((-1)*arrowAngle,0,0,1);      
       glTranslatef(Aposx,Aposy,0);
       Aposx = (Aposx + ox);
       Aposy = (Aposy + oy);
       glTranslatef(-Aposx,-Aposy,0);         
       draw_arrow();     
     glPopAttrib();                      
     glPopMatrix(); 

     glutSwapBuffers();
     glutSetWindow(window3D);     //Set active window back to 3D
}     
Lord_Evil
Lord_Evil
What's your resize() callback?
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
mbanghart
mbanghart
Right now my resize callback is commented out - haven't made sure its correct yet.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.