home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
-
-
- #include <aux.h>
- #include <auxPrivate.h>
-
- /**************************************************************************
- * auxGetWindow() - Match an X window to an auxWindow id
- **************************************************************************/
-
- auxWindow *
- auxGetWindow( GLint windowId )
- {
- auxWindow *tmp;
-
- for ( tmp = auxState.head; tmp; tmp = tmp->next )
- if ( tmp->id == windowId )
- return tmp;
- auxFatalError( "Unable to find window" );
- }
-
-
- /**************************************************************************
- * auxWinSet() - make a window the current drawable
- **************************************************************************/
-
- GLvoid
- auxWinSet( GLint windowId )
- {
- auxWindow *tmp;
-
- #ifdef DEBUG
- printf(" In auxWinSet() ... windowId = %d\n", windowId );
- #endif
-
- if ( windowId < ZERO )
- tmp = auxState.current;
- else
- tmp = auxGetWindow( windowId );
-
- #ifdef DEBUG
- printf( " In auxWinSet() ... about to call glXMakeCurrent()\n\n" );
- printf( "\tid = %d\n", tmp->id );
- printf( "\tglxWindow = 0x%x\n", tmp->glxWindow );
- printf( "\tglxContext = 0x%x\n", tmp->glxContext );
- #endif
-
- if ( !glXMakeCurrent( auxState.display, tmp->glxWindow, tmp->glxContext ) )
- auxFatalError( "Unable to set window" );
- }
-
-
- /**************************************************************************
- * auxWinGet() - return the current grahics window id
- **************************************************************************/
-
- GLint
- auxWinGet( GLvoid )
- {
- return auxState.current->id;
- }
-
- /**************************************************************************
- * auxWinClose() - Destroy a window
- **************************************************************************/
-
- GLvoid
- auxWinClose( GLint windowId )
- {
- auxWindow *tmp;
-
- tmp = auxGetWindow( windowId );
-
- if ( !tmp->prev ) { /* Head of list */
- auxState.head = tmp->next;
- auxState.head->prev = (auxWindow *) NULL;
- } else if ( !tmp->next ) { /* Tail of list */
- auxState.tail = tmp->prev;
- auxState.tail->next = (auxWindow *) NULL;
- } else { /* Somewhere in middle of list */
- tmp->next->prev = tmp->prev;
- tmp->prev->next = tmp->next;
- }
-
- XUnmapWindow( auxState.display, tmp->glxWindow );
- glXDestroyContext( auxState.display, tmp->glxContext );
- XDestroyWindow( auxState.display, tmp->glxWindow );
-
- free( tmp );
- }
-
-
- /**************************************************************************
- * auxSwapBuffers() - swap the front and back buffers
- **************************************************************************/
-
- GLvoid
- auxSwapBuffers( GLvoid )
- {
- glXSwapBuffers( auxState.display, auxState.current->glxWindow );
- }
-
-
- /**************************************************************************
- * auxGetSize() - retrieve the size of a window
- **************************************************************************/
-
- GLvoid
- auxGetSize( GLsizei *width, GLsizei *height )
- {
- *width = auxState.current->width;
- *height = auxState.current->height;
- }
-
-
- /**************************************************************************
- * auxGetOrigin() - retrieve the position of a window
- **************************************************************************/
-
- GLvoid
- auxGetOrigin( GLint *x, GLint *y )
- {
- *x = auxState.current->x;
- *y = auxState.current->y;
- }
-
-
- /**************************************************************************
- * auxGetScreenSize() - retrieve the size of a window
- **************************************************************************/
-
- GLvoid
- auxGetScreenSize( GLsizei *width, GLsizei *height )
- {
- if ( !auxInitCalled )
- auxInit();
-
- *width = WidthOfScreen( auxState.screen );
- *height = HeightOfScreen( auxState.screen );
- }
-