PERSEGI 4
keterangan :
pakek openGL microsoft visual c++ 2010 express.
source code
#include <Windows.h>
#include <math.h>
#include <gl/glut.h>
void display(){
glColor3f(1.0,1.0,1.0);
//bentuk setengah oval asli
glPushMatrix();
glTranslated(-90,0,0);
glLineWidth(5);
glBegin(GL_POLYGON);
for(float theta=0; theta<=180; theta++){
GLfloat radt = (theta/180)*(3.14);
glVertex2f(radt*50, sin(radt)*100+200);
}
glEnd();
glPopMatrix();
//bentuk setengal oval, diputar 90 derajat ke kiri
glPushMatrix();
glRotated(90,0,0,1);
glTranslated(45,-110,0);
glLineWidth(5);
glBegin(GL_POLYGON);
for(float theta=0; theta<=180; theta++){
GLfloat radt = (theta/180)*(3.14);
glVertex2f(radt*50, sin(radt)*100+200);
}
glEnd();
glPopMatrix();
//bentuk setengal oval, diputar 180 derajat ke kiri
glPushMatrix();
glRotated(180,0,0,1);
glTranslated(-68,-246,0);
glLineWidth(5);
glBegin(GL_POLYGON);
for(float theta=0; theta<=180; theta++){
GLfloat radt = (theta/180)*(3.14);
glVertex2f(radt*50, sin(radt)*100+200);
}
glEnd();
glPopMatrix();
//bentuk setengal oval, diputar 270 derajat ke kiri
glPushMatrix();
glRotated(270,0,0,1);
glTranslated(-200,-133,0);
glLineWidth(5);
glBegin(GL_POLYGON);
for(float theta=0; theta<=180; theta++){
GLfloat radt = (theta/180)*(3.14);
glVertex2f(radt*50, sin(radt)*100+200);
}
glEnd();
glPopMatrix();
//bentuk persegi untuk mengisi bagian tengah
glColor3f(0.0,0.0,1.0);
glPopMatrix();
glTranslated(-90,40,0);
glBegin(GL_POLYGON);
glVertex2f(0,0);
glVertex2f(0,160);
glVertex2f(160,160);
glVertex2f(160,0);
glEnd();
glPushMatrix();
glFlush();
}
void init(){
GLfloat w=1024, h=600;
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0,0,(GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-500,w,-300,h);
glMatrixMode(GL_MODELVIEW);
}
void FnKey (unsigned char key, int x, int y) {
if (key==27){
exit(1);
}
}
int main(int argc, char** argv){
FreeConsole();
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (768, 450);
glutInitWindowPosition (100, 100);
glutCreateWindow ("Create Circle");
init ();
glutKeyboardFunc(FnKey);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
Subscribe to:
Post Comments (Atom)
Cara Refund Google Ads
Non Aktifkan Akun gogle dulu. Baru semua saldo yang berada di dalamnya, akan otomatis di kembalikan, lengkap dengan tgl berapa akan di kem...
No comments:
Post a Comment