Flip BabyStep Tutorial

 

BabyStep 0: Starting Point

This chapter makes an introduction about the very starting point of the baby steps tutorials. It relies on the babystep0 ... babystep3 contained into src/samples/flip/ folder.

Important:Please read the readme.html file contained in those folders for build instructions.

Overview

Multiple files are present in the folder. The following describes each file and what it is used for.

The babystep.xcodeproj and babystep.sln are the project or solution used for your IDE. They contains the other files from this folder, as well as all the files needed to compile a fully working babystep application.

The Info.plist is MacOS XCode specific file.

The main.cpp file contains the main code for our project.

The BabystepGui.cpp and BabystepGui.h defines the BabystepGui class that makes a very basic GUI for our application, with a main window and a menu bar. This is also where almost every flip view code is located.

The ModelRoot.cpp and ModelRoot.h defines the ModelRoot class which is a very basic data model. This is where almost every flip controller code is located.

The BundleRoot.cpp/.h , FrameRoot.cpp/.h and PrimRoot.cpp/.h give a basic GUI to manipulate the model and see how it is manipulated. Those classes use the opal/opak framework which is beyond the scope of this tutorial. However the classes are very simple and easy to understand.

The main.cpp File

The main.cpp file is for now filled with a very simple main code for the application. it has support for Windows and MacOS. The Windows code essentially deduces the boot parameters argc and argv .

opa::ApplicationWindowSimple window (argc, argv);
BabystepGui gui (window);
window.run ();

The above code is the essential of the main function. It is enclosed in a try/catch block.

opa::ApplicationWindowSimple window (argc, argv);

This line will construct a very simple application when one main windows is assumed. This window will have a menu bar on Windows, where as the MacOS version will have its standard menu bar.

BabystepGui gui (window);

This line will construct our application GUI and attach it to window .

window.run ();

Finally this line starts the application event loop, the loop to which used inputs events are directed.

The BabystepGui class, while being used in the code, is inactive. It does not contain any useful code for now. The ModelRoot class is also almost empty, and does not contain useful code for now. The other classes are not empty, but have commented code that we will uncomment as needed.

At this stage, you should be able to build the project without issues. If you then run the project, you should see a window appearing with probably graphic garbage in it. It is now time to move to the next chapter and add actual flip code to our application.