If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Sorting objects by color (material)

Will I have improvements in drawing with OpenGL, if I would sort objects by their colors (materials) and call functions glColor, glMaterial when the color is changed? How fast glColor, glMaterial functions, what is inside of them?

Re: Sorting objects by color (material)

The question of how fast glColor and glMaterial are leaves out the question of manipulating textures, and doesn't account for the fact that every implementation of OpenGL could have very different performance characteristics.

The order in which a sorting order provides performance increases does depend on the OpenGL implementation at hand. For example, there's a popular OpenGLES implementation that doesn't benefit from sorting by Z order, but does benefit by sorting by texture - and also requires that you order drawing by opaque objects first, then transparent objects last - where the transparent objects ARE sorted in Z order.

Other OpenGL implementations may be much better served with objects sorted in Z order.

However, generally, when a particular OpenGL implementation does perform best when ordered by texture and material, its not because of the function calls themselves, but because of the way the underlying hardware functions when performing that work.

In some implementations, the OpenGL calls you're making are not executed at the time you make the call (they're processed by the hardware from a queue). In some cases the OpenGL function is implemented like a call to a runtime library, or an OS function - it's executed by the CPU when you make the call. In other implementations, the call may be implemented by the GPU hardware.

In other words, without context, there's no simple answer to your question.

If my post was interesting or helpful, perhaps you would consider clicking the 'rate this post' to let me know (middle icon of the group in the upper right of the post).

Re: Sorting objects by color (material)

I think what you are saying is that you're writing an application that uses OpenGL as is available when you compiling on Windows, according to the MS documentation of OpenGL as found on MSDN.

Every graphics card and it's driver will update that to 'adapt' to that graphics card, it's feature set - and the implementation that you end up using could be for an NVidia implementation.

That is, if I inquire about OpenGL version and features on any number of Windows based computers, I'll get different answers depending on the graphics card installed.

However, sorting by texture isn't a bad choice. Materials and textures aren't the same thing specifically, though sometimes the words are used interchangeably. A texture is, specifically, a bitmap image used to 'apply' to an object, whereas a material deals with the color in various categories, properties of shininess, etc.

In most cases it is the texture, and the implications of selecting a texture into texture units for processing, that has a performance impact relative to sorting (so the changes to the texture units are minimized during rendering).

There is much less impact on speed by simply sorting by object color.

If my post was interesting or helpful, perhaps you would consider clicking the 'rate this post' to let me know (middle icon of the group in the upper right of the post).

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.