Page 1 of 1

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

Posted: Wed Jan 05, 2011 11:37 pm
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();

Posted: Wed Jan 05, 2011 11:41 pm
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)

Posted: Wed Jan 05, 2011 11:50 pm
by macron12388
The tutorials explain how to do this.

Posted: Thu Jan 06, 2011 12:17 am
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

Posted: Thu Jan 06, 2011 12:22 am
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.

Posted: Thu Jan 06, 2011 5:16 am
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.

Posted: Thu Jan 06, 2011 9:26 am
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.