* Initializes our shaders so that the game has shadows.
*/
- #ifdef SHADERS
- std::cout << "Initializing shaders!" << std::endl;
+ std::cout << "Initializing shaders!" << std::endl;
- fragShader = glCreateShader(GL_FRAGMENT_SHADER);
+ fragShader = glCreateShader(GL_FRAGMENT_SHADER);
- std::string shaderFileContents = readFile("test.frag");
- const GLchar *shaderSource = shaderFileContents.c_str();
+ std::string shaderFileContents = readFile("test.frag");
+ const GLchar *shaderSource = shaderFileContents.c_str();
- GLint bufferln = GL_FALSE;
- int logLength;
+ GLint bufferln = GL_FALSE;
+ int logLength;
- glShaderSource(fragShader, 1, &shaderSource, NULL);
- glCompileShader(fragShader);
+ glShaderSource(fragShader, 1, &shaderSource, NULL);
+ glCompileShader(fragShader);
- glGetShaderiv(fragShader, GL_COMPILE_STATUS, &bufferln);
- glGetShaderiv(fragShader, GL_INFO_LOG_LENGTH, &logLength);
- std::vector<char>fragShaderError((logLength > 1) ? logLength : 1);
- glGetShaderInfoLog(fragShader, logLength, NULL, &fragShaderError[0]);
- std::cout << &fragShaderError[0] << std::endl;
-
- if(bufferln == GL_FALSE){
- std::cout << "Error compiling shader" << std::endl;
- }
+ glGetShaderiv(fragShader, GL_COMPILE_STATUS, &bufferln);
+ glGetShaderiv(fragShader, GL_INFO_LOG_LENGTH, &logLength);
+ std::vector<char>fragShaderError((logLength > 1) ? logLength : 1);
+ glGetShaderInfoLog(fragShader, logLength, NULL, &fragShaderError[0]);
+ std::cout << &fragShaderError[0] << std::endl;
+
+ if(bufferln == GL_FALSE){
+ std::cout << "Error compiling shader" << std::endl;
+ }
- shaderProgram = glCreateProgram();
- glAttachShader(shaderProgram, fragShader);
- glLinkProgram(shaderProgram);
- glValidateProgram(shaderProgram);
+ shaderProgram = glCreateProgram();
+ glAttachShader(shaderProgram, fragShader);
+ glLinkProgram(shaderProgram);
+ glValidateProgram(shaderProgram);
- glGetProgramiv(shaderProgram, GL_LINK_STATUS, &bufferln);
- glGetProgramiv(shaderProgram, GL_INFO_LOG_LENGTH, &logLength);
- std::vector<char> programError( (logLength > 1) ? logLength : 1 );
- glGetProgramInfoLog(shaderProgram, logLength, NULL, &programError[0]);
- std::cout << &programError[0] << std::endl;
+ glGetProgramiv(shaderProgram, GL_LINK_STATUS, &bufferln);
+ glGetProgramiv(shaderProgram, GL_INFO_LOG_LENGTH, &logLength);
+ std::vector<char> programError( (logLength > 1) ? logLength : 1 );
+ glGetProgramInfoLog(shaderProgram, logLength, NULL, &programError[0]);
+ std::cout << &programError[0] << std::endl;
- #endif //SHADERS
//glEnable(GL_DEPTH_TEST); //THIS DOESN'T WORK ON LINUX
glEnable(GL_MULTISAMPLE);
uniform sampler2D sampler;\r
\r
uniform int numLight;\r
-uniform vec2 lightLocation[1024];\r
+uniform vec2 lightLocation[64];\r
uniform vec3 lightColor;\r
uniform float amb;\r
\r
float minLight = .05;\r
float radius = sqrt(1.0 / (b * minLight));\r
\r
+//float radius = b*minlight;\r
+\r
void main(){\r
- vec4 color = vec4(0.0f,0.0f,0.0f,0.0f);\r
+ vec4 color = vec4(0.0,0.0,0.0,0.0);\r
for(int i = 0; i < numLight; i++){\r
vec2 loc = lightLocation[i];\r
float dist = length(loc - gl_FragCoord.xy);\r
//float attenuation=1.0/(1.0+0.01*dist+0.00000000001*dist*dist);\r
float attenuation = clamp(1.0 - dist*dist/(radius*radius), 0.0, 1.0); attenuation *= attenuation;\r
\r
- color += vec4(attenuation, attenuation, attenuation, 1.0f) * vec4(lightColor, 1.0f);\r
+ color += vec4(attenuation, attenuation, attenuation, 1.0) * vec4(lightColor, 1.0);\r
}\r
vec2 coords = gl_TexCoord[0].st;\r
vec4 tex = texture2D(sampler, coords);\r
\r
- color += vec4(amb,amb,amb,1.0f+amb);\r
+ color += vec4(amb,amb,amb,1.0+amb);\r
gl_FragColor = tex * vec4(color)*tex.a;\r
}\r
\r
.00008 500\r
.00002 1000\r
.00005 2000\r
-*/\r
+*/
\ No newline at end of file