Note: The WindowFramework class is for use in C++ only. If you use Python, you can just use DirectStart to open a window and skip this page.
This page will explain how to use the WindowFramework class in C++ to open a blank window.
First of all, we need to include the appropiate header files:
#include "pandaFramework.h"
#include "pandaSystem.h"
Second, we need to create an instance of the WindowFramework class and open the main int of course.
PandaFramework framework;
int main(int argc, char *argv[]) {
Now, we must open the framework, give the window a nice title and open the window:
framework.open_framework(argc, argv);
framework.set_window_title("Hello World!");
//open it!
WindowFramework *window = framework.open_window();
Now, we're going to check if the window has opened successfully.
If so, the main loop must be called, using the function framework.main_loop(). This is equal to the run() function in Python.
if (window != (WindowFramework *)NULL) {
nout << "Opened the window successfully!\n";
//put here your own code, such as the loading of your models
framework.main_loop();
} else {
nout << "Could not load the window!\n";
}
Afterwards, we need to close the framework:
framework.close_framework();
return (0);
}
Now, compile and run your file and you have your own window opened!
For the lazy ones among us, here is the full code:
//include all the stuff
#include "pandaFramework.h"
#include "pandaSystem.h"
//init the PandaFramework class
PandaFramework framework;
int main(int argc, char *argv[]) {
//open the framework
framework.open_framework(argc, argv);
//set a nice title
framework.set_window_title("Hello World!");
//open it!
WindowFramework *window = framework.open_window();
//check whether the window is loaded correctly
if (window != (WindowFramework *)NULL) {
nout << "Opened the window successfully!\n";
//put here your own code, such as the loading of your models
//do the main loop
framework.main_loop();
} else {
nout << "Could not load the window!\n";
}
//close the framework
framework.close_framework();
return (0);
}
|