]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
RENDERING
authordrumsetmonkey <abelleisle@roadrunner.com>
Thu, 12 May 2016 12:03:57 +0000 (08:03 -0400)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Thu, 12 May 2016 12:03:57 +0000 (08:03 -0400)
14 files changed:
include/common.hpp
include/entities.hpp
main.cpp
shaders/new.frag
shaders/new.vert
src/common.cpp
src/entities.cpp
src/inventory.cpp
src/ui.cpp
src/world.cpp
ttf/atomics.TTF [new file with mode: 0644]
ttf/atomicsc.TTF [new file with mode: 0644]
ttf/yapix.ttf [new file with mode: 0644]
xml/playerSpawnHill1.xml

index eb8a2900507047e106c3c4be26de5f038a1a4f08..24c5204f30e684a6d9ad8b71837a7cd37ba58c74 100644 (file)
@@ -218,6 +218,7 @@ extern GLuint textShader;
 extern GLint textShader_attribute_coord;
 extern GLint textShader_attribute_tex;
 extern GLint textShader_uniform_texture;
+extern GLint textShader_uniform_color;
 
 extern GLuint worldShader;
 extern GLint worldShader_attribute_coord;
index 3e78687dbf453e07a165ff8d1a58cd0e2675637d..5159d24f4fc077d6c53fc257d6ff81e594d288b8 100644 (file)
@@ -149,7 +149,7 @@ public:
        ~Particles(void){}
 
        // draws the particle
-       std::vector<std::pair<vec2, vec3>> draw(void) const;
+       void draw(std::vector<GLfloat> &verts, std::vector<GLfloat> &tex) const;
 
        // updates a particle
        void update(float _gravity, float ground_y);
index 570f12f5ce7316d315a87899f195e395f023d070..aad70cd797feb747cc942dba9551b5d2e6315b55 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -64,6 +64,7 @@ GLint textShader_attribute_coord;
 GLint textShader_attribute_tex;
 GLint textShader_uniform_texture;
 GLint textShader_uniform_transform;
