How do I draw a triangle in irrlicht like I do in opengl?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
openglman
Posts: 15
Joined: Wed Jan 05, 2011 11:34 pm

How do I draw a triangle in irrlicht like I do in opengl?

Post by openglman »

This is how I draw a triangle in opengl, How do I do this same operation using irrlicht? I can't figure it out. It seems like it is easier to load a model then to draw a triangle? lol

Thank you in advance!

Code: Select all

glBegin(GL_TRIANGLES);						// Drawing Using Triangles
		glVertex3f( 0.0f, 1.0f, 0.0f);				// Top
		glVertex3f(-1.0f,-1.0f, 0.0f);				// Bottom Left
		glVertex3f( 1.0f,-1.0f, 0.0f);				// Bottom Right
	glEnd();
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

well, that's kind of the point of a rendering engine, not having to build geometry manually
So yes, it's actually easier to load a model instead of manually defining vertices/indices to draw a triangle, as it should be ;) (not that it's impossible of course)
macron12388
Posts: 126
Joined: Wed Sep 29, 2010 8:23 pm

Post by macron12388 »

The tutorials explain how to do this.
openglman
Posts: 15
Joined: Wed Jan 05, 2011 11:34 pm

Post by openglman »

macron12388 wrote:The tutorials explain how to do this.
Ok so is it the custom scene node tutorial that I should use to draw my own primitives?

Thanks
macron12388
Posts: 126
Joined: Wed Sep 29, 2010 8:23 pm

Post by macron12388 »

openglman wrote:
macron12388 wrote:The tutorials explain how to do this.
Ok so is it the custom scene node tutorial that I should use to draw my own primitives?

Thanks
Pretty much. There might be some more obscure, closer to the OpenGL backend methods, but you should pass meshes to the scene manager as an ISceneNode derived object so it can do things like occluding, octree, and other rendering optimizations with it.
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

If you're looking ONLY to draw the triangles and don't care about the scene node, look in the render function for the Custom Scene Node tutorial.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

For mesh creation we also have example 23 (or somewhere near), which really creates a mesh instead of passing the raw data as in the custom scene node. This will make the optimization possibilities much simpler.
For single triangles you can also use draw3DTriangle, but that will become very slow with just a few triangles already.
Post Reply