Mercurial > fife-parpg
comparison ext/guichan-0.8.1/examples/openglsdlhelloworld.cpp @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 /** | |
2 * This is an example that shows a simple Hello World example | |
3 * with Guichan. The example uses the OpenGL back end and the | |
4 * SDL back end. | |
5 */ | |
6 | |
7 #include <guichan.hpp> | |
8 #include <iostream> | |
9 | |
10 // Here we store a global Gui object. We make it global | |
11 // so it's easily accessable. Of course, global variables | |
12 // should normally be avioded when it comes to OOP, but | |
13 // this examples is not an example that shows how to make a | |
14 // good and clean C++ application but merely an example | |
15 // that shows how to use Guichan. | |
16 namespace globals | |
17 { | |
18 gcn::Gui* gui; | |
19 } | |
20 | |
21 // Include code to set up an OpenGL and SDL application with Guichan. | |
22 // The openglsdl.hpp file is responsible for creating and deleting | |
23 // the global Gui object. | |
24 #include "openglsdl.hpp" | |
25 // Include code to set up a Guichan GUI with a simple Hello | |
26 // World example. The code populates the global Gui object. | |
27 #include "helloworld.hpp" | |
28 | |
29 int main(int argc, char **argv) | |
30 { | |
31 try | |
32 { | |
33 openglsdl::init(); | |
34 helloworld::init(); | |
35 openglsdl::run(); | |
36 helloworld::halt(); | |
37 openglsdl::halt(); | |
38 } | |
39 // Catch all Guichan exceptions. | |
40 catch (gcn::Exception e) | |
41 { | |
42 std::cerr << e.getMessage() << std::endl; | |
43 return 1; | |
44 } | |
45 // Catch all Std exceptions. | |
46 catch (std::exception e) | |
47 { | |
48 std::cerr << "Std exception: " << e.what() << std::endl; | |
49 return 1; | |
50 } | |
51 // Catch all unknown exceptions. | |
52 catch (...) | |
53 { | |
54 std::cerr << "Unknown exception" << std::endl; | |
55 return 1; | |
56 } | |
57 | |
58 return 0; | |
59 } |