1 /*
2  *------------------------------------------------------------
3  * Copyright(c) 2009-2010 by Digital Media Professionals Inc.
4  * All rights reserved.
5  *------------------------------------------------------------
6  * This source code is the confidential and proprietary
7  * of Digital Media Professionals Inc.
8  *------------------------------------------------------------
9  */
10 #ifndef DMP_GAS_H__
11 #define DMP_GAS_H__
12 
13 #include <nn/gx.h>
14 
15 /*
16  * Definitions
17  */
18 
19 #define APP_NAME            "GasCessna"
20 
21 /* accumulation buffer should have same size as display buffer */
22 #define GAS_ACC_WIDTH       (nn::gx::DISPLAY0_WIDTH)
23 #define GAS_ACC_HEIGHT      (nn::gx::DISPLAY0_HEIGHT)
24 /* texture should have powered by 2 size which is bigger than DISPLAY size */
25 #define GAS_TEX_WIDTH       (512)
26 #define GAS_TEX_HEIGHT      (512)
27 
28 /* Default buffer ID */
29 #define DISPLAY_BUFFER      (0)     /* default frame buffer */
30 
31 /* Particle pattern */
32 #define PARTICLE_PATTERNS   (1)
33 #define PARTICLE_FILES       "rom:/resources/ptcl0.tga"
34 
35 
36 struct gas_data {
37     /* point sprite*/
38     GLuint          gasgeo_center_ID;               /* used in accumulation pass. Point sprite center*/
39     GLuint          gasgeo_density_ID               /* used in accumulation pass. Point sprite color (i.e. density in case of gas)*/;
40     GLuint          gasgeo_size_ID;                 /* used in accumulation pass. Point sprite size */
41     GLuint          gasgeo_ind_ID;                  /* used in accumulation pass. unused____????????????????? */
42 
43     GLuint          pattern[PARTICLE_PATTERNS]; /* Texture ID applied to each particle */
44     GLsizei         gasgeo_size;                /* Number of elements (triangles) defining the gaseous object*/
45     GLfloat         _dela_z;                    /* used in accumulation pass, to control final alpha blending*/
46 
47     GLint           _autoAcc;                   /* used in post synthesis pass */
48     float           _densMax;                   /* used in post synthesis pass. Shading control*/
49     GLfloat         _lightDirX;                 /* used in post synthesis pass. Shading control */
50     GLfloat         _lightDirY;                 /* used in post synthesis pass. Shading control */
51     GLfloat         _LightXY[4];                /* used in post synthesis pass. Shading control */
52     GLfloat         _LightZ[4];                 /* used in post synthesis pass. Shading control */
53     GLuint          FogLut_ID;                  /* used in post synthesis pass. Look up table ID */
54     GLuint          CollectionLUT_ID;           /* used in post synthesis pass. Texture collection ID */
55     GLuint          gasTransfert_ID[3];         /* used in post synthesis pass. Lookup table ID for gas color look up table */
56     float           RR[16],GG[16],BB[16];       /* used in post synthesis pass. Lookup table for gas color content */
57     float           fogTable[256];              /* used in post synthesis pass. Fog look up table for density to alpha conversion*/
58     GLenum          shadingDensitySrc;          /* used in post synthesis pass. Density selection for shading input*/
59     GLenum          colorLutInput;              /* used in post synthesis pass. Input selection for the gas color look up*/
60     /* Gas geometry definition / simple quad (post synthesis pass) */
61     GLuint          quad_index_ID;              /* used in post synthesis pass. Vertex Index buffer ID */
62     GLuint          quad_vertBuf_ID;            /* used in post synthesis pass. Vertex position buffer ID */
63     GLuint          quad_texBuf_ID;             /* used in post synthesis pass. Vertex Texture coordinates buffer ID */
64     GLuint          quad_colBuf_ID;             /* used in post synthesis pass. Vertex color buffer ID */
65 
66 };
67 
68 /*
69  * Function declarations
70  */
71 
72 /* buffer initialization */
73 void GasInitialize(GLuint depthBuf);
74 
75 /* gaseous object data structure default initialization */
76 void DefaultGasObject(struct gas_data *gas,float *gasColorTable);
77 
78 /* utility function to update the gas color lookup table */
79 void SetGasColorTable(struct gas_data *gas,float *gasColorTable);
80 
81 void SetGasAccumulationUniform(void);
82 void SetGasShadingUniform(void);
83 
84 /* accumulation pass */
85 void GasAccumulation();
86 
87 /* shading pass */
88 void GasShading(void);
89 
90 #endif /* DMP_GAS_H__ */
91