示例#1
0
文件: texture.c 项目: mdtrooper/goxel
texture_t *texture_new_surface(int w, int h, int flags)
{
    texture_t *tex;
    tex = calloc(1, sizeof(*tex));
    tex->tex_w = next_pow2(w);
    tex->tex_h = next_pow2(h);
    tex->w = w;
    tex->h = h;
    tex->flags = flags | TF_HAS_TEX;
    tex->format = (flags & TF_RGB) ? GL_RGB : GL_RGBA;
    texture_create_empty(tex);
    tex->ref = 1;
    return tex;
}
示例#2
0
文件: texture.c 项目: fordream/goxel
texture_t *texture_new_buffer(int w, int h, int flags)
{
    texture_t *tex;
    tex = calloc(1, sizeof(*tex));
    tex->format = (flags & TF_RGB) ? GL_RGB : GL_RGBA;
    tex->tex_w = next_pow2(w);
    tex->tex_h = next_pow2(h);
    tex->w = w;
    tex->h = h;
    tex->flags = flags | TF_HAS_FB | TF_HAS_TEX;
    texture_create_empty(tex);
    generate_framebuffer(tex);
    tex->ref = 1;
    LL_APPEND(g_textures, tex);
    return tex;
}
示例#3
0
文件: texture.c 项目: mdtrooper/goxel
texture_t *texture_new_from_buf(const uint8_t *data,
                                int w, int h, int bpp, int flags)
{
    texture_t *tex;
    tex = calloc(1, sizeof(*tex));
    tex->tex_w = next_pow2(w);
    tex->tex_h = next_pow2(h);
    tex->w = w;
    tex->h = h;
    tex->flags = TF_HAS_TEX | flags;
    tex->format = (int[]){0, 0, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA}[bpp];
    texture_create_empty(tex);
    texture_set_data(tex, data, w, h, bpp);
    tex->ref = 1;
    return tex;
}
示例#4
0
文件: texture.c 项目: fordream/goxel
texture_t *texture_new_image(const char *path)
{
    texture_t *tex;
    uint8_t *img;
    int w, h, bpp = 0;
    img = img_read(path, &w, &h, &bpp);
    tex = calloc(1, sizeof(*tex));
    tex->path = strdup(path);
    tex->tex_w = next_pow2(w);
    tex->tex_h = next_pow2(h);
    tex->w = w;
    tex->h = h;
    tex->flags = TF_HAS_TEX;
    tex->format = (int[]){0, 0, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA}[bpp];
    texture_create_empty(tex);
    texture_set_data(tex, img, w, h, bpp);
    free(img);
    tex->ref = 1;
    LL_APPEND(g_textures, tex);
    return tex;
}
示例#5
0
文件: texture.c 项目: mdtrooper/goxel
texture_t *texture_new_image(const char *path, int flags)
{
    texture_t *tex;
    uint8_t *img;
    int w, h, bpp = 0;
    img = img_read(path, &w, &h, &bpp);
    if (!img) {
        LOG_W("Cannot open image '%s'", path);
        return NULL;
    }
    tex = calloc(1, sizeof(*tex));
    tex->path = strdup(path);
    tex->tex_w = next_pow2(w);
    tex->tex_h = next_pow2(h);
    tex->w = w;
    tex->h = h;
    tex->flags = TF_HAS_TEX | flags;
    tex->format = (int[]){0, 0, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA}[bpp];
    texture_create_empty(tex);
    texture_set_data(tex, img, w, h, bpp);
    free(img);
    tex->ref = 1;
    return tex;
}