From f6f7e270e30946d0bb3ea4d5c556c994125e590f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 1 Dec 2011 12:12:39 +0000 Subject: Slight refactor of VBO code to deal with multiple textures. Added compareDrawSettings callback to driver mesh's callbacks which are drawing textured faces (mapped and not mapped). This new callback checks if two faces are drawing with the same settings (testures, shading etc) and if they not, flush of faces happens into ogl using glDrawArrays and next face would be drawn with it's own settings. Currently implemented compareDrawSettings is used to resolve issue from bug report only, probably there are extra places where this callback is needed, but haven't seen configuration where current logic will fail, so it should be ok. Also reordered arguments passing to drawMappedFaces DM's callbacks, so now all drawing callback are accepting list of callbacks and then userData, instead of using mixed order of callbacks and userData which was a bit confusing to work with. This commit fixes: - #26410: VBO & multitexture doesnt work - #29464: VBO enabled causes UV coruption --- source/blender/blenkernel/BKE_DerivedMesh.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/BKE_DerivedMesh.h') diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 84f1bf75a3f..3e4868fb8b9 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -255,7 +255,11 @@ struct DerivedMesh { */ void (*drawFacesTex)(DerivedMesh *dm, int (*setDrawOptions)(struct MTFace *tface, - int has_mcol, int matnr)); + int has_mcol, int matnr), + int (*compareDrawOptions)(void *userData, + int cur_index, + int next_index), + void *userData); /* Draw all faces with GLSL materials * o setMaterial is called for every different material nr @@ -280,9 +284,11 @@ struct DerivedMesh { void (*drawMappedFaces)(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), - void *userData, int useColors, int (*setMaterial)(int, void *attribs), - int (*compareDrawOptions)(void *userData, int cur_index, int next_index)); + int (*compareDrawOptions)(void *userData, + int cur_index, + int next_index), + void *userData, int useColors); /* Draw mapped faces using MTFace * o Drawing options too complicated to enumerate, look at code. @@ -290,6 +296,9 @@ struct DerivedMesh { void (*drawMappedFacesTex)(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), + int (*compareDrawOptions)(void *userData, + int cur_index, + int next_index), void *userData); /* Draw mapped faces with GLSL materials @@ -299,7 +308,8 @@ struct DerivedMesh { */ void (*drawMappedFacesGLSL)(DerivedMesh *dm, int (*setMaterial)(int, void *attribs), - int (*setDrawOptions)(void *userData, int index), void *userData); + int (*setDrawOptions)(void *userData, int index), + void *userData); /* Draw mapped edges as lines * o Only if !setDrawOptions or setDrawOptions(userData, mapped-edge) -- cgit v1.2.3