Sorting objects by color (material)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Sorting objects by color (material)

Hybrid View

  1. #1
    Join Date
    Feb 2009
    Posts
    12

    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?

  2. #2
    Join Date
    Nov 2006
    Posts
    1,611

    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).

  3. #3
    Join Date
    Feb 2009
    Posts
    12

    Re: Sorting objects by color (material)

    We use standard OpenGL from MicroSoft

  4. #4
    Join Date
    Nov 2006
    Posts
    1,611

    Re: Sorting objects by color (material)

    Well, actually, you probably don't.

    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).

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center