/afs/csl.tjhsst.edu/students/2007/kkassing/work/liballoy/alloy.h

Go to the documentation of this file.
00001 #ifndef __ALLOY_H__
00002 #define __ALLOY_H__
00003 
00004 #include <GL/gl.h>
00005 #include <GL/glu.h>
00006 
00007 #include <stdio.h>
00008 #include "libmala/vector.h"
00009 
00010 #include "image.h"
00011 
00012 typedef enum                    // these should be flags instead!
00013 {
00014         ALLOY_NONE=0,
00015         ALLOY_TEX1D,
00016         ALLOY_TEX2D,
00017         ALLOY_TEX3D,
00018         ALLOY_SPHEREMAP,
00019         ALLOY_CUBEMAP
00020 } alloy_textype;
00021 
00022 typedef struct alloy_lightprops
00023 {
00024         vec4 specular;
00025         vec4 ambient;
00026         vec4 diffuse;
00027         vec4 emission;
00028         float shininess;        // specular exponent
00029 } alloy_lightprops_t;
00030 
00031 typedef struct alloy_shader
00032 {
00033         char* name;
00034         int shader_prog;
00035 } alloy_shader_t;
00036 
00037 typedef struct alloy_texture
00038 {
00039         char* filename;
00040         unsigned int id;
00041         alloy_textype type;
00042         int width;
00043         int height;
00044 } alloy_texture_t;
00045 
00046 typedef struct alloy_blend
00047 {
00048         // blend mode (on top of existing layers)
00049         int blend_src;  
00050                 // GL_ZERO, GL_ONE, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR
00051                 // GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA
00052                 // GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA_SATURATE
00053         int blend_dest;
00054                 // GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR
00055                 // GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA
00056                 // GL_ONE_MINUS_DST_ALPHA
00057         
00058         // multitexture mode
00059         int combine[2];
00060                 // combine_[rgb,alpha]_arb
00061                 // replace,modulate,add,add_signed_arb,interpolate_arb,subtract_arb
00062         int multi_op[3][2];
00063                 // operand[0,1,2]_rgb_arb
00064                 // src_color,one_minus_src_color,src_alpha,one_minus_src_alpha
00065                 //  OR
00066                 // operand[0,1,2]_alpha_rgb
00067                 // src_alpha,one_minus_src_alpha
00068         int multi_src[3][2];
00069                 // source[0,1,2]_[rgb,alpha]_arb
00070                 // texture,constant_arb,primary_color_arb,previous_arb
00071         
00072 
00073         /* There should be one interface for blending options
00074          * even though it could be multipass rendering or
00075          * multitexturing behind the scenes. So we need to 
00076          * know blend source and dest (limit to adjacent layers
00077          * and multipass capabilities) */
00078 } alloy_blend_t;
00079 
00080 typedef struct alloy_material
00081 {
00082         alloy_shader_t* shader;                 // most expensive state change
00083         alloy_lightprops_t* lightprops;         // second most expensive
00084         alloy_texture_t** textures;             // third most expensive (are all texture units equally expensive to change?)
00085         alloy_blend_t* blends;
00086         int num_textures;
00087 } alloy_material_t;
00088 
00089 void alloy_init();                              // check shader, multitexturing capabilities
00090 void alloy_shutdown();
00091 void alloy_bind_texture(alloy_texture_t*);
00092 void alloy_unbind_texture(alloy_texture_t*);
00093 void alloy_bind_material(alloy_material_t*);
00094 
00095 void alloy_load_texture(const char*,alloy_texture_t*); // flags!
00096 unsigned int alloy_build_mipmaps_2d(alloy_image_t);
00097 
00098 void alloy_write_material(FILE*,alloy_material_t*);
00099 void alloy_read_material(FILE*,alloy_material_t*);
00100 
00101 //alloy_material_t* alloy_get_material(const char*);    // what format?
00102 alloy_texture_t* alloy_get_texture(const char*);
00103 
00104 // private
00105 void alloy_init_material(alloy_material_t*);
00106 
00107 
00108 #define _glActiveTexture glActiveTextureARB
00109 #define _GL_TEXTURE0 GL_TEXTURE0_ARB
00110 #define _GL_COMBINE GL_COMBINE_ARB
00111 #define _glUseProgram sin
00112 #define _GL_TEXTURE_CUBE_MAP GL_TEXTURE_CUBE_MAP_EXT
00113 #define _GL_REFLECTION_MAP GL_REFLECTION_MAP_EXT
00114 
00115 #endif

Generated on Fri Jun 1 09:08:55 2007 for Antigone by  doxygen 1.4.7