]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Draw Rect
authordrumsetmonkey <abelleisle@roadrunner.com>
Tue, 10 May 2016 15:53:49 +0000 (11:53 -0400)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Tue, 10 May 2016 15:53:49 +0000 (11:53 -0400)
include/common.hpp
include/texture.hpp
src/common.cpp
src/inventory.cpp
src/texture.cpp
src/ui.cpp

index bbe852fbe260058d17f9130d1ce58d57a97bf184..eb8a2900507047e106c3c4be26de5f038a1a4f08 100644 (file)
@@ -146,16 +146,25 @@ public:
        float red;
        float green;
        float blue;
-       Color()
+       float alpha;
+    Color()
        {
-               red = green = blue = 0;
+               red = green = blue = alpha = 0;
        }
        Color(float r, float g ,float b)
        {
                red = r;
                green = g;
                blue = b;
+        alpha = 255;
        }
+    Color(float r, float g, float b, float a)
+    {
+        red = r;
+        green = g;
+        blue = b;
+        alpha = a;
+    }
        Color operator-=(float a) {
                red-=a;
                green-=a;
@@ -170,6 +179,19 @@ public:
        }
 };
 
+/*
+ * A function used to tell the program what shader, attributes, and uniforms
+ * we want to draw our rectangles to. See below |
+ *                                             \|/
+ */
+void useShader(GLuint *sh, GLint *tu, GLint *ca, GLint *ta);
+
+/*
+ * A function to draw a colored box for opengl
+ * To use it, the lower left hand and upper right hand coords are passed along
+ */
+void drawRect(vec2 ll, vec2 ur);
+
 // gets the length of `n` HLINEs
 template<typename T>
 inline T HLINES(const T &n)
index ecf85e49facc243caa8bf9275529b1c97ad5ad66..df2a83c38a553bc879e9b2359228981eb6b469e0 100644 (file)
@@ -26,6 +26,7 @@ namespace Texture {
         */
 
        GLuint loadTexture(std::string fileName);
+    GLuint genColor(Color c);
 
        void freeTextures(void);
 
index 77be09819c79f3a9b6b278a20021609f0e7b4b7f..05a5f356afba7d47a0ff8e74603bf4a3373acdc3 100644 (file)
@@ -34,6 +34,50 @@ std::vector<std::string> StringTokenizer(const std::string& str, char delim)
        return tokens;
 }
 
