Trying to add procedural geometry and getting a blank screen

Hi guys,
I’m trying to get a couple of triangles on the screen, but all I’m getting is a blank gray window.

I think I followed the docs pretty closely. I tried scaling the node (I thought it might be too small to notice) and explicitly making the camera look at it, but with no results.

Here is my C++ code:

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

void createAndAddGeometry(WindowFramework* w)
	// Create GeomVertexData
	PT(GeomVertexData) vdata;
	vdata = new GeomVertexData("name", GeomVertexFormat::get_v3n3c4(), Geom::UH_static);
	GeomVertexWriter vw(vdata, "vertex"), cw(vdata, "color"), nw(vdata, "normal");
	vw.add_data3f(0, 0, 0);
	vw.add_data3f(1, 0, 0);
	vw.add_data3f(1, 1, 0);
	vw.add_data3f(0, 1, 0);
	cw.add_data4f(1, 0, 0, 1);
	cw.add_data4f(0, 1, 0, 1);
	cw.add_data4f(0, 0, 1, 1);
	cw.add_data4f(1, 1, 0, 1);
	nw.add_data3f(0, 0, 1);
	nw.add_data3f(0, 0, 1);
	nw.add_data3f(0, 0, 1);
	nw.add_data3f(0, 0, 1);

	// Create GeomTriangles
	PT(GeomTriangles) primitive;
	primitive = new GeomTriangles(Geom::UH_static);
	primitive -> add_vertices(0, 1, 2);
	primitive -> close_primitive();
	primitive -> add_vertices(0, 2, 3);
	primitive -> close_primitive();

	// Create Geom
	PT(Geom) g;
	g = new Geom(vdata);

	// Create GeomNode and add it to scene
	PT(GeomNode) gn;
	gn = new GeomNode("gnode");
	/// Add geom node to scene graph
	NodePath gnp = w->get_render().attach_new_node(gn);

int main(int argc, char* argv[])
	PandaFramework f;
	f.open_framework(argc, argv);
	WindowFramework* w = f.open_window();
	return 0;

What am I doing wrong here?

I suspect you need to put the new geometry someplace other than (0, 0, 0), or put the camera someplace other than (0, 0, 0).

Try to start with loading and displaying a standard model like smiley.egg or something.


Did you mean to give it an HPR of 180, 180, 180 instead of 0.5, 0.5, 0.5?

Right now, the camera is looking at your plane from the side, which means it won’t be able to see it. Just reposition your objects appropriately. Keep in mind that geometry is one-sided and thus invisible from the back until you enable set_two_sided(true).