[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33163] trunk/blender/source/blender: Bugfix #22052

Ton Roosendaal ton at blender.org
Thu Nov 18 20:11:05 CET 2010


Revision: 33163
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33163
Author:   ton
Date:     2010-11-18 20:11:05 +0100 (Thu, 18 Nov 2010)

Log Message:
-----------
Bugfix #22052

OpenGL viewport render gave squeezed results in cases.
Reason: some graphics cards only give offscreen buffers in multiples
of 256 or 512 (my case). 

Current fix uses the actual size returned by graphics card, which
is also safe for too large renders.
More elaborate cropping or matching is for another time.

(Added printf for feedback on this, might disappear)

Modified Paths:
--------------
    trunk/blender/source/blender/editors/render/render_opengl.c
    trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
    trunk/blender/source/blender/gpu/GPU_extensions.h
    trunk/blender/source/blender/gpu/intern/gpu_extensions.c

Modified: trunk/blender/source/blender/editors/render/render_opengl.c
===================================================================
--- trunk/blender/source/blender/editors/render/render_opengl.c	2010-11-18 16:47:22 UTC (rev 33162)
+++ trunk/blender/source/blender/editors/render/render_opengl.c	2010-11-18 19:11:05 UTC (rev 33163)
@@ -257,7 +257,8 @@
 	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.");

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_draw.c	2010-11-18 16:47:22 UTC (rev 33162)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_draw.c	2010-11-18 19:11:05 UTC (rev 33163)
@@ -2140,7 +2140,7 @@
 	GPUOffScreen *ofs;
 
 	/* bind */
-	ofs= GPU_offscreen_create(sizex, sizey);
+	ofs= GPU_offscreen_create(&sizex, &sizey);
 	if(ofs == NULL)
 		return NULL;
 

Modified: trunk/blender/source/blender/gpu/GPU_extensions.h
===================================================================
--- trunk/blender/source/blender/gpu/GPU_extensions.h	2010-11-18 16:47:22 UTC (rev 33162)
+++ trunk/blender/source/blender/gpu/GPU_extensions.h	2010-11-18 19:11:05 UTC (rev 33163)
@@ -144,9 +144,10 @@
 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);

Modified: trunk/blender/source/blender/gpu/intern/gpu_extensions.c
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_extensions.c	2010-11-18 16:47:22 UTC (rev 33162)
+++ trunk/blender/source/blender/gpu/intern/gpu_extensions.c	2010-11-18 19:11:05 UTC (rev 33163)
@@ -847,7 +847,7 @@
 	GPUTexture *depth;
 };
 
-GPUOffScreen *GPU_offscreen_create(int width, int height)
+GPUOffScreen *GPU_offscreen_create(int *width, int *height)
 {
 	GPUOffScreen *ofs;
 
@@ -859,18 +859,24 @@
 		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;





More information about the Bf-blender-cvs mailing list