#include #include typedef struct { GLint texture_wrap_s; GLint texture_wrap_t; GLint texture_min_filter; GLint texture_max_filter; gboolean generate_mipmap; GLuint texture_id; } ShimattaOpenglTexturePrivate; G_DEFINE_TYPE_WITH_PRIVATE(ShimattaOpenglTexture, shimatta_opengl_texture, G_TYPE_OBJECT); static int shimatta_opengl_texure_use_default_impl(ShimattaOpenglTexture *texture, unsigned int slot, gboolean use_slot) { ShimattaOpenglTexturePrivate *priv; g_return_val_if_fail(SHIMATTA_IS_OPENGL_TEXTURE(texture), -1001); priv = shimatta_opengl_texture_get_instance_private(texture); if (use_slot) { if (slot > 31) return -1002; else glActiveTexture(GL_TEXTURE0+slot); } glBindTexture(GL_TEXTURE_2D, priv->texture_id); return 0; } static int use_in_slot_default(ShimattaOpenglTexture *texture, unsigned int slot) { return shimatta_opengl_texure_use_default_impl(texture, slot, TRUE); } static void use_default(ShimattaOpenglTexture *texture) { (void)shimatta_opengl_texure_use_default_impl(texture, 0U, FALSE); } static void shimatta_opengl_texture_class_init(ShimattaOpenglTextureClass *klass) { } static void shimatta_opengl_texture_init(ShimattaOpenglTexture *self) { ShimattaOpenglTexturePrivate *priv; priv = shimatta_opengl_texture_get_instance_private(self); priv->texture_id = 0; priv->texture_wrap_s = GL_REPEAT; priv->texture_wrap_s = GL_REPEAT; priv->texture_min_filter = GL_LINEAR; priv->texture_max_filter = GL_LINEAR; priv->generate_mipmap = TRUE; glGenTextures(1, &priv->texture_id); glBindTexture(GL_TEXTURE_2D, priv->texture_id); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } void shimatta_opengl_texture_use(ShimattaOpenglTexture *texture) { ShimattaOpenglTextureClass *klass; g_return_if_fail(SHIMATTA_IS_OPENGL_TEXTURE(texture)); klass = SHIMATTA_OPENGL_TEXTURE_GET_CLASS(texture); klass->use(texture); } int shimatta_opengl_texture_use_in_slot(ShimattaOpenglTexture *texture, unsigned int slot) { ShimattaOpenglTextureClass *klass; g_return_val_if_fail(SHIMATTA_IS_OPENGL_TEXTURE(texture), -1001); klass = SHIMATTA_OPENGL_TEXTURE_GET_CLASS(texture); return klass->use_in_slot(texture, slot); } ShimattaOpenglTexture *shimatta_opengl_texture_new() { } void shimatta_opengl_texture_set_filter(ShimattaOpenglTexture *texture, int filter_s, int filter_t) { ShimattaOpenglTexturePrivate *priv; g_return_if_fail(SHIMATTA_IS_OPENGL_TEXTURE(texture)); priv = shimatta_opengl_texture_get_instance_private(texture); } void shimatta_opengl_texture_set_wrap(ShimattaOpenglTexture *texture, int wrap_s, int wrap_t) { } void shimatta_opengl_texture_set_gen_mipmap(ShimattaOpenglTexture *texture, gboolean gen_mipmap) { } int shimatta_opengl_texture_get_filter(ShimattaOpenglTexture *texture, int *filter_s, int *filter_t) { } int shimatta_opengl_texture_get_wrap(ShimattaOpenglTexture *texture, int *filter_s, int *filter_t) { } gboolean shimatta_opengl_texture_get_gen_mipmap(ShimattaOpenglTexture *texture) { } int shimatta_opengl_texture_set_data(ShimattaOpenglTexture *texture, unsigned int width, unsigned int height, GLenum format, void *buffer) { ShimattaOpenglTexturePrivate *priv; g_return_val_if_fail(SHIMATTA_IS_OPENGL_TEXTURE(texture), -1001); priv = shimatta_opengl_texture_get_instance_private(texture); return 0; } int shimatta_opengl_texture_set_from_image(ShimattaOpenglTexture *texture, const char *path) { ShimattaOpenglTexturePrivate *priv; g_return_val_if_fail(SHIMATTA_IS_OPENGL_TEXTURE(texture), -1001); priv = shimatta_opengl_texture_get_instance_private(texture); return 0; }