#include <math.h>
#include <assert.h>
#include "texture.h"
+#include "datamap.h"
#include "image.h"
#include "opengl.h"
#include "imago2.h"
+#include "logger.h"
static int glifmt_from_ifmt(unsigned int ifmt);
static int glfmt_from_ifmt(unsigned int ifmt);
void Texture::create(int xsz, int ysz, TextureType textype, unsigned int ifmt)
{
if(textype == TEX_CUBE && xsz != ysz) {
- fprintf(stderr, "trying to create cubemap with different width and height (%dx%d)\n", xsz, ysz);
+ error_log("trying to create cubemap with different width and height (%dx%d)\n", xsz, ysz);
return;
}
pixels += 4;
}
}
- default_img->save("/tmp/foo.png");
}
switch(type) {
{
Image img;
if(!img.load(fname)) {
- fprintf(stderr, "failed to load 2D texture: %s\n", fname);
+ error_log("failed to load 2D texture: %s\n", fname);
return false;
}
set_image(img);
- printf("loaded 2D texture: %s\n", fname);
+ info_log("loaded 2D texture: %s\n", fname);
return true;
}
bool TextureSet::load_tex(Texture *tex, const char *fname)
{
+ char *pathbuf;
+ int nsize = datamap_path_size(fname);
+ if(nsize) {
+ pathbuf = (char*)alloca(nsize);
+ datamap_lookup(fname, pathbuf, nsize);
+ } else {
+ pathbuf = (char*)fname;
+ }
+
Image *img = new Image;
- if(!img->load(fname)) {
+ if(!img->load(pathbuf)) {
delete img;
return false;
}