Friday, June 26, 2015

Computer Graphics : Triangle Primitive


Triangle Fan

#include<GL/glut.h>

void myInit()
{
    glClearColor(1.0,1.0,1.0,0.0);
    glColor3f(1.0,0.0,0.0);
    glPointSize(1);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0.0,640.0,0.0,480.0);
}

void myDisplay()
{
    glClear(GL_COLOR_BUFFER_BIT);

    glBegin(GL_TRIANGLE_FAN);
        glVertex2d(200,200);
       
        glVertex2d(150,250);
        glVertex2d(250,250);
       
        glVertex2d(300,225);
        glVertex2d(300,175);
       
        glVertex2d(250,150);
        glVertex2d(150,150);
       
        glVertex2d(100,175);
        glVertex2d(100,225);
        glVertex2d(150,250);
    glEnd();

    glFlush();
}

int main(int argc,char* argv[])
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(640,480);
    glutCreateWindow("First Exercise");
    glutDisplayFunc(myDisplay);
    myInit();
    glutMainLoop();
    return 1;
}

This was nice...you should try this


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.