aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2015-12-18 07:32:05 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2015-12-18 07:32:05 -0500
commit0f379ae55e07d4e1e7904a3eb33b1c29c2177ec1 (patch)
tree7e6b0303ec43fec9c19d54dd875c0e77b3681237
parentf871cdcce267621adac4e5eb1f6705fd26462544 (diff)
Added lights
-rw-r--r--include/common.h3
-rw-r--r--main.cpp12
-rw-r--r--src/entities.cpp4
-rw-r--r--src/world.cpp1
-rw-r--r--test.frag21
5 files changed, 31 insertions, 10 deletions
diff --git a/include/common.h b/include/common.h
index 5c90222..9dcc110 100644
--- a/include/common.h
+++ b/include/common.h
@@ -14,6 +14,7 @@
#include <math.h>
#include <string>
#include <fstream>
+#include <thread>
#define GLEW_STATIC
#include <GL/glew.h>
@@ -34,7 +35,7 @@ typedef unsigned int uint;
* This flag lets the compiler know that we want to use shaders.
*/
-#define SHADERSs
+#define SHADERS
/**
* This structure contains a set of coordinates for ease of coding.
diff --git a/main.cpp b/main.cpp
index 80bbeb9..014d950 100644
--- a/main.cpp
+++ b/main.cpp
@@ -595,7 +595,6 @@ void render(){
* Call the world's draw function, drawing the player, the world, the background, and entities. Also
* draw the player's inventory if it exists.
*/
- glUseProgramObjectARB(shaderProgram);
player->near=true; // Draw the player's name
@@ -676,12 +675,20 @@ void render(){
}
glUseProgramObjectARB(0);
}
+
+ glUseProgramObjectARB(shaderProgram);
+ glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 250,250);
+ glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1,0,0);
+ glColor4f(0.0f,0.0f,0.0f,1.0f);
+ glRectf(-SCREEN_WIDTH/2,0,SCREEN_WIDTH/2,SCREEN_HEIGHT);
+ glUseProgramObjectARB(0);
+
player->inv->draw();
/*
* Here we draw a black overlay if it's been requested.
*/
- glUseProgramObjectARB(0);
+ //glUseProgramObjectARB(0);
if(fadeIntensity){
@@ -772,6 +779,7 @@ void render(){
static volatile bool objectInteracting = false;
void logic(){
+
/*
* NPCSelected is used to insure that only one NPC is made interactable with the mouse
* if, for example, multiple entities are occupying one space.
diff --git a/src/entities.cpp b/src/entities.cpp
index 6a2f4db..cd8d29e 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -83,8 +83,8 @@ Player::Player(){ //sets all of the player specific traits on object creation
subtype = 0;
health = maxHealth = 100;
speed = 1;
- //tex = new Texturec(3, "assets/player1.png", "assets/player.png", "assets/player2.png");
- tex = new Texturec(3, "assets/maybeplayer.png", "assets/maybeplayer.png", "assets/maybeplayer.png");
+ tex = new Texturec(3, "assets/player1.png", "assets/player.png", "assets/player2.png");
+ //tex = new Texturec(3, "assets/maybeplayer.png", "assets/maybeplayer.png", "assets/maybeplayer.png");
inv = new Inventory(PLAYER_INV_SIZE);
}
Player::~Player(){
diff --git a/src/world.cpp b/src/world.cpp
index 7f4d6f6..0ecf7ee 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -555,7 +555,6 @@ LOOP2:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //for the s direction
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //for the t direction
glBegin(GL_QUADS);
- std::cout<<shade<<std::endl;
for(i=is;i<(unsigned)ie-GEN_INC;i++){
cline[i].y+=(yoff-DRAW_Y_OFFSET); // Add the y offset
if(!cline[i].y){
diff --git a/test.frag b/test.frag
index 13fe6bc..18b03df 100644
--- a/test.frag
+++ b/test.frag
@@ -1,4 +1,17 @@
-#version 120
-void main(){
- gl_FragColor = glColor;
-}
+uniform vec2 lightLocation;
+uniform vec3 lightColor;
+uniform float screenHeight;
+
+float radius = 4.9;
+float minLight = .01;
+float a = .01;
+float b = 1.0 / (radius*radius * minLight);
+
+void main() {
+ float distance = length(lightLocation - gl_FragCoord.xy);
+ //float attenuation = 1.0 / (1.0 + a*distance + b*distance*distance);
+ float attenuation = clamp(1.0 - distance*distance/(radius*radius), 0.0, 1.0); attenuation *= attenuation;
+ vec4 color = vec4(attenuation, attenuation, attenuation, attenuation) * vec4(lightColor, 1);
+
+ gl_FragColor = color;
+} \ No newline at end of file