Documentos de Académico
Documentos de Profesional
Documentos de Cultura
utilizar y color
glutDisplayFunc(display); //*funcion de dibujado: display
glClearColor(0,0,1,0); //*Color de fondo, color de borrado
glClear(GL_COLOR_BUFFER_BIT); //*Cuando se mueve para que se vuelva a
dibujar primero limpiando
glFlush(); //*limpiar el buffer
glOrtho(-10.0,10.0,-10.0,10,-10.0,10.0); //*Inicializar la cámara
*GL_PI -> M_PI
--------------------------------------------------------------------------------------------
glutInitWindowSize(200, 200); //Cambiar el tamaño de la ventana
glOrtho(-50.0, 50.0, -50.0, 50, -1.0, 1.0); //En sist. de coordenadas OpenGL 100
//pixeles horizontales, 100 verticales;
*coord. Enteras
glOrtho(-100.0, 100.0, -100.0, 100, -1.0, 1.0); //200 pixeles x 200
++
//Algoritmo antialiasing para suavizar bordes en rectas
void init(void)
{
glClearColor(0,0.5,0.2,0); //Color de fondo de la ventana
glPointSize(10); //Para tamaño del punto
glColor3f(0,1,1); // Color para dibujar todos los puntos
glShadeModel(GL_FLAT);
}
--------------------------------------------------------------------------------------------
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glBegin(GL_POINTS);
glVertex2f(0,0); //Graficar puntos
glVertex2d(5,5); //Otra manera
glEnd();
glPopMatrix();
glFlush();
}
--------------------------------------------------------------------------------------------
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glPointSize(5); //Tamaño del punto antes del glBegin()
glBegin(GL_POINTS);
glColor3f(1,0,0); //Color de punto
glVertex2f(0,0); //
glColor3f(1,1,0); // Otro color de punto
glVertex2f(3,3); //
glEnd();
glPopMatrix();
glFlush();
}
--------------------------------------------------------------------------------------------
void display(void)
{
GLfloat ang, radio = 8.0f, x, y;
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glLineWidth(9); //Grosor de línea
glColor3f(1,0,0); //Color de líneas
glBegin(GL_LINE_LOOP); //Figura cerrada sin relleno
//glBegin(GL_POLYGON); //Figura cerrada con relleno
glColor3f(0,0,1);
glVertex2f(0,0);
glEnd();
glPopMatrix(); /
glFlush();
}
--------------------------------------------------------------------------------------------
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glColor3f(0,0,0);
glRectf(0,0,8,8); //Dibujar rectángulo plano
glRectf(-8,-8,0,0); //
glColor3f(1,1,1);
glRectf(-8,0,0,8); //
glRectf(0,-8,8,0); //
glPopMatrix();
glFlush();
}
--------------------------------------------------------------------------------------------
Disco hueco
GLUquadricObj *pt;
pt=gluNewQuadric();
// esta orden especifica como va a ser renderizado:
gluQuadricDrawStyle(pt,GLU_LINE);
glColor3f (1.0, 0.0, 0.0);
// Dibuja Discos
gluDisk(pt, 4, 9, 15, 6);
--------------------------------------------------------------------------------------------
Sector de disco hueco
GLUquadricObj *pt;
pt=gluNewQuadric();
// renderizar con lineas
gluQuadricDrawStyle(pt,GLU_LINE);
glColor3f (1.0, 0.0, 0.0);
// Dibuja Disco parcial
gluPartialDisk(pt, 4, 9, 15, 6,0,90);
------------------------------------------------------------------------------------------------------
//HACAR LINEA
void linea(int x0, int y0,int x1,int y1){
glBegin(GL_LINES);
glVertex2f(x0,y0);
glVertex2f(x1,y1);
glEnd();
}
------------------------------------------------------------------------------------------------------
LABO 01
EJERCICIO 2
void display(void)
{
GLfloat ang, radio = 8.0f, x, y, aux1, aux2;
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glColor3f(1,0,0);
GLfloat vx[4];
vx[0]=-lado/2;
vx[1]=lado/2;
vx[2]=lado/2;
vx[3]=-lado/2;
GLfloat vy[4];
vy[0]=lado/2;
vy[1]=lado/2;
vy[2]=-lado/2;
vy[3]=-lado/2;
EJERCICIO 3
void display(void)
{
GLfloat ang, radio = 8.0f, x, y, aux1, aux2;
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix(); // salva el estado actual de la matriz
glColor3f(0,0,0);
glBegin(GL_LINE_LOOP);
}
glEnd();
glColor3f(1,0,0);
GLUquadricObj *pt;
pt=gluNewQuadric();
// esta orden especifica como va a ser renderizado:
gluQuadricDrawStyle(pt,GLU_LINE);
glColor3f (1.0, 0.0, 0.0);
// Dibuja Discos
gluDisk(pt, 0, 9, 15, 6);