/* * Copyright (c) 1996-1999 Silicon Graphics, Inc. All rights reserved. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE * POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* background.c - open a window and clear the background. * glutMainLoop() calls drawScene whenever the window needs * to be updated. */ #include /* includes gl.h, glu.h */ #include /* Function Prototypes */ GLvoid initgfx( GLvoid ); GLvoid drawScene( GLvoid ); void checkError( char * ); void main( int argc, char *argv[] ) { GLsizei width, height; /* Le seguenti variabili sono utilizzate per mostrare il numero di bit (bitplane) per colore */ GLint redplanes, greenplanes, blueplanes, alphaplanes; glutInit( &argc, argv ); /* create a window that is 1/4 the size of the screen, * and position it in the middle of the screen. */ width = glutGet( GLUT_SCREEN_WIDTH ); height = glutGet( GLUT_SCREEN_HEIGHT ); glutInitWindowPosition( width / 4, height / 4 ); glutInitWindowSize( width / 2, height / 2 ); glutInitDisplayMode( GLUT_RGBA ); glutCreateWindow( argv[0] ); /* Verifichiamo il numero di bitplane della finestra appena definita */ glGetIntegerv( GL_RED_BITS, &redplanes ); glGetIntegerv( GL_GREEN_BITS, &greenplanes ); glGetIntegerv( GL_BLUE_BITS, &blueplanes ); glGetIntegerv( GL_ALPHA_BITS, &alphaplanes ); printf("bitplane per colore: R->%d G->%d B->%d A->%d\n", redplanes,greenplanes,blueplanes,alphaplanes); initgfx(); glutDisplayFunc( drawScene ); glutMainLoop(); } GLvoid initgfx( GLvoid ) { /* set clear color to magenta */ glClearColor( 1.0, 0.0, 1.0, 1.0 ); } void checkError( char *label ) { GLenum error; while ( (error = glGetError()) != GL_NO_ERROR ) printf( "%s: %s\n", label, gluErrorString(error) ); } GLvoid drawScene( GLvoid ) { glClear( GL_COLOR_BUFFER_BIT ); /* Do all your OpenGL rendering here */ checkError( "drawScene" ); glFlush(); }