October 10, 2011

OPEN GL

Untuk membuat  segitiga , persegi, garis.
- Klik file -> new project -> multimedia -> openGL
- Maka akan tampil source code automatis

SEGITIGA

glBegin (GL_TRIANGLES);                                            
glColor3f (1.0f, 0.0f, 0.0f);   glVertex2f (0.0f, 1.0f);       
glColor3f (0.0f, 1.0f, 0.0f);   glVertex2f (0.87f, -0.5f);    
glColor3f (0.0f, 0.0f, 1.0f);   glVertex2f (-0.87f, -0.5f);   
glEnd ();  
SwapBuffers (hDC);


Sleep (1); 
Hasilnya :                                                                       

















PERSEGI


glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClear (GL_COLOR_BUFFER_BIT);


glBegin (GL_POLYGON);
glColor3f (1.0f, 0.0f, 0.0f); glVertex2f (-0.5f, -0.5f);
glColor3f (0.0f, 1.0f, 0.0f); glVertex2f (-0.5f, 0.5f);
glColor3f (0.0f, 2.0f, 0.0f); glVertex2f (0.5f, 0.5f);
glColor3f (0.0f, 0.0f, 3.0f); glVertex2f (0.5f, -0.5f);
glEnd ();

SwapBuffers (hDC);


Sleep (1);
Hasilnya :
GARIS
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClear (GL_COLOR_BUFFER_BIT);

glPushMatrix ();
glClearColor(1,1,1,0);
glColor3f(1,1,1); //

glBegin(GL_LINES);
glVertex3f(0,0,-0.8);
glVertex3f(9.9,8.9,0.1);

glEnd ();
glPopMatrix ();

SwapBuffers (hDC);

Sleep (1);
Hasilnya :


Powered by Blogger.
 

Black Box Copyright © 2011 -- Template created by O Pregador -- Powered by Blogger