opengl color quadrangle
Posted
by Tyzak
on Stack Overflow
See other posts from Stack Overflow
or by Tyzak
Published on 2010-04-03T23:11:17Z
Indexed on
2010/04/03
23:13 UTC
Read the original article
Hit count: 369
hello i try out opengl.
i have a programm that creates a black border an white corner (quadrangle).
now i want to make the corner of the quadrangle in an different color.
i don't know where exactly to write the code, and i don't know much a but color4f, i searcherd on google, but didn't get it. (is there a good description somewhere?)
#include <iostream>
#include <GL/freeglut.h>
void Init()
{
glColor4f(100,0,0,0);
}
void RenderScene() //Zeichenfunktion
{
glLoadIdentity ();
glBegin( GL_POLYGON );
glVertex3f( -0.5, -0.5, -0.5 );
glVertex3f( 0.5, -0.5, -0.5 );
glVertex3f( 0.5, 0.5, -0.5 );
glVertex3f( -0.5, 0.5, -0.5 );
glEnd();
glFlush();
}
void Reshape(int width,int height)
{
}
void Animate (int value)
{
std::cout << "value=" << value << std::endl;
glutPostRedisplay();
glutTimerFunc(100, Animate, ++value);
}
int main(int argc, char **argv)
{
glutInit( &argc, argv ); // GLUT initialisieren
glutInitDisplayMode( GLUT_RGB ); // Fenster-Konfiguration
glutInitWindowSize( 600, 600 );
glutCreateWindow( "inkrement screen; visual screen" ); // Fenster-Erzeugung
glutDisplayFunc( RenderScene ); // Zeichenfunktion bekannt machen
glutReshapeFunc( Reshape );
glutTimerFunc( 10, Animate, 0);
Init();
glutMainLoop();
return 0;
}
© Stack Overflow or respective owner