+GLint textShader_uniform_color;
 
 /**
  * These are the source and index variables for the world
@@ -218,7 +219,7 @@ int main(int argc, char *argv[]){
        textShader_attribute_tex = get_attrib(textShader, "tex_coord");
        textShader_uniform_texture = get_uniform(textShader, "sampler");
        textShader_uniform_transform = get_uniform(textShader, "ortho");
-
+    textShader_uniform_color = get_uniform(textShader, "tex_color");
 
        /**
         *      Creating the world's shader and its attributes/uniforms
@@ -305,7 +306,7 @@ int main(int argc, char *argv[]){
        // close up the game stuff
        currentWorld->save();
        delete arena;
-       delete currentWorld;
+       //delete currentWorld;
 
     return 0; // Calls everything passed to atexit
 }
@@ -379,18 +380,20 @@ void render() {
                                                                                10.0f,                                                          //near
                                                                                -10.0f);                                                        //far
 
-       glm::mat4 view = glm::lookAt(glm::vec3(0,0,10.0f),  //pos
-                                                                glm::vec3(0,0,0.0f), //looking at
+       glm::mat4 view = glm::lookAt(glm::vec3(0,0,0.0f),  //pos
+                                                                glm::vec3(0,0,-10.0f), //looking at
                                                                 glm::vec3(0,1.0f,0)); //up vector
 
        glm::mat4 ortho = projection * view;
 
        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
-       //glEnable(GL_DEPTH_TEST);
+       // TODO add depth
+    //glEnable(GL_DEPTH_TEST);
 
        glUseProgram(textShader);
        glUniformMatrix4fv(textShader_uniform_transform, 1, GL_FALSE, glm::value_ptr(ortho));
-       glUseProgram(worldShader);
+    glUniform4f(textShader_uniform_color, 1.0, 1.0, 1.0, 1.0);
+    glUseProgram(worldShader);
        glUniformMatrix4fv(worldShader_uniform_transform, 1, GL_FALSE, glm::value_ptr(ortho));
 
        /**************************
index 8812d72365a1584575bb000c01053e6b1e4ad985..fa8a260222eef42a38af7e078bf32510d67ffe52 100644 (file)
@@ -1,9 +1,9 @@
 uniform sampler2D sampler;
 
 varying vec2 texCoord;
-varying float join;
+varying vec4 color;
 
 void main(){
-    vec4 color = texture2D(sampler, vec2(texCoord.x, texCoord.y));
-    gl_FragColor = color;
+    vec4 pixelColor = texture2D(sampler, vec2(texCoord.x, texCoord.y));
+    gl_FragColor = pixelColor * color;
 }
index 1bedfd3feb3b631419702dfc5190abe54c97b550..b2fcba4bc8793714286383123839c3d670f6cec2 100644 (file)
@@ -2,10 +2,13 @@ attribute vec3 coord2d;
 attribute vec2 tex_coord;
 
 uniform mat4 ortho;
+uniform vec4 tex_color;
 
 varying vec2 texCoord;
+varying vec4 color;
 
 void main(){
     texCoord = tex_coord;
+    color = tex_color;
     gl_Position = ortho * vec4(coord2d.xyz, 1.0);
 }
index 05a5f356afba7d47a0ff8e74603bf4a3373acdc3..916070c5e8b6c34329632f756dbd2e1bad99fd49 100644 (file)
@@ -57,13 +57,13 @@ void drawRect(vec2 ll, vec2 ur)
                        ll.x, ur.y, 1.0,
                        ll.x, ll.y, 1.0};
    
-    GLfloat tex[] = {0.0, 0.0,
-                     1.0, 0.0,
+    GLfloat tex[] = {0.0, 1.0,
                      1.0, 1.0,
+                     1.0, 0.0,
 
-                     1.0, 1.0,
-                     0.0, 1.0,
-                     0.0, 0.0};
+                     1.0, 0.0,
+                     0.0, 0.0,
+                     0.0, 1.0};
 
     glUniform1i(*tex_uni, 0);
 
index a8f5e484cec5dca85584734f17410fddb0182623..efe9d13edc1747cc9cbaccd1b9c1def627c3c249 100644 (file)
@@ -88,7 +88,7 @@ void Entity::spawn(float x, float y)
        //canMove       = true;
        ground  = false;
        forcedMove = false;
-       z = 1.0f;
+       z = -1.0f;
 
        ticksToUse = 0;
        hitCooldown = 0;
@@ -425,23 +425,23 @@ if (health != maxHealth) {
        glUniform1i(worldShader_uniform_texture, 0);
 
        GLfloat coord_back[] = {
-               loc.x,                  loc.y + height,                         1.0,
-               loc.x + width,  loc.y + height,                         1.0,
-               loc.x + width,  loc.y + height + game::HLINE * 2, 1.0,
+               loc.x,                  loc.y + height,                              z,
+               loc.x + width,  loc.y + height,                              z,
+               loc.x + width,  loc.y + height + game::HLINE * 2,z,
 
-               loc.x + width,  loc.y + height + game::HLINE * 2, 1.0,
-               loc.x,                  loc.y + height + game::HLINE * 2,       1.0,
-               loc.x,                  loc.y + height,                         1.0,
+               loc.x + width,  loc.y + height + game::HLINE * 2,z,
+               loc.x,                  loc.y + height + game::HLINE * 2,z,
+               loc.x,                  loc.y + height,                              z,
        };
 
        GLfloat coord_front[] = {
-               loc.x,                                      loc.y + height,                   1.0,
-               loc.x + health / maxHealth * width, loc.y + height,                   1.0,
-               loc.x + health / maxHealth * width, loc.y + height + game::HLINE * 2, 1.0,
+               loc.x,                                      loc.y + height,                   z,
+               loc.x + health / maxHealth * width, loc.y + height,                   z,
+               loc.x + health / maxHealth * width, loc.y + height + game::HLINE * 2, z,
 
-               loc.x + health / maxHealth * width, loc.y + height + game::HLINE * 2, 1.0,
-               loc.x,                              loc.y + height + game::HLINE * 2, 1.0,
-               loc.x,                              loc.y + height,                   1.0,
+               loc.x + health / maxHealth * width, loc.y + height + game::HLINE * 2, z,
+               loc.x,                              loc.y + height + game::HLINE * 2, z,
+               loc.x,                              loc.y + height,                   z,
        };
 
        static const vec2 index1 = Texture::getIndex(Color(0,0,0));
@@ -860,21 +860,43 @@ Particles::Particles(float x, float y, float w, float h, float vx, float vy, Col
        index = Texture::getIndex(c);
 }
 
-std::vector<std::pair<vec2, vec3>> Particles::draw(void) const
+void Particles::draw(std::vector<GLfloat> &verts, std::vector<GLfloat> &tex) const
 {
        vec2 tc = vec2 {0.25f * index.x, 0.125f * (8-index.y)};
 
-       std::vector<std::pair<vec2, vec3>> tmp;
+    float z = 0.0;
+    if (behind)
+        z = 2.0;
+
+    verts.push_back(loc.x);
+    verts.push_back(loc.y);
+    verts.push_back(z);
+
+    verts.push_back(loc.x + width);
+    verts.push_back(loc.y);
+    verts.push_back(z);
+       
+    verts.push_back(loc.x + width);
+    verts.push_back(loc.y + height);
+    verts.push_back(z);
+
+
+    verts.push_back(loc.x + width);
+    verts.push_back(loc.y + height);
+    verts.push_back(z);
 
-       tmp.push_back(std::make_pair(vec2(tc.x, tc.y), vec3(loc.x,                 loc.y,               1.0)));
-       tmp.push_back(std::make_pair(vec2(tc.x, tc.y), vec3(loc.x + width, loc.y,                   1.0)));
-       tmp.push_back(std::make_pair(vec2(tc.x, tc.y), vec3(loc.x + width, loc.y + height,  1.0)));
+    verts.push_back(loc.x);
+    verts.push_back(loc.y + height);
+    verts.push_back(z);
 
-       tmp.push_back(std::make_pair(vec2(tc.x, tc.y), vec3(loc.x + width, loc.y + height,  1.0)));
-       tmp.push_back(std::make_pair(vec2(tc.x, tc.y), vec3(loc.x,         loc.y + height,  1.0)));
-       tmp.push_back(std::make_pair(vec2(tc.x, tc.y), vec3(loc.x,         loc.y,                   1.0)));
+    verts.push_back(loc.x);
+    verts.push_back(loc.y);
+    verts.push_back(z);
 
-       return tmp;
+    for (int i = 0; i < 6; i++){
+        tex.push_back(tc.x);
+        tex.push_back(tc.y);
+    }
 }
 
 void Particles::update(float _gravity, float ground_y)
index 7f58d304a0e3737ed46be6563c3f055d1c30b886..e6c502925b358ea16fd089908ea257d15d7c63e3 100644 (file)
@@ -346,7 +346,7 @@ void Inventory::draw(void) {
        if (invOpening) {
                for (auto &d : dfp) {
                        if (!a || dfp[a - 1] > 50)
-                               d += 1.65f * deltaTime;
+                               d += 4.0f * deltaTime;
                        if (d > range)
                                d = range;
                        a++;
@@ -354,7 +354,7 @@ void Inventory::draw(void) {
 
                for (auto &cd : curdfp) {
                        if (!a || curdfp[a - 1] > 90)
-                               cd += 1.5f * deltaTime;
+                               cd += 3.0f * deltaTime;
                        if (cd > curRange)
                                cd = curRange;
                        a++;
@@ -362,7 +362,7 @@ void Inventory::draw(void) {
 
                while (a < massOrder.size()) {
                        if (!a || massDfp[massOrder[a - 1]] > massRange * 0.75f)
-                               massDfp[massOrder[a]] += 5.0f * deltaTime;
+                               massDfp[massOrder[a]] += 20.0f * deltaTime;
                        if (massDfp[massOrder[a]] > massRange)
                                massDfp[massOrder[a]] = massRange;
                        a++;
@@ -373,16 +373,16 @@ void Inventory::draw(void) {
        } else {
                for (auto &d : dfp) {
                        if (d > 0)
-                               d -= 1.65f * deltaTime;
+                               d -= 4.5f * deltaTime;
                }
                for (auto &cd : curdfp) {
                        if (cd > 0)
-                               cd -= 1.0f * deltaTime;
+                               cd -= 3.0f * deltaTime;
                }
 
                while (a < massRay.size()) {
                        if (!a || massDfp[massOrderClosing[a - 1]] <= 0)
-                               massDfp[massOrderClosing[a]] -= 10.0f * deltaTime;
+                               massDfp[massOrderClosing[a]] -= 30.0f * deltaTime;
                        else if (massDfp[massOrderClosing[a - 1]] < 0)
                                massDfp[massOrderClosing[a - 1]] = 0;
                        a++;
@@ -420,26 +420,20 @@ void Inventory::draw(void) {
 
             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]);
-                               glColor4f(1.0f, 1.0f, 1.0f, ((float)massDfp[a]/(float)(massRange?massRange:1))*0.8f);
-                               glBegin(GL_QUADS);
-                                       if (Items[a+numSlot].first->dim.y > Items[a+numSlot].first->dim.x) {
-                                               glTexCoord2i(0,1);glVertex2i(mr.x-((itemWide/2)*((float)Items[a+numSlot].first->dim.x/(float)Items[a+numSlot].first->dim.y)),   mr.y-(itemWide/2));
-                                               glTexCoord2i(1,1);glVertex2i(mr.x+((itemWide/2)*((float)Items[a+numSlot].first->dim.x/(float)Items[a+numSlot].first->dim.y)),   mr.y-(itemWide/2));
-                                               glTexCoord2i(1,0);glVertex2i(mr.x+((itemWide/2)*((float)Items[a+numSlot].first->dim.x/(float)Items[a+numSlot].first->dim.y)),   mr.y+(itemWide/2));
-                                               glTexCoord2i(0,0);glVertex2i(mr.x-((itemWide/2)*((float)Items[a+numSlot].first->dim.x/(float)Items[a+numSlot].first->dim.y)),   mr.y+(itemWide/2));
-                                       }else{
-                                               glTexCoord2i(0,1);glVertex2i(mr.x-(itemWide/2),mr.y-(itemWide/2)*((float)Items[a+numSlot].first->dim.y/(float)Items[a+numSlot].first->dim.x));
-                                               glTexCoord2i(1,1);glVertex2i(mr.x+(itemWide/2),mr.y-(itemWide/2)*((float)Items[a+numSlot].first->dim.y/(float)Items[a+numSlot].first->dim.x));
-                                               glTexCoord2i(1,0);glVertex2i(mr.x+(itemWide/2),mr.y+(itemWide/2)*((float)Items[a+numSlot].first->dim.y/(float)Items[a+numSlot].first->dim.x));
-                                               glTexCoord2i(0,0);glVertex2i(mr.x-(itemWide/2),mr.y+(itemWide/2)*((float)Items[a+numSlot].first->dim.y/(float)Items[a+numSlot].first->dim.x));
-                                       }
-                               glEnd();
-                               glDisable(GL_TEXTURE_2D);
+                               glUseProgram(textShader);
+                glBindTexture(GL_TEXTURE_2D, Items[a+numSlot].first->tex->image[0]);//itemtex[items[a+numSlot].id]);
+                               glUniform4f(textShader_uniform_color, 1.0f, 1.0f, 1.0f, ((float)massDfp[a]/(float)(massRange?massRange:1))*0.8f);
+                if (Items[a+numSlot].first->dim.y > Items[a+numSlot].first->dim.x) {
+                    drawRect(vec2(mr.x-((itemWide/2)*((float)Items[a+numSlot].first->dim.x/(float)Items[a+numSlot].first->dim.y)),     mr.y-(itemWide/2)),
+                             vec2(mr.x+((itemWide/2)*((float)Items[a+numSlot].first->dim.x/(float)Items[a+numSlot].first->dim.y)),     mr.y+(itemWide/2)));
+                }else{
+                    drawRect(vec2(mr.x-(itemWide/2),mr.y-(itemWide/2)*((float)Items[a+numSlot].first->dim.y/(float)Items[a+numSlot].first->dim.x)),
+                             vec2(mr.x-(itemWide/2),mr.y+(itemWide/2)*((float)Items[a+numSlot].first->dim.y/(float)Items[a+numSlot].first->dim.x)));
+                }
                                ui::setFontColor(255,255,255,((float)massDfp[a]/(float)(massRange?massRange:1))*255);
                                ui::putText(mr.x-(itemWide/2)+(itemWide*.85),mr.y-(itemWide/2),"%d",Items[a+numSlot].second);
                                ui::setFontColor(255,255,255,255);
+                glUseProgram(0);
                        }
                        a++;
                }a=0;
@@ -448,14 +442,14 @@ void Inventory::draw(void) {
                        curCurCoord[a].x -= float((curdfp[a]) * cos(-1));
                        curCurCoord[a].y += float((curdfp[a]) * sin(0));
                        cr.end = curCurCoord[a];
+            
+            float curTrans = (((float)curdfp[a]/(float)(curRange?curRange:1))*0.5f);
 
-                       glColor4f(0.0f, 0.0f, 0.0f, ((float)curdfp[a]/(float)(curRange?curRange:1))*0.5f);
-                       glBegin(GL_QUADS);
-                               glVertex2i(cr.end.x-(itemWide/2),                cr.end.y-(itemWide/2));
-                               glVertex2i(cr.end.x-(itemWide/2)+itemWide,cr.end.y-(itemWide/2));
-                               glVertex2i(cr.end.x-(itemWide/2)+itemWide,cr.end.y-(itemWide/2)+itemWide);
-                               glVertex2i(cr.end.x-(itemWide/2),                cr.end.y-(itemWide/2)+itemWide);
-                       glEnd();
+            glUseProgram(textShader);
+                       glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(0.0f, 0.0f, 0.0f, curTrans >= 0 ? 255 * curTrans : 0)));
+            drawRect(vec2(cr.end.x-(itemWide/2),                cr.end.y-(itemWide/2)),
+                     vec2(cr.end.x-(itemWide/2)+itemWide,cr.end.y-(itemWide/2)+itemWide));
+            glUseProgram(0);
                        a++;
                }a=0;
 
@@ -465,42 +459,33 @@ void Inventory::draw(void) {
                        curCoord[a].y += float((dfp[a]) * sin(angle*PI/180));
                        r.end = curCoord[a];
 
-                       glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)(range?range:1))*0.5f);
-                       glBegin(GL_QUADS);
-                               glVertex2i(r.end.x-(itemWide/2),                 r.end.y-(itemWide/2));
-                               glVertex2i(r.end.x-(itemWide/2)+itemWide,r.end.y-(itemWide/2));
-                               glVertex2i(r.end.x-(itemWide/2)+itemWide,r.end.y-(itemWide/2)+itemWide);
-                               glVertex2i(r.end.x-(itemWide/2),                 r.end.y-(itemWide/2)+itemWide);
-                       glEnd();
+            float t = ((float)dfp[a]/(float)(range?range:1))*0.5f;
+
+            glUseProgram(textShader);
+                       glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(0.0f, 0.0f, 0.0f, t >= 0 ? 255 * t : 0)));
+            drawRect(vec2(r.end.x-(itemWide/2),                 r.end.y-(itemWide/2)),
+                     vec2(r.end.x-(itemWide/2)+itemWide,r.end.y-(itemWide/2)+itemWide));
 
                        if (!Items.empty() && a < numSlot && Items[a].second) {
-                               glEnable(GL_TEXTURE_2D);
                                glBindTexture(GL_TEXTURE_2D, Items[a].first->tex->image[0]);//itemtex[items[a].id]);
-                               glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)(range?range:1))*0.8f);
-                               glBegin(GL_QUADS);
+                               glUniform4f(textShader_uniform_color, 1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)(range?range:1))*0.8f);
                                if (Items[a].first->dim.y > Items[a].first->dim.x) {
-                                       glTexCoord2i(0,1);glVertex2i(r.end.x-((itemWide/2)*((float)Items[a].first->dim.x/(float)Items[a].first->dim.y)),        r.end.y-(itemWide/2));
-                                       glTexCoord2i(1,1);glVertex2i(r.end.x+((itemWide/2)*((float)Items[a].first->dim.x/(float)Items[a].first->dim.y)),        r.end.y-(itemWide/2));
-                                       glTexCoord2i(1,0);glVertex2i(r.end.x+((itemWide/2)*((float)Items[a].first->dim.x/(float)Items[a].first->dim.y)),        r.end.y+(itemWide/2));
-                                       glTexCoord2i(0,0);glVertex2i(r.end.x-((itemWide/2)*((float)Items[a].first->dim.x/(float)Items[a].first->dim.y)),        r.end.y+(itemWide/2));
-                               }else{
-                                       glTexCoord2i(0,1);glVertex2i(r.end.x-(itemWide/2),r.end.y-(itemWide/2)*((float)Items[a].first->dim.y/(float)Items[a].first->dim.x));
-                                       glTexCoord2i(1,1);glVertex2i(r.end.x+(itemWide/2),r.end.y-(itemWide/2)*((float)Items[a].first->dim.y/(float)Items[a].first->dim.x));
-                                       glTexCoord2i(1,0);glVertex2i(r.end.x+(itemWide/2),r.end.y+(itemWide/2)*((float)Items[a].first->dim.y/(float)Items[a].first->dim.x));
-                                       glTexCoord2i(0,0);glVertex2i(r.end.x-(itemWide/2),r.end.y+(itemWide/2)*((float)Items[a].first->dim.y/(float)Items[a].first->dim.x));
+                                   drawRect(vec2(r.end.x-((itemWide/2)*((float)Items[a].first->dim.x/(float)Items[a].first->dim.y)),   r.end.y-(itemWide/2)),
+                             vec2(r.end.x+((itemWide/2)*((float)Items[a].first->dim.x/(float)Items[a].first->dim.y)),  r.end.y+(itemWide/2)));
+                }else{
+                    drawRect(vec2(r.end.x-(itemWide/2),r.end.y-(itemWide/2)*((float)Items[a].first->dim.y/(float)Items[a].first->dim.x)),
+                             vec2(r.end.x+(itemWide/2),r.end.y+(itemWide/2)*((float)Items[a].first->dim.y/(float)Items[a].first->dim.x)));
                                }
-                               glEnd();
-                               glDisable(GL_TEXTURE_2D);
                                ui::setFontColor(255,255,255,((float)dfp[a]/(float)(range?range:1))*255);
                                ui::putStringCentered(r.end.x,r.end.y-(itemWide*.9),Items[a].first->name);//itemMap[items[a].id]->name);
                                ui::putText(r.end.x-(itemWide/2)+(itemWide*.85),r.end.y-(itemWide/2),"%d",Items[a].second);
                                ui::setFontColor(255,255,255,255);
                        }
-
+            glUseProgram(0);
                        if (sel == a) {
                                static float sc = 1;
                                static bool up;
-                               up ? sc += .0005*deltaTime : sc -= .0005*deltaTime;
+                               up ? sc += .0025*deltaTime : sc -= .0025*deltaTime;
                                if (sc > 1.2) {
                                        up = false;
                                        sc = 1.2;
@@ -509,28 +494,36 @@ void Inventory::draw(void) {
                                        up = true;
                                        sc = 1.0;
                                }
-                               glBegin(GL_QUADS);
-                                       glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)(range?range:1)));
-                                       glVertex2f(r.end.x - (itemWide*sc)/2 - (itemWide*sc)*.09,r.end.y - (itemWide*sc)/2 - (itemWide*sc)*.09);
-                                       glVertex2f(r.end.x + (itemWide*sc)/2 + (itemWide*sc)*.09,r.end.y - (itemWide*sc)/2 - (itemWide*sc)*.09);
-                                       glVertex2f(r.end.x + (itemWide*sc)/2 + (itemWide*sc)*.09,r.end.y - (itemWide*sc)/2);
-                                       glVertex2f(r.end.x - (itemWide*sc)/2 - (itemWide*sc)*.09,r.end.y - (itemWide*sc)/2);
-
-                                       glVertex2f(r.end.x - (itemWide*sc)/2 - (itemWide*sc)*.09,r.end.y + (itemWide*sc)/2 + (itemWide*sc)*.09);
-                                       glVertex2f(r.end.x + (itemWide*sc)/2 + (itemWide*sc)*.09,r.end.y + (itemWide*sc)/2 + (itemWide*sc)*.09);
-                                       glVertex2f(r.end.x + (itemWide*sc)/2 + (itemWide*sc)*.09,r.end.y + (itemWide*sc)/2);
-                                       glVertex2f(r.end.x - (itemWide*sc)/2 - (itemWide*sc)*.09,r.end.y + (itemWide*sc)/2);
-
-                                       glVertex2f(r.end.x - (itemWide*sc)/2 - (itemWide*sc)*.09,r.end.y - (itemWide*sc)/2 - (itemWide*sc)*.09);
-                                       glVertex2f(r.end.x - (itemWide*sc)/2                               ,r.end.y - (itemWide*sc)/2 - (itemWide*sc)*.09);
-                                       glVertex2f(r.end.x - (itemWide*sc)/2                               ,r.end.y + (itemWide*sc)/2 + (itemWide*sc)*.09);
-                                       glVertex2f(r.end.x - (itemWide*sc)/2 - (itemWide*sc)*.09,r.end.y + (itemWide*sc)/2 + (itemWide*sc)*.09);
-
-                                       glVertex2f(r.end.x + (itemWide*sc)/2                                    ,r.end.y - (itemWide*sc)/2 - (itemWide*sc)*.09);
-                                       glVertex2f(r.end.x + (itemWide*sc)/2 + (itemWide*sc)*.09,r.end.y - (itemWide*sc)/2 - (itemWide*sc)*.09);
-                                       glVertex2f(r.end.x + (itemWide*sc)/2 + (itemWide*sc)*.09,r.end.y + (itemWide*sc)/2 + (itemWide*sc)*.09);
-                                       glVertex2f(r.end.x + (itemWide*sc)/2                                    ,r.end.y + (itemWide*sc)/2 + (itemWide*sc)*.09);
-                               glEnd();
+                float t = ((float)dfp[a]/(float)(range?range:1));
+                useShader(&textShader,
+                          &textShader_uniform_texture,
+                          &textShader_attribute_coord,
+                          &textShader_attribute_tex);
+                               
+                glUseProgram(textShader);
+                glUniform4f(textShader_uniform_color, 1.0, 1.0, 1.0, 1.0);
+
+                // bottom
+                glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(255, 255, 255, t >= 0 ? 255 * t : 0)));
+                drawRect(vec2(r.end.x - (itemWide*sc)/2 - (itemWide*sc)*.09,r.end.y - (itemWide*sc)/2 - (itemWide*sc)*.09),
+                         vec2(r.end.x + (itemWide*sc)/2 + (itemWide*sc)*.09,r.end.y - (itemWide*sc)/2));
+                // top
+                glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(255, 255, 255, t  >= 0 ? 255 * t : 0)));
+                drawRect(vec2(r.end.x - (itemWide*sc)/2 - (itemWide*sc)*.09,r.end.y + (itemWide*sc)/2 + (itemWide*sc)*.09),
+                         vec2(r.end.x + (itemWide*sc)/2 + (itemWide*sc)*.09,r.end.y + (itemWide*sc)/2));
+
+                // left
+                glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(255, 255, 255, t >= 0 ? 255 * t : 0)));
+                drawRect(vec2(r.end.x - (itemWide*sc)/2 - (itemWide*sc)*.09,r.end.y - (itemWide*sc)/2 - (itemWide*sc)*.09),
+                         vec2(r.end.x - (itemWide*sc)/2                                   ,r.end.y + (itemWide*sc)/2 + (itemWide*sc)*.09));
+
+                // right
+                glBindTexture(GL_TEXTURE_2D, Texture::genColor(Color(255, 255, 255, t >= 0 ? 255 * t : 0)));
+                drawRect(vec2(r.end.x + (itemWide*sc)/2                                        ,r.end.y - (itemWide*sc)/2 - (itemWide*sc)*.09),
+                         vec2(r.end.x + (itemWide*sc)/2 + (itemWide*sc)*.09,r.end.y + (itemWide*sc)/2 + (itemWide*sc)*.09));
+
+                //glUseProgram(0);
                        }
                        a++;
                }
@@ -627,10 +620,7 @@ void itemDraw(Player *p, Item *d) {
 
        itemLoc.y = p->loc.y+(p->height/3);
        itemLoc.x = p->left?p->loc.x-d->dim.x/2:p->loc.x+p->width-d->dim.x/2;
-       glPushMatrix();
 
-       glUseProgram(shaderProgram);
-       glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
        if (p->left) {
                glTranslatef(itemLoc.x+d->dim.x/2,itemLoc.y,0);
                glRotatef(d->rotation, 0.0f, 0.0f, 1.0f);
@@ -640,26 +630,44 @@ void itemDraw(Player *p, Item *d) {
                glRotatef(d->rotation, 0.0f, 0.0f, 1.0f);
                glTranslatef(-itemLoc.x-d->dim.x/2,-itemLoc.y,0);
        }
-       glEnable(GL_TEXTURE_2D);
+
+    GLfloat itemTex[12] = {0.0, 0.0,
+                           1.0, 0.0,
+                           1.0, 1.0,
+
+                           1.0, 1.0,
+                           0.0, 1.0,
+                           0.0, 0.0};
+    if (!p->left) {
+        itemTex[0] = 1.0;
+        itemTex[2] = 0.0;
+        itemTex[4] = 0.0;
+        itemTex[6] = 0.0;
+        itemTex[8] = 1.0;
+        itemTex[10] = 1.0;
+    }
+
+    GLfloat itemCoords[] = {itemLoc.x,          itemLoc.y,          1.0,
+                            itemLoc.x+d->dim.x, itemLoc.y,          1.0,
+                            itemLoc.x+d->dim.x, itemLoc.y+d->dim.y, 1.0,
+
+                            itemLoc.x+d->dim.x, itemLoc.y+d->dim.y, 1.0,
+                            itemLoc.x,          itemLoc.y+d->dim.y, 1.0,
+                            itemLoc.x,          itemLoc.y,          1.0};
+       glUseProgram(worldShader);
        glBindTexture(GL_TEXTURE_2D,d->tex->image[0]);
-       glColor4ub(255,255,255,255);
-       glBegin(GL_QUADS);
-               if (p->left) {
-                       glTexCoord2i(0,1);glVertex2f(itemLoc.x,                                   itemLoc.y);
-                       glTexCoord2i(1,1);glVertex2f(itemLoc.x+d->dim.x,itemLoc.y);
-                       glTexCoord2i(1,0);glVertex2f(itemLoc.x+d->dim.x,itemLoc.y+d->dim.y);
-                       glTexCoord2i(0,0);glVertex2f(itemLoc.x,                 itemLoc.y+d->dim.y);
-               } else {
-                       glTexCoord2i(1,1);glVertex2f(itemLoc.x,                                   itemLoc.y);
-                       glTexCoord2i(0,1);glVertex2f(itemLoc.x+d->dim.x,itemLoc.y);
-                       glTexCoord2i(0,0);glVertex2f(itemLoc.x+d->dim.x,itemLoc.y+d->dim.y);
-                       glTexCoord2i(1,0);glVertex2f(itemLoc.x,                 itemLoc.y+d->dim.y);
-               }
-       glEnd();
-       glDisable(GL_TEXTURE_2D);
-       glTranslatef(player->loc.x*2,0,0);
-       glPopMatrix();
-       glUseProgram(0);
+
+    glEnableVertexAttribArray(worldShader_attribute_coord);
+    glEnableVertexAttribArray(worldShader_attribute_tex);
+
+    glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, itemCoords);
+    glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, itemTex);
+    glDrawArrays(GL_TRIANGLES, 0, 6);
+
+       glDisableVertexAttribArray(worldShader_attribute_coord);
+    glDisableVertexAttribArray(worldShader_attribute_tex);
+
+    glUseProgram(0);
 }
 
 /*
index 0b58f0dae963e9b386a84449a3603e8e263d674d..dc6da8ea441eef2cb6a8e7c06c2794f1b46cd243 100644 (file)
@@ -324,11 +324,19 @@ namespace ui {
                        c1.x,           c1.y+c2.y-c2.y, 1.0,    //top left
                        c1.x,           c1.y     -c2.y, 1.0,    //bottom left
                };
+        
+        glUniform4f(textShader_uniform_color, 
+                    static_cast<float>(fontColor[0]/255), 
+                    static_cast<float>(fontColor[1]/255), 
+                    static_cast<float>(fontColor[2]/255), 
+                    static_cast<float>(fontColor[3]/255)); 
 
                glVertexAttribPointer(textShader_attribute_coord,       3, GL_FLOAT, GL_FALSE, 0, text_vert);
                glVertexAttribPointer(textShader_attribute_tex,         2, GL_FLOAT, GL_FALSE, 0, tex_coord);
                glDrawArrays(GL_TRIANGLES, 0, 6);
 
+        glUniform4f(textShader_uniform_color, 1.0, 1.0, 1.0, 1.0);
+
                glDisableVertexAttribArray(textShader_attribute_tex);
                glDisableVertexAttribArray(textShader_attribute_coord);
 
index 362cc8b89eb32c2cde37428289e2ac905d07cdac..fb408648fdc1813f1086bc0e03f8e98da178f6e5 100644 (file)
@@ -294,13 +294,13 @@ draw(Player *p)
        glEnd();*/
 
     bgTex(0);
