openGPMP
Open Source Mathematics Package
Macros | Functions
openGL_tri.c File Reference
#include <GL/glut.h>
#include <math.h>
#include <stdio.h>

Go to the source code of this file.

Macros

#define pi   3.142857
 

Functions

void display ()
 
int main (int argc, char **argv)
 

Macro Definition Documentation

◆ pi

#define pi   3.142857

Definition at line 8 of file openGL_tri.c.

Function Documentation

◆ display()

void display ( void  )

Definition at line 10 of file openGL_tri.c.

10  {
11  // setting every pixel in frame buffer to a clear color
12  glClear(GL_COLOR_BUFFER_BIT);
13 
14  // being drawing
15  glBegin(GL_POLYGON);
16  glColor3f(1, 0, 1);
17  glVertex3f(-0.6, -0.75, 0.5);
18  glColor3f(0, 1, 0);
19  glVertex3f(0.6, -0.75, 0);
20  glColor3f(0, 0, 1);
21  glVertex3f(0, 0.75, 0);
22  glEnd();
23 
24  // flush the draw cmd to display image immediately
25  glFlush();
26 }

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 28 of file openGL_tri.c.

28  {
29  glutInit(&argc, argv);
30  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
31 
32  // Position window at (80,80)-(480,380) and give it a title.
33  glutInitWindowPosition(80, 80);
34  glutInitWindowSize(1000, 800);
35  glutCreateWindow("A Shaded Triangle");
36 
37  // Tell GLUT that whenever the main window needs to be repainted
38  // that it should call the function display().
39  glutDisplayFunc(display);
40 
41  glutMainLoop();
42 
43  return 0;
44 }
void display()
Definition: openGL_tri.c:10

References display().