Here is the program we will be discussing FirstWindow.cpp:
00001: #include <wkgl/Window.h> 00002: 00003: using namespace wkgl; 00004: 00005: WPARAM main() 00006: { 00007: //Construct the window 00008: Window win( "Hello World" ); 00009: 00010: //Make the window ready to display 00011: win.show(); 00012: 00013: //Begin actual program 00014: return win.beginMessageLoop(); 00015: }
The first line includes the header header needed to access the library. All the classes found in the WKGL are in the namespace wkgl, so we must say "using namespace wkgl". The main function is the entry point to the application. Next, the the window is created using the Window component. Notice that the argument is the message that appears in the title bar of the window. Then we instruct the window to make itself displayable by calling show. BeginMessageLoop() is the heart of all our programs. It displays the window and fires all of its events, we will get to those soon.
For those of you who are wondering why don't we just use the win32 api? Well we did three lines of code what would take 77 lines of code to do by hand. So when the programs seem long and complicated just remember doing it by hand would be a lot longer. If you are used to programming the using that API, you could be asking your self, what happend to WinMain? Well for simplification I wrote WinMain to simply copy its parameters into the appropriate global variables (see docs), and call main().