]> Dogcows Code - chaz/yoink/blobdiff - src/Scene.cc
converted image management to resource handles
[chaz/yoink] / src / Scene.cc
index 2d8f12025d3c8fd119d99d86e58368f03793a876..c756ec89c296decd840baaa14eeb67ce2f8ff50c 100644 (file)
@@ -20,7 +20,7 @@
 #include <moof/math.hh>
 #include <moof/script.hh>
 #include <moof/settings.hh>
-#include <moof/texture.hh>
+#include <moof/sprite.hh>
 
 #include "Character.hh"
 #include "Scene.hh"
@@ -41,7 +41,7 @@ struct Scene::impl : public moof::manager<impl>
                Quad(const moof::vector3* vertices[4],
                         const std::string& texture,
                         int tileIndex) :
-                       mTilemap(texture),
+                       mTilemap(texture, tileIndex),
                        mBlending(false),
                        mFog(false),
                        mSurface(NONE)
@@ -55,17 +55,6 @@ struct Scene::impl : public moof::manager<impl>
                                //}
                        }
 
-                       if (!mTilemap.tile_coordinates(tileIndex, mTexCoords))
-                       {
-                               moof::log_warning << "no index " << tileIndex <<
-                                       " in texture " << texture << std::endl;
-
-                               mTexCoords[0] = mTexCoords[1] =
-                                       mTexCoords[3] = mTexCoords[6] = 0.0;
-                               mTexCoords[2] = mTexCoords[4] =
-                                       mTexCoords[5] = mTexCoords[7] = 1.0;
-                       }
-
                        aabb_.enclose_vertices(mVertices, 4);
                        sphere_.point = aabb_.center();
                        sphere_.radius = (aabb_.min - sphere_.point).length();
@@ -106,12 +95,7 @@ struct Scene::impl : public moof::manager<impl>
                        }
 
                        //glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-                       mTilemap.bind();
-
-                       glVertexPointer(3, GL_SCALAR, 0, mVertices[0].data());
-                       glTexCoordPointer(2, GL_SCALAR, 0, mTexCoords);
-
-                       glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+                       mTilemap.draw(mVertices);
 
                        glDisable(GL_BLEND);
                        glDisable(GL_FOG);
@@ -123,10 +107,9 @@ struct Scene::impl : public moof::manager<impl>
                }
 
 
-               moof::vector3           mVertices[4];
-               moof::scalar            mTexCoords[8];
+               moof::vector3   mVertices[4];
                
-               moof::texture           mTilemap;
+               moof::sprite    mTilemap;
 
                bool                    mBlending;
                bool                    mFog;
@@ -135,8 +118,8 @@ struct Scene::impl : public moof::manager<impl>
 
 
 
-       moof::matrix4                           mTransform;
-       std::string                             mTexture;
+       moof::matrix4           mTransform;
+       std::string                     mTexture;
 
        std::list< boost::shared_ptr<impl::Quad> >      mObjects;
        std::list<moof::line2>                                          mLines;
@@ -348,7 +331,7 @@ struct Scene::impl : public moof::manager<impl>
                                vertices[h][wPlus1] = moof::demote(mTransform *
                                                moof::vector4(wPlus1, h, 0.0, 1.0));
 
-                               if (index == moof::texture::no_tile) continue;
+                               if (index == moof::image::no_tile) continue;
 
                                const moof::vector3* corners[4] = {
                                        &vertices[h][w],
This page took 0.023158 seconds and 4 git commands to generate.