+static GLuint *Gshader;
+static GLint *tex_uni;
+static GLint *coord_attrib;
+static GLint *tex_attrib;
+
+void useShader(GLuint *sh, GLint *tu, GLint *ca, GLint *ta)
+{
+    Gshader = sh;
+    tex_uni = tu;
+    coord_attrib = ca;
+    tex_attrib = ta;
+}
+
+void drawRect(vec2 ll, vec2 ur)
+{
+    GLfloat verts[] = {ll.x, ll.y, 1.0,
+                       ur.x, ll.y, 1.0,
+                       ur.x, ur.y, 1.0,
+                       
+                       ur.x, ur.y, 1.0,
+                       ll.x, ur.y, 1.0,
+                       ll.x, ll.y, 1.0};
+   
+    GLfloat tex[] = {0.0, 0.0,
+                     1.0, 0.0,
+                     1.0, 1.0,
+
+                     1.0, 1.0,
+                     0.0, 1.0,
+                     0.0, 0.0};
+
+    glUniform1i(*tex_uni, 0);
+
+    glEnableVertexAttribArray(*coord_attrib);
+    glEnableVertexAttribArray(*tex_attrib);
+
+    glVertexAttribPointer(*coord_attrib, 3, GL_FLOAT, GL_FALSE, 0, verts);
+    glVertexAttribPointer(*tex_attrib, 2, GL_FLOAT, GL_FALSE, 0, tex);
+    glDrawArrays(GL_TRIANGLES, 0, 6);
+
+    glDisableVertexAttribArray(*tex_attrib);  
+    glDisableVertexAttribArray(*coord_attrib);
+}
+
 void DEBUG_prints(const char* file, int line, const char *s,...)
 {
        va_list args;
index a1181e282f6861cdbeebc94e1d98019cb5b3b5c6..7f58d304a0e3737ed46be6563c3f055d1c30b886 100644 (file)
@@ -404,15 +404,21 @@ void Inventory::draw(void) {
 
         C("Start drawing inventory");
        if (invOpen) {
-
+        useShader(&textShader,
+                  &textShader_uniform_texture,
+                  &textShader_attribute_coord,
+                  &textShader_attribute_tex);
                for(auto &mr : massRay) {
-                       glColor4f(0.0f,0.0f,0.0f, ((float)massDfp[a]/(float)massRange)*.5f);
-                       glBegin(GL_QUADS);
-                               glVertex2i(mr.x-(itemWide/2),            mr.y-(itemWide/2));
-                               glVertex2i(mr.x-(itemWide/2)+itemWide,mr.y-(itemWide/2));
-                               glVertex2i(mr.x-(itemWide/2)+itemWide,mr.y-(itemWide/2)+itemWide);
-                               glVertex2i(mr.x-(itemWide/2),            mr.y-(itemWide/2)+itemWide);
-                       glEnd();
+            float t = (((float)massDfp[a]/(float)massRange)*.5f);
+            glActiveTexture(GL_TEXTURE0);
+            glUseProgram(textShader);
+            
+                       glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(0.0f,0.0f,0.0f, t >= 0? 255*t : 0)));
+            glUniform1i(textShader_uniform_texture, 0);
+
+            drawRect(vec2(mr.x-(itemWide/2), mr.y-(itemWide/2)), vec2(mr.x-(itemWide/2)+itemWide, mr.y-(itemWide/2)+itemWide));
+
+            glUseProgram(0);
                        if (!Items.empty() && a+numSlot < Items.size() && Items[a+numSlot].second) {
                                glEnable(GL_TEXTURE_2D);
                                glBindTexture(GL_TEXTURE_2D, Items[a+numSlot].first->tex->image[0]);//itemtex[items[a+numSlot].id]);
index d4578313b5d49664cb3392768b3a93c0e9235c87..0f01c83c46e1abbb3644dbb55e2d115ae9718615 100644 (file)
@@ -19,6 +19,19 @@ struct index_t {
        int indexy;
 };
 
+// convert any type to octal
+template <typename T>
+uint toOctal(T toConvert)
+{
+    int n = 0;
+    uint t = 0;
+    while (toConvert > 0) {
+        t += (pow(10, n++)) * (static_cast<int>(toConvert) % 8);
+        toConvert /= 8;
+    }
+    return t;
+}
+
 /**
  * A vector of all loaded textures.
  *
@@ -89,6 +102,49 @@ namespace Texture{
                return object;
        }
 
+    GLuint genColor(Color c)
+    {
+        std::string out;
+        
+        // add the red
+        out += static_cast<int>(c.red);
+
+        // add the green
+        out += static_cast<int>(c.green);
+
+        // add the blue
+        out += static_cast<int>(c.blue);
+
+        // add the alpha
+        out += static_cast<int>(c.alpha);
+
+        GLuint object;
+
+        glActiveTexture(GL_TEXTURE0);
+        glGenTextures(1,&object);                              // Turns "object" into a texture
+               glBindTexture(GL_TEXTURE_2D,object);    // Binds "object" to the top of the stack
+               //glPixelStorei(GL_UNPACK_ALIGNMENT,1);
+
+               //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);    // Sets the "min" filter
+               //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);    // The the "max" filter of the stack
+
+               //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // Wrap the texture to the matrix
+               //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); //
+
+               glTexImage2D(GL_TEXTURE_2D,     // Sets the texture to the image file loaded above
+                                        0,                 // level
+                                        GL_RGBA,           // internal format
+                                        1,                 // width
+                                        1,                 // height
+                                        0,                 // border
+                                        GL_RGBA,           // image format
+                                        GL_UNSIGNED_BYTE,  // type
+                                        out.data()         // source
+                                       );
+        
+        return object;
+    }
+
        dim2 imageDim(std::string fileName) {
                for(auto &t : LoadedTexture) {
                        if (t.name == fileName)
index 6a68cc0a1fe427471fba2716491bd983f0323137..0b58f0dae963e9b386a84449a3603e8e263d674d 100644 (file)
@@ -294,8 +294,8 @@ namespace ui {
                */
 
                glActiveTexture(GL_TEXTURE0);
-               glUniform1i(textShader_uniform_texture, 0);
                glBindTexture(GL_TEXTURE_2D,(*ftex)[c-33]);
+               glUniform1i(textShader_uniform_texture, 0);
 
                //glDisable(GL_DEPTH_TEST);
 
@@ -639,11 +639,6 @@ namespace ui {
        }
 
        void drawBox(vec2 c1, vec2 c2) {
-        static vec2 lineIndexF = Texture::getIndex(Color(255, 255, 255));
-        static vec2 lineIndex = vec2(0.25f * lineIndexF.x, 0.125f * (8-lineIndexF.y));
-        static vec2 boxIndexF = Texture::getIndex(Color(0, 0, 0));
-        static vec2 boxIndex = vec2(0.25f * boxIndexF.x, 0.125f * (8-boxIndexF.y));
-
         GLfloat box[] = {c1.x, c1.y, 1.0,
                          c2.x, c1.y, 1.0,
                          c2.x, c2.y, 1.0,
@@ -655,26 +650,23 @@ namespace ui {
         GLfloat line_strip[] = {c1.x,     c1.y, 1.0,
                                 c2.x + 1, c1.y, 1.0,
                                 c2.x + 1, c2.y, 1.0,
-                                c1.x - 1, c2.y, 1.0,
+                                c1.x,     c2.y, 1.0,
                                 c1.x,     c1.y, 1.0};
 
-        static GLfloat box_tex[] = {boxIndex.x,boxIndex.y,
-                                    boxIndex.x,boxIndex.y,
-                                    boxIndex.x,boxIndex.y,
+        GLfloat box_tex[] = {0,0,
+                             1,0,
+                             1,1,
 
-                                    boxIndex.x,boxIndex.y,
-                                    boxIndex.x,boxIndex.y,
-                                    boxIndex.x,boxIndex.y};
+                             1,1,
+                             0,1,
+                             0,0};
 
-        static GLfloat line_tex[] = {lineIndex.x, lineIndex.y,
-                                     lineIndex.x, lineIndex.y,
-                                     lineIndex.x, lineIndex.y,
-                                     lineIndex.x, lineIndex.y,
-                                     lineIndex.x, lineIndex.y};
+        static GLuint boxT = Texture::genColor(Color(0,0,0));
+        static GLuint lineT = Texture::genColor(Color(255,255,255));
 
-        glActiveTexture(GL_TEXTURE9); 
-        glBindTexture(GL_TEXTURE_2D, colorIndex);
-        glUniform1i(textShader_uniform_texture, 9);
+        glActiveTexture(GL_TEXTURE0); 
+        glBindTexture(GL_TEXTURE_2D, boxT);
+        glUniform1i(textShader_uniform_texture, 0);
         glUseProgram(textShader);
 
         glEnableVertexAttribArray(textShader_attribute_coord);
@@ -683,16 +675,18 @@ namespace ui {
         glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, box);
         glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, box_tex);
         glDrawArrays(GL_TRIANGLES, 0 ,6);
-      
-        glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, line_strip);
-        glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, line_tex);
-        glDrawArrays(GL_LINE_STRIP, 0 ,5);
+       
+        glBindTexture(GL_TEXTURE_2D, lineT);
+        glUniform1i(textShader_uniform_texture, 0);
 
+        glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, line_strip);
+        glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, box_tex);
+        glDrawArrays(GL_LINE_STRIP, 0 ,8);
+         
         glDisableVertexAttribArray(textShader_attribute_coord);
         glDisableVertexAttribArray(textShader_attribute_tex);
         
         glUseProgram(0);
-        glActiveTexture(GL_TEXTURE0);  
        }
 
        void draw(void){
@@ -700,22 +694,46 @@ namespace ui {
                float x,y,tmp;
                std::string rtext;
 
-               auto SCREEN_WIDTH = game::SCREEN_WIDTH;
-               auto SCREEN_HEIGHT = game::SCREEN_HEIGHT;
+               auto SCREEN_WIDTH = static_cast<float>(game::SCREEN_WIDTH);
+               auto SCREEN_HEIGHT = static_cast<float>(game::SCREEN_HEIGHT);
 
                // will return if not toggled
                action::draw(vec2 {player->loc.x + player->width / 2, player->loc.y + player->height + game::HLINE});
 
                if (pageTexReady) {
-                       glEnable(GL_TEXTURE_2D);
-                       glBindTexture(GL_TEXTURE_2D, pageTex);
-                       glBegin(GL_QUADS);
-                               glTexCoord2i(0, 0); glVertex2i(offset.x - 300, SCREEN_HEIGHT - 100);
-                               glTexCoord2i(1, 0); glVertex2i(offset.x + 300, SCREEN_HEIGHT - 100);
-                               glTexCoord2i(1, 1); glVertex2i(offset.x + 300, SCREEN_HEIGHT - 600);
-                               glTexCoord2i(0, 1); glVertex2i(offset.x - 300, SCREEN_HEIGHT - 600);
-                       glEnd();
-                       glDisable(GL_TEXTURE_2D);
+
+            GLfloat page_loc[] = {offset.x - 300, SCREEN_HEIGHT - 100, 1.0,
+                                  offset.x + 300, SCREEN_HEIGHT - 100, 1.0,
+                                  offset.x + 300, SCREEN_HEIGHT - 600, 1.0,
+
+                                  offset.x + 300, SCREEN_HEIGHT - 600, 1.0,
+                                  offset.x - 300, SCREEN_HEIGHT - 600, 1.0,
+                                  offset.x - 300, SCREEN_HEIGHT - 100, 1.0};
+
+            GLfloat page_tex[] = {0.0, 0.0,
+                                  1.0, 0.0,
+                                  1.0, 1.0,
+
+                                  1.0, 1.0,
+                                  0.0, 1.0,
+                                  0.0, 0.0};
+
+            glActiveTexture(GL_TEXTURE0); 
+            glBindTexture(GL_TEXTURE_2D, pageTex);
+            glUniform1i(textShader_uniform_texture, 0);
+            glUseProgram(textShader);
+
+            glEnableVertexAttribArray(textShader_attribute_coord);
+            glEnableVertexAttribArray(textShader_attribute_tex);
+       
+            glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, page_loc);
+            glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, page_tex);
+            glDrawArrays(GL_TRIANGLES, 0 ,6);
+           
+            glDisableVertexAttribArray(textShader_attribute_coord);
+            glDisableVertexAttribArray(textShader_attribute_tex);
+            
+            glUseProgram(0);
 
                } else if (dialogBoxExists) {
                        rtext = typeOut(dialogBoxText);
@@ -756,25 +774,53 @@ namespace ui {
                                putStringCentered(merchBase.x - SCREEN_WIDTH / 10     , merchBase.y + 40 + fontSize    , merchTrade.item[1]);
                                putStringCentered(offset.x, merchBase.y + 60, "for");
 
-                               glEnable(GL_TEXTURE_2D);
-
-                               glBindTexture(GL_TEXTURE_2D, getItemTexture(merchTrade.item[0]));
-                               glBegin(GL_QUADS);
-                                       glTexCoord2d(0,1);glVertex2f(offset.x - (SCREEN_WIDTH / 10)     ,offset.y + (SCREEN_HEIGHT/5));
-                                       glTexCoord2d(1,1);glVertex2f(offset.x - (SCREEN_WIDTH / 10) + 40,offset.y + (SCREEN_HEIGHT/5));
-                                       glTexCoord2d(1,0);glVertex2f(offset.x - (SCREEN_WIDTH / 10) + 40,offset.y + (SCREEN_HEIGHT/5) + 40);
-                                       glTexCoord2d(0,0);glVertex2f(offset.x - (SCREEN_WIDTH / 10)     ,offset.y + (SCREEN_HEIGHT/5) + 40);
-                               glEnd();
-
-                               glBindTexture(GL_TEXTURE_2D, getItemTexture(merchTrade.item[1]));
-                               glBegin(GL_QUADS);
-                                       glTexCoord2d(0,1);glVertex2f(offset.x + (SCREEN_WIDTH / 10) - 40,offset.y + (SCREEN_HEIGHT/5));
-                                       glTexCoord2d(1,1);glVertex2f(offset.x + (SCREEN_WIDTH / 10)     ,offset.y + (SCREEN_HEIGHT/5));
-                                       glTexCoord2d(1,0);glVertex2f(offset.x + (SCREEN_WIDTH / 10)     ,offset.y + (SCREEN_HEIGHT/5) + 40);
-                                       glTexCoord2d(0,0);glVertex2f(offset.x + (SCREEN_WIDTH / 10) - 40,offset.y + (SCREEN_HEIGHT/5) + 40);
-                               glEnd();
-
-                               glDisable(GL_TEXTURE_2D);
+                // render the two items we are trading
+                GLfloat item_tex[] = {0.0, 1.0,
+                                      1.0, 1.0,
+                                      1.0, 0.0,
+
+                                      1.0, 0.0,
+                                      0.0, 0.0,
+                                      0.0, 1.0};
+
+                GLfloat left_item[] = {offset.x - (SCREEN_WIDTH / 10),      offset.y + (SCREEN_HEIGHT / 5),     1.0,
+                                       offset.x - (SCREEN_WIDTH / 10) + 40, offset.y + (SCREEN_HEIGHT / 5),     1.0,
+                                       offset.x - (SCREEN_WIDTH / 10) + 40, offset.y + (SCREEN_HEIGHT / 5) + 40,1.0,
+
+                                       offset.x - (SCREEN_WIDTH / 10) + 40, offset.y + (SCREEN_HEIGHT / 5) + 40,1.0,
+                                       offset.x - (SCREEN_WIDTH / 10),      offset.y + (SCREEN_HEIGHT / 5) + 40,1.0,
+                                       offset.x - (SCREEN_WIDTH / 10),      offset.y + (SCREEN_HEIGHT / 5),     1.0};
+
+                GLfloat right_item[] = {offset.x + (SCREEN_WIDTH / 10) - 40,    offset.y + (SCREEN_HEIGHT / 5),     1.0,
+                                        offset.x + (SCREEN_WIDTH / 10),         offset.y + (SCREEN_HEIGHT / 5),     1.0,
+                                        offset.x + (SCREEN_WIDTH / 10),         offset.y + (SCREEN_HEIGHT / 5) + 40,1.0,
+
+                                        offset.x + (SCREEN_WIDTH / 10),         offset.y + (SCREEN_HEIGHT / 5) + 40,1.0,
+                                        offset.x + (SCREEN_WIDTH / 10) - 40,    offset.y + (SCREEN_HEIGHT / 5) + 40,1.0,
+                                        offset.x + (SCREEN_WIDTH / 10) - 40,    offset.y + (SCREEN_HEIGHT / 5),     1.0};
+
+                glActiveTexture(GL_TEXTURE0); 
+                glBindTexture(GL_TEXTURE_2D, getItemTexture(merchTrade.item[0]));
+                glUniform1i(textShader_uniform_texture, 0);
+                glUseProgram(textShader);
+
+                glEnableVertexAttribArray(textShader_attribute_coord);
+                glEnableVertexAttribArray(textShader_attribute_tex);
+           
+                glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, left_item);
+                glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, item_tex);
+                glDrawArrays(GL_TRIANGLES, 0 ,6);
+               
+                glBindTexture(GL_TEXTURE_2D, getItemTexture(merchTrade.item[1]));
+
+                glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, right_item);
+                glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, item_tex);
+                glDrawArrays(GL_TRIANGLES, 0 ,6);
+
+                glDisableVertexAttribArray(textShader_attribute_coord);
+                glDisableVertexAttribArray(textShader_attribute_tex);
+                
+                glUseProgram(0);
 
                                merchArrowLoc[0].x = offset.x - (SCREEN_WIDTH / 8.5) - 16;
                                merchArrowLoc[1].x = offset.x + (SCREEN_WIDTH / 8.5) + 16;
