GPU Texture: Use switch instead of if/else
This commit is contained in:
		@@ -722,17 +722,20 @@ void GPU_texture_update(GPUTexture *tex, const float *pixels)
 | 
			
		||||
 | 
			
		||||
	glBindTexture(tex->target, tex->bindcode);
 | 
			
		||||
 | 
			
		||||
	if (tex->target == GL_TEXTURE_2D ||
 | 
			
		||||
	    tex->target == GL_TEXTURE_2D_MULTISAMPLE ||
 | 
			
		||||
	    tex->target == GL_TEXTURE_1D_ARRAY)
 | 
			
		||||
	{
 | 
			
		||||
		glTexSubImage2D(tex->target, 0, 0, 0, tex->w, tex->h, format, data_format, pixels);
 | 
			
		||||
	}
 | 
			
		||||
	else if (tex->target == GL_TEXTURE_1D) {
 | 
			
		||||
		glTexSubImage1D(tex->target, 0, 0, tex->w, format, data_format, pixels);
 | 
			
		||||
	}
 | 
			
		||||
	else { /* GL_TEXTURE_3D */
 | 
			
		||||
		glTexSubImage3D(tex->target, 0, 0, 0, 0, tex->w, tex->h, tex->d, format, data_format, pixels);
 | 
			
		||||
	switch (tex->target) {
 | 
			
		||||
		case GL_TEXTURE_2D:
 | 
			
		||||
		case GL_TEXTURE_2D_MULTISAMPLE:
 | 
			
		||||
		case GL_TEXTURE_1D_ARRAY:
 | 
			
		||||
			glTexSubImage2D(tex->target, 0, 0, 0, tex->w, tex->h, format, data_format, pixels);
 | 
			
		||||
			break;
 | 
			
		||||
		case GL_TEXTURE_1D:
 | 
			
		||||
			glTexSubImage1D(tex->target, 0, 0, tex->w, format, data_format, pixels);
 | 
			
		||||
			break;
 | 
			
		||||
		case GL_TEXTURE_3D:
 | 
			
		||||
			glTexSubImage3D(tex->target, 0, 0, 0, 0, tex->w, tex->h, tex->d, format, data_format, pixels);
 | 
			
		||||
			break;
 | 
			
		||||
		default:
 | 
			
		||||
			BLI_assert(!"tex->target mode not supported");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	glBindTexture(tex->target, 0);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user