Application crashes during GraphicsWindow method



I’ve had some experience making apps with panda3d in python with decent success and have since tried to work in C++, which I suppose I’m a relative noob only having took 2 semesters of C++ in college.

My current problem is I’m running one of the very basic examples from the manual, and simply injected some TextNode and GraphicsWindow code for playing with the C++ equivalent classes.

The app runs fine up until the point that I actually make a call to a GraphicsWindow method, at which point I get the windows “test.exe has stopped working” message. Debugging it just seems to tell me about some assembly code error, which is probably unimportant but just incase…

First-chance exception at 0x0188c0c4 in Veritus.exe: 0xC0000005: Access violation reading location 0x0000039c.
Unhandled exception at 0x0188c0c4 in Veritus.exe: 0xC0000005: Access violation reading location 0x0000039c.
WindowProps = WindowGFX->get_properties();
->0118111C push    eax
└>0188C0C4 mov     eax,dword ptr [esi+8]

the file is relatively the same minus the couple lines I added in the camera task, but here’s the whole thing in case I did something very wrong.


#ifndef VERITUS_H
#define VERITUS_H
#include <stdlib.h>
#include <sstream>



#include "Veritus.h"
#include "pandaFramework.h"
#include "pandaSystem.h"
#include "graphicsWindow.h"
PandaFramework framework;
PT( GraphicsWindow ) WindowGFX;
WindowProperties WindowProps;
// The global task manager
PT(AsyncTaskManager) taskMgr = AsyncTaskManager::get_global_ptr(); 
// The global clock
PT(ClockObject) globalClock = ClockObject::get_global_clock();
// Here's what we'll store the camera in.
NodePath camera;
PT( TextNode ) UIText;
// This is our task - a global or static function that has to return DoneStatus.
// The task object is passed as argument, plus a void* pointer, cointaining custom data.
// For more advanced usage, we can subclass AsyncTask and override the do_task method.
AsyncTask::DoneStatus spinCameraTask(GenericAsyncTask* task, void* data) {
  // Calculate the new position and orientation (inefficient - change me!)
  double time = globalClock->get_real_time();
  double angledegrees = time * 6.0;
  double angleradians = angledegrees * (3.14 / 180.0);
  camera.set_hpr(angledegrees, 0, 0);
  std::string testString;
  int numDevices = 10;
  //This line crashes it...
  WindowProps = WindowGFX->get_properties();
  //So does this...
  //int numDevices = WindowGFX->get_num_input_devices();
  std::string numDevicesStr;
  std::stringstream numDevicesStrStream;
  numDevicesStrStream << numDevices;
  numDevicesStr = numDevicesStrStream.str();
  //and so do these two (separately i mean)...
  //testString = WindowGFX->get_window_event();
  //UIText->set_text( WindowGFX->get_window_event() );
  UIText->set_text( numDevicesStr );

  // Tell the task manager to continue this task the next frame.
  return AsyncTask::DS_cont;
int main(int argc, char *argv[]) {
    // Load the window and set its title.
    framework.open_framework(argc, argv);
    framework.set_window_title("Veritus v0.1");
    WindowFramework *window = framework.open_window();
    // Get the camera and store it in a variable.
    camera = window->get_camera_group();
    // Load the environment model.
    NodePath environ = window->load_model(framework.get_models(), "models/environment");
    // Reparent the model to render.
    // Apply scale and position transforms to the model.
    environ.set_scale(0.25, 0.25, 0.25);
    environ.set_pos(-8, 42, 0);
    // Add our task.
    // If we specify custom data instead of NULL, it will be passed as the second argument
    // to the task function.
    taskMgr->add(new GenericAsyncTask("Spins the camera", &spinCameraTask, (void*) NULL));

	UIText = new TextNode( "node name" );
	UIText->set_text( "oh hai there" );
	NodePath textNodePath = window->get_aspect_2d().attach_new_node(UIText);
    // Run the engine.
    // Shut down the engine when done.
    return (0);

I haven’t seen any other errors, just 20 or so deprecated function call warnings. All the debugger seems to indicate about WindowGFX variable is that it has a void pointer.

Also, when I try to run the app from VS it states that libp3framework.dll was not found, though executing from the .exe directly seems to work just fine, or rather without calling any GraphicsWindow methods it does.

I’m working in VS2008 with Panda3D-1.7.2 on Vista Home Premium 64-bit


Some of your global variables like GFXWindow never get initializes as far I can see.


Yeah, that line crashes because WindowGFX is NULL at that point, so you’re dereferencing a NULL pointer.