aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.cpp54
-rw-r--r--test.frag12
2 files changed, 33 insertions, 33 deletions
diff --git a/main.cpp b/main.cpp
index 79c7250..c363875 100644
--- a/main.cpp
+++ b/main.cpp
@@ -341,43 +341,41 @@ int main(/*int argc, char *argv[]*/){
* 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);
diff --git a/test.frag b/test.frag
index 5c9054e..07b4a8a 100644
--- a/test.frag
+++ b/test.frag
@@ -2,7 +2,7 @@
uniform sampler2D sampler;
uniform int numLight;
-uniform vec2 lightLocation[1024];
+uniform vec2 lightLocation[64];
uniform vec3 lightColor;
uniform float amb;
@@ -10,20 +10,22 @@ float b = .0005;
float minLight = .05;
float radius = sqrt(1.0 / (b * minLight));
+//float radius = b*minlight;
+
void main(){
- vec4 color = vec4(0.0f,0.0f,0.0f,0.0f);
+ vec4 color = vec4(0.0,0.0,0.0,0.0);
for(int i = 0; i < numLight; i++){
vec2 loc = lightLocation[i];
float dist = length(loc - gl_FragCoord.xy);
//float attenuation=1.0/(1.0+0.01*dist+0.00000000001*dist*dist);
float attenuation = clamp(1.0 - dist*dist/(radius*radius), 0.0, 1.0); attenuation *= attenuation;
- color += vec4(attenuation, attenuation, attenuation, 1.0f) * vec4(lightColor, 1.0f);
+ color += vec4(attenuation, attenuation, attenuation, 1.0) * vec4(lightColor, 1.0);
}
vec2 coords = gl_TexCoord[0].st;
vec4 tex = texture2D(sampler, coords);
- color += vec4(amb,amb,amb,1.0f+amb);
+ color += vec4(amb,amb,amb,1.0+amb);
gl_FragColor = tex * vec4(color)*tex.a;
}
@@ -34,4 +36,4 @@ void main(){
.00008 500
.00002 1000
.00005 2000
-*/
+*/ \ No newline at end of file