Yak! Bertemu lagi dengan tutorial ataupun latihan cara menggunakan CodeBlocks pada mata kuliah Komputer Grafik. Pada latihan kali ini, saya disuruh membuat objek bintang. Hasilnya bisa Anda lihat pada gambar disamping ini.
Source codenya sudah saya paste di bawah. Silahkan yang mau mencoba untuk dipraktekan di komputer masing-masing.
#include <windows.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <stdlib.h>
GLfloat v[3][2]={{-1.0,-0.58},{1.0,-0.58},{0.0,1.15}};
int n;
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0,0.5,1.5);
glLineWidth(5);
glBegin(GL_LINE_LOOP);
glVertex2f(-1.40,-1.60);
glVertex2f(-0.90,-0.15);
glVertex2f(-2.0,0.75);
glVertex2f(-0.5,0.75);
glVertex2f(0.0,2.0);
glVertex2f(0.5,0.75);
glVertex2f(2.0,0.75);
glVertex2f(0.90,-0.15);
glVertex2f(1.40,-1.60);
glVertex2f(0.0,-0.75);
glEnd();
glFlush();
}
void myinit()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-2.0,2.0,-2.0,2.0);
glMatrixMode(GL_MODELVIEW);
glClearColor(0.0,0.0,0.0,1.0);
glColor3f(0.0,0.0,0.0);
}
int main(int argc, char* argv[])
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(425,150);
glutCreateWindow("STARLET");
glutDisplayFunc(display);
myinit();
glutMainLoop();
return 0;
}
mas, cara setting codeblock nya biar bisa glutInit itu gimana ya, codeblock saya saat coba source code punya mas ga bisa.
ReplyDeletekurang lebih seperti ini build messege nya:
C:\Users\fahmi_ed\Desktop\uji coba\main.o:main.c|| undefined reference to `__glutInitWithExit@12'|
masukkan di Project -> Build Option -> Linker Setting add libopengl32, libglu32, libfreeglut
ReplyDeleteCari Wallpaper?
klu ada tulisan gene gmn mas?
ReplyDeleteChecking for existence: C:\Program Files\Common Files\opengl\bin\Debug\opengl.exe
Executing: "C:\Program Files\CodeBlocks/cb_console_runner.exe" "C:\Program Files\Common Files\opengl\bin\Debug\opengl.exe" (in C:\Program Files\Common Files\opengl\.)
Process terminated with status -1073741510 (0 minutes, 3 seconds)
kalo pake java ada ya??
ReplyDelete