Hi, I have some problem with panda window on my PC (Ubuntu 18 with NVIDIA GPU and AMD Ryzen9 CPU): it shows only Black Screen with python and with C++ code. On another PC (ubuntu 18 and Intel+Intel GPU) and other system’s its work, but not on my Ubuntu 18. How can I fix this Problem?
Can you run other OpenGL programs successfully on the affected machine? For example, can you run the command-line program “glxgears”?
You forgot to create an instance.
>>> from direct.showbase.ShowBase import ShowBase
>>> base = ShowBase()
>>> base.run()
Or:
>>> from direct.directbase import DirectStart
>>> run()
Actually, looking at the code, if that’s everything then the model hasn’t been attached to the scene-graph (e.g. “myPanda.reparentTo(render)”), and hasn’t been moved into the view of the default camera (presuming that it’s centred on (0, 0, 0), and thus in the same place as said camera).
The problem here is the lack of a loop.
I think that it’s a combination of effects:
Trying out similar code on my own side, I can get similar results. However, they can be fixed by doing the following:
- Attach the model to the scene-graph
- Move the model into view of the camera
- And finally, call “base.graphicsEngine.renderFrame()”, possibly more than once.
That last is somewhat in line with what you’re suggesting, serega: it’s essentially a “manual” way of doing part of what the built-in game-loop does “automatically”.
thanks for the help, it works now with python, but still not in c ++. I wrote a little piece of code using Python to check that it worked, but forgot to add run to it.
Here is some C ++ code to initialize the window. It works on another PC and on this PC with Ubuntu 20, but not 18.
Its runs with some frameworks parallel, because of it i needed to start PandaFramework parallel to another frameworks (here with googleTest, to test only one function, normal runs with GTK as GUI).
testing::InitGoogleTest(&argc, argv);
int result = 0;
bool tRun = true;
ClockObject::get_global_clock()->set_mode(ClockObject::M_limited);
ClockObject::get_global_clock()->set_frame_rate(20);
mPandaFramework = new PandaFramework();
//open a new window framework
mPandaFramework->open_framework(argc, argv);
//set the window title to My Panda3D Window
mPandaFramework->set_window_title("IMS-360");
mPandaWindow = mPandaFramework->open_window();
mPandaWindow->setup_trackball();
while (mPandaFramework->get_num_windows() == 0)
{
std::cout << "main window still closed";
}
#pragma omp parallel sections shared(result, mPandaFramework)
{
#pragma omp section
{
mPandaFramework->main_loop();
}
#pragma omp section
{
int total_test_count = 0;
int time = 0;
int failed = 0;
for (int repeat = 0; repeat < 1; ++repeat)
{
result += RUN_ALL_TESTS();
testing::UnitTest *gtestInstance = testing::UnitTest::GetInstance();
total_test_count += gtestInstance->total_test_count();
time += gtestInstance->elapsed_time();
failed += gtestInstance->failed_test_count();
}
mPandaFramework->set_exit_flag();
tRun = false;
printf("Total Result: TestCount: %d\t time: %d ms\t failed: %d\t", total_test_count, time, failed);
}
}
mPandaWindow = nullptr;
mPandaFramework->close_framework();
delete mPandaFramework;
return result;
Why do you ignore the start of the loop and then say that it does not work?
#include "pandaFramework.h"
#include "pandaSystem.h"
int main(int argc, char *argv[]) {
// Open a new window framework
PandaFramework framework;
framework.open_framework(argc, argv);
// Set the window title and open the window
framework.set_window_title("My Panda3D Window");
WindowFramework *window = framework.open_window();
// Here is room for your own code
// Do the main loop, equal to run() in python
framework.main_loop();
framework.close_framework();
return (0);
}
In python I have got some bad example from internet, have not seen that it have not run (ok have not known that i need to ad run to it, have not worked with python for long time.) sorry.
in C++ if I put my code like you show it, it don’t work. If I put my code into
// Here is room for your own code
it blocs Panda and code inside the my code use panda (load Model and make some panda operations) Its don’t works, because panda main_loop was not started. and when my code is ready, its main_loop, but it mus close program at that time. It must run somehow parallel to main_loop() (because my code is blocking and main_loop is blocking).
my code is in RUN_ALL_TESTS part.
I could use events, but which Event, Panda ore GTK or Google test. It don’t work to (both frameworks are Main).
I Use framework.main_loop(); parallel to RUN_ALL_TESTS() with openmp ```
#pragma omp section
Obviously, if you have abandoned the Panda loop, you need to call the frame render function as needed.
render_frame()
But I use main_loop().
#pragma omp section
{
mPandaFramework->main_loop();
}
"#pragma omp section " says run parallel (in one thread).
I will check to start render_frame() parallel to main_loop, maby there is something worden with Main_loop on my system (it works on other systems).
Here some simpl code that must show zup-axis. It dont work on my PC.
I have tried with only main_loop part and with render_frame
ClockObject::get_global_clock()->set_mode(ClockObject::M_limited);
ClockObject::get_global_clock()->set_frame_rate(20);
mPandaFramework = new PandaFramework();
//open a new window framework
mPandaFramework->open_framework(argc, argv);
//set the window title to My Panda3D Window
mPandaFramework->set_window_title("IMS-360");
mPandaWindow = mPandaFramework->open_window();
mPandaWindow->setup_trackball();
while (mPandaFramework->get_num_windows() == 0)
{
std::cout << "main window still closed";
}
uint tFrame = 0;
#pragma omp parallel sections shared(result, mPandaFramework)
{
#pragma omp section
{
mPandaFramework->main_loop();
}
#pragma omp section
{
sleep(1);
NodePath mScene = mPandaWindow->get_render().attach_new_node("world");
NodePath tZupAxis = mPandaWindow->load_model(mPandaFramework->get_models(), "zup-axis");
tZupAxis.set_scale(1, 1, 1);
tZupAxis.reparent_to(mScene);
while (true)
{
mPandaFramework->get_graphics_engine()->render_frame();// Comment it to check main_loop
std::cout << "Frame: " << tFrame++;
sleep(1);
}
}
}
mPandaWindow = nullptr;
mPandaFramework->close_framework();
delete mPandaFramework;
return result;
The first thought that comes to mind is to call render_frame () twice. This is necessary from double buffering.
call render_frame () twice didn’t help, but if I run only render_frame() without thread than it works (after second frame). Maybe i need to give somehow thread ID to make work it with thread?
You have implemented parallelism incorrectly. You should call render_frame () when GTK is idle, it should have a callback for that.
This code now runs without GTK only GTest. I try to write all code in modules and test it separately. Strange is that it works good on other systems.
for module idea is: GTK creates an panda instance (in idle, when all was loaded and initialized) and give an pointer for Window/Framework/MainScen to module. Modul can be started with GTK if GUI is needed or without, (or with some other framework like JTest or something, need only give Window/Framework/MainScen and parameter for init).
I will try thread without OpenMP (pure c++), maybe OpenMP is broken on this system.
after c++ try:
does not work with the c ++ thread either.