
#ifndef _LODESTONE_H_
#define _LODESTONE_H_

/* gl.h has to be loaded before this header. As many systems have different
   conventions how to do that, it is not done here */

#ifdef __cplusplus
extern "C" {
#endif

/* Types */

typedef void *lsNode;
typedef void *lsGroup;
typedef void *lsGeometry;
typedef void *lsStateSet;
typedef void *lsTexture;
typedef void *lsLightSource;
typedef void *lsTransformation;

/* Version Info */

#define LS_MAJOR_VERSION 0
#define LS_MINOR_VERSION 1

/* Interface Structure */

typedef struct lsInterface
{    
    /* General Interface Access */
    
    int (*getMajorVersion)(void);
    int (*getMinorVersion)(void);
    
    int (*hasExtension)(const char *name);
    void *(*getExtensionFunction)(const char *name);
  
  
    /* File Handling */
    
    char *(*findFile)(const char *name);
    
    
    /* General Node Functions */
    
    void (*setName)(lsNode node, const char *name);
    
    
    /* Group Functions */
    
    lsGroup (*createGroup)(void);
    void (*addChild)(lsGroup group, lsNode node);
 
    
    /* Geometry Functions */
    
    lsGeometry (*createGeometry)(void);

    void (*setVertexCount)(lsGeometry geo, int n);
    void (*setVertices)(lsGeometry geo, GLfloat *v);
    void (*addVertex)(lsGeometry geo, GLfloat *v);

    void (*setNormalCount)(lsGeometry geo, int n);
    void (*setNormals)(lsGeometry geo, GLfloat *v);
    void (*addNormal)(lsGeometry geo, GLfloat *v);

    void (*setColorCount)(lsGeometry geo, int n);
    void (*setColors)(lsGeometry geo, GLfloat *v);
    void (*addColor)(lsGeometry geo, GLfloat *v);

    void (*setTexCoordCount)(lsGeometry geo, int n);
    void (*setTexCoords)(lsGeometry geo, GLfloat *);
    void (*addTexCoord)(lsGeometry geo, GLfloat *v);
 
    void (*addFace)(lsGeometry geo, GLenum type, int n, GLuint *indices);
    
    void (*closeGeometry)(lsStateSet set);
 
    
    /* State Set Functions */
    
    lsStateSet (*createStateSet)(void);
    
    void (*openStateSet)(lsStateSet set);
    
    void (*stateEnable)(lsStateSet set, GLenum value);
    void (*stateMaterialfv)(lsStateSet set, GLenum face, GLenum pname, 
                          GLfloat *values);
    void (*stateMaterialf)(lsStateSet set, GLenum face, GLenum pname, 
                           GLfloat value);
    void (*stateColorMaterial)(lsStateSet set, GLenum face, GLenum value);
    void (*statePolygonOffset)(lsStateSet set, GLfloat factor, GLfloat bias);
    void (*statePolygonMode)(lsStateSet set, GLenum face, GLenum value);
    void (*stateCullFace)(lsStateSet set, GLenum face);
    void (*stateSetTexture)(lsStateSet set, lsTexture tex);

    void (*closeStateSet)(lsStateSet set);

    void (*activateStateSet)(lsStateSet set);

    
    /* Texture Functions */
    
    lsTexture (*createTexture)(void);
    
    void (*texSetImage)(lsTexture tex, const char *filename);
    void (*texParameterf)(lsTexture tex, GLenum pname, GLfloat value);
    void (*texEnvf)(lsTexture tex, GLenum pname, GLfloat value);
    void (*texEnvfv)(lsTexture tex, GLenum pname, GLfloat *values);
    void (*texGenf)(lsTexture tex, GLenum coord, GLenum pname, GLfloat value);
    void (*texGenfv)(lsTexture tex, GLenum coord, GLenum pname, GLfloat *values);
    
    void (*closeTexture)(lsTexture tex);
    

    /* Transformation Functions */
    
    lsTransformation (*createTransformation)(void);
    
    void (*setTransformation)(lsTransformation trans, GLdouble *matrix);
 
    
    /* Light Source Functions */
    
    lsLightSource (*createLightSource)(void);

    void (*lightfv)(lsLightSource source, GLenum pname, GLfloat *values);
    void (*lightf) (lsLightSource source, GLenum pname, GLfloat  value);
    
    void (*closeLightSource)(lsLightSource source);
    
    
} lsInterface;

/* get the interface */

lsInterface *lsGetInterface(void);


#ifdef __cplusplus
}
#endif

#endif /* _LODESTONE_H_ */
