root/trunk/llmozlib2/tests/ubrowser/app.cpp

Revision 9, 4.2 kB (checked in by rob.linden, 2 years ago)

Added files missed in first commit

  • Property svn:eol-style set to native
Line 
1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * The contents of this file are subject to the Mozilla Public License Version
5  * 1.1 (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS" basis,
10  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11  * for the specific language governing rights and limitations under the
12  * License.
13  *
14  * The Original Code is Linden Lab Inc. (http://lindenlab.com) code.
15  *
16  * The Initial Developer of the Original Code is:
17  *   Callum Prentice (callum@ubrowser.com)
18  *
19  * Portions created by the Initial Developer are Copyright (C) 2006
20  * the Initial Developer. All Rights Reserved.
21  *
22  * Contributor(s):
23  *  Callum Prentice (callum@ubrowser.com)
24  *
25  * Alternatively, the contents of this file may be used under the terms of
26  * either the GNU General Public License Version 2 or later (the "GPL"), or
27  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28  * in which case the provisions of the GPL or the LGPL are applicable instead
29  * of those above. If you wish to allow use of your version of this file only
30  * under the terms of either the GPL or the LGPL, and not to allow others to
31  * use your version of this file under the terms of the MPL, indicate your
32  * decision by deleting the provisions above and replace them with the notice
33  * and other provisions required by the GPL or the LGPL. If you do not delete
34  * the provisions above, a recipient may use your version of this file under
35  * the terms of any one of the MPL, the GPL or the LGPL.
36  *
37  * ***** END LICENSE BLOCK ***** */
38
39 #include "ubrowser.h"
40
41 #include "GL/glut.h"
42 #include "glui.h"
43
44 uBrowser* theApp;
45
46 ////////////////////////////////////////////////////////////////////////////////
47 //
48 void glutReshape( int widthIn, int heightIn )
49 {
50         if ( theApp )
51                 theApp->reshape( widthIn, heightIn );
52 };
53
54 ////////////////////////////////////////////////////////////////////////////////
55 //
56 void glutDisplay()
57 {
58         if ( theApp )
59                 theApp->display();
60 };
61
62 ////////////////////////////////////////////////////////////////////////////////
63 //
64 void glutIdle()
65 {
66         if ( theApp )
67                 theApp->idle();
68 };
69
70 ////////////////////////////////////////////////////////////////////////////////
71 //
72 void glutKeyboard( unsigned char keyIn, int xIn, int yIn )
73 {
74         if ( theApp )
75                 theApp->keyboard( keyIn, xIn, yIn );
76 };
77
78 ////////////////////////////////////////////////////////////////////////////////
79 //
80 void glutSpecialKeyboard( int keyIn, int xIn, int yIn )
81 {
82         // appears that you need this defined even if it's empty
83         // passing NULL for the handler func ptr crashes this app
84 };
85
86 ////////////////////////////////////////////////////////////////////////////////
87 //
88 void glutPassiveMouse( int xIn, int yIn )
89 {
90         if ( theApp )
91                 theApp->passiveMouse( xIn, yIn );
92 }
93
94 ////////////////////////////////////////////////////////////////////////////////
95 //
96 void glutMouseMove( int xIn , int yIn )
97 {
98         if ( theApp )
99                 theApp->mouseMove( xIn, yIn );
100 }
101
102 ////////////////////////////////////////////////////////////////////////////////
103 //
104 void glutMouseButton( int buttonIn, int stateIn, int xIn, int yIn )
105 {
106         if ( theApp )
107                 theApp->mouseButton( buttonIn, stateIn, xIn, yIn );
108 }
109
110 ////////////////////////////////////////////////////////////////////////////////
111 //
112 int main( int argc, char* argv[] )
113 {
114         theApp = new uBrowser;
115
116         if ( theApp )
117         {
118                 glutInit( &argc, argv );
119                 glutInitDisplayMode( GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB );
120
121                 glutInitWindowPosition( 80, 0 );
122                 glutInitWindowSize( 1024, 900 );
123
124                 int appWindow = glutCreateWindow( theApp->getName().c_str() );
125
126                 glutDisplayFunc( glutDisplay );
127
128                 GLUI_Master.set_glutReshapeFunc( glutReshape );
129                 GLUI_Master.set_glutKeyboardFunc( glutKeyboard );
130                 GLUI_Master.set_glutMouseFunc( glutMouseButton );
131                 GLUI_Master.set_glutSpecialFunc( glutSpecialKeyboard );
132
133                 glutPassiveMotionFunc( glutPassiveMouse );
134                 glutMotionFunc( glutMouseMove );
135
136                 glutSetWindow( appWindow );
137
138                 theApp->init( argv[ 0 ], appWindow );
139
140                 GLUI_Master.set_glutIdleFunc( glutIdle );
141
142                 glutMainLoop();
143
144                 delete theApp;
145         };
146
147         return 1;
148 }
149
Note: See TracBrowser for help on using the browser.