diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/render/render_opengl.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/GPU_extensions.h | 5 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 12 |
4 files changed, 15 insertions, 7 deletions
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 6b067a94003..8dd9adf0777 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -257,7 +257,8 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op) sizex= (scene->r.size*scene->r.xsch)/100; sizey= (scene->r.size*scene->r.ysch)/100; - ofs= GPU_offscreen_create(sizex, sizey); + /* corrects render size with actual size, some gfx cards return units of 256 or 512 */ + ofs= GPU_offscreen_create(&sizex, &sizey); if(!ofs) { BKE_report(op->reports, RPT_ERROR, "Failed to create OpenGL offscreen buffer."); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 2bdba27a237..9765c740698 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2140,7 +2140,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in GPUOffScreen *ofs; /* bind */ - ofs= GPU_offscreen_create(sizex, sizey); + ofs= GPU_offscreen_create(&sizex, &sizey); if(ofs == NULL) return NULL; diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index d545a553da9..a9b4b7a8544 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -144,9 +144,10 @@ void GPU_framebuffer_free(GPUFrameBuffer *fb); void GPU_framebuffer_restore(); /* GPU OffScreen - - wrapper around framebuffer and texture for simple offscreen drawing */ + - wrapper around framebuffer and texture for simple offscreen drawing + - changes size if graphics card can't support it */ -GPUOffScreen *GPU_offscreen_create(int width, int height); +GPUOffScreen *GPU_offscreen_create(int *width, int *height); void GPU_offscreen_free(GPUOffScreen *ofs); void GPU_offscreen_bind(GPUOffScreen *ofs); void GPU_offscreen_unbind(GPUOffScreen *ofs); diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 4298ec8d44d..7f44d21f2b1 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -847,7 +847,7 @@ struct GPUOffScreen { GPUTexture *depth; }; -GPUOffScreen *GPU_offscreen_create(int width, int height) +GPUOffScreen *GPU_offscreen_create(int *width, int *height) { GPUOffScreen *ofs; @@ -859,18 +859,24 @@ GPUOffScreen *GPU_offscreen_create(int width, int height) return NULL; } - ofs->depth = GPU_texture_create_depth(width, height); + ofs->depth = GPU_texture_create_depth(*width, *height); if(!ofs->depth) { GPU_offscreen_free(ofs); return NULL; } + if(*width!=ofs->depth->w || *height!=ofs->depth->h) { + *width= ofs->depth->w; + *height= ofs->depth->h; + printf("Offscreen size differs from given size!\n"); + } + if(!GPU_framebuffer_texture_attach(ofs->fb, ofs->depth)) { GPU_offscreen_free(ofs); return NULL; } - ofs->color = GPU_texture_create_2D(width, height, NULL); + ofs->color = GPU_texture_create_2D(*width, *height, NULL); if(!ofs->color) { GPU_offscreen_free(ofs); return NULL; |