Sekarang kita akan membuat sebuah kotak berbentuk 2D/ 2 dimensi dengan codeblock, langsung saja anda tinggal membuka aplikasi codeblocks dan sebuah project baru, bila belum mengerti untuk membuat project baru silahkan klik link berikut ini ->
Setelah project baru telah dibuat anda tinggal copas code berikut pada project anda
code:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <GL/glut.h>
void mydisplay(){
glClear(GL_COLOR_BUFFER_BIT); // Menghapus layar
glBegin(GL_POLYGON);
glColor3f(1,0,0);//untuk warna
glVertex2f(-0.5, -0.5);// dari sini sampe bawah adalah dot untuk membentuk kotak nya
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
}
int main(int argc, char** argv)
{
printf("ini adalah kotak 2D by Firmand");
glutCreateWindow("Kotak 2D");
glutDisplayFunc(mydisplay);
glutMainLoop();
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <GL/glut.h>
void mydisplay(){
glClear(GL_COLOR_BUFFER_BIT); // Menghapus layar
glBegin(GL_POLYGON);
glColor3f(1,0,0);//untuk warna
glVertex2f(-0.5, -0.5);// dari sini sampe bawah adalah dot untuk membentuk kotak nya
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
}
int main(int argc, char** argv)
{
printf("ini adalah kotak 2D by Firmand");
glutCreateWindow("Kotak 2D");
glutDisplayFunc(mydisplay);
glutMainLoop();
}
tinggal anda klik build and run maka output akan keluar seperti berikut:
![]() | |||
Grafika Komputer Codeblocks kotak 2D |
This comment has been removed by the author.
ReplyDeleteSangat membantu apalagi kalo ditambah pengertian tiap baris
ReplyDelete