@@ -789,14 +835,34 @@ namespace ui {
                                                (mouse.x < merchArrowLoc[i].x     && mouse.x > merchArrowLoc[i].z)) &&
                                             mouse.y > merchArrowLoc[i].y - 8 && mouse.y < merchArrowLoc[i].y + 8) {
                                                glColor3ub(255,255, 0);
-                                       }else{
+                        glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(255,255,0)));
+                    }else{
                                                glColor3ub(255,255,255);
+                        glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(255,255,255)));
                                        }
-                                       glBegin(GL_TRIANGLES);
-                                               glVertex2f(merchArrowLoc[i].x,merchArrowLoc[i].y);
-                                               glVertex2f(merchArrowLoc[i].z,merchArrowLoc[i].y-8);
-                                               glVertex2f(merchArrowLoc[i].z,merchArrowLoc[i].y+8);
-                                       glEnd();
+
+                    GLfloat tri_t[] = {0.0, 0.0,
+                                       0.0, 1.0,
+                                       1.0, 1.0};
+
+                    GLfloat tri_c[] = {merchArrowLoc[i].x, merchArrowLoc[i].y,      1.0,
+                                       merchArrowLoc[i].z, merchArrowLoc[i].y - 8,  1.0,
+                                       merchArrowLoc[i].z, merchArrowLoc[i].y + 8,  1.0};
+
+                    glUniform1i(textShader_uniform_texture, 0);
+                    glUseProgram(textShader);
+
+                    glEnableVertexAttribArray(textShader_attribute_coord);
+                    glEnableVertexAttribArray(textShader_attribute_tex);
+               
+                    glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, tri_c);
+                    glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, tri_t);
+                    glDrawArrays(GL_TRIANGLES, 0 ,6);
+                   
+                    glDisableVertexAttribArray(textShader_attribute_coord);
+                    glDisableVertexAttribArray(textShader_attribute_tex);
+                    
+                    glUseProgram(0);
                                }
 
 
