Menu

Tutorial 1 - Writing Your First OpenFrames Program

R. S.
Attachments
Tut1-1-50.jpg (8118 bytes)
Tut1-2-60.jpg (17316 bytes)
Tut1-3-60.jpg (2284 bytes)
Tut1-4-Solution-60.jpg (10572 bytes)
Tut1-5-60.jpg (28142 bytes)
Tut1-6-60.jpg (15398 bytes)

This tutorial gives step-by-step instructions for writing a simple OpenFrames program for execution on Windows. The code in this tutorial was built with the following tools: Windows 10 (version 1803, build no. 17134.228); CMake (version 3.10.3); and Visual Studio 2013 (version 12.0.40629.00, update 5, which uses .NET Framework version 4.7.03056). CMake (see CMake documentation) is a cross-platform tool that is used here to generate a Visual Studio solution (.sln) file. Visual Studio is then used to compile the program into an executable binary. Successful results may be possible with other versions of these tools; we will supplement the tutorial with more information as our testing expands.

There are seven basic steps involved in making an OpenFrames program. The first step is to write a program that uses OpenFrames functionality. The short program Tutorial1.cpp is an example. It draws a single Reference Frame, as shown in the image below. A Reference Frame and any associated content (e.g. geometric models, or text) is a basic component of the OpenFrames package.

Tutorial 1 Image

The short length of the example file gives an idea of OpenFrames' ease-of-use.

For reasons discussed further below, it is convenient to place the code for a standalone OpenFrames application into a folder of its own. Here that has been done by placing the file "Tutorial1.cpp" in a folder called "install-dir"\Demos\CPP\Tutorial1\ -

CodeFolder

In addition to the source-code file, a file named "CMakeLists.txt" should be placed in the folder. There is one such file in all of the folders in "install-dir"\Demos\CPP\. For the most part, these files only differ by a single "SET" assignment line, shown here-

CMakeListsKeyLine

The name of the folder should be put in the place where "Tutorial1" appears above. This specification is used by the CMake application to build a separate executable from all of the others in the various folders in "install-dir"\Demos\CPP\.

In Step 4 of the overall process, CMake is used to generate a new Visual Studio solution file. As shown here-

New VS Solution File

the "Generate" button, circled in red, should be clicked to produce a new Visual Studio solution file. The latter will contain "Tutorial1" as a distinct project.

The new solution file will be located in whatever folder has been specified to CMake in the "Where to build the binaries" line, as can be seen in the above figure. It will be named "OpenFrames.sln". When it is opened in Visual Studio, the Solution Explorer in this case should show Tutorial1 as a distinct project-

Use CMake to gen new VS solution

To confirm that everything is working as expected you can open the project and build the tutorial, as shown here-

BuildingTutorial1

When the application finishes compiling you should install the binary into the folder that holds all the executables; this is done by right-clicking on the "INSTALL" target and selecting "Build" -

InstallTheBinary

The binary, Tutorial1.exe in this case, can then be found in the folder "install-dir"\OpenFrames-Windows-install\bin\ that contains all the other executables in the solution. The final step of this tutorial is to cd into that folder and run the example by typing ".\Tutorial1.exe" (followed by the Enter key). The first figure of this tutorial should then appear on-screen in a popup.


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.