Membuat Bintang dengan Dev C++

16 Feb

membuat bintang dengan dev c++ ..

#include <gl/glut.h>
#include <gl/gl.h>
#include <math.h>
void tantidinantinanti(void)
{
glClear(GL_COLOR_BUFFER_BIT);

glPushMatrix();//3.1 miring kanan
glLineWidth(2.0f);
glBegin(GL_LINES);
glColor3f (1.0,0.0,0.0)  ;glVertex2f(0.0,0.5);
glColor3f (0.10,0.10,0.10);glVertex2f(0.2,0.1);
glEnd();
glFlush();
glPopMatrix();

glPushMatrix();//3.1 miring kiri
glLineWidth(2.0f);
glBegin(GL_LINES);
glColor3f (1.0,0.0,0.0)  ;glVertex2f(0.0,0.5);
glColor3f (0.10,0.10,0.10);glVertex2f(-0.2,0.1);
glEnd();
glFlush();
glPopMatrix();

glPushMatrix();//3.2 horizontal
glLineWidth(2.0f);
glBegin(GL_LINES);
glColor3f (1.0,0.0,0.0)  ;glVertex2f(0.2,0.1);
glColor3f (0.10,0.10,0.10);glVertex2f(0.5,0.1);
glEnd();
glFlush();
glPopMatrix();

glPushMatrix();//3.2 miring bawah
glLineWidth(2.0f);
glBegin(GL_LINES);
glColor3f (1.0,0.0,0.0)  ;glVertex2f(0.5,0.1);
glColor3f (0.10,0.10,0.10);glVertex2f(0.2,-0.2);
glEnd();
glFlush();
glPopMatrix();

glPushMatrix();//3.3 miring 1
glLineWidth(2.0f);
glBegin(GL_LINES);
glColor3f (1.0,0.0,0.0)  ;glVertex2f(0.2,-0.2);
glColor3f (0.10,0.10,0.10);glVertex2f(0.5,-0.5);
glEnd();
glFlush();
glPopMatrix();

glPushMatrix();//3.3 miring 2
glLineWidth(2.0f);
glBegin(GL_LINES);
glColor3f (1.0,0.0,0.0)  ;glVertex2f(0.5,-0.5);
glColor3f (0.10,0.10,0.10);glVertex2f(0.0,-0.3);
glEnd();
glFlush();
glPopMatrix();

glPushMatrix();//3.4 miring 1
glLineWidth(2.0f);
glBegin(GL_LINES);
glColor3f (0.10,0.10,0.10);glVertex2f(0.0,-0.3);
glColor3f (1.0,0.0,0.0)  ;glVertex2f(-0.5,-0.5);
glEnd();
glFlush();
glPopMatrix();

glPushMatrix();//3.4 miring 2
glLineWidth(2.0f);
glBegin(GL_LINES);
glColor3f (0.10,0.10,0.10);glVertex2f(-0.5,-0.5);
glColor3f (1.0,0.0,0.0)  ;glVertex2f(-0.2,-0.2);
glEnd();
glFlush();
glPopMatrix();

glPushMatrix();//3.5 miring 1
glLineWidth(2.0f);
glBegin(GL_LINES);
glColor3f (0.10,0.10,0.10);glVertex2f(-0.2,-0.2);
glColor3f (1.0,0.0,0.0)   ;glVertex2f(-0.5,0.1);
glEnd();
glFlush();
glPopMatrix();

glPushMatrix();//3.5 vertikal
glLineWidth(2.0f);
glBegin(GL_LINES);
glColor3f (0.10,0.10,0.10);glVertex2f(-0.5,0.1);
glColor3f (1.0,0.0,0.0)   ;glVertex2f(-0.2,0.1);
glEnd();
glFlush();
glPopMatrix();

glPushMatrix();
#define PI 3.1415926535898
glBegin(GL_LINE_LOOP);
GLint circle_points = 100;
int i;
float angle;
for (i = 0; i < circle_points; i++) {
angle = 2*PI*i/circle_points;
glVertex2f(cos(angle), sin(angle));
}
glEnd();
glPopMatrix();
glFlush();
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(640,480);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
glutCreateWindow(“tantidinantinanti”);
glutDisplayFunc(tantidinantinanti);
glClearColor(1.9f, 0.9f, 0.9f, 1.9f);
glutMainLoop();
return 0;
}

output:

3 Responses to “Membuat Bintang dengan Dev C++”

  1. ichsanblog.wordpress.com February 17, 2011 at 7:10 am #

    Nice post sayang..^^

    Keep Posting on Blog….

  2. felhie1 March 3, 2013 at 6:57 pm #

    kagak mau kak.. error… –, apa yang salah ya

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: