clcontext.c

00001 #include <cl.h>
00002 
00003 /* input cannot be NULL, return -1 if material is not in context */
00004 
00005 /*
00006 GLuint clContextMaterialIndex(const CLcontext* context, 
00007                               const CLmaterial* material)
00008 {
00009   GLuint i;
00010   
00011   for (i = 0; i < context->num_materials; i++)
00012     if (context->materials[i] == material)
00013       return i;
00014 
00015   return -1;
00016 }
00017 
00018 GLuint clContextTextureIndex(const CLcontext* context, 
00019                              const CLtexture* texture)
00020 {
00021   GLuint i;
00022   
00023   for (i = 0; i < context->num_textures; i++)
00024     if (context->textures[i] == texture)
00025       return i;
00026 
00027   return -1;
00028 }
00029 
00030 GLuint clContextLightIndex(const CLcontext* context, 
00031                            const CLlight* light)
00032 {
00033   GLuint i;
00034   
00035   for (i = 0; i < context->num_lights; i++)
00036     if (context->lights[i] == light)
00037       return i;
00038 
00039   return -1;
00040 }
00041 
00042 GLuint clContextMeshIndex(const CLcontext* context, 
00043                           const CLmesh* mesh)
00044 {
00045   GLuint i;
00046   
00047   for (i = 0; i < context->num_meshes; i++)
00048     if (context->meshes[i] == mesh)
00049       return i;
00050 
00051   return -1;
00052 }
00053 
00054 GLuint clContextModelIndex(const CLcontext* context, 
00055                            const CLmodel* model)
00056 {
00057   GLuint i;
00058   
00059   for (i = 0; i < context->num_models; i++)
00060     if (context->models[i] == model)
00061       return i;
00062 
00063   return -1;
00064 }
00065 */
00066 
00067 unsigned int clContextAddMaterial(CLcontext* context, CLmaterial* material)
00068 {
00069   unsigned int i;
00070 
00071   if (!(context && material))
00072     return -1;
00073 
00074   for (i = 0; i < context->num_materials; i++)
00075     if (context->materials[i] == material)
00076       return i;
00077   
00078   context->num_materials++;
00079   context->materials = (CLmaterial**)realloc(context->materials, 
00080                                              context->num_materials 
00081                                              * sizeof(CLmaterial*));
00082   context->materials[context->num_materials - 1] = material;
00083 
00084   return context->num_materials - 1;
00085 }
00086 
00087 unsigned int clContextAddTexture(CLcontext* context, CLtexture* texture)
00088 {
00089   unsigned int i;
00090   
00091   if (!(context && texture))
00092     return -1;
00093   
00094   for (i = 0; i < context->num_textures; i++)
00095     if (context->textures[i] == texture)
00096       return i;
00097   
00098   context->num_textures++;
00099   context->textures = (CLtexture**)realloc(context->textures, 
00100                                              context->num_textures 
00101                                              * sizeof(CLtexture*));
00102   context->textures[context->num_textures - 1] = texture;
00103 
00104   return context->num_textures - 1;
00105 }
00106 
00107 unsigned int clContextAddLight(CLcontext* context, CLlight* light)
00108 {
00109   unsigned int i;
00110 
00111   if (!(context && light))
00112     return -1;
00113 
00114   for (i = 0; i < context->num_lights; i++)
00115     if (context->lights[i] == light)
00116       return i;
00117   
00118   context->num_lights++;
00119   context->lights = (CLlight**)realloc(context->lights, 
00120                                        context->num_lights 
00121                                        * sizeof(CLlight*));
00122   context->lights[context->num_lights - 1] = light;
00123 
00124   return context->num_lights - 1;
00125 }
00126 
00127 unsigned int clContextAddModel(CLcontext* context, CLmodel* model)
00128 {
00129   unsigned int i;
00130 
00131   if (!(context && model))
00132     return -1;
00133 
00134   for (i = 0; i < context->num_models; i++)
00135     if (context->models[i] == model)
00136       return i;
00137   
00138   context->num_models++;
00139   context->models = (CLmodel**)realloc(context->models, 
00140                                        context->num_models 
00141                                        * sizeof(CLmodel*));
00142   context->models[context->num_models - 1] = model;
00143 
00144   model->context = context;
00145 
00146   for (i = 0 ; i < model->num_meshes ; i++)
00147   {
00148       model->meshes[i]->context = context;
00149   }
00150 
00151   return context->num_models - 1;
00152 }
00153 
00154 /*
00155 GLboolean clContextRemoveMaterial(CLcontext* context, GLuint index)
00156 {
00157   return GL_TRUE;
00158 }
00159 
00160 GLboolean clContextRemoveTexture(CLcontext* context, GLuint index)
00161 {
00162   return GL_TRUE;
00163 }
00164 
00165 GLboolean clContextRemoveLight(CLcontext* context, GLuint index)
00166 {
00167   return GL_TRUE;
00168 }
00169 
00170 GLboolean clContextRemoveMesh(CLcontext* context, GLuint index)
00171 {
00172   return GL_TRUE;
00173 }
00174 
00175 GLboolean clContextRemoveModel(CLcontext* context, GLuint index)
00176 {
00177   return GL_TRUE;
00178 }
00179 */

Generated on Thu Dec 27 13:53:41 2007 for CL by  doxygen 1.4.6