-    GLfloat back_tex_coord[] = {offset.x - backgroundOffset.x - 5, offset.y + backgroundOffset.y, 1.0f,
-                                offset.x + backgroundOffset.x + 5, offset.y + backgroundOffset.y, 1.0f,
-                                offset.x + backgroundOffset.x + 5, offset.y - backgroundOffset.y, 1.0f,
+    GLfloat back_tex_coord[] = {offset.x - backgroundOffset.x - 5, offset.y + backgroundOffset.y, 10.0f,
+                                offset.x + backgroundOffset.x + 5, offset.y + backgroundOffset.y, 10.0f,
+                                offset.x + backgroundOffset.x + 5, offset.y - backgroundOffset.y, 10.0f,
 
-                                offset.x + backgroundOffset.x + 5, offset.y - backgroundOffset.y, 1.0f,
-                                offset.x - backgroundOffset.x - 5, offset.y - backgroundOffset.y, 1.0f,
-                                offset.x - backgroundOffset.x - 5, offset.y + backgroundOffset.y, 1.0f};
+                                offset.x + backgroundOffset.x + 5, offset.y - backgroundOffset.y, 10.0f,
+                                offset.x - backgroundOffset.x - 5, offset.y - backgroundOffset.y, 10.0f,
+                                offset.x - backgroundOffset.x - 5, offset.y + backgroundOffset.y, 10.0f};
 
     glUseProgram(worldShader);
 
