Advertisement Jump to content


This topic is now archived and is closed to further replies.


a good rendering loop

This topic is 5460 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I started rewriting my renderer in hopes of making it substantially faster. I have found that I may be looping through the vertices and triangles of each mesh too many times. In my old loop, I went through the mesh once per light for lighting, 3-4 times per light for stencil shadow volumes, once per light for bump map coords, and another time to finally render it. That's obviously enough looping to kill any performance I might have had. So, I came up with this psuedo code loop, and was wondering if some of you guys could critique it, or what-not (For clarity: My renderer will render batches of meshes per material by using its own pre-allocated vertex array):
for( each draw_pack) //a draw_pack contains info like depth testing and blending functions


	for( each material )//a material contains texture info

		SetupMaterial(); //binds current textures

		for( each visible mesh )
			for(each visible triangle)
				for(each light)

			for(each vertice)

	ClearLists();				//doesn't iterate through list, just sets # used to 0



Anyway, i may have forgotten some things, but i was just hoping some of you could critique the basic loop. Thankyou for any help! ----------------------------- I never chew my cabbage twice [edited by - odiousangel on February 6, 2004 4:04:07 PM] [edited by - odiousangel on February 6, 2004 4:05:47 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!