PEMANDANGA DI GLUT C++
OpenGL
#include <GL/glut.h>
#include <stdlib.h>
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glLineWidth(3);
glBegin(GL_POLYGON);//baground
glColor3f(1.0,1.0,1.0); glVertex2f(-10,10);
glColor3f(1.0,1.0,1.0); glVertex2f(10,10);
glColor3f(0.0,0.0,1.0); glVertex2f(10,-10);
glColor3f(0.0,0.0,1.0); glVertex2f(-10,-10);
glEnd();
glBegin(GL_POLYGON);//gunung
glColor3f(0.0,1.0,0.0); glVertex2f(-2,5);
glColor3f(0.0,1.0,0.0); glVertex2f(5,-1);
glColor3f(0.0,1.0,0.0); glVertex2f(-10,-1);
glEnd();
glBegin(GL_POLYGON);//gunung2
glColor3f(0.0,1.0,0.0); glVertex2f(5,5);
glColor3f(0.0,1.0,0.0); glVertex2f(15,-1);
glColor3f(0.0,1.0,0.0); glVertex2f(-5,-1);
glEnd();
glColor3f(1.0,1.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(-10,0);
glVertex2f(-8,0);
glVertex2f(-8,-3.5);
glVertex2f(-10,-3.5);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(-8,-0.8);
glVertex2f(-7,-0.8);
glVertex2f(-7,-3.5);
glVertex2f(-8,-3.5);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(-7,1);
glVertex2f(-5.5,1);
glVertex2f(-5.5,-3.5);
glVertex2f(-7,-3.5);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(-6.3,2.5);
glVertex2f(-5.5,1);
glVertex2f(-7,1);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(-5.5,0);
glVertex2f(-4,0);
glVertex2f(-4,-3.5);
glVertex2f(-5.5,-3.5);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(-4,-0.9);
glVertex2f(-1,-0.9);
glVertex2f(-1,-3.5);
glVertex2f(-4,-3.5);
glEnd();
glBegin(GL_POLYGON);//baground2
glColor3f(0.0,1.0,1.0);
glVertex2f(-10,-1);
glVertex2f(10,-1);
glVertex2f(10,-10);
glVertex2f(-10,-10);
glEnd();
glBegin(GL_LINES);//garis
glColor3f(1.0,1.0,1.0);
glVertex2f (-5,-10);
glVertex2f (0,-1);
glVertex2f (5,-10);
glVertex2f (1,-1);
glEnd();
glBegin(GL_LINE_LOOP);//kotak
glColor3f(1.0,1.0,1.0);
glVertex2f (4,-5);
glVertex2f (6,-2);
glVertex2f (9,-3);
glVertex2f (7,-7);
glEnd();
/* glBegin(GL_LINE_LOOP);
glColor3f(1.0,1.0,1.0);
glVertex2f (-5,-2);
glVertex2f (-8,-3);
glVertex2f (-9,-6);
glVertex2f (-6,-5);
glEnd();*/
glBegin(GL_LINES);
glColor3f (1.0,1.0,1.0);
glVertex2f(0.5,-1);
glVertex2f(0.5,-2);
glVertex2f(0.5,-3);
glVertex2f(0.5,-4);
glVertex2f(0.5,-5);
glVertex2f(0.5,-6);
glVertex2f(0.5,-7);
glVertex2f(0.5,-8);
glVertex2f(0.5,-9);
glVertex2f(0.5,-10);
glEnd();
glFlush();
}
int main(int argc, char *argv[]){
glutInitWindowSize(1000,700);
glutInitWindowPosition(0,0);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutCreateWindow("M.Harun Daulay");
gluOrtho2D(-10.,10.,-10.,10.);
glutMainLoop();
return 0;
}
Hasil
Semoga bermanfaat :
#include <GL/glut.h>
#include <stdlib.h>
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glLineWidth(3);
glBegin(GL_POLYGON);//baground
glColor3f(1.0,1.0,1.0); glVertex2f(-10,10);
glColor3f(1.0,1.0,1.0); glVertex2f(10,10);
glColor3f(0.0,0.0,1.0); glVertex2f(10,-10);
glColor3f(0.0,0.0,1.0); glVertex2f(-10,-10);
glEnd();
glBegin(GL_POLYGON);//gunung
glColor3f(0.0,1.0,0.0); glVertex2f(-2,5);
glColor3f(0.0,1.0,0.0); glVertex2f(5,-1);
glColor3f(0.0,1.0,0.0); glVertex2f(-10,-1);
glEnd();
glBegin(GL_POLYGON);//gunung2
glColor3f(0.0,1.0,0.0); glVertex2f(5,5);
glColor3f(0.0,1.0,0.0); glVertex2f(15,-1);
glColor3f(0.0,1.0,0.0); glVertex2f(-5,-1);
glEnd();
glColor3f(1.0,1.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(-10,0);
glVertex2f(-8,0);
glVertex2f(-8,-3.5);
glVertex2f(-10,-3.5);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(-8,-0.8);
glVertex2f(-7,-0.8);
glVertex2f(-7,-3.5);
glVertex2f(-8,-3.5);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(-7,1);
glVertex2f(-5.5,1);
glVertex2f(-5.5,-3.5);
glVertex2f(-7,-3.5);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(-6.3,2.5);
glVertex2f(-5.5,1);
glVertex2f(-7,1);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(-5.5,0);
glVertex2f(-4,0);
glVertex2f(-4,-3.5);
glVertex2f(-5.5,-3.5);
glEnd();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(-4,-0.9);
glVertex2f(-1,-0.9);
glVertex2f(-1,-3.5);
glVertex2f(-4,-3.5);
glEnd();
glBegin(GL_POLYGON);//baground2
glColor3f(0.0,1.0,1.0);
glVertex2f(-10,-1);
glVertex2f(10,-1);
glVertex2f(10,-10);
glVertex2f(-10,-10);
glEnd();
glBegin(GL_LINES);//garis
glColor3f(1.0,1.0,1.0);
glVertex2f (-5,-10);
glVertex2f (0,-1);
glVertex2f (5,-10);
glVertex2f (1,-1);
glEnd();
glBegin(GL_LINE_LOOP);//kotak
glColor3f(1.0,1.0,1.0);
glVertex2f (4,-5);
glVertex2f (6,-2);
glVertex2f (9,-3);
glVertex2f (7,-7);
glEnd();
/* glBegin(GL_LINE_LOOP);
glColor3f(1.0,1.0,1.0);
glVertex2f (-5,-2);
glVertex2f (-8,-3);
glVertex2f (-9,-6);
glVertex2f (-6,-5);
glEnd();*/
glBegin(GL_LINES);
glColor3f (1.0,1.0,1.0);
glVertex2f(0.5,-1);
glVertex2f(0.5,-2);
glVertex2f(0.5,-3);
glVertex2f(0.5,-4);
glVertex2f(0.5,-5);
glVertex2f(0.5,-6);
glVertex2f(0.5,-7);
glVertex2f(0.5,-8);
glVertex2f(0.5,-9);
glVertex2f(0.5,-10);
glEnd();
glFlush();
}
int main(int argc, char *argv[]){
glutInitWindowSize(1000,700);
glutInitWindowPosition(0,0);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutCreateWindow("M.Harun Daulay");
gluOrtho2D(-10.,10.,-10.,10.);
glClearColor(1.0,1.0,1.0,1.0);
glutDisplayFunc(display);glutMainLoop();
return 0;
}
Hasil
Semoga bermanfaat :
Komentar
Posting Komentar