예제 #1
0
파일: tex.c 프로젝트: chc4/IntenseLogic
void ilG_tex_loadimage(ilG_tex *self, struct ilA_img *img)
{
    GLenum format, internalformat, type;

    format = getImgFormat(img);
    type = getImgType(img);
    internalformat = getImgIFormat(img);
    ilG_tex_loaddata(self, GL_TEXTURE_2D, internalformat, img->width, img->height, 1, format, type, img->data);
}
예제 #2
0
void ilG_tex_loadimage(ilG_tex *tex, struct ilA_img img)
{
    GLenum format, internalformat, type;

    format = getImgFormat(&img);
    type = getImgType(&img);
    internalformat = getImgIFormat(&img);
    ilG_tex_loaddata(tex, GL_TEXTURE_2D, internalformat,
                     img.width, img.height, 1,
                     format, type, img.data);
}
예제 #3
0
파일: tex.c 프로젝트: chc4/IntenseLogic
static void tex_cube_build(ilG_tex *self, struct ilG_context *context)
{
    (void)context;
    ilA_img **faces = self->data;
    static const GLenum targets[6] = {
        GL_TEXTURE_CUBE_MAP_POSITIVE_X,
        GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
        GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
        GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
        GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
        GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
    };

    glGenTextures(1, &self->object);
    glBindTexture(GL_TEXTURE_CUBE_MAP, self->object);
    for (unsigned i = 0; i < 6; i++) {
        glTexImage2D(targets[i], 0, getImgIFormat(faces[i]), faces[i]->width, 
                     faces[i]->height, 0, getImgFormat(faces[i]), 
                     getImgType(faces[i]), faces[i]->data);
    }
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
예제 #4
0
void ilG_tex_loadcube(ilG_tex *tex, struct ilA_img faces[6])
{
    static const GLenum targets[6] = {
        GL_TEXTURE_CUBE_MAP_POSITIVE_X,
        GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
        GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
        GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
        GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
        GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
    };

    tex->target = GL_TEXTURE_CUBE_MAP;
    glGenTextures(1, &tex->object);
    glBindTexture(GL_TEXTURE_CUBE_MAP, tex->object);
    for (unsigned i = 0; i < 6; i++) {
        glTexImage2D(targets[i], 0, getImgIFormat(&faces[i]),
                     faces[i].width, faces[i].height, 0,
                     getImgFormat(&faces[i]),
                     getImgType(&faces[i]), faces[i].data);
        ilA_img_free(faces[i]);
    }
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}