Cara membuat garis pada Dev C++ :
1. Buka Dev C++
2. Pilih File > New > Project...
3. Klik Misc (biasanya harus klik dulu tab lain, klik saja consose maka tab misc akan muncul)
4. Pilih glut dan berikan nama > OK > Save
5. Hapus semua codingan yang ada
6. Masukkan codingan berikut
#include <gl/glut.h>7. Klik Compile & Run (F11) > Save
void nama(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glLineWidth(5.0f);
glBegin(GL_LINES);
glColor3f(1.0f, 1.0f, 1.0f);
//S
glVertex3f(0.250, 0.22, 0.0);
glVertex3f(-0.300, 0.22, 0.0);
glVertex3f(-0.300, 0.22, 0.0);
glVertex3f(-0.300, 0.10, 0.0);
glVertex3f(-0.300, 0.10, 0.0);
glVertex3f(-0.200, 0.10, 0.0);
glVertex3f(-0.200, 0.10, 0.0);
glVertex3f(-0.200, -0.04, 0.0);
glVertex3f(-0.200, -0.04, 0.0);
glVertex3f(-0.300, -0.04, 0.0);
glVertex3f(-0.200, -0.04, 0.0);
glVertex3f(0.250, -0.04, 0.0);
//U
glVertex3f(-0.110, 0.14, 0.0);
glVertex3f(-0.110, 0.03, 0.0);
glVertex3f(-0.110, 0.03, 0.0);
glVertex3f(-0.130, 0.00, 0.0);
glVertex3f(-0.130, 0.00, 0.0);
glVertex3f(-0.150, 0.00, 0.0);
glVertex3f(-0.150, 0.00, 0.0);
glVertex3f(-0.170, 0.03, 0.0);
glVertex3f(-0.170, 0.03, 0.0);
glVertex3f(-0.170, 0.14, 0.0);
//S
glVertex3f(-0.04, 0.10, 0.0);
glVertex3f(-0.07, 0.15, 0.0);
glVertex3f(-0.07, 0.15, 0.0);
glVertex3f(-0.100, 0.10, 0.0);
glVertex3f(-0.100, 0.10, 0.0);
glVertex3f(-0.04, 0.05, 0.0);
glVertex3f(-0.04, 0.05, 0.0);
glVertex3f(-0.07, 0.00, 0.0);
glVertex3f(-0.07, 0.00, 0.0);
glVertex3f(-0.100, 0.04, 0.0);
//A
glVertex3f(0.00, 0.15, 0.0);
glVertex3f(-0.04, 0.00, 0.0);
glVertex3f(0.00, 0.15, 0.0);
glVertex3f(0.04, 0.00, 0.0);
glVertex3f(-0.02, 0.060, 0.0);
glVertex3f(0.02, 0.060, 0.0);
//N
glVertex3f(0.05, 0.00, 0.0);
glVertex3f(0.05, 0.15, 0.0);
glVertex3f(0.05, 0.15, 0.0);
glVertex3f(0.10, 0.00, 0.0);
glVertex3f(0.10, 0.00, 0.0);
glVertex3f(0.10, 0.15, 0.0);
//T
glVertex3f(-0.180, 0.18, 0.0);
glVertex3f(0.250, 0.18, 0.0);
glVertex3f(0.140, 0.18, 0.0);
glVertex3f(0.140, 0.00, 0.0);
//O
glVertex3f(0.170, 0.11, 0.0);
glVertex3f(0.190, 0.14, 0.0);
glVertex3f(0.190, 0.14, 0.0);
glVertex3f(0.220, 0.14, 0.0);
glVertex3f(0.220, 0.14, 0.0);
glVertex3f(0.240, 0.11, 0.0);
glVertex3f(0.240, 0.11, 0.0);
glVertex3f(0.240, 0.03, 0.0);
glVertex3f(0.240, 0.03, 0.0);
glVertex3f(0.220, 0.00, 0.0);
glVertex3f(0.220, 0.00, 0.0);
glVertex3f(0.190, 0.00, 0.0);
glVertex3f(0.190, 0.00, 0.0);
glVertex3f(0.170, 0.03, 0.0);
glVertex3f(0.170, 0.03, 0.0);
glVertex3f(0.170, 0.11, 0.0);
glEnd();
glFlush();
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(640,480);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
glutCreateWindow("NAMAKU");
glutDisplayFunc(nama);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glutMainLoop();
return 0;
}
8. Hasilnya sudah keluar
Keterangan :
glVertex3f(0.250, 0.22, 0.0);Pada codingan di atas ada 2 titik (x1,y1) dan (x2,y2) dimana x1 = 0.250, y2 = 0.22 dan x2 = -0.300, y2 = 0.22. Nah dari kedua titik terebut maka didapatkan garis yaitu dari (x1,y1) sampai (x2,y2).
glVertex3f(-0.300, 0.22, 0.0);
[update title="Informasi buat sobat" icon="info-circle"]Saat ini sobat sedang membaca artikel Cara membuat titik dan garis menggunakan Dev C++
Sumber:
Jangan lupa untuk memberikan komentar supaya situs ini terus update, terima kasih.[/update]
Posting Komentar