diff options
Diffstat (limited to 'linden/indra/llrender/llglslshader.h')
-rw-r--r-- | linden/indra/llrender/llglslshader.h | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/linden/indra/llrender/llglslshader.h b/linden/indra/llrender/llglslshader.h new file mode 100644 index 0000000..0fa8e41 --- /dev/null +++ b/linden/indra/llrender/llglslshader.h | |||
@@ -0,0 +1,139 @@ | |||
1 | /** | ||
2 | * @file llglslshader.h | ||
3 | * @brief GLSL shader wrappers | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | ||
22 | * By copying, modifying or distributing this software, you acknowledge | ||
23 | * that you have read and understood your obligations described above, | ||
24 | * and agree to abide by those obligations. | ||
25 | * | ||
26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
28 | * COMPLETENESS OR PERFORMANCE. | ||
29 | * $/LicenseInfo$ | ||
30 | */ | ||
31 | |||
32 | #ifndef LL_LLGLSLSHADER_H | ||
33 | #define LL_LLGLSLSHADER_H | ||
34 | |||
35 | #include "llgl.h" | ||
36 | |||
37 | class LLShaderFeatures | ||
38 | { | ||
39 | public: | ||
40 | bool calculatesLighting; | ||
41 | bool calculatesAtmospherics; | ||
42 | bool hasLighting; // implies no transport (it's possible to have neither though) | ||
43 | bool isShiny; | ||
44 | bool isFullbright; // implies no lighting | ||
45 | bool isSpecular; | ||
46 | bool hasWaterFog; // implies no gamma | ||
47 | bool hasTransport; // implies no lighting (it's possible to have neither though) | ||
48 | bool hasSkinning; | ||
49 | bool hasAtmospherics; | ||
50 | bool hasGamma; | ||
51 | |||
52 | // char numLights; | ||
53 | |||
54 | LLShaderFeatures(); | ||
55 | }; | ||
56 | |||
57 | class LLGLSLShader | ||
58 | { | ||
59 | public: | ||
60 | |||
61 | enum | ||
62 | { | ||
63 | SG_DEFAULT = 0, | ||
64 | SG_SKY, | ||
65 | SG_WATER | ||
66 | }; | ||
67 | |||
68 | LLGLSLShader(); | ||
69 | |||
70 | void unload(); | ||
71 | BOOL createShader(std::vector<std::string> * attributes, | ||
72 | std::vector<std::string> * uniforms); | ||
73 | BOOL attachObject(std::string object); | ||
74 | void attachObject(GLhandleARB object); | ||
75 | void attachObjects(GLhandleARB* objects = NULL, S32 count = 0); | ||
76 | BOOL mapAttributes(const std::vector<std::string> * attributes); | ||
77 | BOOL mapUniforms(const std::vector<std::string> * uniforms); | ||
78 | void mapUniform(GLint index, const std::vector<std::string> * uniforms); | ||
79 | void uniform1f(U32 index, GLfloat v); | ||
80 | void uniform2f(U32 index, GLfloat x, GLfloat y); | ||
81 | void uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z); | ||
82 | void uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); | ||
83 | void uniform1fv(U32 index, U32 count, const GLfloat* v); | ||
84 | void uniform2fv(U32 index, U32 count, const GLfloat* v); | ||
85 | void uniform3fv(U32 index, U32 count, const GLfloat* v); | ||
86 | void uniform4fv(U32 index, U32 count, const GLfloat* v); | ||
87 | void uniform1f(const std::string& uniform, GLfloat v); | ||
88 | void uniform2f(const std::string& uniform, GLfloat x, GLfloat y); | ||
89 | void uniform3f(const std::string& uniform, GLfloat x, GLfloat y, GLfloat z); | ||
90 | void uniform4f(const std::string& uniform, GLfloat x, GLfloat y, GLfloat z, GLfloat w); | ||
91 | void uniform1fv(const std::string& uniform, U32 count, const GLfloat* v); | ||
92 | void uniform2fv(const std::string& uniform, U32 count, const GLfloat* v); | ||
93 | void uniform3fv(const std::string& uniform, U32 count, const GLfloat* v); | ||
94 | void uniform4fv(const std::string& uniform, U32 count, const GLfloat* v); | ||
95 | void uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); | ||
96 | void uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); | ||
97 | void uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); | ||
98 | void uniformMatrix2fv(const std::string& uniform, U32 count, GLboolean transpose, const GLfloat *v); | ||
99 | void uniformMatrix3fv(const std::string& uniform, U32 count, GLboolean transpose, const GLfloat *v); | ||
100 | void uniformMatrix4fv(const std::string& uniform, U32 count, GLboolean transpose, const GLfloat *v); | ||
101 | |||
102 | void vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); | ||
103 | void vertexAttrib4fv(U32 index, GLfloat* v); | ||
104 | |||
105 | GLint getUniformLocation(const std::string& uniform); | ||
106 | |||
107 | GLint mapUniformTextureChannel(GLint location, GLenum type); | ||
108 | |||
109 | |||
110 | //enable/disable texture channel for specified uniform | ||
111 | //if given texture uniform is active in the shader, | ||
112 | //the corresponding channel will be active upon return | ||
113 | //returns channel texture is enabled in from [0-MAX) | ||
114 | S32 enableTexture(S32 uniform, S32 mode = GL_TEXTURE_2D); | ||
115 | S32 disableTexture(S32 uniform, S32 mode = GL_TEXTURE_2D); | ||
116 | |||
117 | BOOL link(BOOL suppress_errors = FALSE); | ||
118 | void bind(); | ||
119 | void unbind(); | ||
120 | |||
121 | // Unbinds any previously bound shader by explicitly binding no shader. | ||
122 | static void bindNoShader(void); | ||
123 | |||
124 | GLhandleARB mProgramObject; | ||
125 | std::vector<GLint> mAttribute; //lookup table of attribute enum to attribute channel | ||
126 | std::vector<GLint> mUniform; //lookup table of uniform enum to uniform location | ||
127 | std::map<std::string, GLint> mUniformMap; //lookup map of uniform name to uniform location | ||
128 | std::map<GLint, LLVector4> mValue; //lookup map of uniform location to last known value | ||
129 | std::vector<GLint> mTexture; | ||
130 | S32 mActiveTextureChannels; | ||
131 | S32 mShaderLevel; | ||
132 | S32 mShaderGroup; | ||
133 | BOOL mUniformsDirty; | ||
134 | LLShaderFeatures mFeatures; | ||
135 | std::vector< std::pair< std::string, GLenum > > mShaderFiles; | ||
136 | std::string mName; | ||
137 | }; | ||
138 | |||
139 | #endif | ||