سؤال

Now and then the phrase "sort by texture" appears in OpenGL-related posts. While I see how this sort could be implemented for a single texture bound to a certain texture unit, I am not certain how this might be done for multiple textures bound to arbitrary texture units. Perhaps by capturing the state of the TUs into an integer id, then use the id as an index into either an array or a map? How to best do the "sort by texture" in an OpenGL application?

هل كانت مفيدة؟

المحلول

Treating texture units as levels in a tree and do a sorted depth-first traversal is a good starting point.

Ideally what you want to do is minimize the number of texture unit state changes which may mean that the same texture gets selected and deselected multiple times in the optimal case. You suggestion of sorting the tuples of texture IDs is a good idea as well.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top