@@ -865,18 +931,47 @@ namespace ui {
                                                                                                (unsigned)player->maxHealth
                                                                                                );
                        if (player->isAlive()) {
-                               glColor3ub(150,0,0);
                                hub.y-=fontSize*1.15;
-                               glRectf(hub.x,
-                                               hub.y,
-                                               hub.x+150,
-                                               hub.y+12);
-                               glColor3ub(255,0,0);
-                               glRectf(hub.x,
-                                               hub.y,
-                                               hub.x+(player->health/player->maxHealth * 150),
-                                               hub.y+12);
-                       }
+
+                GLfloat tex[] = {0.0, 0.0,
+                                 1.0, 0.0,
+                                 0.0, 1.0,
+                                 1.0, 1.0};
+
+                GLfloat back[] = {hub.x,        hub.y,      1.0,
+                                  hub.x + 150,  hub.y,      1.0,
+                                  hub.x,        hub.y + 12, 1.0,
+                                  hub.x + 150,  hub.y + 12, 1.0};
+
+                GLfloat front[] = {hub.x,       hub.y,      1.0,
+                                   hub.x + 150, hub.y,      1.0,
+                                   hub.x,       hub.y + 12, 1.0,
+                                   hub.x + 150, hub.y + 12, 1.0};
+
+                
+                glUniform1i(textShader_uniform_texture, 0);
+                glUseProgram(textShader);
+
+                glEnableVertexAttribArray(textShader_attribute_coord);
+                glEnableVertexAttribArray(textShader_attribute_tex);
+           
+                glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(150,0,0)));
+
+                glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, front);
+                glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, tex);
+                glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+               
+                glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(255,0,0)));
+                
+                glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, back);
+                glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, tex);
+                glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+                glDisableVertexAttribArray(textShader_attribute_coord);
+                glDisableVertexAttribArray(textShader_attribute_tex);             
+
+                glUseProgram(0);
+            }
 
                        /*
                         *      Lists all of the quests the player is currently taking.
@@ -1328,16 +1423,36 @@ EXIT:
                }
 
                if (fadeWhite)
-                       safeSetColorA(255, 255, 255, fadeIntensity);
+                       glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(255, 255, 255, fadeIntensity)));
                else
-                       safeSetColorA(0, 0, 0, fadeIntensity);
+                       glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(0, 0, 0, fadeIntensity)));
+
+        GLfloat tex[] = {0.0, 0.0,
+                        1.0, 0.0,
+                        0.0, 1.0,
+                        1.0, 1.0};
+
+        GLfloat backdrop[] = {offset.x - SCREEN_WIDTH / 2, offset.y - SCREEN_HEIGHT / 2, 1.0,
+                              offset.x + SCREEN_WIDTH / 2, offset.y - SCREEN_HEIGHT / 2, 1.0,
+                              offset.x - SCREEN_WIDTH / 2, offset.y + SCREEN_HEIGHT / 2, 1.0,
+                              offset.x + SCREEN_WIDTH / 2, offset.y + SCREEN_HEIGHT / 2, 1.0};
+           
+        glUniform1i(textShader_uniform_texture, 0);
+        glUseProgram(textShader);
 
-               glRectf(offset.x - SCREEN_WIDTH  / 2,
-                               offset.y - SCREEN_HEIGHT / 2,
-                               offset.x + SCREEN_WIDTH  / 2,
-                               offset.y + SCREEN_HEIGHT / 2
-                           );
-       }
+        glEnableVertexAttribArray(textShader_attribute_coord);
+        glEnableVertexAttribArray(textShader_attribute_tex);
+   
+        glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, backdrop);
+        glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, tex);
+        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+       
+        glDisableVertexAttribArray(textShader_attribute_coord);
+        glDisableVertexAttribArray(textShader_attribute_tex);
+        
+        glUseProgram(0);
+
+    }
 
        void fadeUpdate(void) {
                if (fadeEnable) {