]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Shit
authordrumsetmonkey <abelleisle@roadrunner.com>
Thu, 17 Dec 2015 13:29:01 +0000 (08:29 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Thu, 17 Dec 2015 13:29:01 +0000 (08:29 -0500)
assets/door.png [new file with mode: 0644]
include/common.h
main.cpp
src/ui.cpp
test.frag

diff --git a/assets/door.png b/assets/door.png
new file mode 100644 (file)
index 0000000..7db551d
Binary files /dev/null and b/assets/door.png differ
index 08ec73f625cf758d2a3efa1577d22c08680b881d..5c90222f06dea94dc1ef1d181524d9d8e97e5e82 100644 (file)
@@ -70,7 +70,7 @@ typedef struct{
  * The desired width of the game window.
  */
 
-#define SCREEN_WIDTH   1024
+#define SCREEN_WIDTH   1280
 
 /**
  * The desired height of the game window.
index a9cc2fa969f484dfc37332da7ea7d4f84ee4e3a6..f7a1e8396a5c38fec7c78839fc886e57d347df4c 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -344,7 +344,7 @@ int main(/*int argc, char *argv[]*/){
 
                fragShader = glCreateShader(GL_FRAGMENT_SHADER);
 
-               std::string shaderFileContents = readFile("shader.frag");
+               std::string shaderFileContents = readFile("test.frag");
                const GLchar *shaderSource = shaderFileContents.c_str();
 
                GLint bufferln = GL_FALSE;
@@ -571,10 +571,7 @@ void render(){
        glOrtho((offset.x-SCREEN_WIDTH/2),(offset.x+SCREEN_WIDTH/2),offset.y-SCREEN_HEIGHT/2,offset.y+SCREEN_HEIGHT/2,-1,1);
        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
-       glLoadIdentity();
-       glEnable(GL_STENCIL_TEST);
-       glPushMatrix();
-       
+       glLoadIdentity();       
        /*
         * glPushAttrib         This passes attributes to the renderer so it knows what it can
         *                                      render. In our case, GL_DEPTH_BUFFER_BIT allows the renderer to
@@ -597,6 +594,7 @@ 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
 
@@ -606,17 +604,6 @@ void render(){
         *      Apply shaders if desired.
        */
 
-       #ifdef SHADERS
-               glUseProgramObjectARB(shaderProgram);
-               glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 640,100);
-               glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1,1,1);
-               glUniform1f(glGetUniformLocation(shaderProgram, "lightStrength"), 100 + (1000-(shade*10)));
-               //std::cout << 100 + (1000-(shade*10)) << std::endl;
-               glColor4ub(0,0,0,200);
-               glRectf(offset.x-SCREEN_WIDTH/2,0,offset.x+SCREEN_WIDTH/2,SCREEN_HEIGHT);
-               glUseProgramObjectARB(0);
-       #endif //SHADERS
-
        handAngle = atan((ui::mouse.y - (player->loc.y + player->height/2)) / (ui::mouse.x - player->loc.x + player->width/2))*180/PI;
        if(ui::mouse.x < player->loc.x){
                if(handAngle <= 0)
@@ -693,6 +680,8 @@ void render(){
        /*
         *      Here we draw a black overlay if it's been requested.
        */
+       glUseProgramObjectARB(0);
+
        
        if(fadeIntensity){
                if(fadeWhite)
index 08f503f1f5baf64016639cb67b03ca34e960b83b..b7590129c3ff8bba1eb6a40c0269932f555fa9c6 100644 (file)
@@ -556,7 +556,7 @@ namespace ui {
                                hub.y-=fontSize*1.15;
                                glRectf(hub.x,
                                                hub.y,
-                                               hub.x+(player->health/player->maxHealth)*130,
+                                               hub.x+(player->health/player->maxHealth?player->maxHealth:1)*130,
                                                hub.y+12);
                        }
                        
index c30ef4d78504e6b986071f0ca6ea4726b0902840..13fe6bc526dfac8ca8ec3ea11b2ef47ae6828c08 100644 (file)
--- a/test.frag
+++ b/test.frag
@@ -1,4 +1,4 @@
 #version 120\r
 void main(){\r
-       gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\r
+       gl_FragColor = glColor;\r
 }\r