@@ -350,13 +350,13 @@ draw(Player *p)
        //safeSetColorA(150 + shadeBackground * 2, 150 + shadeBackground * 2, 150 + shadeBackground * 2, 255);
     auto xcoord = width / 2 * -1 + offset.x * 0.85f;
        for (unsigned int i = 0; i <= worldData.size() * HLINE / 1920; i++) {
-        bg_items.push_back(vec3(1920 * i       + xcoord, GROUND_HEIGHT_MINIMUM, 1.0f));
-        bg_items.push_back(vec3(1920 * (i + 1) + xcoord, GROUND_HEIGHT_MINIMUM, 1.0f));
-        bg_items.push_back(vec3(1920 * (i + 1) + xcoord, GROUND_HEIGHT_MINIMUM + 1080, 1.0f));
+        bg_items.push_back(vec3(1920 * i       + xcoord, GROUND_HEIGHT_MINIMUM, 8.0f));
+        bg_items.push_back(vec3(1920 * (i + 1) + xcoord, GROUND_HEIGHT_MINIMUM, 8.0f));
+        bg_items.push_back(vec3(1920 * (i + 1) + xcoord, GROUND_HEIGHT_MINIMUM + 1080, 8.0f));
 
-        bg_items.push_back(vec3(1920 * (i + 1) + xcoord, GROUND_HEIGHT_MINIMUM + 1080, 1.0f));
-        bg_items.push_back(vec3(1920 * i       + xcoord, GROUND_HEIGHT_MINIMUM + 1080, 1.0f));
-        bg_items.push_back(vec3(1920 * i       + xcoord, GROUND_HEIGHT_MINIMUM, 1.0f));
+        bg_items.push_back(vec3(1920 * (i + 1) + xcoord, GROUND_HEIGHT_MINIMUM + 1080, 8.0f));
+        bg_items.push_back(vec3(1920 * i       + xcoord, GROUND_HEIGHT_MINIMUM + 1080, 8.0f));
+        bg_items.push_back(vec3(1920 * i       + xcoord, GROUND_HEIGHT_MINIMUM, 8.0f));
        }
 
     std::vector<GLfloat> bg_i;
