First window
The first thing to do when beginning a session using HOOPS Visualize is to instantiate a HPS::World
object. This call sets up the HPS::Database
, which is the primary store of information for your HOOPS Visualize scene. The only parameter needed to start your HPS::World
is your license key.
int main(int, char**)
{
HPS::World world(HOOPS_LICENSE);
All functions in the HPS API are members of the HPS namespace.
We also need to set up a few other items such as the models directory, the resources directory and the HOOPS Exchange install location:
stExchangeModelsFolder = HEXCHANGE_INSTALL_DIR + "/samples/data/";
world.SetExchangeLibraryDirectory(HEXCHANGE_INSTALL_DIR + "/bin/" + bin_subdir);
world.SetPublishResourceDirectory(HEXCHANGE_INSTALL_DIR + "/bin/resource");
Now that your HPS::World
object is set, let’s get a window on the screen. HOOPS Visualize can make use of several types of windows. Here, we are using a HPS::StandAloneWindow
, which doesn’t rely on any particular GUI framework. The code to create the window looks like this:
StandAloneWindowOptionsKit windowOptions;
windowOptions.SetMobility(Window::Mobility::Free);
windowOptions.SetSubscreen(HPS::Rectangle(-0.75f, 0.75f, -0.75f, 0.75f));
windowOptions.SetDriver(Window::Driver::Default3D);
windowOptions.SetTitle("HPS Basic");
StandAloneWindowKey windowKey = Database::CreateStandAloneWindow(windowOptions);
This code establishes the rendering context as well as a few other things, such as the driver to use (OpenGL, DirectX, etc), the area of the window that HOOPS Visualize will render to, and the window title. Notice the StandAloneWindowOptionsKit
, which is a group of options used to create the window. Many object types in HOOPS Visualize are created using this “kit-to-object” paradigm. Finally, the last line of the code sample uses the kit we configured to insert the window object into the HPS::Database
.
IMPORTANT: For this tutoral, we are using a
HPS::StandAloneWindow
. This type of window is meant for very simple demonstrations and tests. It is not capable of meeting the demands of a full-fledged application. However, it is simple to create and is the only window type which is completely platform-independent. Your end-user application will almost certainly require anHPS::ApplicationWindow
which integrates more closely with the particular platform and GUI subsystem you’ll be using.
If you were to only execute the code above, the window will be created and HOOPS Native Platform will be running, but we need a few more things before we can actually get geometry rendering.