27f4968d77939635d57f5b2d24c0c6c1373d0cc8
[freeglut] / src / blackberry / fg_state_blackberry.c
1 /*
2  * fg_state_blackberry.c
3  *
4  * BlackBerry-specific freeglut state query methods.
5  *
6  * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
7  * Written by John F. Fay, <fayjf@sourceforge.net>
8  * Copyright (C) 2012  Sylvain Beucler
9  * Copyright (C) 2013  Vincent Simonetti
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included
19  * in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
24  * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
25  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27  */
28
29 #include <GL/freeglut.h>
30 #include <stdio.h>
31 #include <screen/screen.h>
32 #include "fg_internal.h"
33 #include "egl/fg_state_egl.h"
34
35 //From fg_state_android.c
36 int fgPlatformGlutDeviceGet ( GLenum eWhat )
37 {
38     switch( eWhat )
39     {
40     case GLUT_HAS_KEYBOARD:
41         /* BlackBerry has a keyboard, though it may be virtual. */
42         return 1;
43
44     case GLUT_HAS_MOUSE:
45         /* BlackBerry has a touchscreen; until we get proper touchscreen
46            support, consider it as a mouse. */
47         return 1 ;
48
49     case GLUT_NUM_MOUSE_BUTTONS:
50         /* BlackBerry has a touchscreen; until we get proper touchscreen
51            support, consider it as a 1-button mouse. */
52         return 1;
53
54     default:
55         fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
56         break;
57     }
58
59     /* And now -- the failure. */
60     return -1;
61 }
62
63 int fgPlatformGlutGet ( GLenum eWhat )
64 {
65     switch (eWhat) {
66     /* One full-screen window only */
67     case GLUT_WINDOW_X:
68     case GLUT_WINDOW_Y:
69     case GLUT_WINDOW_BORDER_WIDTH:
70     case GLUT_WINDOW_HEADER_HEIGHT:
71         return 0;
72
73     case GLUT_WINDOW_WIDTH:
74     case GLUT_WINDOW_HEIGHT:
75     {
76         if ( fgStructure.CurrentWindow == NULL )
77             return 0;
78         int size[2];
79         if ( screen_get_window_property_iv(fgStructure.CurrentWindow->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0 )
80             return 0;
81         switch ( eWhat )
82         {
83         case GLUT_WINDOW_WIDTH:
84             return size[0];
85         case GLUT_WINDOW_HEIGHT:
86             return size[1];
87         }
88         break;
89     }
90
91     case GLUT_WINDOW_COLORMAP_SIZE:
92         /* 0 for RGBA/non-indexed mode */
93         /* Under BlackBerry and GLES more generally, no indexed-mode */
94         return 0;
95
96     default:
97         return fghPlatformGlutGetEGL(eWhat);
98     }
99     return -1;
100 }