void myinit()
{
glClearColor(0.0, 0.0, 1.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 800.0, 0.0, 800.0);
glMatrixMode(GL_MODELVIEW);
}
void Tampilkan()
{
int h, i, j ,n = 0, m = 0, o = 0;
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
//glColor3f(1.0, 1.0, 1.0);
// membuat kotak putis 1000px * 1000px
/*glBegin(GL_POLYGON);
{
glVertex3i(0,0,0);
glVertex3i(1000,0,0);
glVertex3i(1000,1000,0);
glVertex3i(0,1000,0);
}*/
glColor3f(1.0, 1.0, 1.0);
// membuat kotak putih
for (i = 0; i < 8; i++){
for (j = 0; j < 8; j++)
{
n = 200 * j;
m = 100 * i;
glBegin(GL_POLYGON);
{
glVertex3i(0+n+m,0+m,0);
glVertex3i(100+n+m,0+m,0);
glVertex3i(100+n+m,100+m,0);
glVertex3i(0+n+m,100+m,0);
}
glEnd();
glBegin(GL_POLYGON);
{
glVertex3i(900-n-m,900-m,0);
glVertex3i(1000-n-m,900-m,0);
glVertex3i(1000-n-m,1000-m,0);
glVertex3i(900-n-m,1000-m,0);
}
glEnd();
}
}
glColor3i(1, 1, 1);
// gambar 9 0 1 1 9 0 1 1
// angka 9
for (i = 0; i <= 1; i++){
for (j = 0; j <= 1; j++){
n = 400 * i;
m = 400 * j;
glBegin(GL_POLYGON); // bagian atas
{
glVertex3i(29+m,67+n,0);
glVertex3i(65+m,67+n,0);
glVertex3i(65+m,80+n,0);
glVertex3i(29+m,80+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian bawah
{
glVertex3i(29+m,20+n,0);
glVertex3i(65+m,20+n,0);
glVertex3i(65+m,33+n,0);
glVertex3i(29+m,33+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian tengah
{
glVertex3i(29+m,40+n,0);
glVertex3i(65+m,40+n,0);
glVertex3i(65+m,53+n,0);
glVertex3i(29+m,53+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kanan
{
glVertex3i(51+m,20+n,0);
glVertex3i(65+m,20+n,0);
glVertex3i(65+m,80+n,0);
glVertex3i(51+m,80+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kiri
{
glVertex3i(29+m,50+n,0);
glVertex3i(42+m,50+n,0);
glVertex3i(42+m,80+n,0);
glVertex3i(29+m,80+n,0);
glEnd();
}
}
}
// angka 0
for (i = 0; i <= 1; i++){
for (j = 0; j <= 1; j++){
n = 400 * i;
m = 400 * j;
glBegin(GL_POLYGON); // bagian atas
{
glVertex3i(129+m,67+n,0);
glVertex3i(165+m,67+n,0);
glVertex3i(165+m,80+n,0);
glVertex3i(129+m,80+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian bawah
{
glVertex3i(129+m,20+n,0);
glVertex3i(165+m,20+n,0);
glVertex3i(165+m,33+n,0);
glVertex3i(129+m,33+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kanan
{
glVertex3i(151+m,20+n,0);
glVertex3i(165+m,20+n,0);
glVertex3i(165+m,80+n,0);
glVertex3i(151+m,80+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kiri
{
glVertex3i(129+m,20+n,0);
glVertex3i(142+m,20+n,0);
glVertex3i(142+m,80+n,0);
glVertex3i(129+m,80+n,0);
glEnd();
}
}
}
// angka 1
for (h = 0; h <= 1; h++){
for (i = 0; i <= 1; i++){
for (j = 0; j <= 1; j++){
n = 100 * i;
m = 400 * j;
o = 400 * h;
glBegin(GL_POLYGON); // bagian atas
{
glVertex3i(229+m+n,67+o,0);
glVertex3i(240+m+n,67+o,0);
glVertex3i(240+m+n,80+o,0);
glVertex3i(229+m+n,73+o,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian bawah
{
glVertex3i(229+m+n,20+o,0);
glVertex3i(265+m+n,20+o,0);
glVertex3i(265+m+n,33+o,0);
glVertex3i(229+m+n,33+o,0);
}
glEnd();
glBegin(GL_POLYGON); //
{
glVertex3i(240+m+n,20+o,0);
glVertex3i(254+m+n,20+o,0);
glVertex3i(254+m+n,80+o,0);
glVertex3i(240+m+n,80+o,0);
}
glEnd();
}
}
}
// gambar 1 9 0 1 1 9 0 1
// angka 9
for (i = 0; i <= 1; i++){
for (j = 0; j <= 1; j++){
n = 400 * i;
m = 400 * j;
glBegin(GL_POLYGON); // bagian atas
{
glVertex3i(129+m,167+n,0);
glVertex3i(165+m,167+n,0);
glVertex3i(165+m,180+n,0);
glVertex3i(129+m,180+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian bawah
{
glVertex3i(129+m,120+n,0);
glVertex3i(165+m,120+n,0);
glVertex3i(165+m,133+n,0);
glVertex3i(129+m,133+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian tengah
{
glVertex3i(129+m,140+n,0);
glVertex3i(165+m,140+n,0);
glVertex3i(165+m,153+n,0);
glVertex3i(129+m,153+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kanan
{
glVertex3i(151+m,120+n,0);
glVertex3i(165+m,120+n,0);
glVertex3i(165+m,180+n,0);
glVertex3i(151+m,180+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kiri
{
glVertex3i(129+m,150+n,0);
glVertex3i(142+m,150+n,0);
glVertex3i(142+m,180+n,0);
glVertex3i(129+m,180+n,0);
glEnd();
}
}
}
// angka 0
for (i = 0; i <= 1; i++){
for (j = 0; j <= 1; j++){
n = 400 * i;
m = 400 * j;
glBegin(GL_POLYGON); // bagian atas
{
glVertex3i(229+m,167+n,0);
glVertex3i(265+m,167+n,0);
glVertex3i(265+m,180+n,0);
glVertex3i(229+m,180+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian bawah
{
glVertex3i(229+m,120+n,0);
glVertex3i(265+m,120+n,0);
glVertex3i(265+m,133+n,0);
glVertex3i(229+m,133+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kanan
{
glVertex3i(251+m,120+n,0);
glVertex3i(265+m,120+n,0);
glVertex3i(265+m,180+n,0);
glVertex3i(251+m,180+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kiri
{
glVertex3i(229+m,120+n,0);
glVertex3i(242+m,120+n,0);
glVertex3i(242+m,180+n,0);
glVertex3i(229+m,180+n,0);
glEnd();
}
}
}
// angka 1
for (h = 0; h <= 1; h++){
for (i = 0; i <= 1; i++){
for (j = 0; j <= 1; j++){
n = (100 * j * i);
m = 300 * i;
o = 400 * h;
glBegin(GL_POLYGON); // bagian atas
{
glVertex3i(29+m+n,167+o,0);
glVertex3i(40+m+n,167+o,0);
glVertex3i(40+m+n,180+o,0);
glVertex3i(29+m+n,173+o,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian bawah
{
glVertex3i(29+m+n,120+o,0);
glVertex3i(65+m+n,120+o,0);
glVertex3i(65+m+n,133+o,0);
glVertex3i(29+m+n,133+o,0);
}
glEnd();
glBegin(GL_POLYGON); //
{
glVertex3i(40+m+n,120+o,0);
glVertex3i(54+m+n,120+o,0);
glVertex3i(54+m+n,180+o,0);
glVertex3i(40+m+n,180+o,0);
}
glEnd();
}
}
}
// angka 1 terakhir
for (h = 0; h <= 1; h++){
n = 400 * h;
glBegin(GL_POLYGON); // bagian atas
{
glVertex3i(729,167+n,0);
glVertex3i(740,167+n,0);
glVertex3i(740,180+n,0);
glVertex3i(729,173+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian bawah
{
glVertex3i(729,120+n,0);
glVertex3i(765,120+n,0);
glVertex3i(765,133+n,0);
glVertex3i(729,133+n,0);
}
glEnd();
glBegin(GL_POLYGON); //
{
glVertex3i(740,120+n,0);
glVertex3i(754,120+n,0);
glVertex3i(754,180+n,0);
glVertex3i(740,180+n,0);
}
glEnd();
}
// gambar 1 1 9 0 1 1 9 0
// angka 9
for (i = 0; i <= 1; i++){
for (j = 0; j <= 1; j++){
n = 400 * i;
m = 400 * j;
glBegin(GL_POLYGON); // bagian atas
{
glVertex3i(229+m,267+n,0);
glVertex3i(265+m,267+n,0);
glVertex3i(265+m,280+n,0);
glVertex3i(229+m,280+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian bawah
{
glVertex3i(229+m,220+n,0);
glVertex3i(265+m,220+n,0);
glVertex3i(265+m,233+n,0);
glVertex3i(229+m,233+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian tengah
{
glVertex3i(229+m,240+n,0);
glVertex3i(265+m,240+n,0);
glVertex3i(265+m,253+n,0);
glVertex3i(229+m,253+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kanan
{
glVertex3i(251+m,220+n,0);
glVertex3i(265+m,220+n,0);
glVertex3i(265+m,280+n,0);
glVertex3i(251+m,280+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kiri
{
glVertex3i(229+m,250+n,0);
glVertex3i(242+m,250+n,0);
glVertex3i(242+m,280+n,0);
glVertex3i(229+m,280+n,0);
glEnd();
}
}
}
// angka 0
for (i = 0; i <= 1; i++){
for (j = 0; j <= 1; j++){
n = 400 * i;
m = 400 * j;
glBegin(GL_POLYGON); // bagian atas
{
glVertex3i(329+m,267+n,0);
glVertex3i(365+m,267+n,0);
glVertex3i(365+m,280+n,0);
glVertex3i(329+m,280+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian bawah
{
glVertex3i(329+m,220+n,0);
glVertex3i(365+m,220+n,0);
glVertex3i(365+m,233+n,0);
glVertex3i(329+m,233+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kanan
{
glVertex3i(351+m,220+n,0);
glVertex3i(365+m,220+n,0);
glVertex3i(365+m,280+n,0);
glVertex3i(351+m,280+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kiri
{
glVertex3i(329+m,220+n,0);
glVertex3i(342+m,220+n,0);
glVertex3i(342+m,280+n,0);
glVertex3i(329+m,280+n,0);
glEnd();
}
}
}
// angka 1
for (h = 0; h <= 1; h++){
for (i = 0; i <= 1; i++){
for (j = 0; j <= 1; j++){
n = 100 * i;
m = 400 * j;
o = 400 * h;
glBegin(GL_POLYGON); // bagian atas
{
glVertex3i(29+m+n,267+o,0);
glVertex3i(40+m+n,267+o,0);
glVertex3i(40+m+n,280+o,0);
glVertex3i(29+m+n,273+o,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian bawah
{
glVertex3i(29+m+n,220+o,0);
glVertex3i(65+m+n,220+o,0);
glVertex3i(65+m+n,233+o,0);
glVertex3i(29+m+n,233+o,0);
}
glEnd();
glBegin(GL_POLYGON); //
{
glVertex3i(40+m+n,220+o,0);
glVertex3i(54+m+n,220+o,0);
glVertex3i(54+m+n,280+o,0);
glVertex3i(40+m+n,280+o,0);
}
glEnd();
}
}
}
// gambar 0 1 1 9 0 1 1 9
// angka 9
for (i = 0; i <= 1; i++){
for (j = 0; j <= 1; j++){
n = 400 * i;
m = 400 * j;
glBegin(GL_POLYGON); // bagian atas
{
glVertex3i(329+m,367+n,0);
glVertex3i(365+m,367+n,0);
glVertex3i(365+m,380+n,0);
glVertex3i(329+m,380+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian bawah
{
glVertex3i(329+m,320+n,0);
glVertex3i(365+m,320+n,0);
glVertex3i(365+m,333+n,0);
glVertex3i(329+m,333+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian tengah
{
glVertex3i(329+m,340+n,0);
glVertex3i(365+m,340+n,0);
glVertex3i(365+m,353+n,0);
glVertex3i(329+m,353+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kanan
{
glVertex3i(351+m,320+n,0);
glVertex3i(365+m,320+n,0);
glVertex3i(365+m,380+n,0);
glVertex3i(351+m,380+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kiri
{
glVertex3i(329+m,350+n,0);
glVertex3i(342+m,350+n,0);
glVertex3i(342+m,380+n,0);
glVertex3i(329+m,380+n,0);
glEnd();
}
}
}
// angka 0
for (i = 0; i <= 1; i++){
for (j = 0; j <= 1; j++){
n = 400 * i;
m = 400 * j;
glBegin(GL_POLYGON); // bagian atas
{
glVertex3i(29+m,367+n,0);
glVertex3i(65+m,367+n,0);
glVertex3i(65+m,380+n,0);
glVertex3i(29+m,380+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian bawah
{
glVertex3i(29+m,320+n,0);
glVertex3i(65+m,320+n,0);
glVertex3i(65+m,333+n,0);
glVertex3i(29+m,333+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kanan
{
glVertex3i(51+m,320+n,0);
glVertex3i(65+m,320+n,0);
glVertex3i(65+m,380+n,0);
glVertex3i(51+m,380+n,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian kiri
{
glVertex3i(29+m,320+n,0);
glVertex3i(42+m,320+n,0);
glVertex3i(42+m,380+n,0);
glVertex3i(29+m,380+n,0);
glEnd();
}
}
}
// angka 1
for (h = 0; h <= 1; h++){
for (i = 0; i <= 1; i++){
for (j = 0; j <= 1; j++){
n = 100 * i;
m = 400 * j;
o = 400 * h;
glBegin(GL_POLYGON); // bagian atas
{
glVertex3i(129+m+n,367+o,0);
glVertex3i(140+m+n,367+o,0);
glVertex3i(140+m+n,380+o,0);
glVertex3i(129+m+n,373+o,0);
}
glEnd();
glBegin(GL_POLYGON); // bagian bawah
{
glVertex3i(129+m+n,320+o,0);
glVertex3i(165+m+n,320+o,0);
glVertex3i(165+m+n,333+o,0);
glVertex3i(129+m+n,333+o,0);
}
glEnd();
glBegin(GL_POLYGON); //
{
glVertex3i(140+m+n,320+o,0);
glVertex3i(154+m+n,320+o,0);
glVertex3i(154+m+n,380+o,0);
glVertex3i(140+m+n,380+o,0);
}
glEnd();
}
}
}
glutSwapBuffers ();
}
int main(int argc, char* argv[])
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(350,100);
glutCreateWindow("Tugas Komgraf");
glutDisplayFunc(Tampilkan);
myinit();
glutIdleFunc (NULL);
glutMainLoop();
}