openGPMP
Open Source Mathematics Package
Macros | Functions
openGL_example00.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 myInit (void)
 
void display (void)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

◆ pi

#define pi   3.142857

Definition at line 8 of file openGL_example00.c.

Function Documentation

◆ display()

void display ( void  )

Definition at line 29 of file openGL_example00.c.

29  {
30  glClear(GL_COLOR_BUFFER_BIT);
31  glBegin(GL_POINTS);
32  float x, y, i;
33 
34  // iterate y up to 2*pi, i.e., 360 degree
35  // with small increment in angle as
36  // glVertex2i just draws a point on specified co-ordinate
37  for (i = 0; i < (2 * pi); i += 0.001) {
38  // let 200 is radius of circle and as,
39  // circle is defined as x=r*cos(i) and y=r*sin(i)
40  x = 200 * cos(i);
41  y = 200 * sin(i);
42 
43  glVertex2i(x, y);
44  }
45  glEnd();
46  glFlush();
47 }
#define pi

References pi.

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 49 of file openGL_example00.c.

49  {
50  glutInit(&argc, argv);
51  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
52 
53  // giving window size in X- and Y- direction
54  glutInitWindowSize(1366, 768);
55  glutInitWindowPosition(0, 0);
56 
57  // Giving name to window
58  glutCreateWindow("Circle Drawing");
59  myInit();
60 
61  glutDisplayFunc(display);
62  glutMainLoop();
63 }
void display(void)
void myInit(void)

References display(), and myInit().

◆ myInit()

void myInit ( void  )

Definition at line 11 of file openGL_example00.c.

11  {
12  // making background color black as first
13  // 3 arguments all are 0.0
14  glClearColor(0.0, 0.0, 0.0, 1.0);
15 
16  // making picture color green (in RGB mode), as middle argument
17  // is 1.0
18  glColor3f(0.0, 1.0, 0.0);
19 
20  // breadth of picture boundary is 1 pixel
21  glPointSize(1.0);
22  glMatrixMode(GL_PROJECTION);
23  glLoadIdentity();
24 
25  // setting window dimension in X- and Y- direction
26  gluOrtho2D(-780, 780, -420, 420);
27 }

Referenced by main().