crash at setting a texturestage!!!

hi,
im wondering why this code crashs at setting a texturestage in set_texture?

#include "pandaFramework.h"
#include "pandaSystem.h"
#include "texturePool.h"
#include "cardMaker.h"
#include "textureStage.h"

PandaFramework framework;
WindowFramework *window;
GraphicsEngine *engine;

PT(ClockObject) globalClock = ClockObject::get_global_clock();
PT(AsyncTaskManager) taskMgr = AsyncTaskManager::get_global_ptr(); 
CardMaker cmTEST("test"); 
PT(TextureStage) stage1;
NodePath camera,testPLANE(cmTEST.generate()); 
PT(Texture) textureTEST;
float offsetV;

void windowOPEN() {
	WindowProperties *props = new WindowProperties(); 
	props->set_size(640,480);
	props->set_undecorated(false); 
	window = framework.open_window(*props,0);
	window->get_graphics_window()->get_active_display_region(0)->set_clear_color(Colorf(0,0,0,1));
}	
void getCAMERA() {
	camera = window->get_camera_group(); 
}
void billboards() {
	textureTEST=TexturePool::load_texture("test.tif");
	testPLANE.reparent_to(window->get_render_2d()); 
	testPLANE.set_transparency(TransparencyAttrib::Mode alpha,1);
	testPLANE.set_scale(.1,0,.8);
	testPLANE.set_texture(stage1,textureTEST,1);
}
void animate() {
	offsetV -= .1;
	testPLANE.set_tex_pos(stage1,0,offsetV,0); // EDIT: i had here a wrong piece of code in, i changed the names of my vars for this online doc. before i used instead of offsetV the var timer. but thats not the problem
}

AsyncTask::DoneStatus mainTASK(GenericAsyncTask* task, void* data) { 
	animate();
	return AsyncTask::DS_cont;
}

int main(int argc, char *argv[]) {
	framework.open_framework(argc, argv);
	windowOPEN();
	getCAMERA();
	billboards();

	taskMgr->add(new GenericAsyncTask("main task", &mainTASK, (void*) NULL));

	framework.main_loop();
	framework.close_framework();
	return (0);
} 

I’m guessing because you never initialized stage1.

David

same error if im doing: PT(TextureStage) stage1 = new TextureStage(“stage1”);

Perhaps there is something else uninitialized. Have you tried looking at the C++ stack trace?

David

everything works nicly, just if im using a textureStage it crash.

crtexe.c

#else  /* WPRFLAG */
            __initenv = envp;
            mainret = main(argc, argv, envp);// <- points on this line 

maybe it has anything to do with the framework, it also points sometime on this line, in my main ini.

framework.close_framework();

thats quite a pita…

anyway, maybe someone have a idea, till this moment im screwing on some other parts.

This code works fine for me using gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1 and Panda 1.7.0. after the following tweaks:

  1. TextureStage actually initialised as described above.
  2. Substituting my own test texture for ‘test.tif’.
  3. Changing
   testPLANE.set_transparency(TransparencyAttrib::Mode alpha,1); 

to

   testPLANE.set_transparency(TransparencyAttrib::M_alpha,1); 

On my system the code would not compile without this last change. It is possible that your compiler is creating a temporary variable of type TransparencyAttrib::Mode with rubbish in it and passing it to set_transparency.

Hope that’s of some use to you.