thanks Alex, I didnt know it was faster with 0-255. Considering Nathan's argument "most of the color system's I've ever encountered have used 0-255 for rgb values" and your benchmarks, I am convinced that 0-255 is a best convention.
On 26 mar, 19:50, "Alex Holkner" <[EMAIL PROTECTED]> wrote: > On 3/27/08, Thomas Woelz <[EMAIL PROTECTED]> wrote: > > > > > Responding Nathan, > > pyglet 1.1 uses 0-255 colors for instance in the new text module (like > > text.Label) > > I also prefer reading 0-1 colors so I am still using 0-1 and using a > > conversion function: > > def to_rgb(a_gl_color): > > return tuple([int(x * 255) for x in a_gl_color]) > > Maybe thats not a good idea, since it involves 2 conversions, since > > pyglet will probably have to convert it back to float for OpenGL to > > draw it right? > > The graphics module, like OpenGL, allows colors to be set with any > data type (0-1, 0-255, 0-65536, etc, ..). Internally, all current > video drivers use the 0-255 range. To convert to this from a Python > 0-1 float requires first a double->float conversion (by ctypes, as > Python uses doubles internally), followed by a float->int > scale+conversion (by the video driver). > > Seeing as the choice to use 0-1 seemed fairly arbitrary to me (only > glClearColor enforces it in OpenGL, from memory), the text and sprite > modules (which use pyglet.graphics for rendering) were designed to use > the most efficient format. My benchmarks showed that there was a > small but measurable difference. > > Alex. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
