Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_texture.c
| Show All 15 Lines | |||||
| * The Original Code is Copyright (C) 2005 Blender Foundation. | * The Original Code is Copyright (C) 2005 Blender Foundation. | ||||
| * All rights reserved. | * All rights reserved. | ||||
| */ | */ | ||||
| /** \file | /** \file | ||||
| * \ingroup gpu | * \ingroup gpu | ||||
| */ | */ | ||||
| #include <string.h> | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_image_types.h" | #include "DNA_image_types.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_math_base.h" | #include "BLI_math_base.h" | ||||
| ▲ Show 20 Lines • Show All 1,398 Lines • ▼ Show 20 Lines | else { | ||||
| glGetTexImage(tex->target, miplvl, data_format, data_type, buf); | glGetTexImage(tex->target, miplvl, data_format, data_type, buf); | ||||
| } | } | ||||
| glBindTexture(tex->target, 0); | glBindTexture(tex->target, 0); | ||||
| return buf; | return buf; | ||||
| } | } | ||||
| void GPU_texture_clear(GPUTexture *tex, eGPUDataFormat gpu_data_format, const void *color) | |||||
| { | |||||
| if (GLEW_ARB_clear_texture) { | |||||
| GLenum data_format = gpu_get_gl_dataformat(tex->format, &tex->format_flag); | |||||
| GLenum data_type = gpu_get_gl_datatype(gpu_data_format); | |||||
| glClearTexImage(tex->bindcode, 0, data_format, data_type, color); | |||||
| } | |||||
| else { | |||||
| size_t buffer_len = gpu_texture_memory_footprint_compute(tex); | |||||
| unsigned char *pixels = MEM_mallocN(buffer_len, __func__); | |||||
| if (color) { | |||||
| size_t bytesize = tex->bytesize; | |||||
| for (size_t byte = 0; byte < buffer_len; byte += bytesize) { | |||||
| memset(&pixels[byte], color, bytesize); | |||||
| } | |||||
| } | |||||
| else { | |||||
| memset(pixels, 0, buffer_len); | |||||
| } | |||||
| GPU_texture_update(tex, gpu_data_format, pixels); | |||||
| MEM_freeN(pixels); | |||||
| } | |||||
| } | |||||
| void GPU_texture_update(GPUTexture *tex, eGPUDataFormat data_format, const void *pixels) | void GPU_texture_update(GPUTexture *tex, eGPUDataFormat data_format, const void *pixels) | ||||
| { | { | ||||
| GPU_texture_update_sub(tex, data_format, pixels, 0, 0, 0, tex->w, tex->h, tex->d); | GPU_texture_update_sub(tex, data_format, pixels, 0, 0, 0, tex->w, tex->h, tex->d); | ||||
| } | } | ||||
| void GPU_invalid_tex_init(void) | void GPU_invalid_tex_init(void) | ||||
| { | { | ||||
| memory_usage = 0; | memory_usage = 0; | ||||
| ▲ Show 20 Lines • Show All 355 Lines • Show Last 20 Lines | |||||