Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: my first program not working

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2011
    Posts
    5

    my first program not working

    hi all,i hav been trying to draw a polygon without any succes please help the code is given below:
    #include<stdio.h>
    #include<GL/glut.H>

    #include<conio.h>
    void dis(void)
    {
    glClearColor(1.0,1.0,1.0,0.0);
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glDisable(GL_DEPTH_TEST);


    glBegin(GL_POLYGON);
    glVertex2f(3.0,3.0);
    glVertex2f(9.0,9.0);
    glVertex2f(6.0,5.0);

    glEnd();

    glFlush();
    }




    void main(int argc,char**argv)
    {
    glutInit(&amp;argc,argv);
    printf("hi");
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(500,500);
    glutInitWindowPosition(0,0);
    glutCreateWindow("hi");

    glutDisplayFunc(dis);
    glutMainLoop();


    }
    asdasd

  2. #2
    Junior Member Regular Contributor
    Join Date
    Nov 2010
    Location
    Brazil, Rio de Janeiro
    Posts
    147

    Re: my first program not working

    First, you need to set the type of projection you wanna use.

    Take a look at http glOrtho (http://www.opengl.org/sdk/docs/man/xhtml/glOrtho.xml).

    Second, you need to load a model view matrix before any draw operations, something like:

    Code :
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();

    If you're not comfortable with something, take a look at the Red Book (http://fly.cc.fer.hr/~unreal/theredbook/chapter01.html)

Posting Permissions

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