@@ -401,13 +401,13 @@ draw(Player *p)
                   );*/
         auto xcoord = offset.x * bgDraw[i][2];
                for (int j = worldStart; j <= -worldStart; j += 600) {
-            c.push_back(vec3(j       + xcoord, GROUND_HEIGHT_MINIMUM, 1));
-            c.push_back(vec3(j + 600 + xcoord, GROUND_HEIGHT_MINIMUM, 1));
-            c.push_back(vec3(j + 600 + xcoord, GROUND_HEIGHT_MINIMUM + 400, 1));
+            c.push_back(vec3(j       + xcoord, GROUND_HEIGHT_MINIMUM, 7-(i*.1)));
+            c.push_back(vec3(j + 600 + xcoord, GROUND_HEIGHT_MINIMUM, 7-(i*.1)));
+            c.push_back(vec3(j + 600 + xcoord, GROUND_HEIGHT_MINIMUM + 400, 7-(i*.1)));
 
-            c.push_back(vec3(j + 600 + xcoord, GROUND_HEIGHT_MINIMUM + 400, 1));
-            c.push_back(vec3(j       + xcoord, GROUND_HEIGHT_MINIMUM + 400, 1));
-            c.push_back(vec3(j       + xcoord, GROUND_HEIGHT_MINIMUM, 1));
+            c.push_back(vec3(j + 600 + xcoord, GROUND_HEIGHT_MINIMUM + 400, 7-(i*.1)));
+            c.push_back(vec3(j       + xcoord, GROUND_HEIGHT_MINIMUM + 400, 7-(i*.1)));
+            c.push_back(vec3(j       + xcoord, GROUND_HEIGHT_MINIMUM, 7-(i*.1)));
                }
 
         bg_i.clear();
