Professional Documents
Culture Documents
Program openGL
Program openGL
#include <windows.h> #include <gl/gl.h> void userdraw() { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1, 1, 0); glClearColor (0.1f, 0.1f, 0.1f, 0.1f); glClear (GL_COLOR_BUFFER_BIT); glPointSize(5.0f); glBegin(GL_POINTS); glPushMatrix (); glClearColor(1,1,1,0); glBegin (GL_POINTS); glVertex3f (0,0,-0.0); glVertex3f (0.0,0.2,0.0); glVertex3f (0.3,0.2,0.0);
int main(int argc, char** argv){ glutCreateWindow("Fajri Jauhari (Gambar Titik)"); glutDisplayFunc(display); glutMainLoop(); return 0; }
Output
Menggambar Garis
Input :
#include <windows.h> #include <gl/gl.h> void userdraw() { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_LINES); glColor3f(1, 1, 1); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glEnd(); glFlush();
} void display(void) { glClear(GL_COLOR_BUFFER_BIT); userdraw(); glutSwapBuffers(); } int main(int argc, char** argv){ glutCreateWindow("Fajri Jauhari(Garis)"); glutDisplayFunc(display); glutMainLoop(); return 0; }
Output
Menggambar PolyLine Input : #include <windows.h> #include <gl/gl.h> void userdraw() { glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINE_STRIP); glColor3f(1, 1, 1); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0, 0.75); glEnd(); glFlush(); } void display(void) { glClear(GL_COLOR_BUFFER_BIT); userdraw(); glutSwapBuffers(); } int main(int argc, char** argv){ glutCreateWindow("Fajri Jauhari(PolyLine)"); glutDisplayFunc(display); glutMainLoop(); return 0; }
Output
void userdraw()
glVertex2f(-0.5, -0.5); glVertex2f(-0.75, 0); glVertex2f(-0.5, 0.5); glVertex2f(0, 0.75); glVertex2f(0.5, 0.5); glVertex2f(0.75, 0); glVertex2f(0.5, -0.5); glVertex2f(0,-0.75); glEnd(); glFlush(); } void display(void) { glClear(GL_COLOR_BUFFER_BIT);
userdraw(); glutSwapBuffers(); } int main(int argc, char** argv){ glutCreateWindow("Fajri Jauhari (Polygon)");