Friday, May 9, 2014

GL_TRIANGLE_FAN Example In OpenGl

#include <GL/glut.h>      
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,0.0);
glBegin(GL_TRIANGLE_FAN);
glVertex3f(0.1, 0.1,0.0);
glVertex3f(0.6, 0.1,0.0);
glVertex3f(0.8,0.3,0.0);
glVertex3f(0.6,0.6,0.0);
glVertex3f(0.1,0.6,0.0);
glVertex3f(0.0,0.3,0.0);
glEnd();
glFlush();
}
void init()
{
glClearColor(0.0,0.5,0.2,0.8);
}
int main(int argc, char** argv)
{
glutCreateWindow("simple 3D");
glutDisplayFunc(display);
init();
glutMainLoop();
}

GL_POLYGON Example In OpenGl

#include <GL/glut.h>      
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,0.0);
glBegin(GL_POLYGON);
glVertex3f(0.1, 0.1,0.0);
glVertex3f(0.6, 0.1,0.0);
glVertex3f(0.8,0.3,0.0);
glVertex3f(0.6,0.6,0.0);
glVertex3f(0.1,0.6,0.0);
glVertex3f(0.0,0.3,0.0);
glEnd();
glFlush();
}
void init()
{
glClearColor(0.0,0.5,0.2,0.8);
}
int main(int argc, char** argv)
{
glutCreateWindow("simple 3D");
glutDisplayFunc(display);
init();
glutMainLoop();
}

GL_QUAD_STRIP Example In OpenGl

#include <GL/glut.h>      
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,0.0);
glBegin(GL_QUAD_STRIP);
glVertex3f(0.2, 0.2,0.0);
glVertex3f(0.8, 0.2,0.0);
glVertex3f(0.2,0.4,0.0);
glVertex3f(0.8,0.4,0.0);
glVertex3f(0.2,0.8,0.0);
glVertex3f(0.8,0.8,0.0);
glEnd();
glFlush();
}
void init()
{
glClearColor(0.0,0.5,0.2,0.8);
}
int main(int argc, char** argv)
{
glutCreateWindow("simple 3D");
glutDisplayFunc(display);
init();
glutMainLoop();
}

GL_QUADS Example In OpenGl

#include <gl glut.h="">         
void display()
{
glClear(GL_COLOR_BUFFER_BIT); 
glColor3f(1.0,1.0,0.0);
glBegin(GL_QUADS);
glVertex3f(0.2, 0.2,0.0);
glVertex3f(0.8, 0.2,0.0);
glVertex3f(0.6,0.4,0.0);
glVertex3f(0.4,0.4,0.0);
glVertex3f(0.4,0.6,0.0);
glVertex3f(0.6,0.6,0.0);
glVertex3f(0.8,0.8,0.0);
glVertex3f(0.2,0.8,0.0);
glEnd();
glFlush(); 
}
void init()
{
glClearColor(0.0,0.5,0.2,0.8);
}
int main(int argc, char** argv)
{
glutCreateWindow("simple 3D"); 
glutDisplayFunc(display);
init();
glutMainLoop();
}

GL_TRIANGLES Example In OpenGl

#include <GL/glut.h>      
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,0.0);
glBegin(GL_TRIANGLES);
glVertex3f(0.2, 0.2,0.0);
glVertex3f(0.8, 0.2,0.0);
glVertex3f(0.2, 0.5,0.0);
//glVertex3f(0.8, 0.5,0.0);
//glVertex3f(0.2, 0.8,0.0);
//glVertex3f(0.8, 0.8,0.0);
glEnd();
glFlush();
}
void init()
{
glClearColor(0.0,0.5,0.2,0.8);
}
int main(int argc, char** argv)
{
glutCreateWindow("simple 3D");
glutDisplayFunc(display);
init();
glutMainLoop();
}

GL_TRIANGLE_STRIP Example In OpenGl

#include <GL/glut.h>         
void display()
{
glClear(GL_COLOR_BUFFER_BIT); 
glColor3f(1.0,1.0,0.0);
glBegin(GL_TRIANGLE_STRIP);
glVertex3f(0.2, 0.2,0.0);
glVertex3f(0.8, 0.2,0.0);
glVertex3f(0.2, 0.5,0.0);
glVertex3f(0.8, 0.5,0.0);
glVertex3f(0.2, 0.8,0.0);
glVertex3f(0.8, 0.8,0.0);
glEnd();
glFlush(); 
}
void init()
{
glClearColor(0.0,0.5,0.2,0.8);
}
int main(int argc, char** argv)
{
glutCreateWindow("simple 3D"); 
glutDisplayFunc(display);
init();
glutMainLoop();
}

GL_LINE_LOOP Example In OpenGl

#include <GL/glut.h>      
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,0.0);
glBegin(GL_LINE_LOOP);
glVertex3f(0.2, 0.2,0.0);
glVertex3f(0.8, 0.2,0.0);
glVertex3f(0.2, 0.5,0.0);
glVertex3f(0.8, 0.5,0.0);
glVertex3f(0.2, 0.8,0.0);
glVertex3f(0.8, 0.8,0.0);
glEnd();
glFlush();
}
void init()
{
glClearColor(0.0,0.5,0.2,0.8);
}
int main(int argc, char** argv)
{
glutCreateWindow("simple 3D");
glutDisplayFunc(display);
init();
glutMainLoop();
}

GL_LINE_STRIP Example In OpenGl


#include <GL/glut.h>         
void display()
{
glClear(GL_COLOR_BUFFER_BIT); 
glColor3f(1.0,1.0,0.0);
glBegin(GL_LINE_STRIP);
glVertex3f(0.2, 0.2,0.0);
glVertex3f(0.8, 0.2,0.0);
glVertex3f(0.2, 0.5,0.0);
glVertex3f(0.8, 0.5,0.0);
glVertex3f(0.2, 0.8,0.0);
glVertex3f(0.8, 0.8,0.0);
glEnd();
glFlush(); 
}
void init()
{
glClearColor(0.0,0.5,0.2,0.8);
}
int main(int argc, char** argv)
{
glutCreateWindow("simple 3D"); 
glutDisplayFunc(display);
init();
glutMainLoop();
}

Simple line drawing in OpenGl



#include <GL/glut.h>         

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT); 
glColor3f(1.0,1.0,0.0);
glBegin(GL_LINES);
glVertex2f(0.5, -0.5);
glVertex2f(-0.5, 0.5);
glEnd();
glFlush(); 
}
void init(){
glClearColor(0.0,0.5,0.2,0.8);
}

int main(int argc, char** argv)
{
glutCreateWindow("simple line"); 
glutDisplayFunc(display);
init();
glutMainLoop();

}