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:
authorMike Erwin <significant.bit@gmail.com>2015-12-08 09:19:08 +0300
committerMike Erwin <significant.bit@gmail.com>2015-12-08 09:19:55 +0300
commit6006173f4adb44cefd6fb92e451aef19d69d0ea7 (patch)
treee86ed139119ff727b955fd926516fbb38a11a9f3 /source/blender/gpu
parentc013d64a0a2dd1455111d5080fd968561fdad8d0 (diff)
OpenGL: use sized texture internal formats
Maybe this is pedantic but I read it’s best to explicitly set the desired component size. Also append “_ARB” to float texture formats since those need an extension in GL 2.1.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/intern/gpu_draw.c8
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c12
2 files changed, 11 insertions, 9 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index d35536f04b9..719dc53f9fe 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -755,12 +755,12 @@ void GPU_create_gl_tex(unsigned int *bind, unsigned int *rect, float *frect, int
if (use_high_bit_depth) {
if (GLEW_ARB_texture_float)
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
}
else
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
@@ -786,12 +786,12 @@ void GPU_create_gl_tex(unsigned int *bind, unsigned int *rect, float *frect, int
ImBuf *mip = ibuf->mipmap[i - 1];
if (use_high_bit_depth) {
if (GLEW_ARB_texture_float)
- glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA16F, mip->x, mip->y, 0, GL_RGBA, GL_FLOAT, mip->rect_float);
+ glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA16F_ARB, mip->x, mip->y, 0, GL_RGBA, GL_FLOAT, mip->rect_float);
else
glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA16, mip->x, mip->y, 0, GL_RGBA, GL_FLOAT, mip->rect_float);
}
else {
- glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, mip->x, mip->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, mip->rect);
+ glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA8, mip->x, mip->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, mip->rect);
}
}
}
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 6410418615a..ff62e07b449 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -484,17 +484,19 @@ static GPUTexture *GPU_texture_create_nD(
case GPU_HDR_NONE:
internalformat = GL_RGBA8;
break;
+ /* the following formats rely on ARB_texture_float or OpenGL 3.0 */
case GPU_HDR_HALF_FLOAT:
- internalformat = GL_RGBA16F;
+ internalformat = GL_RGBA16F_ARB;
break;
case GPU_HDR_FULL_FLOAT:
- internalformat = GL_RGBA32F;
+ internalformat = GL_RGBA32F_ARB;
break;
default:
break;
}
}
else if (components == 2) {
+ /* these formats rely on ARB_texture_rg or OpenGL 3.0 */
format = GL_RG;
switch (hdr_type) {
case GPU_HDR_NONE:
@@ -615,11 +617,11 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, int channels, const f
type = GL_FLOAT;
if (channels == 4) {
format = GL_RGBA;
- internalformat = GL_RGBA;
+ internalformat = GL_RGBA8;
}
else {
format = GL_RED;
- internalformat = GL_INTENSITY;
+ internalformat = GL_INTENSITY8;
}
/* 3D textures are quite heavy, test if it's possible to create them first */
@@ -1542,7 +1544,7 @@ void GPU_offscreen_read_pixels(GPUOffScreen *ofs, int type, void *pixels)
}
glBindTexture(GL_TEXTURE_2D, tex_blit);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, type, 0);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, type, 0);
#ifdef USE_FBO_CTX_SWITCH
/* read from multi-sample buffer */