

Task

Display a smooth shaded triangle with OpenGL.

 Triangle created using C example compiled with GCC 4.1.2 and freeglut3.


PRAGMA INCLUDE <GL/gl.h> <GL/freeglut.h>
PRAGMA LDFLAGS GL glut
 
OPTION PARSE FALSE
 
SUB Triangle
 
    glViewport(0, 0, 640, 480)
    glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
 
    glClearColor(0.0, 0.0, 0.0, 1.0)
    glClear(GL_COLOR_BUFFER_BIT)
 
    glTranslatef(-15.0, -15.0, 0.0)
 
    glBegin(GL_TRIANGLES)
    glColor3f(1.0, 0.0, 0.0)
    glVertex2f(0.0, 0.0)
    glColor3f(0.0, 1.0, 0.0)
    glVertex2f(30.0, 0.0)
    glColor3f(0.0, 0.0, 1.0)
    glVertex2f(0.0, 30.0)
    glEnd()
 
    glutSwapBuffers()
 
END SUB
 
glutInit(&argc, argv)
glutInitWindowSize(640, 480)
glutCreateWindow("Triangle")
 
glutDisplayFunc(Triangle)
glutMainLoop()