+struct texture_attributes
+{
+ texture_attributes() :
+ min_filter(GL_NEAREST),
+ mag_filter(GL_NEAREST),
+ tile_s(1),
+ tile_t(1),
+ wrap_s(GL_CLAMP_TO_EDGE),
+ wrap_t(GL_CLAMP_TO_EDGE) {}
+
+ void init(const std::string& info)
+ {
+ script script;
+ log::import(script);
+
+ script::slot g = script.globals();
+#define EXPORT_CONSTANT(K) g.set_field(#K, GL_##K)
+ EXPORT_CONSTANT(CLAMP);
+ EXPORT_CONSTANT(CLAMP_TO_EDGE);
+ EXPORT_CONSTANT(REPEAT);
+ EXPORT_CONSTANT(LINEAR);
+ EXPORT_CONSTANT(NEAREST);
+ EXPORT_CONSTANT(LINEAR_MIPMAP_LINEAR);
+ EXPORT_CONSTANT(LINEAR_MIPMAP_NEAREST);
+ EXPORT_CONSTANT(NEAREST_MIPMAP_LINEAR);
+ EXPORT_CONSTANT(NEAREST_MIPMAP_NEAREST);
+#undef export_constant
+
+ if (script.do_string(info) != script::success)
+ {
+ std::string str;
+ script[-1].get(str);
+ log_warning(str);
+ }
+ else
+ {
+ log_info("loading texture information...");
+
+ script::slot globals = script.globals();
+ globals.get(min_filter, "min_filter");
+ globals.get(mag_filter, "mag_filter");
+ globals.get(tile_s, "tile_s");
+ globals.get(tile_t, "tile_t");
+ globals.get(wrap_s, "wrap_s");
+ globals.get(wrap_t, "wrap_t");
+ }
+ }
+
+ GLuint min_filter;
+ GLuint mag_filter;
+ int tile_s;
+ int tile_t;
+ GLuint wrap_s;
+ GLuint wrap_t;
+};
+
+
+static SDL_Surface* load_png(const std::string& path, texture_attributes& attribs)