Coconut Data Framework  beta
CNColorTable.h
Go to the documentation of this file.
00001 
00008 #import "CNColor.h"
00009 
00014 void
00015 CNSetupColorTable(struct CNResource * resource) ;
00016 
00027 const struct CNColor *
00028 CNAllocateColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) ;
00029 
00035 static inline const struct CNColor *
00036 CNBasicIdToColor(CNBasicColorId colorid)
00037 {
00038         extern const struct CNColor * CNSharedBasicColorTable[] ;
00039         return CNSharedBasicColorTable[colorid] ;
00040 }
00041 
00047 static inline GLfloat
00048 CNColor16PartToColorPart(unsigned int src)
00049 {
00050         GLfloat result ;
00051         if(src > 0){
00052                 result = (src + 1.0) / 16.0 ;
00053         } else {
00054                 result = 0.0 ;
00055         }
00056         return result ;
00057 }
00058 
00064 static inline const struct CNColor *
00065 CNColor16ToColor(CNColor16 src)
00066 {
00067         unsigned int s0 = (src >> 12) & 0xf ;
00068         unsigned int s1 = (src >>  8) & 0xf ;
00069         unsigned int s2 = (src >>  4) & 0xf ;
00070         unsigned int s3 = (src      ) & 0xf ;
00071         GLfloat          d0 = CNColor16PartToColorPart(s0) ;
00072         GLfloat          d1 = CNColor16PartToColorPart(s1) ;
00073         GLfloat          d2 = CNColor16PartToColorPart(s2) ;
00074         GLfloat          d3 = CNColor16PartToColorPart(s3) ;
00075         return CNAllocateColor(d0, d1, d2, d3) ;
00076 }
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085