Imported Upstream version 2.81
[platform/upstream/libbullet.git] / Extras / sph / common / gl_helper.h
1 /*
2   FLUIDS v.1 - SPH Fluid Simulator for CPU and GPU
3   Copyright (C) 2009. Rama Hoetzlein, http://www.rchoetzlein.com
4
5   ZLib license
6   This software is provided 'as-is', without any express or implied
7   warranty.  In no event will the authors be held liable for any damages
8   arising from the use of this software.
9
10   Permission is granted to anyone to use this software for any purpose,
11   including commercial applications, and to alter it and redistribute it
12   freely, subject to the following restrictions:
13
14   1. The origin of this software must not be misrepresented; you must not
15      claim that you wrote the original software. If you use this software
16      in a product, an acknowledgment in the product documentation would be
17      appreciated but is not required.
18   2. Altered source versions must be plainly marked as such, and must not be
19      misrepresented as being the original software.
20   3. This notice may not be removed or altered from any source distribution.
21 */
22
23 #ifndef GL_HELPER
24         #define GL_HELPER
25
26         #include "common_defs.h"
27
28         #include <glee.h>
29         #include <gl/glext.h>   
30
31         #ifdef _MSC_VER                                         // Windows
32                 #ifdef USE_SHADOWS
33                         #include <gl/glee.h>
34                         #include <gl/glext.h>   
35                 #endif                  
36                 #include <gl/glut.h>
37         #else                                                           // Linux
38                 #ifdef USE_SHADOWS
39                         #include "GLee.h"
40                 #endif
41                 #include <GL/glext.h>   
42                 #include <GL/glut.h>    
43         #endif
44         
45         #include "image.h"
46         #include "mtime.h"
47
48         extern void checkOpenGL ();
49         extern void drawText ( int x, int y, char* msg);
50         extern void drawGrid ();
51         extern void measureFPS ();
52
53         extern mint::Time       tm_last;
54         extern int                      tm_cnt;
55         extern float            tm_fps;
56         
57
58         extern void disableShadows ();
59         extern void checkFrameBuffers ();
60
61         extern GLuint glSphere;
62         extern float  glRadius;
63         extern void setSphereRadius ( float f );
64         extern void drawSphere ();
65
66         #ifdef USE_SHADOWS
67                 extern void setShadowLight ( float fx, float fy, float fz, float tx, float ty, float tz, float fov );
68                 extern void setShadowLightColor ( float dr, float dg, float db, float sr, float sg, float sb );
69                 
70                 extern void createFrameBuffer ();
71                 extern void createShadowTextures ();
72                 extern void computeLightMatrix ( int n, int tx, int ty );
73                 extern void renderDepthMap_Clear ( float wx, float wy );
74                 extern void renderDepthMap_FrameBuffer ( int n, float wx, float wy );
75                 extern void renderShadowStage ( int n, float* vmat );
76                 extern void renderShadows ( float* vmat );
77                 extern void drawScene ( float* view_mat, bool bShaders );               // provided by user
78
79                 extern float light_proj[16];
80                 extern float light_x, light_y, light_z;
81                 extern float light_tox, light_toy, light_toz;
82                 extern float light_mfov;
83
84                 extern GLuint           shadow1_id;
85                 extern GLuint           shadow2_id;
86         #endif
87
88
89 #endif