Initial revision
[freeglut] / freeglut-1.3 / freeglut_display.c
1 /*
2  * freeglut_display.c
3  *
4  * Display message posting, context buffer swapping.
5  *
6  * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7  * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8  * Creation date: Fri Dec 3 1999
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  * Permission is hereby granted, free of charge, to any person obtaining a
15  * copy of this software and associated documentation files (the "Software"),
16  * to deal in the Software without restriction, including without limitation
17  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18  * and/or sell copies of the Software, and to permit persons to whom the
19  * Software is furnished to do so, subject to the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be included
22  * in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
27  * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
28  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30  */
31
32 #ifdef HAVE_CONFIG_H
33 #include "config.h"
34 #endif
35
36 #define  G_LOG_DOMAIN  "freeglut-display"
37
38 #include "../include/GL/freeglut.h"
39 #include "../include/GL/freeglut_internal.h"
40
41
42 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
43
44 /*
45  * Marks the current window to have the redisplay performed when possible...
46  */
47 void FGAPIENTRY glutPostRedisplay( void )
48 {
49     /*
50      * Is there a current window set?
51      */
52     freeglut_assert_ready; freeglut_assert_window;
53
54     /*
55      * Just mark the window as one that we need to redisplay...
56      */
57     fgStructure.Window->State.Redisplay = TRUE;
58 }
59
60 /*
61  * Swaps the buffers for the current window (if any)
62  */
63 void FGAPIENTRY glutSwapBuffers( void )
64 {
65     /*
66      * As long as we've got a current window set...
67      */
68     freeglut_assert_ready; freeglut_assert_window;
69
70     /*
71      * Have the mouse cursor and/or the menus drawn for the current window
72      */
73     fgDisplayMenu();
74     fgDisplayCursor();
75
76     /*
77      * Make sure the current context is flushed
78      */
79     glFlush();
80
81 #if TARGET_HOST_UNIX_X11
82     /*
83      * Issue the glXSwapBuffers call and be done with it
84      */
85     glXSwapBuffers( fgDisplay.Display, fgStructure.Window->Window.Handle );
86
87 #elif TARGET_HOST_WIN32
88     /*
89      * Swap the window's buffers
90      */
91     SwapBuffers( fgStructure.Window->Window.Device );
92
93 #endif
94 }
95
96 /*
97  * Mark appropriate window to be displayed
98  */
99 void FGAPIENTRY glutPostWindowRedisplay( int windowID )
100 {
101     SFG_Window* window;
102
103     freeglut_assert_ready;
104
105     /*
106      * Try looking for the window
107      */
108     window = fgWindowByID( windowID );
109
110     /*
111      * If failed, return
112      */
113     freeglut_return_if_fail( window != NULL );
114
115     /*
116      * Otherwise mark the window for being redisplayed
117      */
118     window->State.Redisplay = TRUE;
119 }
120
121 /*** END OF FILE ***/