Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-06-11 23:30:59 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-06-11 23:30:59 +0300
commit8242a5bc853a74da1273fc7ad4b959ac716c563c (patch)
tree82f930c68a2dd6b665e775a98685e6fcae5d662d /source/blender/gpu/intern/gpu_texture.c
parent0054dff67eb5262aabb1a0ee1f70641859044e65 (diff)
Cleanup: remove image->bindcode, always wrap in GPUTexture.
Diffstat (limited to 'source/blender/gpu/intern/gpu_texture.c')
-rw-r--r--source/blender/gpu/intern/gpu_texture.c29
1 files changed, 3 insertions, 26 deletions
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index aac75014b3e..4bb26128aa2 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -79,7 +79,6 @@ struct GPUTexture {
GLenum target_base; /* same as target, (but no multisample)
* use it for unbinding */
GLuint bindcode; /* opengl identifier for texture */
- int fromblender; /* we got the texture from Blender */
GPUTextureFormat format;
GPUTextureFormatFlag format_flag;
@@ -673,42 +672,24 @@ GPUTexture *GPU_texture_create_buffer(GPUTextureFormat data_type, const GLuint b
return tex;
}
-GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget, bool is_data, double UNUSED(time), int mipmap)
+GPUTexture *GPU_texture_from_bindcode(int textarget, int bindcode)
{
- int gputt;
- /* this binds a texture, so that's why to restore it to 0 */
- GLint bindcode = GPU_verify_image(ima, iuser, textarget, 0, mipmap, is_data);
-
/* see GPUInput::textarget: it can take two values - GL_TEXTURE_2D and GL_TEXTURE_CUBE_MAP
* these values are correct for glDisable, so textarget can be safely used in
* GPU_texture_bind/GPU_texture_unbind through tex->target_base */
/* (is any of this obsolete now that we don't glEnable/Disable textures?) */
- if (textarget == GL_TEXTURE_2D)
- gputt = TEXTARGET_TEXTURE_2D;
- else
- gputt = TEXTARGET_TEXTURE_CUBE_MAP;
-
- if (ima->gputexture[gputt]) {
- ima->gputexture[gputt]->bindcode = bindcode;
- glBindTexture(textarget, 0);
- return ima->gputexture[gputt];
- }
-
GPUTexture *tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture");
tex->bindcode = bindcode;
tex->number = -1;
tex->refcount = 1;
tex->target = textarget;
tex->target_base = textarget;
- tex->fromblender = 1;
tex->format = -1;
tex->components = -1;
tex->samples = 0;
- ima->gputexture[gputt] = tex;
-
if (!glIsTexture(tex->bindcode)) {
- GPU_print_error_debug("Blender Texture Not Loaded");
+ GPU_print_error_debug("Invalid bindcode in GPU_texture_from_bindcode");
}
else {
GLint w, h;
@@ -725,10 +706,9 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget
glGetTexLevelParameteriv(gettarget, 0, GL_TEXTURE_HEIGHT, &h);
tex->w = w;
tex->h = h;
+ glBindTexture(textarget, 0);
}
- glBindTexture(textarget, 0);
-
return tex;
}
@@ -1090,9 +1070,6 @@ void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat)
static void gpu_texture_delete(GPUTexture *tex)
{
- if (tex->bindcode && !tex->fromblender)
- glDeleteTextures(1, &tex->bindcode);
-
gpu_texture_memory_footprint_remove(tex);
MEM_freeN(tex);