I was trying to use the setup_render_texture method, always it gives a null pointer error can someone tell what am i doing incorrectly?
Any help would be greatly appreciated.
// MovingPanda.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "pandaFramework.h"
#include "pandaSystem.h"
#include "displayregion.h"
#include "genericAsyncTask.h"
#include "asyncTaskManager.h"
#include "eventHandler.h"
#include "buttonThrower.h"
#include "PNMImage.h"
#include "texture.h"
PandaFramework framework;
PT(AsyncTaskManager) taskMgr = AsyncTaskManager::get_global_ptr();
PT(ClockObject) globalClock = ClockObject::get_global_clock();
NodePath camera;
NodePath pandaActor;
WindowFramework *window;
PT(Texture) ptex;
void event_button_down (const Event* evenmt, void* data) ;
// Task to move the camera
AsyncTask::DoneStatus SpinCameraTask(GenericAsyncTask* task, void* data) {
double time = globalClock->get_real_time();
double angledegrees = time * 6.0;
double angleradians = angledegrees * (3.14 / 180.0);
// Using PNMImage too slow
// PNMImage pImage;
// window->get_graphics_output()->get_screenshot(pImage);
// ptex->get_ram_image().get_data();
window->get_graphics_output()->get_texture()->get_ram_image().get_data();
// Error in the above lines NULL pointer error.
pandaActor.set_pos(10*cos(angleradians),10*sin(angleradians),0);
pandaActor.set_hpr(180+angledegrees,0,0);
return AsyncTask::DS_cont;
}
int main(int argc, char *argv[]) {
framework.open_framework(argc, argv);
framework.set_window_title("My Panda3D Window");
// Open the window
window = framework.open_window();
camera = window->get_camera(0); // Get the camera and store it
NodePath environ = window->load_model(framework.get_models(), "models/environment");
environ.reparent_to(window->get_render());
environ.set_scale(0.25 , 0.25, 0.25);
environ.set_pos(-8, 42, 0);
camera.set_pos(0,0,3);
camera.set_hpr(0, 0, 0);
// Load our panda
pandaActor = window->load_model(framework.get_models(), "panda-model");
pandaActor.set_scale(0.005);
pandaActor.reparent_to(window->get_render());
// Load the walk animation
window->load_model(pandaActor, "panda-walk4");
window->loop_animations(0);
taskMgr->add(new GenericAsyncTask("Spins the camera", &SpinCameraTask, (void*) NULL));
//window->get_graphics_output()->setup_render_texture(ptex,false,true);
//did not work
framework.main_loop();
framework.close_framework();
return (0);
}