]> Dogcows Code - chaz/yoink/blobdiff - src/moof/image.cc
further implementing runloop support
[chaz/yoink] / src / moof / image.cc
index abe1677095c9bb12df0fb55826a1c35a143441bf..94d468727107a5e45e8b9fcabb8a73e6344fa2ca 100644 (file)
@@ -27,6 +27,8 @@
 namespace moof {
 
 
+MOOF_REGISTER_RESOURCE(image, png, textures);
+
 //static int power_of_two(int input)
 //{
        //int value = 1;
@@ -51,7 +53,7 @@ image::image(const std::string& path) :
        tile_width_(1),
        tile_height_(1)
 {
-       FILE* fp = resource::open_file(path);
+       FILE* fp = fopen(path.c_str(), "rb");
        if (!fp) throw std::runtime_error("image not found at " + path);
 
        png_byte        signature[8];
@@ -133,7 +135,7 @@ image::image(const std::string& path) :
        rows = new png_bytep[height_];
        for (int i = 0; i < height_; ++i)
        {
-               rows[i] = (png_bytep)(pixels_ + i * channels_ * width_);
+               rows[height_-1-i] = (png_bytep)(pixels_ + i * channels_ * width_);
        }
 
        png_read_image(pngObj, rows);
@@ -299,10 +301,10 @@ void image::context_recreated()
  */
 void image::set_properties() const
 {
-       //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter_);
-       //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter_);
-       //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s_);
-       //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_t_);
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter_);
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter_);
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s_);
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_t_);
 }
 
 
@@ -338,27 +340,13 @@ void image::set_texture_info(const std::string& info)
                globals.get(mag_filter_, "mag_filter");
                globals.get(wrap_s_, "wrap_s");
                globals.get(wrap_t_, "wrap_t");
+               //min_filter_ = GL_LINEAR;
+               //mag_filter_ = GL_LINEAR;
+               //wrap_s_ = GL_CLAMP;
+               //wrap_t_ = GL_CLAMP;
        }
 }
 
 
-class image_resource_loader
-{
-public:
-       
-       image_resource_loader()
-       {
-               resource::register_type<image>("png");
-       }
-
-       ~image_resource_loader()
-       {
-               resource::unregister_type("png");
-       }
-};
-
-static image_resource_loader loader;
-
-
 } // namespace moof
 
This page took 0.02027 seconds and 4 git commands to generate.