Skip to content

Commit 9d68a9f

Browse files
authored
Create Alphabet(C).cpp
1 parent 9514c9c commit 9d68a9f

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

OpenGL/Alphabet(C).cpp

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#include <GL/glut.h>
2+
#include <stdlib.h>
3+
GLfloat T = 0;
4+
void MyInit() {
5+
glClearColor(0, 0, 0, 1);
6+
glColor3f(1, 0, 0);
7+
glEnable(GL_DEPTH_TEST);
8+
}
9+
void Face(GLfloat A[], GLfloat B[], GLfloat C[], GLfloat D[])
10+
{
11+
glBegin(GL_POLYGON);
12+
glVertex3fv(A);
13+
glVertex3fv(B);
14+
glVertex3fv(C);
15+
glVertex3fv(D);
16+
glEnd();
17+
}
18+
void Cube(GLfloat V0[], GLfloat V1[], GLfloat V2[], GLfloat V3[], GLfloat V4[], GLfloat V5[], GLfloat V6[], GLfloat V7[])
19+
{
20+
glColor3f(0.6, 0, 0.6);
21+
Face(V0, V1, V2, V3);//back
22+
glColor3f(0.5, 0.9, 0.5);
23+
Face(V4, V5, V6, V7);
24+
glColor3f(1, 0.4, 0);
25+
Face(V0, V3, V7, V4);
26+
glColor3f(1, 0.5, 1);
27+
Face(V1, V2, V6, V5);
28+
glColor3f(0.5, 0.6, 1);
29+
Face(V0, V1, V5, V4);
30+
glColor3f(0.5, 0.4, 1);
31+
Face(V2, V3, V7, V6);
32+
}
33+
void Draw() {
34+
GLfloat V[8][3] = { {-0.2, 0.2, 0.3},
35+
{-0.1, 0.2, 0.3},
36+
{-0.1, -0.2, 0.3},
37+
{-0.2, -0.2, 0.3},
38+
39+
{-0.2, 0.2, -0.3},
40+
{-0.1, 0.2, -0.3},
41+
{-0.1, -0.2, -0.3},
42+
{-0.2, -0.2, -0.3},
43+
};
44+
GLfloat V2[8][3] = { {-0.2, 0.2, 0.3},
45+
{0.2, 0.2, 0.3},
46+
{0.2, 0.1, 0.3},
47+
{-0.2, 0.1, 0.3},
48+
49+
{-0.2, 0.2, -0.3},
50+
{0.2, 0.2, -0.3},
51+
{0.2, 0.1, -0.3},
52+
{-0.2, 0.1, -0.3},
53+
};
54+
55+
GLfloat V3[8][3] = { {-0.2, -0.2, 0.3},
56+
{0.2, -0.2, 0.3},
57+
{0.2, -0.3, 0.3},
58+
{-0.2, -0.3, 0.3},
59+
60+
{-0.2, -0.2, -0.3},
61+
{0.2, -0.2, -0.3},
62+
{0.2, -0.3, -0.3},
63+
{-0.2, -0.3, -0.3},
64+
};
65+
66+
67+
68+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
69+
70+
glLoadIdentity();
71+
glRotatef(10, 1, 1, -1);
72+
Cube(V[0], V[1], V[2], V[3], V[4], V[5], V[6], V[7]);
73+
Cube(V2[0], V2[1], V2[2], V2[3], V2[4], V2[5], V2[6], V2[7]);
74+
Cube(V3[0], V3[1], V3[2], V3[3], V3[4], V3[5], V3[6], V3[7]);
75+
76+
glutSwapBuffers();
77+
}
78+
79+
int main(int C, char* V[])
80+
{
81+
glutInit(&C, V);
82+
83+
glutInitWindowPosition(250, 50);
84+
glutInitWindowSize(600, 600);
85+
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
86+
glutCreateWindow("BASANTA");
87+
MyInit();
88+
glutDisplayFunc(Draw);
89+
glutMainLoop();
90+
91+
return 0;
92+
}

0 commit comments

Comments
 (0)