@@ -455,24 +455,12 @@ draw(Player *p)
     glEnableVertexAttribArray(worldShader_attribute_coord);
     glEnableVertexAttribArray(worldShader_attribute_tex);
 
-    std::vector<std::vector<std::pair<vec2, vec3>>> partv(0);
     std::vector<GLfloat> partc(0);
     std::vector<GLfloat> partt(0);
 
     for (auto &p : particles) {
         if (p.behind)
-            partv.push_back(p.draw());
-    }
-
-    for (auto &pv : partv) {
-        for (auto &v : pv){
-            partc.push_back(v.second.x);
-            partc.push_back(v.second.y);
-            partc.push_back(v.second.z);
-            
-            partt.push_back(v.first.x);
-            partt.push_back(v.first.y);
-        }
+            p.draw(partc, partt);
     }
 
     glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, &partc[0]);
@@ -714,24 +702,12 @@ draw(Player *p)
     glEnableVertexAttribArray(worldShader_attribute_coord);
     glEnableVertexAttribArray(worldShader_attribute_tex);
 
-    partv.clear();
     partc.clear();
     partt.clear();
 
     for (auto &p : particles) {
         if (!p.behind)
-            partv.push_back(p.draw());
-    }
-
-    for (auto &pv : partv) {
-        for (auto &v : pv){
-            partc.push_back(v.second.x);
-            partc.push_back(v.second.y);
-            partc.push_back(v.second.z);
-            
-            partt.push_back(v.first.x);
-            partt.push_back(v.first.y);
-        }
+            p.draw(partc, partt);
     }
 
     glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, &partc[0]);
