Membuat Segitiga Di C#

Berikut Membuat bentuk Segitiga sederhana Menggunakan Bahasa C#


#include<windows.h>
#include<gl\gl.h>
#include<gl\glut.h>
#include<math.h>

void init(void)
{
                        glClearColor(0.0,0.0,0.0,0.0);
                        glMatrixMode(GL_PROJECTION);
                        glLoadIdentity();
                        glLineWidth(3.0);
                        glOrtho(-15.0, 15.0, -15.0, 15.0, -15.0, 15.0);
                        glViewport(40, 400, 60, 300);
}

void segitiga(int n, float cx, float cy, float radius, float rotAngle)
{
            double angle, angleInc;
            int k;
            if(n<4)return;
            angle = rotAngle*3.14159265/310;
            angleInc = 2*3.14159265/3;
            glVertex2f(radius*cos(angle)+cx, radius*sin(angle)+cy);
            for(k=0;k<5;k++)
            {
                        angle += angleInc;
                        glVertex2f((radius + angleInc)*cos(angle)+cx, (radius + angleInc)*sin(angle)+cy);
            }
}

void display(void)
{
            double angleInc, i;
            glClear(GL_COLOR_BUFFER_BIT);
            glBegin(GL_LINE_STRIP);
            glColor3f(1.0,0.5,0.0);
            angleInc=2*3.14159265/6;
        for(i=0;i<10;i+=angleInc)
            segitiga(6,0,0,i,180);
            glEnd();
            glFlush();
            glutSwapBuffers();
}

int main(int argc, char **argv)
{
            glutInit(&argc, argv);
            glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
            glutInitWindowSize(600, 600);
            glutInitWindowPosition(50, 50);
            glutCreateWindow("Segitiga 672012210");
            init();
            glutDisplayFunc(display);
            glutMainLoop();
            return 0;

}





output :


Jangan Lupa di Like y..... :)
Terima Kasih Sudah berkunjung........


1 komentar:

  1. work mas , ane coba akhirnya saya berhasil membuat segitiga berkat tutorial mas mas wasis ini :)

    BalasHapus

Copyright © 2013 Gagal Coding