Problems with procedural 3D surfaces

Hi all.

I’ve run into some problems while trying to create 3D procedural surfaces. I have a simple task: creating a plane. Actually, I’ve done it before, but now I can’t get it to work. The code I’ve used before was the following:

#include "pandaFramework.h"
#include "pandaSystem.h"
#include <geomTristrips.h>

PandaFramework framework;

int main(int argc, char *argv[]) {
	// Initialize framework object, create window...
	framework.open_framework(argc, argv);
	framework.set_window_title("My Panda3D Window");
	WindowFramework *window = framework.open_window();

	// Write some vertex data...
	PT(GeomVertexData) m_vertexData( new GeomVertexData( "abc", GeomVertexFormat::get_v3t2(), Geom::UH_static ) );

	GeomVertexWriter writerVertex( m_vertexData, "vertex" );
	GeomVertexWriter writerTex( m_vertexData, "texcoord" );

	writerVertex.add_data3f( 0, 0, 0 );
	writerTex.add_data2f( 0, 1 );

	writerVertex.add_data3f( 0, 0, -1 );
	writerTex.add_data2f( 0, 0 );

	writerVertex.add_data3f( 1, 0, 0 );
	writerTex.add_data2f( 1, 1 );

	writerVertex.add_data3f( 1, 0, -1 );
	writerTex.add_data2f( 1, 0 );

	// Creates a Tristrip primitive
	PT(GeomTristrips) primitive = new GeomTristrips( Geom::UH_static );
	primitive->add_vertex( 0 );
	primitive->add_vertex( 1 );
	primitive->add_vertex( 2 );
	primitive->add_vertex( 3 );
	primitive->close_primitive();

	// Creates the Geom object
	PT(Geom) geometry = new Geom( m_vertexData );
	geometry->add_primitive( primitive );

	// Attach a GeomNode to the graph
	PT(GeomNode) geomNode = new GeomNode( "mygeomnode" );
	geomNode->add_geom( geometry );
	window->get_render().attach_new_node( geomNode );

	// Run main loop. After finishing, close framework and leave.
	framework.main_loop();
	framework.close_framework();
	return 0;
}

The problem seems to be in line 45, when I call geomNode->add_geom( geometry ). The application simply crashes, with no debug info about what happened.

I know it can only be something really simple. :blush:
What am I missing here?

If it is of any use, my system’s info:
Operating system: Windows 7 Professional (64 bits)
Graphics: ATI Mobility Radeon HD 4550 Graphics (512Mb)
Panda3D-1.7.0, Release.
Also building my project in Release mode, of course, under Visual C++ 2008 Express Edition.

Hi, I have exactly the same problem.

[url]GeomVertexData, Geom, GeomNode]

did you find a solution for it ? :confused:

Did you remember to remove NDEBUG from your project defines?

David