Question on OpenGL

This is a discussion on Question on OpenGL within the Game Programming forums, part of the General Programming Boards category; Hello guys, I just started learning opengl from past few days, so i dunno much about it. So probably some ...

  1. #1
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682

    Question on OpenGL

    Hello guys,
    I just started learning opengl from past few days, so i dunno much about it. So probably some one out there would help me out in this simple problem which i am facing on co-ordinated, i mean setting the co-ordinates of the screen. Have a look at code below

    Code:
    #include<GL/gl.h>
    #include<GL/glu.h>
    #include<GL/glut.h>
    #include<windows.h>
    
    void Init(void);
    void Display(void);
    
    int main(int argc, char **argv)
    {
        glutInit(&argc,argv);
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
        glutInitWindowSize(500,500);
        glutInitWindowPosition(100,100);
        glutCreateWindow("Polygon");
        Init();
        glutDisplayFunc(Display);
        glutMainLoop();
        
        return 0;
    }
    
    void Init(void)
    {
        glClearColor (0.0, 0.0, 0.0, 0.0);
        glMatrixMode (GL_PROJECTION);
        glLoadIdentity ();
        gluOrtho2D (0.0, 0.0, 0.0, 0.0);
    }
    
    void Display(void)
    {
        glClear(GL_COLOR_BUFFER_BIT);
        glColor3f(1.0, 1.0, 1.0);
        
        glBegin(GL_POLYGON);
          glVertex2f(0.0, 0.0);
          glVertex2f(0.0, 1.0);
          glVertex2f(1.0, 2.0);
          glVertex2f(6.0, 1.0);
          glVertex2f(2.0, 0.0);
       glEnd();
       
       glFlush();
    }
    i wanted the co-ordinated 0.0 start from the top left of the screen. But by default it starts from the center of the screen which mean what ever i draw its all in the center but i wanted to be on top left of the screen. How do i do that, can any one please guide me in this.

    thank you

    ssharish2005

  2. #2
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    Set gluOrtho2D to the proper dimensions.
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  3. #3
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    Quote Originally Posted by psychopath
    Set gluOrtho2D to the proper dimensions.
    thank u very much psychopath i changed it to

    Code:
    gluOrtho2D(0, 50, 50,   0);
    ssharish2005

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL Question
    By Halo3Master in forum Game Programming
    Replies: 16
    Last Post: 10-02-2007, 03:40 AM
  2. Opengl question
    By Shadowwoelf in forum Windows Programming
    Replies: 3
    Last Post: 06-03-2007, 02:21 PM
  3. OpenGL Camera Question
    By Astra in forum Game Programming
    Replies: 2
    Last Post: 03-25-2007, 02:53 PM
  4. OpenGL Question
    By Shamino in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2005, 03:35 PM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 11:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21