GeomVertexData, Geom, GeomNode


here is some sample code for creating 2 triangles following the (somewhat inconsistent panda3d manual).

#include "pandaFramework.h" 
#include "pandaSystem.h" 
#include "geomTriangles.h"

PandaFramework framework; 

int main(int argc, char *argv[]) 
	//open a new window framework  
	framework.open_framework(argc, argv);    
	//set the window title to My Panda3D Window  
	framework.set_window_title("My Panda3D Window"); 

	//open the window  
	WindowFramework *window = framework.open_window(); 
	//here is room for your own code 

	PT(GeomVertexArrayFormat) array;
	array = new GeomVertexArrayFormat();
	array->add_column(InternalName::make("vertex"), 3, Geom::NT_float32, Geom::C_point);
	array->add_column(InternalName::make("normal"), 3, Geom::NT_float32, Geom::C_vector);
	array->add_column(InternalName::make("color"), 1, Geom::NT_packed_dabc, Geom::C_color);

	PT(GeomVertexFormat) unregistered_format;
	unregistered_format = new GeomVertexFormat();

	CPT(GeomVertexFormat) format;
	format = GeomVertexFormat::register_format(unregistered_format);

	PT(GeomVertexData) vdata;
	vdata = new GeomVertexData("TestTriangle", format, Geom::UH_static);

	GeomVertexWriter vertex, normal, color;
	vertex = GeomVertexWriter(vdata, "vertex");
	normal = GeomVertexWriter(vdata, "normal");
	color = GeomVertexWriter(vdata, "color");

	vertex.add_data3f(1, 0, 0);
	normal.add_data3f(0, 0, 1);
	color.add_data4f(0, 0, 1, 1);

	vertex.add_data3f(1, 1, 0);
	normal.add_data3f(0, 0, 1);
	color.add_data4f(0, 0, 1, 1);

	vertex.add_data3f(0, 1, 0);
	normal.add_data3f(0, 0, 1);
	color.add_data4f(0, 0, 1, 1);

	vertex.add_data3f(0, 0, 0);
	normal.add_data3f(0, 0, 1);
	color.add_data4f(0, 0, 1, 1);

	PT(GeomTriangles) prim;
	prim = new GeomTriangles(Geom::UH_static);

	PT(Geom) geom;
	geom = new Geom(vdata);
	PT(GeomNode) node;
	node = new GeomNode("gnode");

	NodePath nodePath = window->get_render().attach_new_node(node);

	//do the main loop, equal to run() in python  
	//close the window framework  
	return (0); 

In a Release Build this code does crash while in a debug build it doesn’t but it also does not display any triangles. Any ideas what is wrong with it ?

here the crash and callstack :slight_smile:


Nobody knows if this is broken or if iI do something wrong ?

Did you remember to remove NDEBUG from your project defines?

Also, remember that you simply cannot build a project in debug build, unless you are running with your own custom-built debug Panda as well. So you shouldn’t even try debug mode. :slight_smile:


hi yeah I have built my own debug build and it all works fine, just when I try build my custom geometry stuff it don’t work.

I have removed now NDEBUG from the release(forgot to do that in my release build). This doesn’t crash anymore, but I still don’t see any triangle :frowning:

Can you tell me if I am doing something wrong there ?

Scratch that, it works, the triangle was just really really small so I couldnt see it eyerolls

Hi Chrys,

here we go: … 6465#66465