@@ -1750,7 +1726,7 @@ draw(Player *p)
     glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
     glUseProgram(shaderProgram);
 
-    std::for_each(particles.begin(), particles.end(), [](Particles &part) { part.draw(); });
+    //std::for_each(particles.begin(), particles.end(), [](Particles &part) { part.draw(); });
 
     glUseProgram(0);
 
diff --git a/ttf/atomics.TTF b/ttf/atomics.TTF
new file mode 100644 (file)
index 0000000..44c2753
Binary files /dev/null and b/ttf/atomics.TTF differ
diff --git a/ttf/atomicsc.TTF b/ttf/atomicsc.TTF
new file mode 100644 (file)
index 0000000..c346518
Binary files /dev/null and b/ttf/atomicsc.TTF differ
diff --git a/ttf/yapix.ttf b/ttf/yapix.ttf
new file mode 100644 (file)
index 0000000..692718a
Binary files /dev/null and b/ttf/yapix.ttf differ
index d848847354d9cc53616309b0d5de1dad0f5b6323..3a831ce11e388b1ee0b21fe9120c10868a9cf0e9 100644 (file)
@@ -7,7 +7,7 @@
 
        <hill peakx="0" peaky="1000" width="50" />
 
-       <rabbit x="300" aggressive="true" health="100" />
+       <rabbit x="300" aggressive="false" health="100" />
        <bird y="500"/>
        <cat />
 
@@ -71,13 +71,13 @@ And it wasn't stormy.
        </text>
 
        <text id="1" nextid="1" pause="true" >
-               Broooooooooooooo...
+        Broooooooooooooo...
        </text>
 </Dialog>
 
 <Dialog name="Big Dave">
        <text id="0" pause="true">
-               Here have this sword!
+        Hey friend! It's dangerous out there, here take these!
                <give id="Wood Sword" count="1"/>
                <give id="Hunters Bow" count="1"/>
                <give id="Crude Arrow" count="110"/>