-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathequationParabola.c
89 lines (80 loc) · 1.5 KB
/
equationParabola.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include<stdio.h>
#include<string.h>
#include<GL/glut.h>
#include <math.h>
double center[100][2];
double point[100][2];
int count = 0;
int numbPoint=-1;
char buffer[10];
void type(char *string, double X, double Y)
{
char *c;
glColor3f(1.0, 1.0, 1.0);
glRasterPos2f((X+1),Y);
for (c=string; *c != '\0'; c++)
{
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, *c);
}
glFlush();
}
void myName()
{
type("Ayush Jain", -249, 240);
type("CSE-CCVT B-1",-249, 225);
type("R110217039",-249, 210);
type("Question 01",-249, 195);
}
void myInit (void)
{
// making background color black as first
// 3 arguments all are 0.0
gluOrtho2D(-250,250,-250,250);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
myName();
}
void equation()
{
int P = 1;
int Px = 0, Py = 50;
while(Px<=5)
{
printf("(%d, %d)\n", Px, Py);
glBegin(GL_POINTS);
glColor3f(0.0, 1.0, 1.0);
glVertex2i(Px, Py);
glVertex2i(-Px, Py);
glEnd();
glFlush();
if(P>=0){
P = P-1;
}
else{
P = P + 2*(Px) + 1;
++Px;
}
--Py;
}
type("y = 50 - x^2", -249, -225);
type("-5 <= x <= 5", -249,-240);
}
static void Key(unsigned char key, int x, int y)
{
switch (key) {
case 27:
glutDestroyWindow(1);
break;
}
}
int main (int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500, 500);
glutCreateWindow("|| Equation Parabola ||");
myInit();
glutKeyboardFunc(Key);
glutDisplayFunc(equation);
glutMainLoop();
}