viernes, 22 de octubre de 2010

10 primitivas geometricas en open GL usando c++


#include "stdafx.h"
#include
#include
#include
#include
#include
#include

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "GlAux.Lib")
#pragma comment(lib, "glu32.lib")

void main(int argc, char** argv)
{
auxInitDisplayMode (AUX_SINGLE | AUX_RGBA);

auxInitPosition (0, 0, 840, 680);

auxInitWindow (argv[0]);


glBegin(GL_LINE_STRIP);
glColor3f(1.0,1.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glVertex2f(-0.9f,0.8f);
glVertex2f(-0.8f,0.6f);
glVertex2f(-0.7f,0.5f);
glEnd();


glBegin(GL_LINES);
glColor3f(1.0f,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glVertex2f(0.6,-0.2);
glVertex2f(0.9,-0.3);
glEnd();

glBegin(GL_LINE_LOOP);
glColor3f(1.0f,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glVertex2f(-0.2f,0.0f);
glVertex2f(0.0f,-0.2f);
glVertex2f(0.2f,0.0f);
glVertex2f(0.0f,0.2f);
glEnd();



glBegin(GL_POINTS);
glColor3f(0.0,1.0,0.1);
glClear(GL_COLOR_BUFFER_BIT);
glVertex2f(0.1f, 0.5f);
glVertex2f(0.2f, 0.6f);
glVertex2f(0.3f, 0.7f);
glVertex2f(0.4f, 0.8f);
glEnd();


glBegin(GL_TRIANGLE_STRIP);
glColor3f(1.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);

glVertex2f( -0.8,0.8);
glVertex2f( -0.5, 0.5);
glVertex2f(-0.3,0.8);
glVertex2f(-0.3, 0.3);
glEnd();

glBegin(GL_POLYGON);
glColor3f(1.0,1.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
glVertex2f(-0.3f,0.5f);
glVertex2f(-0.2f,0.3f);
glVertex2f(-0.2f,0.4f);
glVertex2f(-0.1f,0.6f);
glVertex2f(-0.1f,0.7f);
glEnd();



glBegin(GL_QUADS);
glColor3f(0.0,1.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glVertex2f( 0.1,-0.7);
glVertex2f( 0.0,-0.7);
glVertex2f( 0.0,-0.8);
glVertex2f(0.1,-0.8);
glEnd();


glBegin(GL_QUAD_STRIP);
glColor3f(0.0f,1.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT);

glVertex2f(0.4f,-0.5f);
glVertex2f(0.4f,-0.4f);
glVertex2f(0.4f,-0.5f);
glVertex2f(0.4f,-0.4f);
glVertex2f(0.3f,-0.4f);
glVertex2f(0.3f,-0.4f);
glVertex2f(0.3f,-0.5f);
glVertex2f(0.3f,-0.4f);
glVertex2f(0.4f,-0.5f);
glVertex2f(0.4f,-0.4f);
glEnd();

glBegin(GL_TRIANGLES);
glColor3f(1.0f,0.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT);

glVertex2f( 0.3f, 0.1f);

glColor3f(0.0f,1.0f,0.0f);
glVertex2f(0.4f,0.3f);

glColor3f(0.0f,0.0f,1.0f);
glVertex2f( 0.6f,0.1f);
glEnd();

glBegin(GL_TRIANGLE_FAN);

glColor3f(1.0f,0.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT);

glVertex2f( -0.5f, -0.5f);

glColor3f(0.0f,1.0f,0.0f);
glVertex2f(-0.8f,-0.8f);

glColor3f(0.0f,0.0f,1.0f);
glVertex2f( -0.2f,-0.8f);

glColor3f(0.0f,1.0f,0.0f);
glVertex2f( -0.5f,-0.5f);

glColor3f(0.0f,0.0f,1.0f);
glVertex2f(-0.5f,-0.5f);

glColor3f(0.0f,1.0f,0.0f);
glVertex2f(-0.5f,-0.5f);
glEnd();

glFlush();
getchar();
}



1 comentario:

danrocha7 dijo...
Este comentario ha sido eliminado por el autor.