2 * Copyright (C) 2006 Claudio Ciccani <klan@users.sf.net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 /*****************************************************************************/
29 static int g_display_changed
= 0;
31 /*****************************************************************************/
35 glutGameModeString( const char *string
)
43 tmp
= strchr( string
, 'x' );
45 x
= strtol( string
, NULL
, 10 );
46 y
= strtol( tmp
+1, NULL
, 10 );
54 tmp
= strchr( string
, ':' );
56 bpp
= strtol( tmp
+1, NULL
, 10 );
65 glutEnterGameMode( void )
67 DFBDisplayLayerConfig prev
, cur
;
69 glutInit( NULL
, NULL
);
71 primary
->GetConfiguration( primary
, &prev
);
72 primary
->SetCooperativeLevel( primary
, DLSCL_EXCLUSIVE
);
75 __glutDestroyWindow( g_game
);
77 g_game
= __glutCreateWindow( GL_TRUE
);
81 __glutSetWindow( g_game
);
82 g_game
->cursor
= GLUT_CURSOR_NONE
;
84 primary
->GetConfiguration( primary
, &cur
);
85 g_display_changed
= (cur
.width
!= prev
.width
||
86 cur
.height
!= prev
.height
||
87 cur
.pixelformat
!= prev
.pixelformat
);
94 glutLeaveGameMode( void )
97 __glutDestroyWindow( g_game
);
99 primary
->SetCooperativeLevel( primary
, DLSCL_ADMINISTRATIVE
);
104 glutGameModeGet( GLenum type
)
107 case GLUT_GAME_MODE_ACTIVE
:
108 return (g_game
!= NULL
);
109 case GLUT_GAME_MODE_POSSIBLE
:
111 DFBDisplayLayerConfig c
;
112 c
.flags
= DLCONF_WIDTH
| DLCONF_HEIGHT
;
116 if (primary
->TestConfiguration( primary
, &c
, 0 ) == DFB_OK
)
120 case GLUT_GAME_MODE_WIDTH
:
123 g_game
->surface
->GetSize( g_game
->surface
, &w
, 0 );
127 case GLUT_GAME_MODE_HEIGHT
:
130 g_game
->surface
->GetSize( g_game
->surface
, 0, &h
);
134 case GLUT_GAME_MODE_PIXEL_DEPTH
:
136 DFBSurfacePixelFormat f
;
137 g_game
->surface
->GetPixelFormat( g_game
->surface
, &f
);
138 return DFB_COLOR_BITS_PER_PIXEL( f
);
141 case GLUT_GAME_MODE_REFRESH_RATE
:
142 return 60; /* assume 60hz */
143 case GLUT_GAME_MODE_DISPLAY_CHANGED
:
144 return g_display_changed
;