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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-09-05 00:51:28 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-09-05 00:51:28 +0400
commitcb89decfdcf5e6b2f26376d416633f4ccf0c532d (patch)
treea299a5c8729dd0cb4359d57501fd9e6970141e5d /source/blender/src
parent2167e5c341f656b2f664b1052d181e8aa32fe698 (diff)
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with scons, make, but not cmake, that seems to have an issue not related to these changes. The changes include: * GLSL support in the viewport and game engine, enable in the game menu in textured draw mode. * Synced and merged part of the duplicated blender and gameengine/ gameplayer drawing code. * Further refactoring of game engine drawing code, especially mesh storage changed a lot. * Optimizations in game engine armatures to avoid recomputations. * A python function to get the framerate estimate in game. * An option take object color into account in materials. * An option to restrict shadow casters to a lamp's layers. * Increase from 10 to 18 texture slots for materials, lamps, word. An extra texture slot shows up once the last slot is used. * Memory limit for undo, not enabled by default yet because it needs the .B.blend to be changed. * Multiple undo for image painting. * An offset for dupligroups, so not all objects in a group have to be at the origin.
Diffstat (limited to 'source/blender/src')
-rw-r--r--source/blender/src/CMakeLists.txt2
-rw-r--r--source/blender/src/Makefile1
-rw-r--r--source/blender/src/SConscript3
-rw-r--r--source/blender/src/buttons_object.c31
-rw-r--r--source/blender/src/buttons_shading.c136
-rw-r--r--source/blender/src/drawarmature.c3
-rw-r--r--source/blender/src/drawmesh.c773
-rw-r--r--source/blender/src/drawobject.c325
-rw-r--r--source/blender/src/drawview.c279
-rw-r--r--source/blender/src/editdeform.c2
-rw-r--r--source/blender/src/editface.c7
-rw-r--r--source/blender/src/editipo_lib.c10
-rw-r--r--source/blender/src/editlattice.c2
-rw-r--r--source/blender/src/editmode_undo.c40
-rw-r--r--source/blender/src/editview.c2
-rw-r--r--source/blender/src/header_image.c6
-rw-r--r--source/blender/src/header_info.c117
-rw-r--r--source/blender/src/header_view3d.c2
-rw-r--r--source/blender/src/headerbuttons.c7
-rw-r--r--source/blender/src/imagepaint.c303
-rw-r--r--source/blender/src/meshtools.c5
-rw-r--r--source/blender/src/playanim.c20
-rw-r--r--source/blender/src/previewrender.c32
-rw-r--r--source/blender/src/renderwin.c17
-rw-r--r--source/blender/src/sculptmode.c7
-rw-r--r--source/blender/src/sequence.c12
-rw-r--r--source/blender/src/space.c51
-rw-r--r--source/blender/src/toets.c4
-rw-r--r--source/blender/src/usiblender.c21
-rw-r--r--source/blender/src/verse_image.c2
30 files changed, 963 insertions, 1259 deletions
diff --git a/source/blender/src/CMakeLists.txt b/source/blender/src/CMakeLists.txt
index 342579fb3b0..d95551940f8 100644
--- a/source/blender/src/CMakeLists.txt
+++ b/source/blender/src/CMakeLists.txt
@@ -35,7 +35,7 @@ SET(INC
../../kernel/gen_system ../../../intern/SoundSystem ../readstreamglue
../quicktime ../../../intern/elbeem/extern
../../../intern/ghost ../../../intern/opennl/extern
- ../nodes ../../../extern/glew/include
+ ../nodes ../../../extern/glew/include ../gpu
${PYTHON_INC}
${SDL_INC}
)
diff --git a/source/blender/src/Makefile b/source/blender/src/Makefile
index 001efc58b5d..46e916b0437 100644
--- a/source/blender/src/Makefile
+++ b/source/blender/src/Makefile
@@ -68,6 +68,7 @@ CPPFLAGS += -I..
CPPFLAGS += -I../../kernel/gen_system
CPPFLAGS += -I../../gameengine/SoundSystem
CPPFLAGS += -I../ftfont
+CPPFLAGS += -I../gpu
# Only used by py_demo.c !!!
CPPFLAGS += -I../radiosity/extern/include
diff --git a/source/blender/src/SConscript b/source/blender/src/SConscript
index 229cc87ef37..c8c517e15ff 100644
--- a/source/blender/src/SConscript
+++ b/source/blender/src/SConscript
@@ -26,7 +26,8 @@ incs += ' #/intern/bsp/extern ../radiosity/extern/include'
incs += ' #/intern/decimation/extern ../blenloader ../python'
incs += ' ../../kernel/gen_system #/intern/SoundSystem ../readstreamglue ../nodes'
incs += ' ../quicktime #/intern/elbeem/extern'
-incs += ' #/intern/ghost #/intern/opennl/extern #/extern/glew/include'
+incs += ' #/intern/ghost #/intern/opennl/extern'
+incs += ' ../gpu #extern/glew/include'
incs += ' ' + env['BF_PYTHON_INC']
diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c
index b0d612456d2..18384dd90b3 100644
--- a/source/blender/src/buttons_object.c
+++ b/source/blender/src/buttons_object.c
@@ -2590,19 +2590,32 @@ static void object_panel_object(Object *ob)
/* all groups */
for(group= G.main->group.first; group; group= group->id.next) {
if(object_in_group(ob, group)) {
- xco= 160;
+ xco= 130;
+ if(group->id.lib) {
+ uiBlockBeginAlign(block);
+ uiSetButLock(GET_INT_FROM_POINTER(group->id.lib), ERROR_LIBDATA_MESSAGE); /* We cant actually use this button */
+ uiDefBut(block, TEX, B_IDNAME, "GR:", 10, 120-yco, 100, 20, group->id.name+2, 0.0, 21.0, 0, 0, "Displays Group name. Click to change.");
+ uiClearButLock();
+
+ but= uiDefIconBut(block, BUT, B_NOP, ICON_PARLIB, 110, 120-yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Make Group local");
+ uiButSetFunc(but, group_local, group, NULL);
+ uiBlockEndAlign(block);
+ } else {
+ but = uiDefBut(block, TEX, B_IDNAME, "GR:", 10, 120-yco, 120, 20, group->id.name+2, 0.0, 21.0, 0, 0, "Displays Group name. Click to change.");
+ uiButSetFunc(but, test_idbutton_cb, group->id.name, NULL);
+ }
+
+ uiSetButLock(GET_INT_FROM_POINTER(group->id.lib), ERROR_LIBDATA_MESSAGE);
uiBlockBeginAlign(block);
- uiSetButLock(GET_INT_FROM_POINTER(group->id.lib), ERROR_LIBDATA_MESSAGE); /* We cant actually use this button */
- but = uiDefBut(block, TEX, B_IDNAME, "GR:", 10, 120-yco, 150, 20, group->id.name+2, 0.0, 21.0, 0, 0, "Displays Group name. Click to change.");
- uiButSetFunc(but, test_idbutton_cb, group->id.name, NULL);
+ uiDefButF(block, NUM, REDRAWALL, "X:", xco+5, 120-yco, 50, 20, &group->dupli_ofs[0], -100000, 100000, 100, 0, "Offset to use when instacing the group");
+ uiDefButF(block, NUM, REDRAWALL, "Y:", xco+55, 120-yco, 50, 20, &group->dupli_ofs[1], -100000, 100000, 100, 0, "Offset to use when instacing the group");
+ uiDefButF(block, NUM, REDRAWALL, "Z:", xco+105, 120-yco, 50, 20, &group->dupli_ofs[2], -100000, 100000, 100, 0, "Offset to use when instacing the group");
+ uiBlockEndAlign(block);
uiClearButLock();
- if(group->id.lib) {
- but= uiDefIconBut(block, BUT, B_NOP, ICON_PARLIB, 160, 120-yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Make Group local");
- uiButSetFunc(but, group_local, group, NULL);
- xco= 180;
- } else { /* cant remove objects from linked groups */
+ xco = 290;
+ if(group->id.lib==0) { /* cant remove objects from linked groups */
but = uiDefIconBut(block, BUT, B_NOP, VICON_X, xco, 120-yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Remove Group membership");
uiButSetFunc(but, group_ob_rem, group, ob);
}
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index 1b580381ca5..3f65f686e93 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -113,6 +113,8 @@
#include "RE_pipeline.h"
+#include "GPU_material.h"
+
/* -----includes for this file specific----- */
#include "butspace.h" // own module
@@ -1542,10 +1544,35 @@ static void texture_panel_colors(Tex *tex)
uiDefButF(block, NUMSLI, B_TEXPRV, "Contr", 160,10,150,20, &tex->contrast, 0.01, 5.0, 0, 0, "Changes the contrast of the color or intensity of a texture");
}
+static int texture_channels_num_display(MTex **mtex)
+{
+ int a, num_mtex;
+
+ if(!mtex)
+ return 0;
+
+ /* compute number of texture channels to draw, 1 more
+ * than the last, used texture channel, and at least 10 */
+ num_mtex = 0;
+
+ for(a=MAX_MTEX-1; a>=0; a--) {
+ if (mtex[a]) {
+ num_mtex = a+1;
+ break;
+ }
+ }
-static void texture_panel_texture(MTex *mtex, Material *ma, World *wrld, Lamp *la, bNode *node, Brush *br, SculptData *sd)
+ if (num_mtex < 10)
+ return 10;
+ else if(num_mtex < MAX_MTEX)
+ return num_mtex + 1;
+ else
+ return MAX_MTEX;
+}
+
+static void texture_panel_texture(MTex *actmtex, Material *ma, World *wrld, Lamp *la, bNode *node, Brush *br, SculptData *sd)
{
- MTex *mt=NULL;
+ MTex **mtex, *mt;
uiBlock *block;
ID *id=NULL, *idfrom;
int a, yco, loos;
@@ -1556,17 +1583,35 @@ static void texture_panel_texture(MTex *mtex, Material *ma, World *wrld, Lamp *l
if(uiNewPanel(curarea, block, "Texture", "Texture", 320, 0, 318, 204)==0) return;
/* first do the browse but */
- if(mtex)
- id= (ID *)mtex->tex;
+ if(actmtex)
+ id= (ID *)actmtex->tex;
else if(node)
id= node->id;
- if(ma) idfrom= &ma->id;
- else if(wrld) idfrom= &wrld->id;
- else if(la) idfrom= &la->id;
- else if(br) idfrom= &br->id;
- else if(sd) idfrom= NULL; /* Not sure what this does */
- else idfrom= NULL;
+ if(ma) {
+ idfrom= &ma->id;
+ mtex= ma->mtex;
+ }
+ else if(wrld) {
+ idfrom= &wrld->id;
+ mtex= wrld->mtex;
+ }
+ else if(la) {
+ idfrom= &la->id;
+ mtex= la->mtex;
+ }
+ else if(br) {
+ idfrom= &br->id;
+ mtex= br->mtex;
+ }
+ else if(sd) {
+ idfrom= NULL; /* Not sure what this does */
+ mtex= sd->mtex;
+ }
+ else {
+ idfrom= NULL;
+ mtex= NULL;
+ }
uiBlockSetCol(block, TH_BUT_SETTING2);
if(ma) {
@@ -1595,15 +1640,13 @@ static void texture_panel_texture(MTex *mtex, Material *ma, World *wrld, Lamp *l
/* CHANNELS */
if(node==NULL) {
+ int num_mtex;
uiBlockBeginAlign(block);
yco= 150;
- for(a= 0; a<MAX_MTEX; a++) {
-
- if(ma) mt= ma->mtex[a];
- else if(wrld) mt= wrld->mtex[a];
- else if(la) mt= la->mtex[a];
- else if(br) mt= br->mtex[a];
- else if(sd) mt= sd->mtex[a];
+
+ num_mtex= texture_channels_num_display(mtex);
+ for(a=0; a<num_mtex; a++) {
+ mt= mtex[a];
if(mt && mt->tex) splitIDname(mt->tex->id.name+2, str, &loos);
else strcpy(str, "");
@@ -2030,7 +2073,7 @@ static void world_panel_texture(World *wrld)
uiBlock *block;
MTex *mtex;
ID *id;
- int a, loos;
+ int a, loos, num_mtex;
char str[64], *strp;
block= uiNewBlock(&curarea->uiblocks, "world_panel_texture", UI_EMBOSS, UI_HELV, curarea->win);
@@ -2041,7 +2084,8 @@ static void world_panel_texture(World *wrld)
/* TEX CHANNELS */
uiBlockSetCol(block, TH_BUT_NEUTRAL);
uiBlockBeginAlign(block);
- for(a= 0; a<MAX_MTEX; a++) {
+ num_mtex= texture_channels_num_display(wrld->mtex);
+ for(a= 0; a<num_mtex; a++) {
mtex= wrld->mtex[a];
if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos);
else strcpy(str, "");
@@ -2506,7 +2550,7 @@ static void lamp_panel_texture(Object *ob, Lamp *la)
uiBlock *block;
MTex *mtex;
ID *id;
- int a, loos;
+ int a, loos, num_mtex;
char *strp, str[64];
block= uiNewBlock(&curarea->uiblocks, "lamp_panel_texture", UI_EMBOSS, UI_HELV, curarea->win);
@@ -2517,7 +2561,8 @@ static void lamp_panel_texture(Object *ob, Lamp *la)
/* TEX CHANNELS */
uiBlockSetCol(block, TH_BUT_NEUTRAL);
uiBlockBeginAlign(block);
- for(a= 0; a<MAX_MTEX; a++) {
+ num_mtex= texture_channels_num_display(la->mtex);
+ for(a= 0; a<num_mtex; a++) {
mtex= la->mtex[a];
if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos);
else strcpy(str, "");
@@ -2603,9 +2648,9 @@ static void lamp_panel_spot(Object *ob, Lamp *la)
uiBlockSetCol(block, TH_BUT_SETTING1);
uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, LA_SHAD_RAY, B_SHADRAY,"Ray Shadow",10,180,80,19,&la->mode, 0, 0, 0, 0, "Use ray tracing for shadow");
+ uiDefButBitI(block, TOG, LA_SHAD_RAY, B_SHADRAY,"Ray Shadow",10,180,80,19,&la->mode, 0, 0, 0, 0, "Use ray tracing for shadow");
if(la->type==LA_SPOT) {
- uiDefButBitS(block, TOG, LA_SHAD_BUF, B_SHADBUF, "Buf.Shadow",10,160,80,19,&la->mode, 0, 0, 0, 0, "Lets spotlight produce shadows using shadow buffer");
+ uiDefButBitI(block, TOG, LA_SHAD_BUF, B_SHADBUF, "Buf.Shadow",10,160,80,19,&la->mode, 0, 0, 0, 0, "Lets spotlight produce shadows using shadow buffer");
if(la->mode & LA_SHAD_BUF) {
char *tip= "Regular buffer type";
if(la->buftype==LA_SHADBUF_IRREGULAR)
@@ -2618,12 +2663,15 @@ static void lamp_panel_spot(Object *ob, Lamp *la)
}
uiBlockEndAlign(block);
- uiDefButBitS(block, TOG, LA_ONLYSHADOW, B_LAMPPRV,"OnlyShadow", 10,110,80,19,&la->mode, 0, 0, 0, 0, "Causes light to cast shadows only without illuminating objects");
+ uiBlockBeginAlign(block);
+ uiDefButBitI(block, TOG, LA_ONLYSHADOW, B_LAMPPRV,"OnlyShadow", 10,110,80,19,&la->mode, 0, 0, 0, 0, "Causes light to cast shadows only without illuminating objects");
+ uiDefButBitI(block, TOG, LA_LAYER_SHADOW, B_LAMPPRV,"Layer", 10,90,80,19,&la->mode, 0, 0, 0, 0, "Causes only objects on the same layer to cast shadows");
+ uiBlockEndAlign(block);
if(la->type==LA_SPOT) {
uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, LA_SQUARE, B_LAMPREDRAW,"Square", 10,60,80,19,&la->mode, 0, 0, 0, 0, "Sets square spotbundles");
- uiDefButBitS(block, TOG, LA_HALO, B_LAMPREDRAW,"Halo", 10,40,80,19,&la->mode, 0, 0, 0, 0, "Renders spotlight with a volumetric halo");
+ uiDefButBitI(block, TOG, LA_SQUARE, B_LAMPREDRAW,"Square", 10,60,80,19,&la->mode, 0, 0, 0, 0, "Sets square spotbundles");
+ uiDefButBitI(block, TOG, LA_HALO, B_LAMPREDRAW,"Halo", 10,40,80,19,&la->mode, 0, 0, 0, 0, "Renders spotlight with a volumetric halo");
uiBlockBeginAlign(block);
uiDefButF(block, NUMSLI,B_LAMPREDRAW,"SpotSi ", 100,180,200,19,&la->spotsize, 1.0, 180.0, 0, 0, "Sets the angle of the spotlight beam in degrees");
@@ -2747,12 +2795,12 @@ static void lamp_panel_yafray(Object *ob, Lamp *la)
/* in yafray arealights always cast shadows, so ray shadow flag not needed */
/* ray shadow also not used when halo for spot enabled */
if ((la->type!=LA_AREA) && (!((la->type==LA_SPOT) && (la->mode & LA_HALO))))
- uiDefButBitS(block, TOG, LA_SHAD_RAY, B_SHADRAY,"Ray Shadow",10,180,80,19,&la->mode, 0, 0, 0, 0, "Use ray tracing for shadow");
+ uiDefButBitI(block, TOG, LA_SHAD_RAY, B_SHADRAY,"Ray Shadow",10,180,80,19,&la->mode, 0, 0, 0, 0, "Use ray tracing for shadow");
/* in yafray the regular lamp can use shadowbuffers (softlight), used by spot with halo as well */
/* to prevent clash with blender shadowbuf flag, a special flag is used for yafray */
if (la->type==LA_LOCAL) {
- uiDefButBitS(block, TOG, LA_YF_SOFT, B_SHADBUF, "Buf.Shadow",10,160,80,19,&la->mode, 0, 0, 0, 0, "Lets light produce shadows using shadow buffer");
+ uiDefButBitI(block, TOG, LA_YF_SOFT, B_SHADBUF, "Buf.Shadow",10,160,80,19,&la->mode, 0, 0, 0, 0, "Lets light produce shadows using shadow buffer");
uiDefButF(block, NUM, B_DIFF, "GloInt:", 100,155,200,19, &la->YF_glowint, 0.0, 1.0, 1, 0, "Sets light glow intensity, 0 is off");
uiDefButF(block, NUM, B_DIFF, "GloOfs:", 100,135,100,19, &la->YF_glowofs, 0.0, 2.0, 1, 0, "Sets light glow offset, the higher, the less 'peaked' the glow");
uiDefButS(block, NUM, B_DIFF, "GlowType:", 200,135,100,19, &la->YF_glowtype, 0, 1, 1, 0, "Sets light glow type");
@@ -2780,7 +2828,7 @@ static void lamp_panel_yafray(Object *ob, Lamp *la)
if (la->type==LA_SPOT) {
- uiDefButBitS(block, TOG, LA_HALO, B_LAMPREDRAW,"Halo", 10,50,80,19,&la->mode, 0, 0, 0, 0, "Renders spotlight with a volumetric halo");
+ uiDefButBitI(block, TOG, LA_HALO, B_LAMPREDRAW,"Halo", 10,50,80,19,&la->mode, 0, 0, 0, 0, "Renders spotlight with a volumetric halo");
uiBlockSetCol(block, TH_AUTO);
uiBlockBeginAlign(block);
@@ -2900,15 +2948,15 @@ static void lamp_panel_lamp(Object *ob, Lamp *la)
uiBlockSetCol(block, TH_BUT_SETTING1);
uiDefButS(block, MENU, B_LAMPREDRAW, "Falloff %t|Constant %x0|Inverse Linear %x1|Inverse Square %x2|Custom Curve %x3|Lin/Quad Weighted %x4|",
10,150,100,19, &la->falloff_type, 0,0,0,0, "Lamp falloff - intensity decay with distance");
- uiDefButBitS(block, TOG, LA_SPHERE, B_LAMPPRV,"Sphere", 10,130,100,19,&la->mode, 0, 0, 0, 0, "Sets light intensity to zero for objects beyond the distance value");
+ uiDefButBitI(block, TOG, LA_SPHERE, B_LAMPPRV,"Sphere", 10,130,100,19,&la->mode, 0, 0, 0, 0, "Sets light intensity to zero for objects beyond the distance value");
}
uiBlockBeginAlign(block);
uiBlockSetCol(block, TH_BUT_SETTING1);
- uiDefButBitS(block, TOG, LA_LAYER, 0,"Layer", 10,70,100,19,&la->mode, 0, 0, 0, 0, "Illuminates objects in the same layer as the lamp only");
- uiDefButBitS(block, TOG, LA_NEG, B_LAMPPRV,"Negative", 10,50,100,19,&la->mode, 0, 0, 0, 0, "Sets lamp to cast negative light");
- uiDefButBitS(block, TOG, LA_NO_DIFF, B_LAMPPRV,"No Diffuse", 10,30,100,19,&la->mode, 0, 0, 0, 0, "Disables diffuse shading of material illuminated by this lamp");
- uiDefButBitS(block, TOG, LA_NO_SPEC, B_LAMPPRV,"No Specular", 10,10,100,19,&la->mode, 0, 0, 0, 0, "Disables specular shading of material illuminated by this lamp");
+ uiDefButBitI(block, TOG, LA_LAYER, 0,"Layer", 10,70,100,19,&la->mode, 0, 0, 0, 0, "Illuminates objects in the same layer as the lamp only");
+ uiDefButBitI(block, TOG, LA_NEG, B_LAMPPRV,"Negative", 10,50,100,19,&la->mode, 0, 0, 0, 0, "Sets lamp to cast negative light");
+ uiDefButBitI(block, TOG, LA_NO_DIFF, B_LAMPPRV,"No Diffuse", 10,30,100,19,&la->mode, 0, 0, 0, 0, "Disables diffuse shading of material illuminated by this lamp");
+ uiDefButBitI(block, TOG, LA_NO_SPEC, B_LAMPPRV,"No Specular", 10,10,100,19,&la->mode, 0, 0, 0, 0, "Disables specular shading of material illuminated by this lamp");
uiBlockEndAlign(block);
uiBlockSetCol(block, TH_AUTO);
@@ -3523,7 +3571,7 @@ static void material_panel_texture(Object *ob, Material *ma)
ID *id;
ParticleSystem *psys;
int loos, psys_mapto=0;
- int a;
+ int a, num_mtex;
char str[64], *strp;
block= uiNewBlock(&curarea->uiblocks, "material_panel_texture", UI_EMBOSS, UI_HELV, curarea->win);
@@ -3539,7 +3587,8 @@ static void material_panel_texture(Object *ob, Material *ma)
uiBlockSetCol(block, TH_BUT_NEUTRAL);
uiBlockBeginAlign(block);
- for(a= 0; a<MAX_MTEX; a++) {
+ num_mtex= texture_channels_num_display(ma->mtex);
+ for(a= 0; a<num_mtex; a++) {
mtex= ma->mtex[a];
if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos);
else strcpy(str, "");
@@ -3553,10 +3602,10 @@ static void material_panel_texture(Object *ob, Material *ma)
/* SEPTEX */
uiBlockSetCol(block, TH_AUTO);
- for(a= 0; a<MAX_MTEX; a++) {
+ for(a= 0; a<num_mtex; a++) {
mtex= ma->mtex[a];
if(mtex && mtex->tex) {
- but=uiDefIconButBitS(block, ICONTOGN, 1<<a, B_MATPRV, ICON_CHECKBOX_HLT-1, -20, 180-18*a, 28, 20, &ma->septex, 0.0, 0.0, 0, 0, "Click to disable or enable this texture channel");
+ but=uiDefIconButBitI(block, ICONTOGN, 1<<a, B_MATPRV, ICON_CHECKBOX_HLT-1, -20, 180-18*a, 28, 20, &ma->septex, 0.0, 0.0, 0, 0, "Click to disable or enable this texture channel");
if(psys_mapto && ma->mtex[a]->mapto & MAP_PA_IVEL)
uiButSetFunc(but, particle_recalc_material, ma, NULL);
@@ -4091,13 +4140,14 @@ static void material_panel_material(Material *ma)
uiBlockSetCol(block, TH_BUT_SETTING1);
uiDefButBitI(block, TOG, MA_VERTEXCOL, B_MAT_VCOL_LIGHT, "VCol Light", 8,166,74,20, &(ma->mode), 0, 0, 0, 0, "Adds vertex colors as extra light");
uiDefButBitI(block, TOG, MA_VERTEXCOLP, B_MAT_VCOL_PAINT, "VCol Paint", 82,166,74,20, &(ma->mode), 0, 0, 0, 0, "Replaces material's colors with vertex colors");
- uiDefButBitI(block, TOG, MA_FACETEXTURE, B_REDR, "TexFace", 156,166,64,20, &(ma->mode), 0, 0, 0, 0, "Sets UV-Editor assigned texture as color and texture info for faces");
- if (ma->mode & MA_FACETEXTURE) uiDefButBitI(block, TOG, MA_FACETEXTURE_ALPHA, B_REDR, "A", 220,166,20,20, &(ma->mode), 0, 0, 0, 0, "Use alpha channel in 'TexFace' assigned images");
- uiDefButBitI(block, TOG, MA_SHLESS, B_MATPRV, "Shadeless", 240,166,63,20, &(ma->mode), 0, 0, 0, 0, "Makes material insensitive to light or shadow");
+ uiDefButBitI(block, TOG, MA_FACETEXTURE, B_MATPRV, "TexFace", 156,166,60,20, &(ma->mode), 0, 0, 0, 0, "Sets UV-Editor assigned texture as color and texture info for faces");
+ uiDefButBitI(block, TOG, MA_FACETEXTURE_ALPHA, B_MATPRV, "A", 216,166,20,20, &(ma->mode), 0, 0, 0, 0, "Use alpha channel in 'TexFace' assigned images");
+ uiDefButBitI(block, TOG, MA_SHLESS, B_MATPRV, "Shadeless", 236,166,67,20, &(ma->mode), 0, 0, 0, 0, "Makes material insensitive to light or shadow");
- uiDefButBitI(block, TOG, MA_NOMIST, B_NOP, "No Mist", 8,146,74,20, &(ma->mode), 0, 0, 0, 0, "Sets the material to ignore mist values");
+ uiDefButBitI(block, TOG, MA_NOMIST, B_MATPRV, "No Mist", 8,146,74,20, &(ma->mode), 0, 0, 0, 0, "Sets the material to ignore mist values");
uiDefButBitI(block, TOG, MA_ENV, B_MATPRV, "Env", 82,146,74,20, &(ma->mode), 0, 0, 0, 0, "Causes faces to render with alpha zero: allows sky/backdrop to show through (only for solid faces)");
- uiDefButF(block, NUM, B_NOP, "Shad A ", 156,146,147,19, &ma->shad_alpha, 0.001, 1.0f, 100, 0, "Shadow casting alpha, only in use for Irregular Shadowbuffer");
+ uiDefButBitS(block, TOG, MA_OBCOLOR, B_MATPRV, "ObColor", 156,146,60,20, &(ma->shade_flag), 0, 0, 0, 0, "Modulate the result with a per object color");
+ uiDefButF(block, NUM, B_NOP, "Shad A ", 216,146,87,20, &ma->shad_alpha, 0.001, 1.0f, 10, 2, "Shadow casting alpha, only in use for Irregular Shadowbuffer");
}
uiBlockSetCol(block, TH_AUTO);
uiBlockBeginAlign(block);
diff --git a/source/blender/src/drawarmature.c b/source/blender/src/drawarmature.c
index 6d78b21dfbb..c37eaf7986c 100644
--- a/source/blender/src/drawarmature.c
+++ b/source/blender/src/drawarmature.c
@@ -2505,6 +2505,9 @@ int draw_armature(Base *base, int dt, int flag)
Object *ob= base->object;
bArmature *arm= ob->data;
int retval= 0;
+
+ if(G.f & G_SIMULATION)
+ return 1;
if(dt>OB_WIRE && arm->drawtype!=ARM_LINE) {
/* we use color for solid lighting */
diff --git a/source/blender/src/drawmesh.c b/source/blender/src/drawmesh.c
index 09f74c01c71..8f22c704fd0 100644
--- a/source/blender/src/drawmesh.c
+++ b/source/blender/src/drawmesh.c
@@ -76,534 +76,12 @@
#include "BSE_drawview.h"
+#include "GPU_extensions.h"
+#include "GPU_draw.h"
+
#include "blendef.h"
#include "nla.h"
-#ifndef GL_CLAMP_TO_EDGE
-#define GL_CLAMP_TO_EDGE 0x812F
-#endif
-
-//#include "glext.h"
-/* some local functions */
-#if defined(GL_EXT_texture_object) && (!defined(__sun__) || (!defined(__sun))) && !defined(__APPLE__) && !defined(__linux__) && !defined(WIN32)
- #define glBindTexture(A,B) glBindTextureEXT(A,B)
- #define glGenTextures(A,B) glGenTexturesEXT(A,B)
- #define glDeleteTextures(A,B) glDeleteTexturesEXT(A,B)
- #define glPolygonOffset(A,B) glPolygonOffsetEXT(A,B)
-
-#else
-
-/* #define GL_FUNC_ADD_EXT GL_FUNC_ADD */
-/* #define GL_FUNC_REVERSE_SUBTRACT_EXT GL_FUNC_REVERSE_SUBTRACT */
-/* #define GL_POLYGON_OFFSET_EXT GL_POLYGON_OFFSET */
-
-#endif
-
- /* (n&(n-1)) zeros the least significant bit of n */
-static int is_pow2(int num) {
- return ((num)&(num-1))==0;
-}
-static int smaller_pow2(int num) {
- while (!is_pow2(num))
- num= num&(num-1);
- return num;
-}
-
-/* These are used to enable texture clamping */
-static int is_pow2_limit(int num) {
- if (U.glreslimit != 0 && num > U.glreslimit) return 0;
- return ((num)&(num-1))==0;
-}
-
-static int smaller_pow2_limit(int num) {
- if (U.glreslimit != 0 && num > U.glreslimit)
- return U.glreslimit;
- return smaller_pow2(num);
-}
-
-static int fCurtile=0, fCurmode=0,fCurtileXRep=0,fCurtileYRep=0;
-static Image *fCurpage=0;
-static short fTexwindx, fTexwindy, fTexwinsx, fTexwinsy;
-static int fDoMipMap = 1;
-static int fLinearMipMap = 0;
-
-/* local prototypes --------------- */
-void update_realtime_textures(void);
-
-
-/* static int source, dest; also not used */
-
-/**
- * Enables or disable mipmapping for realtime images.
- * @param mipmap Turn mipmapping on (mipmap!=0) or off (mipmap==0).
- */
-void set_mipmap(int mipmap)
-{
- if (fDoMipMap != (mipmap != 0)) {
- free_all_realtime_images();
- fDoMipMap = mipmap != 0;
- }
-}
-
-/**
- * Returns the current setting for mipmapping.
- */
-static int get_mipmap(void)
-{
- return fDoMipMap && (!(G.f & G_TEXTUREPAINT));
-}
-
-/**
- * Enables or disable linear mipmap setting for realtime images (textures).
- * Note that this will will destroy all texture bindings in OpenGL.
- * @see free_realtime_image()
- * @param mipmap Turn linear mipmapping on (linear!=0) or off (linear==0).
- */
-void set_linear_mipmap(int linear)
-{
- if (fLinearMipMap != (linear != 0)) {
- free_all_realtime_images();
- fLinearMipMap = linear != 0;
- }
-}
-
-/**
- * Returns the current setting for linear mipmapping.
- */
-int get_linear_mipmap(void)
-{
- return fLinearMipMap;
-}
-
-
-/**
- * Resets the realtime image cache variables.
- */
-void clear_realtime_image_cache()
-{
- fCurpage = NULL;
- fCurtile = 0;
- fCurmode = 0;
- fCurtileXRep = 0;
- fCurtileYRep = 0;
-}
-
-/* REMEMBER! Changes here must go into my_set_tpage() as well */
-int set_tpage(MTFace *tface)
-{
- static int alphamode= -1;
- static MTFace *lasttface= 0;
- Image *ima;
- ImBuf *ibuf;
- unsigned int *rect=NULL, *bind;
- int tpx=0, tpy=0, tilemode, tileXRep,tileYRep;
-
- /* disable */
- if(tface==0) {
- if(lasttface==0) return 0;
-
- lasttface= 0;
- fCurtile= 0;
- fCurpage= 0;
- if(fCurmode!=0) {
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- }
- fCurmode= 0;
- fCurtileXRep=0;
- fCurtileYRep=0;
- alphamode= -1;
-
- glDisable(GL_BLEND);
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_TEXTURE_GEN_S);
- glDisable(GL_TEXTURE_GEN_T);
- glDisable ( GL_ALPHA_TEST );
- return 0;
- }
- lasttface= tface;
-
- if( alphamode != tface->transp) {
- alphamode= tface->transp;
-
- if(alphamode) {
- if(alphamode==TF_ADD) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE);
- glDisable ( GL_ALPHA_TEST );
- /* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
- }
- else if(alphamode==TF_ALPHA) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- /* added after 2.45 to clip alpha */
-
- /*if U.glalphaclip == 1.0, some cards go bonkers... turn off alpha test in this case*/
- if(U.glalphaclip == 1.0) glDisable(GL_ALPHA_TEST);
- else{
- glEnable ( GL_ALPHA_TEST );
- glAlphaFunc ( GL_GREATER, U.glalphaclip );
- }
- } else if (alphamode==TF_CLIP){
- glDisable(GL_BLEND);
- glEnable ( GL_ALPHA_TEST );
- glAlphaFunc(GL_GREATER, 0.5f);
- }
- /* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
- /* else { */
- /* glBlendFunc(GL_ONE, GL_ONE); */
- /* glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT_EXT); */
- /* } */
- } else {
- glDisable(GL_BLEND);
- glDisable ( GL_ALPHA_TEST );
- }
- }
-
- ima= tface->tpage;
-
- /* Enable or disable reflection mapping */
- if (ima && (ima->flag & IMA_REFLECT)){
-
-// glActiveTextureARB(GL_TEXTURE0_ARB);
- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
-
- glEnable(GL_TEXTURE_GEN_S);
- glEnable(GL_TEXTURE_GEN_T);
-
- /* Handle multitexturing here */
- }
- else{
- glDisable(GL_TEXTURE_GEN_S);
- glDisable(GL_TEXTURE_GEN_T);
- }
-
- tilemode= tface->mode & TF_TILES;
- tileXRep = 0;
- tileYRep = 0;
- if (ima) {
- tileXRep = ima->xrep;
- tileYRep = ima->yrep;
- }
-
-
- if(ima==fCurpage && fCurtile==tface->tile && tilemode==fCurmode && fCurtileXRep==tileXRep && fCurtileYRep == tileYRep) return ima!=0;
-
- if(tilemode!=fCurmode || fCurtileXRep!=tileXRep || fCurtileYRep != tileYRep) {
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
-
- if(tilemode && ima!=NULL)
- glScalef(ima->xrep, ima->yrep, 1.0);
-
- glMatrixMode(GL_MODELVIEW);
- }
-
- if(ima==NULL || ima->ok==0) {
- glDisable(GL_TEXTURE_2D);
-
- fCurtile= tface->tile;
- fCurpage= 0;
- fCurmode= tilemode;
- fCurtileXRep = tileXRep;
- fCurtileYRep = tileYRep;
-
- return 0;
- }
-
- ibuf= BKE_image_get_ibuf(ima, NULL);
- if(ibuf==NULL) {
-
- fCurtile= tface->tile;
- fCurpage= 0;
- fCurmode= tilemode;
- fCurtileXRep = tileXRep;
- fCurtileYRep = tileYRep;
-
- glDisable(GL_TEXTURE_2D);
- return 0;
- }
-
- if ((ibuf->rect==NULL) && ibuf->rect_float)
- IMB_rect_from_float(ibuf);
-
- if(ima->tpageflag & IMA_TWINANIM) fCurtile= ima->lastframe;
- else fCurtile= tface->tile;
-
- if(tilemode) {
- if(ima->repbind==0) make_repbind(ima);
-
- if(fCurtile>=ima->totbind) fCurtile= 0;
-
- /* this happens when you change repeat buttons */
- if(ima->repbind) bind= ima->repbind+fCurtile;
- else bind= &ima->bindcode;
-
- if(*bind==0) {
-
- fTexwindx= ibuf->x/ima->xrep;
- fTexwindy= ibuf->y/ima->yrep;
-
- if(fCurtile>=ima->xrep*ima->yrep) fCurtile= ima->xrep*ima->yrep-1;
-
- fTexwinsy= fCurtile / ima->xrep;
- fTexwinsx= fCurtile - fTexwinsy*ima->xrep;
-
- fTexwinsx*= fTexwindx;
- fTexwinsy*= fTexwindy;
-
- tpx= fTexwindx;
- tpy= fTexwindy;
-
- rect= ibuf->rect + fTexwinsy*ibuf->x + fTexwinsx;
- }
- }
- else {
- bind= &ima->bindcode;
-
- if(*bind==0) {
- tpx= ibuf->x;
- tpy= ibuf->y;
- rect= ibuf->rect;
- }
- }
-
- if(*bind==0) {
- int rectw= tpx, recth= tpy;
- unsigned int *tilerect= NULL, *scalerect= NULL;
-
- /*
- * Maarten:
- * According to Ton this code is not needed anymore. It was used only
- * in really old Blenders.
- * Reevan:
- * Actually it is needed for backwards compatibility. Simpledemo 6 does not display correctly without it.
- */
-#if 1
- if (tilemode) {
- int y;
-
- tilerect= MEM_mallocN(rectw*recth*sizeof(*tilerect), "tilerect");
- for (y=0; y<recth; y++) {
- unsigned int *rectrow= &rect[y*ibuf->x];
- unsigned int *tilerectrow= &tilerect[y*rectw];
-
- memcpy(tilerectrow, rectrow, tpx*sizeof(*rectrow));
- }
-
- rect= tilerect;
- }
-#endif
- if (!is_pow2_limit(rectw) || !is_pow2_limit(recth)) {
- rectw= smaller_pow2_limit(rectw);
- recth= smaller_pow2_limit(recth);
-
- scalerect= MEM_mallocN(rectw*recth*sizeof(*scalerect), "scalerect");
- gluScaleImage(GL_RGBA, tpx, tpy, GL_UNSIGNED_BYTE, rect, rectw, recth, GL_UNSIGNED_BYTE, scalerect);
- rect= scalerect;
- }
-
- glGenTextures(1, (GLuint *)bind);
-
- if((G.f & G_DEBUG) || !*bind) {
- GLenum error = glGetError();
- printf("Texture: %s\n", ima->id.name+2);
- printf("name: %d, tpx: %d\n", *bind, tpx);
- printf("tile: %d, mode: %d\n", fCurtile, tilemode);
- if (error)
- printf("error: %s\n", gluErrorString(error));
- }
- glBindTexture( GL_TEXTURE_2D, *bind);
-
- if (!get_mipmap())
- {
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- } else
- {
- int minfilter= fLinearMipMap?GL_LINEAR_MIPMAP_LINEAR:GL_LINEAR_MIPMAP_NEAREST;
-
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minfilter);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- ima->tpageflag |= IMA_MIPMAP_COMPLETE;
- }
-
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- if (tilerect)
- MEM_freeN(tilerect);
- if (scalerect)
- MEM_freeN(scalerect);
- }
- else glBindTexture( GL_TEXTURE_2D, *bind);
-
- /* dont tile x/y as set the the game properties */
- if (ima->tpageflag & IMA_CLAMP_U)
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- else
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- if (ima->tpageflag & IMA_CLAMP_V)
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- else
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
-
- /* tag_image_time(ima);*/ /* Did this get lost in the image recode? */
-
- glEnable(GL_TEXTURE_2D);
-
- fCurpage= ima;
- fCurmode= tilemode;
- fCurtileXRep = tileXRep;
- fCurtileYRep = tileYRep;
-
- return 1;
-}
-
-void update_realtime_image(Image *ima, int x, int y, int w, int h)
-{
- ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
-
- if (ima->repbind || get_mipmap() || !ima->bindcode || !ibuf ||
- (!is_pow2(ibuf->x) || !is_pow2(ibuf->y)) ||
- (w == 0) || (h == 0)) {
- /* these special cases require full reload still */
- free_realtime_image(ima);
- }
- else {
- int row_length = glaGetOneInteger(GL_UNPACK_ROW_LENGTH);
- int skip_pixels = glaGetOneInteger(GL_UNPACK_SKIP_PIXELS);
- int skip_rows = glaGetOneInteger(GL_UNPACK_SKIP_ROWS);
-
- if ((ibuf->rect==NULL) && ibuf->rect_float)
- IMB_rect_from_float(ibuf);
-
- glBindTexture(GL_TEXTURE_2D, ima->bindcode);
-
- glPixelStorei(GL_UNPACK_ROW_LENGTH, ibuf->x);
- glPixelStorei(GL_UNPACK_SKIP_PIXELS, x);
- glPixelStorei(GL_UNPACK_SKIP_ROWS, y);
-
- glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
- GL_UNSIGNED_BYTE, ibuf->rect);
-
- glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
- glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);
- glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows);
-
- if(ima->tpageflag & IMA_MIPMAP_COMPLETE)
- ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
- }
-}
-
-void free_realtime_image(Image *ima)
-{
- if(ima->bindcode) {
- glDeleteTextures(1, (GLuint *)&ima->bindcode);
- ima->bindcode= 0;
- ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
- }
- if(ima->repbind) {
- glDeleteTextures(ima->totbind, (GLuint *)ima->repbind);
-
- MEM_freeN(ima->repbind);
- ima->repbind= NULL;
- ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
- }
-}
-
-void free_all_realtime_images(void)
-{
- Image* ima;
-
- for(ima=G.main->image.first; ima; ima=ima->id.next)
- free_realtime_image(ima);
-}
-
-/* these two functions are called on entering and exiting texture paint mode,
- temporary disabling/enabling mipmapping on all images for quick texture
- updates with glTexSubImage2D. images that didn't change don't have to be
- re-uploaded to OpenGL */
-void texpaint_disable_mipmap(void)
-{
- Image* ima;
-
- if(!fDoMipMap)
- return;
-
- for(ima=G.main->image.first; ima; ima=ima->id.next) {
- if(ima->bindcode) {
- glBindTexture(GL_TEXTURE_2D, ima->bindcode);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- }
- }
-}
-
-void texpaint_enable_mipmap(void)
-{
- Image* ima;
-
- if(!fDoMipMap)
- return;
-
- for(ima=G.main->image.first; ima; ima=ima->id.next) {
- if(ima->bindcode) {
- if(ima->tpageflag & IMA_MIPMAP_COMPLETE) {
- int minfilter= fLinearMipMap?GL_LINEAR_MIPMAP_LINEAR:GL_LINEAR_MIPMAP_NEAREST;
-
- glBindTexture(GL_TEXTURE_2D, ima->bindcode);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minfilter);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- }
- else
- free_realtime_image(ima);
- }
- }
-}
-
-void make_repbind(Image *ima)
-{
- ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
-
- if(ibuf==NULL) return;
-
- if(ima->repbind) {
- glDeleteTextures(ima->totbind, (GLuint *)ima->repbind);
- MEM_freeN(ima->repbind);
- ima->repbind= 0;
- ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
- }
- ima->totbind= ima->xrep*ima->yrep;
- if(ima->totbind>1) {
- ima->repbind= MEM_callocN(sizeof(int)*ima->totbind, "repbind");
- }
-}
-
-void update_realtime_textures()
-{
- Image *ima;
-
- ima= G.main->image.first;
- while(ima) {
- if(ima->tpageflag & IMA_TWINANIM) {
- if(ima->twend >= ima->xrep*ima->yrep) ima->twend= ima->xrep*ima->yrep-1;
-
- /* check: is bindcode not in the array? Free. (to do) */
-
- ima->lastframe++;
- if(ima->lastframe > ima->twend) ima->lastframe= ima->twsta;
-
- }
- ima= ima->id.next;
- }
-}
-
/***/
/* Flags for marked edges */
@@ -627,7 +105,7 @@ static void get_marked_edge_info__orFlags(EdgeHash *eh, int v0, int v1, int flag
*flags_p |= flags;
}
-EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me)
+static EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me)
{
EdgeHash *eh = BLI_edgehash_new();
int i;
@@ -775,81 +253,6 @@ static void draw_tfaces3D(Object *ob, Mesh *me, DerivedMesh *dm)
BLI_edgehash_free(data.eh, NULL);
}
-static int set_gl_light(Object *ob)
-{
- Base *base;
- Lamp *la;
- int count;
- /* float zero[4]= {0.0, 0.0, 0.0, 0.0}; */
- float vec[4];
-
- vec[3]= 1.0;
-
- for(count=0; count<8; count++) glDisable(GL_LIGHT0+count);
-
- count= 0;
-
- base= FIRSTBASE;
- while(base) {
- if(base->object->type==OB_LAMP ) {
- if(base->lay & G.vd->lay) {
- if(base->lay & ob->lay)
- {
- la= base->object->data;
-
- glPushMatrix();
- glLoadMatrixf((float *)G.vd->viewmat);
-
- where_is_object_simul(base->object);
- VECCOPY(vec, base->object->obmat[3]);
-
- if(la->type==LA_SUN) {
- vec[0]= base->object->obmat[2][0];
- vec[1]= base->object->obmat[2][1];
- vec[2]= base->object->obmat[2][2];
- vec[3]= 0.0;
- glLightfv(GL_LIGHT0+count, GL_POSITION, vec);
- }
- else {
- vec[3]= 1.0;
- glLightfv(GL_LIGHT0+count, GL_POSITION, vec);
- glLightf(GL_LIGHT0+count, GL_CONSTANT_ATTENUATION, 1.0);
- glLightf(GL_LIGHT0+count, GL_LINEAR_ATTENUATION, la->att1/la->dist);
- /* post 2.25 engine supports quad lights */
- glLightf(GL_LIGHT0+count, GL_QUADRATIC_ATTENUATION, la->att2/(la->dist*la->dist));
-
- if(la->type==LA_SPOT) {
- vec[0]= -base->object->obmat[2][0];
- vec[1]= -base->object->obmat[2][1];
- vec[2]= -base->object->obmat[2][2];
- glLightfv(GL_LIGHT0+count, GL_SPOT_DIRECTION, vec);
- glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, la->spotsize/2.0);
- glLightf(GL_LIGHT0+count, GL_SPOT_EXPONENT, 128.0*la->spotblend);
- }
- else glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, 180.0);
- }
-
- vec[0]= la->energy*la->r;
- vec[1]= la->energy*la->g;
- vec[2]= la->energy*la->b;
- vec[3]= 1.0;
- glLightfv(GL_LIGHT0+count, GL_DIFFUSE, vec);
- glLightfv(GL_LIGHT0+count, GL_SPECULAR, vec);//zero);
- glEnable(GL_LIGHT0+count);
-
- glPopMatrix();
-
- count++;
- if(count>7) break;
- }
- }
- }
- base= base->next;
- }
-
- return count;
-}
-
static Material *give_current_material_or_def(Object *ob, int matnr)
{
extern Material defmaterial; // render module abuse...
@@ -893,9 +296,9 @@ static int set_draw_settings_cached(int clearcache, int textured, MTFace *texfac
if (textured!=c_textured || texface!=c_texface) {
if (textured ) {
- c_badtex= !set_tpage(texface);
+ c_badtex= !GPU_set_tpage(texface);
} else {
- set_tpage(0);
+ GPU_set_tpage(0);
c_badtex= 0;
}
c_textured= textured;
@@ -950,7 +353,7 @@ static void draw_textured_begin(Object *ob)
}
else
/* draw with lights in the scene otherwise */
- Gtexdraw.islit= set_gl_light(ob);
+ Gtexdraw.islit= GPU_scene_object_lights(G.scene, ob, G.vd->lay, G.vd->viewmat);
obcol[0]= CLAMPIS(ob->col[0]*255, 0, 255);
obcol[1]= CLAMPIS(ob->col[1]*255, 0, 255);
@@ -971,12 +374,12 @@ static void draw_textured_begin(Object *ob)
static void draw_textured_end()
{
/* switch off textures */
- set_tpage(0);
+ GPU_set_tpage(0);
glShadeModel(GL_FLAT);
glDisable(GL_CULL_FACE);
- /* XXX, bad patch - default_gl_light() calls
+ /* XXX, bad patch - GPU_default_lights() calls
* glLightfv(GL_LIGHT_POSITION, ...) which
* is transformed by the current matrix... we
* need to make sure that matrix is identity.
@@ -987,7 +390,7 @@ static void draw_textured_end()
*/
glPushMatrix();
glLoadIdentity();
- default_gl_light();
+ GPU_default_lights();
glPopMatrix();
}
@@ -1057,50 +460,71 @@ static int wpaint__setSolidDrawOptions(void *userData, int index, int *drawSmoot
return 1;
}
-static void draw_game_text_mesh(Object *ob, Mesh *me)
+void draw_mesh_text(Object *ob, int glsl)
{
- DerivedMesh *ddm = mesh_get_derived_deform(ob, CD_MASK_BAREMESH);
- MFace *mface= me->mface;
+ Mesh *me = ob->data;
+ DerivedMesh *ddm;
+ MFace *mf, *mface= me->mface;
MTFace *tface= me->mtface;
MCol *mcol= me->mcol; /* why does mcol exist? */
bProperty *prop = get_property(ob, "Text");
- int a, start= 0, totface= me->totface;
+ GPUVertexAttribs gattribs;
+ int a, totface= me->totface;
+
+ /* don't draw without tfaces */
+ if(!tface)
+ return;
+
+ /* don't draw when editing */
+ if(ob==G.obedit)
+ return;
+ else if(ob==OBACT)
+ if(FACESEL_PAINT_TEST)
+ return;
+
+ ddm = mesh_get_derived_deform(ob, CD_MASK_BAREMESH);
- tface+= start;
- mcol+= start*4;
- for (a=start; a<totface; a++, tface++, mcol+=4) {
- MFace *mf= &mface[a];
+ for(a=0, mf=mface; a<totface; a++, tface++, mf++) {
int mode= tface->mode;
int matnr= mf->mat_nr;
int mf_smooth= mf->flag & ME_SMOOTH;
if (!(mf->flag&ME_HIDE) && !(mode&TF_INVISIBLE) && (mode&TF_BMFONT)) {
- int badtex= set_draw_settings_cached(0, Gtexdraw.istex, tface, Gtexdraw.islit, Gtexdraw.ob, matnr, TF_TWOSIDE);
float v1[3], v2[3], v3[3], v4[3];
char string[MAX_PROPSTRING];
- int characters, index;
- ImBuf *ibuf;
- float curpos;
+ int characters, i, glattrib= -1, badtex= 0;
- if (badtex)
- continue;
+ if(glsl) {
+ GPU_enable_material(matnr+1, &gattribs);
+
+ for(i=0; i<gattribs.totlayer; i++) {
+ if(gattribs.layer[i].type == CD_MTFACE) {
+ glattrib = gattribs.layer[i].glindex;
+ break;
+ }
+ }
+ }
+ else {
+ badtex = set_draw_settings_cached(0, Gtexdraw.istex, tface, Gtexdraw.islit, Gtexdraw.ob, matnr, TF_TWOSIDE);
+ if (badtex) {
+ if (mcol) mcol+=4;
+ continue;
+ }
+ }
ddm->getVertCo(ddm, mf->v1, v1);
ddm->getVertCo(ddm, mf->v2, v2);
ddm->getVertCo(ddm, mf->v3, v3);
if (mf->v4) ddm->getVertCo(ddm, mf->v4, v4);
- // The BM_FONT handling code is duplicated in the gameengine
- // Search for 'Frank van Beek' ;-)
- // string = "Frank van Beek";
+ // The BM_FONT handling is in the gpu module, shared with the
+ // game engine, was duplicated previously
set_property_valstr(prop, string);
characters = strlen(string);
- ibuf= BKE_image_get_ibuf(tface->tpage, NULL);
- if (ibuf == NULL) {
+ if(!BKE_image_get_ibuf(tface->tpage, NULL))
characters = 0;
- }
if (!mf_smooth) {
float nor[3];
@@ -1110,46 +534,11 @@ static void draw_game_text_mesh(Object *ob, Mesh *me)
glNormal3fv(nor);
}
- curpos= 0.0;
- glBegin(mf->v4?GL_QUADS:GL_TRIANGLES);
- for (index = 0; index < characters; index++) {
- float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance;
- int character = string[index];
- char *cp= NULL;
-
- // lets calculate offset stuff
- // space starts at offset 1
- // character = character - ' ' + 1;
-
- matrixGlyph(ibuf, character, & centerx, &centery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
- movex+= curpos;
-
- if (tface->mode & TF_OBCOL)
- glColor3ubv(Gtexdraw.obcol);
- else if (me->mcol) cp= (char *)mcol;
- else glColor3ub(255, 255, 255);
-
- glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy);
- if (cp) glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]);
-
- glTexCoord2f((tface->uv[1][0] - centerx) * sizex + transx, (tface->uv[1][1] - centery) * sizey + transy);
- if (cp) glColor3ub(cp[7], cp[6], cp[5]);
- glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]);
-
- glTexCoord2f((tface->uv[2][0] - centerx) * sizex + transx, (tface->uv[2][1] - centery) * sizey + transy);
- if (cp) glColor3ub(cp[11], cp[10], cp[9]);
- glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]);
-
- if(mf->v4) {
- glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, (tface->uv[3][1] - centery) * sizey + transy);
- if (cp) glColor3ub(cp[15], cp[14], cp[13]);
- glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]);
- }
-
- curpos+= advance;
- }
- glEnd();
+ GPU_render_text(tface, tface->mode, string, characters,
+ (unsigned int*)mcol, v1, v2, v3, (mf->v4? v4: NULL), glattrib);
+ }
+ if (mcol) {
+ mcol+=4;
}
}
@@ -1159,7 +548,6 @@ static void draw_game_text_mesh(Object *ob, Mesh *me)
void draw_mesh_textured(Object *ob, DerivedMesh *dm, int faceselect)
{
Mesh *me= ob->data;
- int editing= 0;
/* correct for negative scale */
if(ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW);
@@ -1168,38 +556,20 @@ void draw_mesh_textured(Object *ob, DerivedMesh *dm, int faceselect)
/* draw the textured mesh */
draw_textured_begin(ob);
-#ifdef WITH_VERSE
- if(me->vnode) {
- /* verse-blender doesn't support uv mapping of textures yet */
- dm->drawFacesTex(dm, NULL);
- }
- else {
-#endif
- if(ob==G.obedit) {
- dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, G.editMesh);
- } else if(faceselect) {
- if(G.f & G_WEIGHTPAINT)
- dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1);
- else
- dm->drawMappedFacesTex(dm, draw_tface_mapped__set_draw, me);
- }
+ if(ob==G.obedit) {
+ dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, G.editMesh);
+ } else if(faceselect) {
+ if(G.f & G_WEIGHTPAINT)
+ dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1);
else
- dm->drawFacesTex(dm, draw_tface__set_draw);
-#ifdef WITH_VERSE
- }
-#endif
-
- /* draw game engine text hack - but not if we are editing the mesh */
- if (me->mtface && get_property(ob, "Text")) {
- if(ob==G.obedit)
- editing= 1;
- else if(ob==OBACT)
- if(FACESEL_PAINT_TEST)
- editing= 1;
-
- if(!editing)
- draw_game_text_mesh(ob, me);
+ dm->drawMappedFacesTex(dm, draw_tface_mapped__set_draw, me);
}
+ else
+ dm->drawFacesTex(dm, draw_tface__set_draw);
+
+ /* draw game engine text hack */
+ if(get_property(ob, "Text"))
+ draw_mesh_text(ob, 0);
draw_textured_end();
@@ -1214,10 +584,3 @@ void draw_mesh_textured(Object *ob, DerivedMesh *dm, int faceselect)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
-void init_realtime_GL(void)
-{
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
-}
-
diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c
index 213f49528f0..4876e6cae7c 100644
--- a/source/blender/src/drawobject.c
+++ b/source/blender/src/drawobject.c
@@ -93,6 +93,7 @@
#include "BKE_object.h"
#include "BKE_anim.h" //for the where_on_path function
#include "BKE_particle.h"
+#include "BKE_property.h"
#include "BKE_utildefines.h"
#ifdef WITH_VERSE
#include "BKE_verse.h"
@@ -129,6 +130,10 @@
#include "BKE_deform.h"
+#include "GPU_draw.h"
+#include "GPU_material.h"
+#include "GPU_extensions.h"
+
/* pretty stupid */
/* extern Lattice *editLatt; already in BKE_lattice.h */
/* editcurve.c */
@@ -143,114 +148,37 @@ static void drawcircle_size(float size);
static void draw_empty_sphere(float size);
static void draw_empty_cone(float size);
-/* ************* Setting OpenGL Material ************ */
-
-// Materials start counting at # one....
-#define MAXMATBUF (MAXMAT + 1)
-static float matbuf[MAXMATBUF][2][4];
-static int totmat_gl= 0;
+/* check for glsl drawing */
-int set_gl_material(int nr)
+int draw_glsl_material(Object *ob, int dt)
{
- static int last_gl_matnr= -1;
- static int last_ret_val= 1;
-
- /* prevent index to use un-initialized array items */
- if(nr>totmat_gl) nr= totmat_gl;
-
- if(nr<0) {
- last_gl_matnr= -1;
- last_ret_val= 1;
- }
- else if(nr<MAXMATBUF && nr!=last_gl_matnr) {
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matbuf[nr][0]);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matbuf[nr][1]);
- last_gl_matnr = nr;
- last_ret_val= matbuf[nr][0][3]!=0.0;
-
- /* matbuf alpha: 0.0 = skip draw, 1.0 = no blending, else blend */
- if(matbuf[nr][0][3]!= 0.0 && matbuf[nr][0][3]!= 1.0) {
- glEnable(GL_BLEND);
- }
- else
- glDisable(GL_BLEND);
-
- }
+ if(!GPU_extensions_minimum_support())
+ return 0;
+ if(G.f & G_PICKSEL)
+ return 0;
+ if(!CHECK_OB_DRAWTEXTURE(G.vd, dt))
+ return 0;
+ if(ob==OBACT && (G.f & G_WEIGHTPAINT))
+ return 0;
- return last_ret_val;
+ return ((G.fileflags & G_FILE_GAME_MAT) &&
+ (G.fileflags & G_FILE_GAME_MAT_GLSL) && (dt >= OB_SHADED));
}
-/* returns 1: when there's alpha needed to be drawn in a 2nd pass */
-int init_gl_materials(Object *ob, int check_alpha)
+static int check_material_alpha(Base *base, Object *ob, int glsl)
{
- extern Material defmaterial; // render module abuse...
- Material *ma;
- int a, has_alpha= 0;
-
- if(ob->totcol==0) {
- matbuf[0][0][0]= defmaterial.r;
- matbuf[0][0][1]= defmaterial.g;
- matbuf[0][0][2]= defmaterial.b;
- matbuf[0][0][3]= 1.0;
-
- matbuf[0][1][0]= defmaterial.specr;
- matbuf[0][1][1]= defmaterial.specg;
- matbuf[0][1][2]= defmaterial.specb;
- matbuf[0][1][3]= 1.0;
-
- /* do material 1 too, for displists! */
- QUATCOPY(matbuf[1][0], matbuf[0][0]);
- QUATCOPY(matbuf[1][1], matbuf[0][1]);
- }
-
- for(a=1; a<=ob->totcol; a++) {
- ma= give_current_material(ob, a);
- ma= editnode_get_active_material(ma);
- if(ma==NULL) ma= &defmaterial;
-
- if(a<MAXMATBUF) {
- if (ma->mode & MA_SHLESS) {
- matbuf[a][0][0]= ma->r;
- matbuf[a][0][1]= ma->g;
- matbuf[a][0][2]= ma->b;
- } else {
- matbuf[a][0][0]= (ma->ref+ma->emit)*ma->r;
- matbuf[a][0][1]= (ma->ref+ma->emit)*ma->g;
- matbuf[a][0][2]= (ma->ref+ma->emit)*ma->b;
- }
+ if(base->flag & OB_FROMDUPLI)
+ return 0;
- /* draw transparent, not in pick-select, nor editmode */
- if(check_alpha && !(G.f & G_PICKSEL) && (ob->dtx & OB_DRAWTRANSP) && !(G.obedit && G.obedit->data==ob->data)) {
- if(G.vd->transp) { // drawing the transparent pass
- if(ma->alpha==1.0) matbuf[a][0][3]= 0.0; // means skip solid
- else matbuf[a][0][3]= ma->alpha;
- }
- else { // normal pass
- if(ma->alpha==1.0) matbuf[a][0][3]= 1.0;
- else {
- matbuf[a][0][3]= 0.0; // means skip transparent
- has_alpha= 1; // return value, to indicate adding to after-draw queue
- }
- }
- }
- else
- matbuf[a][0][3]= 1.0;
+ if(G.f & G_PICKSEL)
+ return 0;
- if (!(ma->mode & MA_SHLESS)) {
- matbuf[a][1][0]= ma->spec*ma->specr;
- matbuf[a][1][1]= ma->spec*ma->specg;
- matbuf[a][1][2]= ma->spec*ma->specb;
- matbuf[a][1][3]= 1.0;
- }
- }
- }
-
- totmat_gl= ob->totcol;
- set_gl_material(-1); // signal for static variable
- return has_alpha;
+ if(G.obedit && G.obedit->data==ob->data)
+ return 0;
+
+ return (glsl || (ob->dtx & OB_DRAWTRANSP));
}
-
/***/
static unsigned int colortab[24]=
{0x0, 0xFF88FF, 0xFFBBFF,
@@ -352,6 +280,9 @@ void drawaxes(float size, int flag, char drawtype)
float v1[3]= {0.0, 0.0, 0.0};
float v2[3]= {0.0, 0.0, 0.0};
float v3[3]= {0.0, 0.0, 0.0};
+
+ if(G.f & G_SIMULATION)
+ return;
switch(drawtype) {
@@ -734,6 +665,9 @@ static void drawlamp(Object *ob)
float pixsize, lampsize;
float imat[4][4], curcol[4];
char col[4];
+
+ if(G.f & G_SIMULATION)
+ return;
la= ob->data;
@@ -1024,6 +958,9 @@ static void drawcamera(Object *ob, int flag)
float vec[8][4], tmat[4][4], fac, facx, facy, depth;
int i;
+ if(G.f & G_SIMULATION)
+ return;
+
cam= ob->data;
glDisable(GL_LIGHTING);
@@ -1830,6 +1767,9 @@ static void draw_verse_debug(Object *ob, EditMesh *em)
struct EditFace *efa=NULL;
float v1[3], v2[3], v3[3], v4[3], fvec[3], col[3];
char val[32];
+
+ if(G.f & G_SIMULATION)
+ return;
if(G.vd->zbuf && (G.vd->flag & V3D_ZBUF_SELECT)==0)
glDisable(GL_DEPTH_TEST);
@@ -1894,6 +1834,9 @@ static void draw_em_measure_stats(Object *ob, EditMesh *em)
char conv_float[5]; /* Use a float conversion matching the grid size */
float area, col[3]; /* area of the face, color of the text to draw */
+ if(G.f & G_SIMULATION)
+ return;
+
/* make the precission of the pronted value proportionate to the gridsize */
if ((G.vd->grid) < 0.01)
strcpy(conv_float, "%.6f");
@@ -2054,12 +1997,20 @@ static int draw_em_fancy__setFaceOpts(void *userData, int index, int *drawSmooth
EditFace *efa = EM_get_face_for_index(index);
if (efa->h==0) {
- set_gl_material(efa->mat_nr+1);
+ GPU_enable_material(efa->mat_nr+1, NULL);
return 1;
- } else {
- return 0;
}
+ else
+ return 0;
}
+
+static int draw_em_fancy__setGLSLFaceOpts(void *userData, int index)
+{
+ EditFace *efa = EM_get_face_for_index(index);
+
+ return (efa->h==0);
+}
+
static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, int dt)
{
Mesh *me = ob->data;
@@ -2082,9 +2033,21 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived
EM_init_index_arrays(1, 1, 1);
if(dt>OB_WIRE) {
- if( CHECK_OB_DRAWTEXTURE(G.vd, dt) ) {
- draw_mesh_textured(ob, finalDM, 0);
- } else {
+ if(CHECK_OB_DRAWTEXTURE(G.vd, dt)) {
+ if(draw_glsl_material(ob, dt)) {
+ glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
+
+ finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material,
+ draw_em_fancy__setGLSLFaceOpts, NULL);
+ GPU_disable_material();
+
+ glFrontFace(GL_CCW);
+ }
+ else {
+ draw_mesh_textured(ob, finalDM, 0);
+ }
+ }
+ else {
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED);
glEnable(GL_LIGHTING);
@@ -2208,6 +2171,7 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived
if(dt>OB_WIRE) {
glDepthMask(1);
bglPolygonOffset(0.0);
+ GPU_disable_material();
}
EM_free_index_arrays();
@@ -2226,8 +2190,9 @@ static void draw_mesh_object_outline(Object *ob, DerivedMesh *dm)
drawFacesSolid() doesn't draw the transparent faces */
if(ob->dtx & OB_DRAWTRANSP) {
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- dm->drawFacesSolid(dm, set_gl_material);
+ dm->drawFacesSolid(dm, GPU_enable_material);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ GPU_disable_material();
}
else {
dm->drawEdges(dm, 0);
@@ -2312,7 +2277,19 @@ static void draw_mesh_fancy(Base *base, int dt, int flag)
draw_mesh_object_outline(ob, dm);
}
- draw_mesh_textured(ob, dm, faceselect);
+ if(draw_glsl_material(ob, dt)) {
+ glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
+
+ dm->drawFacesGLSL(dm, GPU_enable_material);
+ if(get_property(ob, "Text"))
+ draw_mesh_text(ob, 1);
+ GPU_disable_material();
+
+ glFrontFace(GL_CCW);
+ }
+ else {
+ draw_mesh_textured(ob, dm, faceselect);
+ }
if(!faceselect) {
if(base->flag & SELECT)
@@ -2323,18 +2300,17 @@ static void draw_mesh_fancy(Base *base, int dt, int flag)
dm->drawLooseEdges(dm);
}
}
- else if(dt==OB_SOLID ) {
-
- if ((G.vd->flag&V3D_SELECT_OUTLINE) && (base->flag&SELECT) && !draw_wire) {
+ else if(dt==OB_SOLID) {
+ if((G.vd->flag&V3D_SELECT_OUTLINE) && (base->flag&SELECT) && !draw_wire)
draw_mesh_object_outline(ob, dm);
- }
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED );
glEnable(GL_LIGHTING);
glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
- dm->drawFacesSolid(dm, set_gl_material);
+ dm->drawFacesSolid(dm, GPU_enable_material);
+ GPU_disable_material();
glFrontFace(GL_CCW);
glDisable(GL_LIGHTING);
@@ -2352,7 +2328,8 @@ static void draw_mesh_fancy(Base *base, int dt, int flag)
if(ob==OBACT) {
do_draw= 0;
if( (G.f & G_WEIGHTPAINT)) {
- set_gl_material(0); /* enforce defmaterial settings */
+ /* enforce default material settings */
+ GPU_enable_material(0, NULL);
/* but set default spec */
glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
@@ -2367,6 +2344,8 @@ static void draw_mesh_fancy(Base *base, int dt, int flag)
dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1);
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING);
+
+ GPU_disable_material();
}
else if((G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) && me->mcol) {
dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1);
@@ -2385,7 +2364,7 @@ static void draw_mesh_fancy(Base *base, int dt, int flag)
dm->release(dm);
shadeDispList(base);
dl = find_displist(&ob->disp, DL_VERTCOL);
- dm= mesh_get_derived_final(ob, get_viewedit_datamask());
+ dm= mesh_get_derived_final(ob, get_viewedit_datamask());
}
if ((G.vd->flag&V3D_SELECT_OUTLINE) && (base->flag&SELECT) && !draw_wire) {
@@ -2462,7 +2441,7 @@ static int draw_mesh_object(Base *base, int dt, int flag)
{
Object *ob= base->object;
Mesh *me= ob->data;
- int has_alpha= 0, drawlinked= 0, retval= 0;
+ int do_alpha_pass= 0, drawlinked= 0, retval= 0, glsl, check_alpha;
if(G.obedit && ob!=G.obedit && ob->data==G.obedit->data) {
if(ob_get_key(ob));
@@ -2478,7 +2457,12 @@ static int draw_mesh_object(Base *base, int dt, int flag)
cageDM = editmesh_get_derived_cage_and_final(&finalDM,
get_viewedit_datamask());
- if(dt>OB_WIRE) init_gl_materials(ob, 0); // no transp in editmode, the fancy draw over goes bad then
+ if(dt>OB_WIRE) {
+ // no transp in editmode, the fancy draw over goes bad then
+ glsl = draw_glsl_material(ob, dt);
+ GPU_set_object_materials(G.scene, ob, glsl, NULL);
+ }
+
draw_em_fancy(ob, G.editMesh, cageDM, finalDM, dt);
if (G.obedit!=ob && finalDM)
@@ -2491,15 +2475,22 @@ static int draw_mesh_object(Base *base, int dt, int flag)
else {
/* don't create boundbox here with mesh_get_bb(), the derived system will make it, puts deformed bb's OK */
if(me->totface<=4 || boundbox_clip(ob->obmat, (ob->bb)? ob->bb: me->bb)) {
- if(dt==OB_SOLID) has_alpha= init_gl_materials(ob, (base->flag & OB_FROMDUPLI)==0);
+ glsl = draw_glsl_material(ob, dt);
+ check_alpha = check_material_alpha(base, ob, glsl);
+
+ if(dt==OB_SOLID || glsl) {
+ GPU_set_object_materials(G.scene, ob, glsl,
+ (check_alpha)? &do_alpha_pass: NULL);
+ }
+
draw_mesh_fancy(base, dt, flag);
if(me->totvert==0) retval= 1;
}
}
- /* init_gl_materials did the proper checking if this is needed */
- if(has_alpha) add_view3d_after(G.vd, base, V3D_TRANSP, flag);
+ /* GPU_set_object_materials checked if this is needed */
+ if(do_alpha_pass) add_view3d_after(G.vd, base, V3D_TRANSP, flag);
return retval;
}
@@ -2601,9 +2592,10 @@ static int drawDispListwire(ListBase *dlbase)
return 0;
}
-static void drawDispListsolid(ListBase *lb, Object *ob)
+static void drawDispListsolid(ListBase *lb, Object *ob, int glsl)
{
DispList *dl;
+ GPUVertexAttribs gattribs;
float *data, curcol[4];
float *ndata;
@@ -2667,7 +2659,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob)
case DL_SURF:
if(dl->index) {
- set_gl_material(dl->col+1);
+ GPU_enable_material(dl->col+1, (glsl)? &gattribs: NULL);
if(dl->rt & CU_SMOOTH) glShadeModel(GL_SMOOTH);
else glShadeModel(GL_FLAT);
@@ -2675,12 +2667,12 @@ static void drawDispListsolid(ListBase *lb, Object *ob)
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
glNormalPointer(GL_FLOAT, 0, dl->nors);
glDrawElements(GL_QUADS, 4*dl->totindex, GL_UNSIGNED_INT, dl->index);
+ GPU_disable_material();
}
break;
case DL_INDEX3:
-
- set_gl_material(dl->col+1);
+ GPU_enable_material(dl->col+1, (glsl)? &gattribs: NULL);
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
@@ -2693,6 +2685,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob)
glNormalPointer(GL_FLOAT, 0, dl->nors);
glDrawElements(GL_TRIANGLES, 3*dl->parts, GL_UNSIGNED_INT, dl->index);
+ GPU_disable_material();
if(index3_nors_incr==0)
glEnableClientState(GL_NORMAL_ARRAY);
@@ -2700,12 +2693,13 @@ static void drawDispListsolid(ListBase *lb, Object *ob)
break;
case DL_INDEX4:
-
- set_gl_material(dl->col+1);
+ GPU_enable_material(dl->col+1, (glsl)? &gattribs: NULL);
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
glNormalPointer(GL_FLOAT, 0, dl->nors);
glDrawElements(GL_QUADS, 4*dl->parts, GL_UNSIGNED_INT, dl->index);
+
+ GPU_disable_material();
break;
}
@@ -2799,14 +2793,18 @@ static int drawDispList(Base *base, int dt)
draw_index_wire= 1;
}
else {
- if(dt==OB_SHADED) {
+ if(draw_glsl_material(ob, dt)) {
+ GPU_set_object_materials(G.scene, ob, 1, NULL);
+ drawDispListsolid(lb, ob, 1);
+ }
+ else if(dt == OB_SHADED) {
if(ob->disp.first==0) shadeDispList(base);
drawDispListshaded(lb, ob);
}
else {
- init_gl_materials(ob, 0);
+ GPU_set_object_materials(G.scene, ob, 0, NULL);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
- drawDispListsolid(lb, ob);
+ drawDispListsolid(lb, ob, 0);
}
if(ob==G.obedit && cu->bevobj==NULL && cu->taperobj==NULL && cu->ext1 == 0.0 && cu->ext2 == 0.0) {
cpack(0);
@@ -2833,15 +2831,19 @@ static int drawDispList(Base *base, int dt)
if(dl->nors==NULL) addnormalsDispList(ob, lb);
- if(dt==OB_SHADED) {
+ if(draw_glsl_material(ob, dt)) {
+ GPU_set_object_materials(G.scene, ob, 1, NULL);
+ drawDispListsolid(lb, ob, 1);
+ }
+ else if(dt==OB_SHADED) {
if(ob->disp.first==NULL) shadeDispList(base);
drawDispListshaded(lb, ob);
}
else {
- init_gl_materials(ob, 0);
+ GPU_set_object_materials(G.scene, ob, 0, NULL);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
- drawDispListsolid(lb, ob);
+ drawDispListsolid(lb, ob, 0);
}
}
else {
@@ -2857,16 +2859,20 @@ static int drawDispList(Base *base, int dt)
if(solid) {
- if(dt==OB_SHADED) {
+ if(draw_glsl_material(ob, dt)) {
+ GPU_set_object_materials(G.scene, ob, 1, NULL);
+ drawDispListsolid(lb, ob, 1);
+ }
+ else if(dt == OB_SHADED) {
dl= lb->first;
if(dl && dl->col1==0) shadeDispList(base);
drawDispListshaded(lb, ob);
}
else {
- init_gl_materials(ob, 0);
+ GPU_set_object_materials(G.scene, ob, 0, NULL);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
- drawDispListsolid(lb, ob);
+ drawDispListsolid(lb, ob, 0);
}
}
else{
@@ -4624,9 +4630,8 @@ static void drawSolidSelect(Base *base)
drawDispListwire(&ob->disp);
}
else if(ob->type==OB_ARMATURE) {
- if(!(ob->flag & OB_POSEMODE)) {
+ if(!(ob->flag & OB_POSEMODE))
draw_armature(base, OB_WIRE, 0);
- }
}
glLineWidth(1.0);
@@ -5094,8 +5099,9 @@ void draw_object(Base *base, int flag)
drawlattice(ob);
break;
case OB_ARMATURE:
- if(dt>OB_WIRE) set_gl_material(0); // we use defmaterial
+ if(dt>OB_WIRE) GPU_enable_material(0, NULL); // we use default material
empty_object= draw_armature(base, dt, flag);
+ if(dt>OB_WIRE) GPU_disable_material();
break;
default:
drawaxes(1.0, flag, OB_ARROWS);
@@ -5138,9 +5144,8 @@ void draw_object(Base *base, int flag)
}
/* draw extra: after normal draw because of makeDispList */
- if(dtx) {
- if(G.f & G_SIMULATION);
- else if(dtx & OB_AXIS) {
+ if(dtx && !(G.f & G_SIMULATION)) {
+ if(dtx & OB_AXIS) {
drawaxes(1.0f, flag, OB_ARROWS);
}
if(dtx & OB_BOUNDBOX) draw_bounding_volume(ob);
@@ -5411,19 +5416,6 @@ static int bbs_mesh_solid__setDrawOpts(void *userData, int index, int *drawSmoot
}
}
-static int bbs_mesh_wire__setDrawOpts(void *userData, int index)
-{
- struct { Mesh *me; EdgeHash *eh; int offset; } *data = userData;
- MEdge *med = data->me->medge + index;
- uintptr_t flags = (intptr_t)BLI_edgehash_lookup(data->eh, med->v1, med->v2);
-
- if (flags & 1) {
- set_framebuffer_index_color(data->offset+index);
- return 1;
- } else
- return 0;
-}
-
/* TODO remove this - since face select mode now only works with painting */
static void bbs_mesh_solid(Object *ob)
{
@@ -5433,22 +5425,6 @@ static void bbs_mesh_solid(Object *ob)
glColor3ub(0, 0, 0);
dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, me, 0);
- /* draw edges for seam marking in faceselect mode, but not when painting,
- so that painting doesn't get interrupted on an edge */
- if ((G.f & G_FACESELECT) && !(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT))) {
- struct { Mesh *me; EdgeHash *eh; int offset; } userData;
-
- userData.me = me;
- userData.eh = get_tface_mesh_marked_edge_info(me);
- userData.offset = userData.me->totface+1;
-
- bglPolygonOffset(1.0);
- dm->drawMappedEdges(dm, bbs_mesh_wire__setDrawOpts, (void*)&userData);
- bglPolygonOffset(0.0);
-
- BLI_edgehash_free(userData.eh, NULL);
- }
-
dm->release(dm);
}
@@ -5504,6 +5480,7 @@ void draw_object_backbufsel(Object *ob)
static void draw_object_mesh_instance(Object *ob, int dt, int outline)
{
DerivedMesh *dm=NULL, *edm=NULL;
+ int glsl;
if(G.obedit && ob->data==G.obedit->data)
edm= editmesh_get_derived_base();
@@ -5520,8 +5497,10 @@ static void draw_object_mesh_instance(Object *ob, int dt, int outline)
if(outline)
draw_mesh_object_outline(ob, dm?dm:edm);
- if(dm)
- init_gl_materials(ob, 0);
+ if(dm) {
+ glsl = draw_glsl_material(ob, dt);
+ GPU_set_object_materials(G.scene, ob, glsl, NULL);
+ }
else {
glEnable(GL_COLOR_MATERIAL);
BIF_ThemeColor(TH_BONE_SOLID);
@@ -5532,8 +5511,10 @@ static void draw_object_mesh_instance(Object *ob, int dt, int outline)
glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
glEnable(GL_LIGHTING);
- if(dm)
- dm->drawFacesSolid(dm, set_gl_material);
+ if(dm) {
+ dm->drawFacesSolid(dm, GPU_enable_material);
+ GPU_disable_material();
+ }
else if(edm)
edm->drawMappedFaces(edm, NULL, NULL, 0);
diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c
index 2030eb658de..020dfd407ad 100644
--- a/source/blender/src/drawview.c
+++ b/source/blender/src/drawview.c
@@ -64,6 +64,7 @@
#include "DNA_gpencil_types.h"
#include "DNA_image_types.h"
#include "DNA_key_types.h"
+#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -162,6 +163,9 @@
#include "RE_pipeline.h" // make_stars
+#include "GPU_draw.h"
+#include "GPU_material.h"
+
#include "multires.h"
/* For MULTISAMPLE_ARB #define.
@@ -193,132 +197,6 @@ static void star_stuff_term_func(void)
glEnd();
}
-void default_gl_light(void)
-{
- int a;
-
- /* initialize */
- if(U.light[0].flag==0 && U.light[1].flag==0 && U.light[2].flag==0) {
- U.light[0].flag= 1;
- U.light[0].vec[0]= -0.3; U.light[0].vec[1]= 0.3; U.light[0].vec[2]= 0.9;
- U.light[0].col[0]= 0.8; U.light[0].col[1]= 0.8; U.light[0].col[2]= 0.8;
- U.light[0].spec[0]= 0.5; U.light[0].spec[1]= 0.5; U.light[0].spec[2]= 0.5;
- U.light[0].spec[3]= 1.0;
-
- U.light[1].flag= 0;
- U.light[1].vec[0]= 0.5; U.light[1].vec[1]= 0.5; U.light[1].vec[2]= 0.1;
- U.light[1].col[0]= 0.4; U.light[1].col[1]= 0.4; U.light[1].col[2]= 0.8;
- U.light[1].spec[0]= 0.3; U.light[1].spec[1]= 0.3; U.light[1].spec[2]= 0.5;
- U.light[1].spec[3]= 1.0;
-
- U.light[2].flag= 0;
- U.light[2].vec[0]= 0.3; U.light[2].vec[1]= -0.3; U.light[2].vec[2]= -0.2;
- U.light[2].col[0]= 0.8; U.light[2].col[1]= 0.5; U.light[2].col[2]= 0.4;
- U.light[2].spec[0]= 0.5; U.light[2].spec[1]= 0.4; U.light[2].spec[2]= 0.3;
- U.light[2].spec[3]= 1.0;
- }
-
-
- glLightfv(GL_LIGHT0, GL_POSITION, U.light[0].vec);
- glLightfv(GL_LIGHT0, GL_DIFFUSE, U.light[0].col);
- glLightfv(GL_LIGHT0, GL_SPECULAR, U.light[0].spec);
-
- glLightfv(GL_LIGHT1, GL_POSITION, U.light[1].vec);
- glLightfv(GL_LIGHT1, GL_DIFFUSE, U.light[1].col);
- glLightfv(GL_LIGHT1, GL_SPECULAR, U.light[1].spec);
-
- glLightfv(GL_LIGHT2, GL_POSITION, U.light[2].vec);
- glLightfv(GL_LIGHT2, GL_DIFFUSE, U.light[2].col);
- glLightfv(GL_LIGHT2, GL_SPECULAR, U.light[2].spec);
-
- for(a=0; a<8; a++) {
- if(a<3) {
- if(U.light[a].flag) glEnable(GL_LIGHT0+a);
- else glDisable(GL_LIGHT0+a);
-
- // clear stuff from other opengl lamp usage
- glLightf(GL_LIGHT0+a, GL_SPOT_CUTOFF, 180.0);
- glLightf(GL_LIGHT0+a, GL_CONSTANT_ATTENUATION, 1.0);
- glLightf(GL_LIGHT0+a, GL_LINEAR_ATTENUATION, 0.0);
- }
- else glDisable(GL_LIGHT0+a);
- }
-
- glDisable(GL_LIGHTING);
-
- glDisable(GL_COLOR_MATERIAL);
-}
-
-/* also called when render 'ogl'
- keep synced with Myinit_gl_stuff in the game engine! */
-void init_gl_stuff(void)
-{
- float mat_ambient[] = { 0.0, 0.0, 0.0, 0.0 };
- float mat_specular[] = { 0.5, 0.5, 0.5, 1.0 };
- float mat_shininess[] = { 35.0 };
- int a, x, y;
- GLubyte pat[32*32];
- const GLubyte *patc= pat;
-
-
- glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_specular);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
-
- default_gl_light();
-
- /* no local viewer, looks ugly in ortho mode */
- /* glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, &one); */
-
- glDepthFunc(GL_LEQUAL);
- /* scaling matrices */
- glEnable(GL_NORMALIZE);
-
- glShadeModel(GL_FLAT);
-
- glDisable(GL_ALPHA_TEST);
- glDisable(GL_BLEND);
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_FOG);
- glDisable(GL_LIGHTING);
- glDisable(GL_LOGIC_OP);
- glDisable(GL_STENCIL_TEST);
- glDisable(GL_TEXTURE_1D);
- glDisable(GL_TEXTURE_2D);
-
- /* default on, disable/enable should be local per function */
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
-
- glPixelTransferi(GL_MAP_COLOR, GL_FALSE);
- glPixelTransferi(GL_RED_SCALE, 1);
- glPixelTransferi(GL_RED_BIAS, 0);
- glPixelTransferi(GL_GREEN_SCALE, 1);
- glPixelTransferi(GL_GREEN_BIAS, 0);
- glPixelTransferi(GL_BLUE_SCALE, 1);
- glPixelTransferi(GL_BLUE_BIAS, 0);
- glPixelTransferi(GL_ALPHA_SCALE, 1);
- glPixelTransferi(GL_ALPHA_BIAS, 0);
-
- glPixelTransferi(GL_DEPTH_BIAS, 0);
- glPixelTransferi(GL_DEPTH_SCALE, 1);
- glDepthRange(0.0, 1.0);
-
- a= 0;
- for(x=0; x<32; x++) {
- for(y=0; y<4; y++) {
- if( (x) & 1) pat[a++]= 0x88;
- else pat[a++]= 0x22;
- }
- }
-
- glPolygonStipple(patc);
-
-
- init_realtime_GL();
-}
-
void circf(float x, float y, float rad)
{
GLUquadricObj *qobj = gluNewQuadric();
@@ -2737,7 +2615,7 @@ void add_view3d_after(View3D *v3d, Base *base, int type, int flag)
}
/* clears zbuffer and draws it over */
-static void view3d_draw_xray(View3D *v3d)
+static void view3d_draw_xray(View3D *v3d, int clear)
{
View3DAfter *v3da, *next;
int doit= 0;
@@ -2746,7 +2624,7 @@ static void view3d_draw_xray(View3D *v3d)
if(v3da->type==V3D_XRAY) doit= 1;
if(doit) {
- if(v3d->zbuf) glClear(GL_DEPTH_BUFFER_BIT);
+ if(clear && v3d->zbuf) glClear(GL_DEPTH_BUFFER_BIT);
v3d->xray= TRUE;
for(v3da= v3d->afterdraw.first; v3da; v3da= next) {
@@ -2768,7 +2646,7 @@ static void view3d_draw_transp(View3D *v3d)
glDepthMask(0);
v3d->transp= TRUE;
-
+
for(v3da= v3d->afterdraw.first; v3da; v3da= next) {
next= v3da->next;
if(v3da->type==V3D_TRANSP) {
@@ -2946,7 +2824,7 @@ static void draw_sculpt_depths(View3D *v3d)
}
}
-void draw_depth(ScrArea *sa, void *spacedata)
+void draw_depth(ScrArea *sa, void *spacedata, int (* func)(void *))
{
View3D *v3d= spacedata;
Base *base;
@@ -2986,9 +2864,11 @@ void draw_depth(ScrArea *sa, void *spacedata)
if(G.scene->set) {
for(SETLOOPER(G.scene->set, base)) {
if(v3d->lay & base->lay) {
- draw_object(base, 0);
- if(base->object->transflag & OB_DUPLI) {
- draw_dupli_objects_color(v3d, base, TH_WIRE);
+ if (func == NULL || func(base)) {
+ draw_object(base, 0);
+ if(base->object->transflag & OB_DUPLI) {
+ draw_dupli_objects_color(v3d, base, TH_WIRE);
+ }
}
}
}
@@ -2996,12 +2876,13 @@ void draw_depth(ScrArea *sa, void *spacedata)
for(base= G.scene->base.first; base; base= base->next) {
if(v3d->lay & base->lay) {
-
- /* dupli drawing */
- if(base->object->transflag & OB_DUPLI) {
- draw_dupli_objects(v3d, base);
+ if (func == NULL || func(base)) {
+ /* dupli drawing */
+ if(base->object->transflag & OB_DUPLI) {
+ draw_dupli_objects(v3d, base);
+ }
+ draw_object(base, 0);
}
- draw_object(base, 0);
}
}
@@ -3046,6 +2927,84 @@ void draw_depth(ScrArea *sa, void *spacedata)
static void draw_viewport_fps(ScrArea *sa);
+typedef struct View3DShadow{
+ struct View3DShadow*next, *prev;
+ GPULamp *lamp;
+} View3DShadow;
+
+static void gpu_render_lamp_update(View3D *v3d, Object *ob, Object *par, float obmat[][4], ListBase *shadows)
+{
+ GPULamp *lamp;
+ View3DShadow *shadow;
+
+ lamp = GPU_lamp_from_blender(G.scene, ob, par);
+
+ if(lamp) {
+ GPU_lamp_update(lamp, obmat);
+
+ if(GPU_lamp_has_shadow_buffer(lamp)) {
+ shadow= MEM_callocN(sizeof(View3DShadow), "View3DShadow");
+ shadow->lamp = lamp;
+ BLI_addtail(shadows, shadow);
+ }
+ }
+}
+
+static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
+{
+ ListBase shadows;
+ View3DShadow *shadow;
+ Scene *sce;
+ Base *base;
+ Object *ob;
+
+ shadows.first= shadows.last= NULL;
+
+ /* update lamp transform and gather shadow lamps */
+ for(SETLOOPER(G.scene, base)) {
+ ob= base->object;
+
+ if(ob->type == OB_LAMP)
+ gpu_render_lamp_update(v3d, ob, NULL, ob->obmat, &shadows);
+
+ if (ob->transflag & OB_DUPLI) {
+ DupliObject *dob;
+ ListBase *lb = object_duplilist(G.scene, ob);
+
+ for(dob=lb->first; dob; dob=dob->next)
+ if(dob->ob->type==OB_LAMP)
+ gpu_render_lamp_update(v3d, dob->ob, ob, dob->mat, &shadows);
+
+ free_object_duplilist(lb);
+ }
+ }
+
+ /* render shadows after updating all lamps, nested object_duplilist
+ * don't work correct since it's replacing object matrices */
+ for(shadow=shadows.first; shadow; shadow=shadow->next) {
+ /* this needs to be done better .. */
+ float viewmat[4][4], winmat[4][4];
+ int drawtype, lay, winsize, flag2;
+
+ drawtype= v3d->drawtype;
+ lay= v3d->lay;
+ flag2= v3d->flag2 & V3D_SOLID_TEX;
+
+ v3d->drawtype = OB_SOLID;
+ v3d->lay &= GPU_lamp_shadow_layer(shadow->lamp);
+ v3d->flag2 &= ~V3D_SOLID_TEX;
+
+ GPU_lamp_shadow_buffer_bind(shadow->lamp, viewmat, &winsize, winmat);
+ drawview3d_render(v3d, viewmat, winsize, winsize, winmat, 1);
+ GPU_lamp_shadow_buffer_unbind(shadow->lamp);
+
+ v3d->drawtype= drawtype;
+ v3d->lay= lay;
+ v3d->flag2 |= flag2;
+ }
+
+ BLI_freelistN(&shadows);
+}
void drawview3dspace(ScrArea *sa, void *spacedata)
{
@@ -3066,6 +3025,10 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
for(base= G.scene->base.first; base; base= base->next)
object_handle_update(base->object); // bke_object.h
+
+ /* shadow buffers, before we setup matrices */
+ if(draw_glsl_material(NULL, v3d->drawtype))
+ gpu_update_lamps_shadows(G.scene, v3d);
setwinmatrixview3d(sa->winx, sa->winy, NULL); /* 0= no pick rect */
setviewmatrixview3d(); /* note: calls where_is_object for camera... */
@@ -3208,8 +3171,8 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
if(G.scene->radio) RAD_drawall(v3d->drawtype>=OB_SOLID);
/* Transp and X-ray afterdraw stuff */
- view3d_draw_xray(v3d); // clears zbuffer if it is used!
view3d_draw_transp(v3d);
+ view3d_draw_xray(v3d, 1); // clears zbuffer if it is used!
if(!retopo && sculptparticle && (obact && (OBACT->dtx & OB_DRAWXRAY))) {
if(G.f & G_SCULPTMODE)
@@ -3328,18 +3291,29 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
}
-
-void drawview3d_render(struct View3D *v3d, int winx, int winy, float winmat[][4])
+void drawview3d_render(struct View3D *v3d, float viewmat[][4], int winx, int winy, float winmat[][4], int shadow)
{
Base *base;
Scene *sce;
- float v3dwinmat[4][4];
+ float v3dviewmat[4][4], v3dwinmat[4][4];
+
+ /* shadow buffers, before we setup matrices */
+ if(!shadow && draw_glsl_material(NULL, v3d->drawtype))
+ gpu_update_lamps_shadows(G.scene, v3d);
if(!winmat)
setwinmatrixview3d(winx, winy, NULL);
- setviewmatrixview3d();
- myloadmatrix(v3d->viewmat);
+ if(viewmat) {
+ Mat4CpyMat4(v3dviewmat, viewmat);
+ Mat4CpyMat4(v3d->viewmat, viewmat);
+ }
+ else {
+ setviewmatrixview3d();
+ Mat4CpyMat4(v3dviewmat, v3d->viewmat);
+ }
+
+ myloadmatrix(v3dviewmat);
/* when winmat is not NULL, it overrides the regular window matrix */
glMatrixMode(GL_PROJECTION);
@@ -3348,12 +3322,14 @@ void drawview3d_render(struct View3D *v3d, int winx, int winy, float winmat[][4]
mygetmatrix(v3dwinmat);
glMatrixMode(GL_MODELVIEW);
- Mat4MulMat4(v3d->persmat, v3d->viewmat, v3dwinmat);
+ Mat4MulMat4(v3d->persmat, v3dviewmat, v3dwinmat);
Mat4Invert(v3d->persinv, v3d->persmat);
Mat4Invert(v3d->viewinv, v3d->viewmat);
- free_all_realtime_images();
- reshadeall_displist();
+ if(!shadow) {
+ GPU_free_images();
+ reshadeall_displist();
+ }
if(v3d->drawtype > OB_WIRE) {
v3d->zbuf= TRUE;
@@ -3431,8 +3407,8 @@ void drawview3d_render(struct View3D *v3d, int winx, int winy, float winmat[][4]
if(G.scene->radio) RAD_drawall(v3d->drawtype>=OB_SOLID);
/* Transp and X-ray afterdraw stuff */
- view3d_draw_xray(v3d); // clears zbuffer if it is used!
view3d_draw_transp(v3d);
+ view3d_draw_xray(v3d, !shadow); // clears zbuffer if it is used!
if(v3d->flag & V3D_CLIPPING)
view3d_clr_clipping();
@@ -3451,11 +3427,12 @@ void drawview3d_render(struct View3D *v3d, int winx, int winy, float winmat[][4]
G.f &= ~G_SIMULATION;
- glFlush();
+ if(!shadow) {
+ glFlush();
+ GPU_free_images();
+ }
glLoadIdentity();
-
- free_all_realtime_images();
}
diff --git a/source/blender/src/editdeform.c b/source/blender/src/editdeform.c
index 5de4c6ed23c..3f178e1ea2b 100644
--- a/source/blender/src/editdeform.c
+++ b/source/blender/src/editdeform.c
@@ -270,7 +270,7 @@ static void del_defgroup_update_users(Object *ob, int id)
int a;
/* these cases don't use names to refer to vertex groups, so when
- * they get deleted the numbers get out of synce, this corrects that */
+ * they get deleted the numbers get out of sync, this corrects that */
if(ob->soft) {
if(ob->soft->vertgroup == id)
diff --git a/source/blender/src/editface.c b/source/blender/src/editface.c
index 781210cd373..008ddf3b5f0 100644
--- a/source/blender/src/editface.c
+++ b/source/blender/src/editface.c
@@ -82,13 +82,14 @@
#include "BIF_space.h" /* for allqueue */
#include "BIF_drawimage.h" /* for allqueue */
-#include "BDR_drawmesh.h"
#include "BDR_editface.h"
#include "BDR_vpaint.h"
#include "BDR_editface.h"
#include "BDR_vpaint.h"
+#include "GPU_draw.h"
+
#include "mydevice.h"
#include "blendef.h"
#include "butspace.h"
@@ -1315,7 +1316,7 @@ void set_texturepaint() /* toggle */
if(G.f & G_TEXTUREPAINT) {
G.f &= ~G_TEXTUREPAINT;
- texpaint_enable_mipmap();
+ GPU_paint_set_mipmap(1);
}
else if (me) {
G.f |= G_TEXTUREPAINT;
@@ -1324,7 +1325,7 @@ void set_texturepaint() /* toggle */
make_tfaces(me);
brush_check_exists(&G.scene->toolsettings->imapaint.brush);
- texpaint_disable_mipmap();
+ GPU_paint_set_mipmap(0);
}
allqueue(REDRAWVIEW3D, 0);
diff --git a/source/blender/src/editipo_lib.c b/source/blender/src/editipo_lib.c
index e1e286e10cf..7bfd097b87f 100644
--- a/source/blender/src/editipo_lib.c
+++ b/source/blender/src/editipo_lib.c
@@ -392,7 +392,15 @@ int texchannel_to_adrcode(int channel)
case 6: return MA_MAP7;
case 7: return MA_MAP8;
case 8: return MA_MAP9;
- case 9: return MA_MAP10;
+ case 9: return MA_MAP10;
+ case 10: return MA_MAP11;
+ case 11: return MA_MAP12;
+ case 12: return MA_MAP13;
+ case 13: return MA_MAP14;
+ case 14: return MA_MAP15;
+ case 15: return MA_MAP16;
+ case 16: return MA_MAP17;
+ case 17: return MA_MAP18;
default: return 0;
}
}
diff --git a/source/blender/src/editlattice.c b/source/blender/src/editlattice.c
index 0782e012f68..06b092a30ac 100644
--- a/source/blender/src/editlattice.c
+++ b/source/blender/src/editlattice.c
@@ -131,7 +131,7 @@ void make_editLatt(void)
copy_dverts(editLatt->dvert, lt->dvert, tot);
}
- BIF_undo_push("original");
+ BIF_undo_push("Original");
}
diff --git a/source/blender/src/editmode_undo.c b/source/blender/src/editmode_undo.c
index d0a44360ad5..7893dac2408 100644
--- a/source/blender/src/editmode_undo.c
+++ b/source/blender/src/editmode_undo.c
@@ -107,6 +107,7 @@ typedef struct UndoElem {
Object *ob; // pointer to edited object
int type; // type of edited object
void *undodata;
+ uintptr_t undosize;
char name[MAXUNDONAME];
void (*freedata)(void *);
void (*to_editmode)(void *);
@@ -138,6 +139,7 @@ void undo_editmode_push(char *name, void (*freedata)(void *),
{
UndoElem *uel;
int nr;
+ uintptr_t memused, totmem, maxmem;
/* at first here was code to prevent an "original" key to be insterted twice
this was giving conflicts for example when mesh changed due to keys or apply */
@@ -145,9 +147,8 @@ void undo_editmode_push(char *name, void (*freedata)(void *),
/* remove all undos after (also when curundo==NULL) */
while(undobase.last != curundo) {
uel= undobase.last;
- BLI_remlink(&undobase, uel);
uel->freedata(uel->undodata);
- MEM_freeN(uel);
+ BLI_freelinkN(&undobase, uel);
}
/* make new */
@@ -160,7 +161,7 @@ void undo_editmode_push(char *name, void (*freedata)(void *),
uel->from_editmode= from_editmode;
uel->validate_undo= validate_undo;
- /* and limit amount to the maximum */
+ /* limit amount to the maximum amount*/
nr= 0;
uel= undobase.last;
while(uel) {
@@ -171,19 +172,43 @@ void undo_editmode_push(char *name, void (*freedata)(void *),
if(uel) {
while(undobase.first!=uel) {
UndoElem *first= undobase.first;
- BLI_remlink(&undobase, first);
first->freedata(first->undodata);
- MEM_freeN(first);
+ BLI_freelinkN(&undobase, first);
}
}
/* copy */
+ memused= MEM_get_memory_in_use();
curundo->undodata= curundo->from_editmode();
+ curundo->undosize= MEM_get_memory_in_use() - memused;
curundo->ob= G.obedit;
curundo->id= G.obedit->id;
curundo->type= G.obedit->type;
-}
+ if(U.undomemory != 0) {
+ /* limit to maximum memory (afterwards, we can't know in advance) */
+ totmem= 0;
+ maxmem= ((uintptr_t)U.undomemory)*1024*1024;
+
+ uel= undobase.last;
+ while(uel && uel->prev) {
+ totmem+= uel->undosize;
+ if(totmem>maxmem) break;
+ uel= uel->prev;
+ }
+
+ if(uel) {
+ if(uel->prev && uel->prev->prev)
+ uel= uel->prev;
+
+ while(undobase.first!=uel) {
+ UndoElem *first= undobase.first;
+ first->freedata(first->undodata);
+ BLI_freelinkN(&undobase, first);
+ }
+ }
+ }
+}
/* helper to remove clean other objects from undo stack */
static void undo_clean_stack(void)
@@ -205,9 +230,8 @@ static void undo_clean_stack(void)
}
else {
mixed= 1;
- BLI_remlink(&undobase, uel);
uel->freedata(uel->undodata);
- MEM_freeN(uel);
+ BLI_freelinkN(&undobase, uel);
}
uel= next;
diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c
index d2e59ae676d..2133a92a54e 100644
--- a/source/blender/src/editview.c
+++ b/source/blender/src/editview.c
@@ -2247,7 +2247,7 @@ void view3d_border_zoom(void)
/* Get Z Depths, needed for perspective, nice for ortho */
bgl_get_mats(&mats);
- draw_depth(curarea, (void *)v3d);
+ draw_depth(curarea, (void *)v3d, NULL);
/* force updating */
if (v3d->depths) {
diff --git a/source/blender/src/header_image.c b/source/blender/src/header_image.c
index fac9e3af1af..1b90c406f0e 100644
--- a/source/blender/src/header_image.c
+++ b/source/blender/src/header_image.c
@@ -239,8 +239,10 @@ void do_image_buttons(unsigned short event)
if(ima->twsta>=nr) ima->twsta= 1;
if(ima->twend>=nr) ima->twend= nr-1;
if(ima->twsta>ima->twend) ima->twsta= 1;
- allqueue(REDRAWIMAGE, 0);
}
+
+ allqueue(REDRAWIMAGE, 0);
+ allqueue(REDRAWVIEW3D, 0);
}
break;
}
@@ -1293,7 +1295,7 @@ void image_buttons(void)
uiBlockEndAlign(block);
xco+= 166;
}
- uiDefIconButBitI(block, TOG, SI_DRAWTOOL, B_SIMAGEPAINTTOOL, ICON_TPAINT_HLT, xco,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Enables painting textures on the image with left mouse button");
+ uiDefIconButBitI(block, TOG, SI_DRAWTOOL, B_SIMAGEPAINTTOOL, ICON_TPAINT_HLT, xco,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Enable image painting");
xco+= XIC+8;
diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c
index 8b8fd9ef266..9bacc2b6351 100644
--- a/source/blender/src/header_info.c
+++ b/source/blender/src/header_info.c
@@ -39,8 +39,6 @@
#include <config.h>
#endif
-#include "BLO_sys_types.h" // for intptr_t support
-
#include "DNA_group_types.h"
#include "DNA_ID.h"
#include "DNA_image_types.h"
@@ -120,6 +118,9 @@
#include "BPY_extern.h"
#include "BPY_menus.h"
+#include "GPU_extensions.h"
+#include "GPU_material.h"
+
#include "blendef.h"
#include "interface.h"
#include "mydevice.h"
@@ -926,7 +927,7 @@ static void do_info_filemenu(void *arg, int event)
winqueue_break= 1; /* leave queues everywhere */
BKE_reset_undo();
- BKE_write_undo("original"); /* save current state */
+ BKE_write_undo("Original"); /* save current state */
refresh_interface_font();
}
break;
@@ -1591,20 +1592,83 @@ static uiBlock *info_addmenu(void *arg_unused)
/************************** GAME *****************************/
-
+void do_info_game_glslmenu(void *arg, int event)
+{
+ switch (event) {
+ case G_FILE_GLSL_NO_LIGHTS:
+ case G_FILE_GLSL_NO_SHADERS:
+ case G_FILE_GLSL_NO_SHADOWS:
+ case G_FILE_GLSL_NO_RAMPS:
+ case G_FILE_GLSL_NO_NODES:
+ case G_FILE_GLSL_NO_EXTRA_TEX:
+ G.fileflags ^= event;
+ GPU_materials_free();
+ allqueue(REDRAWINFO, 0);
+ allqueue(REDRAWVIEW3D, 0);
+ break;
+ default:
+ break;
+ }
+}
+
+static uiBlock *info_game_glslmenu(void *arg_unused)
+{
+ uiBlock *block;
+ short yco= 0, menuwidth=160;
+ int check;
+
+ block= uiNewBlock(&curarea->uiblocks, "game_glslmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
+ uiBlockSetButmFunc(block, do_info_game_glslmenu, NULL);
+
+ check = (G.fileflags & G_FILE_GLSL_NO_LIGHTS)? ICON_CHECKBOX_DEHLT: ICON_CHECKBOX_HLT;
+ uiDefIconTextBut(block, BUTM, 1, check, "Enable Lights", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GLSL_NO_LIGHTS,
+ "Enable using lights in GLSL materials.");
+ check = (G.fileflags & G_FILE_GLSL_NO_SHADERS)? ICON_CHECKBOX_DEHLT: ICON_CHECKBOX_HLT;
+ uiDefIconTextBut(block, BUTM, 1, check, "Enable Shaders", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GLSL_NO_SHADERS,
+ "Enable using shaders other than Lambert in GLSL materials");
+ check = (G.fileflags & G_FILE_GLSL_NO_SHADOWS)? ICON_CHECKBOX_DEHLT: ICON_CHECKBOX_HLT;
+ uiDefIconTextBut(block, BUTM, 1, check, "Enable Shadows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GLSL_NO_SHADOWS,
+ "Enable using shadows in GLSL materials");
+ check = (G.fileflags & G_FILE_GLSL_NO_RAMPS)? ICON_CHECKBOX_DEHLT: ICON_CHECKBOX_HLT;
+ uiDefIconTextBut(block, BUTM, 1, check, "Enable Ramps", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GLSL_NO_RAMPS,
+ "Enable using ramps in GLSL materials");
+ check = (G.fileflags & G_FILE_GLSL_NO_NODES)? ICON_CHECKBOX_DEHLT: ICON_CHECKBOX_HLT;
+ uiDefIconTextBut(block, BUTM, 1, check, "Enable Nodes", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GLSL_NO_NODES,
+ "Enable using nodes in GLSL materials.");
+ check = (G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX)? ICON_CHECKBOX_DEHLT: ICON_CHECKBOX_HLT;
+ uiDefIconTextBut(block, BUTM, 1, check, "Enable Extra Textures", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GLSL_NO_EXTRA_TEX,
+ "Enable using texture channels other than Col and Alpha in GLSL materials.");
+
+ uiBlockSetDirection(block, UI_RIGHT);
+ uiTextBoundsBlock(block, 50);
+
+ return block;
+}
+
static void do_info_gamemenu(void *arg, int event)
{
switch (event) {
case G_FILE_ENABLE_ALL_FRAMES:
- case G_FILE_DIAPLAY_LISTS:
+ case G_FILE_DISPLAY_LISTS:
case G_FILE_SHOW_FRAMERATE:
case G_FILE_SHOW_DEBUG_PROPS:
case G_FILE_AUTOPLAY:
case G_FILE_GAME_TO_IPO:
- case G_FILE_GAME_MAT:
case G_FILE_SHOW_PHYSICS:
G.fileflags ^= event;
break;
+ case G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL:
+ G.fileflags &= ~(G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL);
+ break;
+ case G_FILE_GAME_MAT:
+ G.fileflags |= G_FILE_GAME_MAT;
+ G.fileflags &= ~G_FILE_GAME_MAT_GLSL;
+ break;
+ case G_FILE_GAME_MAT_GLSL:
+ if(!GPU_extensions_minimum_support())
+ error("GLSL not supported with this graphics card or driver.");
+ G.fileflags |= (G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL);
+ break;
default:
; /* ignore the rest */
}
@@ -1635,22 +1699,14 @@ static uiBlock *info_gamemenu(void *arg_unused)
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Record Game Physics to IPO", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_TO_IPO, "");
} else {
- if(G.fileflags & G_FILE_DIAPLAY_LISTS) {
- uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Generate Display Lists", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_DIAPLAY_LISTS, "");
+ if(G.fileflags & G_FILE_DISPLAY_LISTS) {
+ uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Generate Display Lists", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_DISPLAY_LISTS, "");
} else {
- uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Generate Display Lists", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_DIAPLAY_LISTS, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Generate Display Lists", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_DISPLAY_LISTS, "");
}
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Record Game Physics to IPO", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_TO_IPO, "");
}
- if(G.fileflags & G_FILE_GAME_MAT) {
- uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Use Blender Materials", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_MAT, "");
- } else {
- uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Use Blender Materials", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_MAT, "");
- }
-
-
-
if(G.fileflags & G_FILE_SHOW_FRAMERATE) {
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Show Framerate and Profile", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_FRAMERATE, "");
} else {
@@ -1669,6 +1725,28 @@ static uiBlock *info_gamemenu(void *arg_unused)
} else {
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Show Debug Properties", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_DEBUG_PROPS, "");
}
+
+ uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 1, 0, "");
+
+ if(!(G.fileflags & G_FILE_GAME_MAT)) {
+ uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Texture Face Materials", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
+ } else {
+ uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Texture Face Materials", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL, "");
+ }
+
+ if((G.fileflags & G_FILE_GAME_MAT) && !(G.fileflags & G_FILE_GAME_MAT_GLSL)) {
+ uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Blender Multitexture Materials", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
+ } else {
+ uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Blender Multitexture Materials", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_MAT, "");
+ }
+
+ if((G.fileflags & G_FILE_GAME_MAT) && (G.fileflags & G_FILE_GAME_MAT_GLSL)) {
+ uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Blender GLSL Materials", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
+ } else {
+ uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Blender GLSL Materials", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_MAT_GLSL, "");
+ }
+
+ uiDefIconTextBlockBut(block, info_game_glslmenu, NULL, ICON_RIGHTARROW_THIN, "GLSL Material Settings", 0, yco-=20, menuwidth, 19, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 1, 0, "");
@@ -2108,13 +2186,16 @@ static void info_text(int x, int y)
{
Object *ob= OBACT;
extern float hashvectf[];
- extern uintptr_t mem_in_use, mmap_in_use;
+ uintptr_t mem_in_use, mmap_in_use;
unsigned int swatch_color;
float fac1, fac2, fac3;
char infostr[300], memstr[64];
char *headerstr, *s;
int hsize;
+ mem_in_use= MEM_get_memory_in_use();
+ mmap_in_use= MEM_get_mapped_memory_in_use();
+
s= memstr + sprintf(memstr," | Mem:%.2fM ", ((mem_in_use-mmap_in_use)>>10)/1024.0);
if(mmap_in_use)
sprintf(s,"(%.2fM) ", ((mmap_in_use)>>10)/1024.0);
diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c
index e57a3480b52..5d284f5eab4 100644
--- a/source/blender/src/header_view3d.c
+++ b/source/blender/src/header_view3d.c
@@ -4512,7 +4512,7 @@ static void do_view3d_tpaintmenu(void *arg, int event)
{
switch(event) {
case 0: /* undo image painting */
- imagepaint_undo();
+ undo_imagepaint_step(1);
break;
}
diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c
index 1a91ada1562..44044841a99 100644
--- a/source/blender/src/headerbuttons.c
+++ b/source/blender/src/headerbuttons.c
@@ -154,7 +154,6 @@
#include "BSE_editipo.h"
#include "BSE_drawipo.h"
-#include "BDR_drawmesh.h"
#include "BDR_vpaint.h"
#include "BDR_editface.h"
#include "BDR_editobject.h"
@@ -165,6 +164,8 @@
#include "BPY_extern.h"
#include "BPY_menus.h"
+#include "GPU_draw.h"
+
#include "mydevice.h"
#include "blendef.h"
#include "interface.h"
@@ -1425,11 +1426,11 @@ void do_global_buttons(unsigned short event)
show_splash();
break;
case B_MIPMAPCHANGED:
- set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
+ GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
allqueue(REDRAWVIEW3D, 0);
break;
case B_GLRESLIMITCHANGED:
- free_all_realtime_images(); /* force reloading with new res limit */
+ GPU_free_images(); /* force reloading with new res limit */
allqueue(REDRAWVIEW3D, 0);
break;
case B_NEWSPACE:
diff --git a/source/blender/src/imagepaint.c b/source/blender/src/imagepaint.c
index 15c289cc21c..164c368b6fa 100644
--- a/source/blender/src/imagepaint.c
+++ b/source/blender/src/imagepaint.c
@@ -44,6 +44,8 @@
#include "BLI_winstuff.h"
#endif
#include "BLI_arithb.h"
+#include "BLI_blenlib.h"
+#include "BLI_dynstr.h"
#include "PIL_time.h"
#include "IMB_imbuf.h"
@@ -64,10 +66,12 @@
#include "BKE_brush.h"
#include "BKE_global.h"
#include "BKE_image.h"
+#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_node.h"
#include "BKE_utildefines.h"
+#include "BIF_interface.h"
#include "BIF_mywindow.h"
#include "BIF_screen.h"
#include "BIF_space.h"
@@ -78,10 +82,11 @@
#include "BSE_trans_types.h"
#include "BSE_view.h"
-#include "BDR_drawmesh.h"
#include "BDR_imagepaint.h"
#include "BDR_vpaint.h"
+#include "GPU_draw.h"
+
#include "GHOST_Types.h"
#include "blendef.h"
@@ -103,6 +108,8 @@
#define IMAPAINT_TILE_SIZE (1 << IMAPAINT_TILE_BITS)
#define IMAPAINT_TILE_NUMBER(size) (((size)+IMAPAINT_TILE_SIZE-1) >> IMAPAINT_TILE_BITS)
+#define MAXUNDONAME 64
+
typedef struct ImagePaintState {
Brush *brush;
short tool, blend;
@@ -120,48 +127,206 @@ typedef struct ImagePaintState {
float uv[2];
} ImagePaintState;
-typedef struct ImagePaintUndo {
- Image *image;
- ImBuf *tilebuf;
- void **tiles;
- int xtiles, ytiles;
-} ImagePaintUndo;
+typedef struct UndoTile {
+ struct UndoTile *next, *prev;
+ ID id;
+ void *rect;
+ int x, y;
+} UndoTile;
+
+typedef struct UndoElem {
+ struct UndoElem *next, *prev;
+ char name[MAXUNDONAME];
+ unsigned long undosize;
+
+ ImBuf *ibuf;
+ ListBase tiles;
+} UndoElem;
typedef struct ImagePaintPartialRedraw {
int x1, y1, x2, y2;
int enabled;
} ImagePaintPartialRedraw;
-static ImagePaintUndo imapaintundo = {NULL, NULL, NULL, 0, 0};
+static ListBase undobase = {NULL, NULL};
+static UndoElem *curundo = NULL;
static ImagePaintPartialRedraw imapaintpartial = {0, 0, 0, 0, 0};
-static void init_imagapaint_undo(Image *ima, ImBuf *ibuf)
+/* UNDO */
+
+/* internal functions */
+
+static void undo_copy_tile(UndoTile *tile, ImBuf *tmpibuf, ImBuf *ibuf, int restore)
{
- int xt, yt;
-
- imapaintundo.image = ima;
- imapaintundo.xtiles = xt = IMAPAINT_TILE_NUMBER(ibuf->x);
- imapaintundo.ytiles = yt = IMAPAINT_TILE_NUMBER(ibuf->y);
- imapaintundo.tiles = MEM_callocN(sizeof(void*)*xt*yt, "ImagePaintUndoTiles");
- imapaintundo.tilebuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE,
- ibuf->depth, (ibuf->rect_float)? IB_rectfloat: IB_rect, 0);
+ /* copy or swap contents of tile->rect and region in ibuf->rect */
+ IMB_rectcpy(tmpibuf, ibuf, 0, 0, tile->x*IMAPAINT_TILE_SIZE,
+ tile->y*IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
+
+ if(ibuf->rect_float) SWAP(void*, tmpibuf->rect_float, tile->rect)
+ else SWAP(void*, tmpibuf->rect, tile->rect)
+
+ if(restore)
+ IMB_rectcpy(ibuf, tmpibuf, tile->x*IMAPAINT_TILE_SIZE,
+ tile->y*IMAPAINT_TILE_SIZE, 0, 0, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
}
-static void imapaint_copy_tile(ImBuf *ibuf, int tile, int x, int y, int swapundo)
+static void undo_restore(UndoElem *undo)
{
- IMB_rectcpy(imapaintundo.tilebuf, ibuf, 0, 0, x*IMAPAINT_TILE_SIZE,
- y*IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
+ Image *ima = NULL;
+ ImBuf *ibuf, *tmpibuf;
+ UndoTile *tile;
- if (imapaintundo.tilebuf->rect_float)
- SWAP(void*, imapaintundo.tilebuf->rect_float, imapaintundo.tiles[tile])
- else
- SWAP(void*, imapaintundo.tilebuf->rect, imapaintundo.tiles[tile])
+ if(!undo)
+ return;
+
+ tmpibuf= IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32,
+ IB_rectfloat|IB_rect, 0);
+
+ for(tile=undo->tiles.first; tile; tile=tile->next) {
+ /* find image based on name, pointer becomes invalid with global undo */
+ if(ima && strcmp(tile->id.name, ima->id.name)==0);
+ else {
+ for(ima=G.main->image.first; ima; ima=ima->id.next)
+ if(strcmp(tile->id.name, ima->id.name)==0)
+ break;
+ }
+
+ ibuf= BKE_image_get_ibuf(ima, NULL);
+
+ if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float))
+ continue;
+
+ undo_copy_tile(tile, tmpibuf, ibuf, 1);
+
+ GPU_free_image(ima); /* force OpenGL reload */
+ if(ibuf->rect_float)
+ imb_freerectImBuf(ibuf); /* force recreate of char rect */
+ }
+
+ IMB_freeImBuf(tmpibuf);
+}
+
+static void undo_free(UndoElem *undo)
+{
+ UndoTile *tile;
+
+ for(tile=undo->tiles.first; tile; tile=tile->next)
+ MEM_freeN(tile->rect);
+ BLI_freelistN(&undo->tiles);
+}
+
+static void undo_imagepaint_push_begin(char *name)
+{
+ UndoElem *uel;
+ int nr;
+
+ /* Undo push is split up in begin and end, the reason is that as painting
+ * happens more tiles are added to the list, and at the very end we know
+ * how much memory the undo used to remove old undo elements */
+
+ /* remove all undos after (also when curundo==NULL) */
+ while(undobase.last != curundo) {
+ uel= undobase.last;
+ undo_free(uel);
+ BLI_freelinkN(&undobase, uel);
+ }
+
+ /* make new */
+ curundo= uel= MEM_callocN(sizeof(UndoElem), "undo file");
+ BLI_addtail(&undobase, uel);
+
+ /* name can be a dynamic string */
+ strncpy(uel->name, name, MAXUNDONAME-1);
+
+ /* limit amount to the maximum amount*/
+ nr= 0;
+ uel= undobase.last;
+ while(uel) {
+ nr++;
+ if(nr==U.undosteps) break;
+ uel= uel->prev;
+ }
+ if(uel) {
+ while(undobase.first!=uel) {
+ UndoElem *first= undobase.first;
+ undo_free(first);
+ BLI_freelinkN(&undobase, first);
+ }
+ }
+}
+
+static void undo_imagepaint_push_end()
+{
+ UndoElem *uel;
+ unsigned long totmem, maxmem;
+
+ if(U.undomemory != 0) {
+ /* limit to maximum memory (afterwards, we can't know in advance) */
+ totmem= 0;
+ maxmem= ((unsigned long)U.undomemory)*1024*1024;
+
+ uel= undobase.last;
+ while(uel) {
+ totmem+= uel->undosize;
+ if(totmem>maxmem) break;
+ uel= uel->prev;
+ }
+
+ if(uel) {
+ while(undobase.first!=uel) {
+ UndoElem *first= undobase.first;
+ undo_free(first);
+ BLI_freelinkN(&undobase, first);
+ }
+ }
+ }
+}
+
+/* external functions */
+
+/* 1= an undo, -1 is a redo. */
+void undo_imagepaint_step(int step)
+{
+ UndoElem *undo;
+
+ if(step==1) {
+ if(curundo==NULL) error("No more steps to undo");
+ else {
+ if(G.f & G_DEBUG) printf("undo %s\n", curundo->name);
+ undo_restore(curundo);
+ curundo= curundo->prev;
+ }
+ }
+ else if(step==-1) {
+ if((curundo!=NULL && curundo->next==NULL) || undobase.first==NULL) error("No more steps to redo");
+ else {
+ undo= (curundo && curundo->next)? curundo->next: undobase.first;
+ undo_restore(undo);
+ curundo= undo;
+ if(G.f & G_DEBUG) printf("redo %s\n", undo->name);
+ }
+ }
+
+ allqueue(REDRAWVIEW3D, 0);
+ allqueue(REDRAWIMAGE, 0);
+}
+
+void undo_imagepaint_clear(void)
+{
+ UndoElem *uel;
- if (swapundo)
- IMB_rectcpy(ibuf, imapaintundo.tilebuf, x*IMAPAINT_TILE_SIZE,
- y*IMAPAINT_TILE_SIZE, 0, 0, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
+ uel= undobase.first;
+ while(uel) {
+ undo_free(uel);
+ uel= uel->next;
+ }
+
+ BLI_freelistN(&undobase);
+ curundo= NULL;
}
+/* Imagepaint Partial Redraw & Dirty Region */
+
static void imapaint_clear_partial_redraw()
{
memset(&imapaintpartial, 0, sizeof(imapaintpartial));
@@ -169,7 +334,9 @@ static void imapaint_clear_partial_redraw()
static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w, int h)
{
- int srcx= 0, srcy= 0, origx, tile, allocsize;
+ ImBuf *tmpibuf;
+ UndoTile *tile;
+ int srcx= 0, srcy= 0, origx, allocsize;
IMB_rectclip(ibuf, NULL, &x, &y, &srcx, &srcy, &w, &h);
@@ -195,24 +362,36 @@ static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w,
origx = (x >> IMAPAINT_TILE_BITS);
y = (y >> IMAPAINT_TILE_BITS);
+ tmpibuf= IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32,
+ IB_rectfloat|IB_rect, 0);
+
for (; y <= h; y++) {
for (x=origx; x <= w; x++) {
- if (ima != imapaintundo.image) {
- free_imagepaint();
- init_imagapaint_undo(ima, ibuf);
- }
+ for(tile=curundo->tiles.first; tile; tile=tile->next)
+ if(tile->x == x && tile->y == y && strcmp(tile->id.name, ima->id.name)==0)
+ break;
+
+ if(!tile) {
+ tile= MEM_callocN(sizeof(UndoTile), "ImaUndoTile");
+ tile->id= ima->id;
+ tile->x= x;
+ tile->y= y;
+
+ allocsize= IMAPAINT_TILE_SIZE*IMAPAINT_TILE_SIZE*4;
+ allocsize *= (ibuf->rect_float)? sizeof(float): sizeof(char);
+ tile->rect= MEM_mapallocN(allocsize, "ImaUndoRect");
+
+ undo_copy_tile(tile, tmpibuf, ibuf, 0);
+ curundo->undosize += allocsize;
- tile = y*imapaintundo.xtiles + x;
- if (!imapaintundo.tiles[tile]) {
- allocsize= (ibuf->rect_float)? sizeof(float): sizeof(char);
- imapaintundo.tiles[tile]= MEM_mapallocN(allocsize*4*
- IMAPAINT_TILE_SIZE*IMAPAINT_TILE_SIZE, "ImagePaintUndoTile");
- imapaint_copy_tile(ibuf, tile, x, y, 0);
+ BLI_addtail(&curundo->tiles, tile);
}
}
}
ibuf->userflags |= IB_BITMAPDIRTY;
+
+ IMB_freeImBuf(tmpibuf);
}
static void imapaint_image_update(Image *image, ImBuf *ibuf, short texpaint)
@@ -226,7 +405,7 @@ static void imapaint_image_update(Image *image, ImBuf *ibuf, short texpaint)
if(texpaint || G.sima->lock) {
int w = imapaintpartial.x2 - imapaintpartial.x1;
int h = imapaintpartial.y2 - imapaintpartial.y1;
- update_realtime_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h);
+ GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h);
}
}
@@ -239,7 +418,7 @@ static void imapaint_redraw(int final, int texpaint, Image *image)
allqueue(REDRAWIMAGE, 0);
else if(!G.sima->lock) {
if(image)
- free_realtime_image(image); /* force OpenGL reload */
+ GPU_free_image(image); /* force OpenGL reload */
allqueue(REDRAWVIEW3D, 0);
}
allqueue(REDRAWHEADERS, 0);
@@ -269,46 +448,6 @@ static void imapaint_redraw(int final, int texpaint, Image *image)
force_draw(0);
}
-void imagepaint_undo()
-{
- Image *ima= imapaintundo.image;
- ImBuf *ibuf= BKE_image_get_ibuf(ima, G.sima?&G.sima->iuser:NULL);
- int x, y, tile;
-
- if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float))
- return;
-
- for (tile = 0, y = 0; y < imapaintundo.ytiles; y++)
- for (x = 0; x < imapaintundo.xtiles; x++, tile++)
- if (imapaintundo.tiles[tile])
- imapaint_copy_tile(ibuf, tile, x, y, 1);
-
- free_realtime_image(ima); /* force OpenGL reload */
- if(ibuf->rect_float)
- imb_freerectImBuf(ibuf); /* force recreate of char rect */
-
- allqueue(REDRAWIMAGE, 0);
- allqueue(REDRAWVIEW3D, 0);
-}
-
-void free_imagepaint()
-{
- /* todo: does this need to be in the same places as editmode_undo_clear,
- vertex paint isn't? */
- int i, size = imapaintundo.xtiles*imapaintundo.ytiles;
-
- if (imapaintundo.tiles) {
- for (i = 0; i < size; i++)
- if (imapaintundo.tiles[i])
- MEM_freeN(imapaintundo.tiles[i]);
- MEM_freeN(imapaintundo.tiles);
- }
- if (imapaintundo.tilebuf)
- IMB_freeImBuf(imapaintundo.tilebuf);
-
- memset(&imapaintundo, 0, sizeof(imapaintundo));
-}
-
/* Image Paint Operations */
static void imapaint_ibuf_get_set_rgb(ImBuf *ibuf, int x, int y, short torus, short set, float *rgb)
@@ -580,7 +719,6 @@ static void imapaint_paint_stroke(ImagePaintState *s, BrushPainter *painter, sho
int breakstroke = 0, redraw = 0;
if (texpaint) {
-
/* pick new face and image */
if (facesel_face_pick(s->me, mval, &newfaceindex, 0)) {
ImBuf *ibuf;
@@ -692,7 +830,7 @@ void imagepaint_paint(short mousebutton, short texpaint)
}
settings->imapaint.flag |= IMAGEPAINT_DRAWING;
- free_imagepaint();
+ undo_imagepaint_push_begin("Image Paint");
/* create painter and paint once */
painter= brush_painter_new(s.brush);
@@ -741,6 +879,7 @@ void imagepaint_paint(short mousebutton, short texpaint)
brush_painter_free(painter);
imapaint_redraw(1, texpaint, s.image);
+ undo_imagepaint_push_end();
if (texpaint) {
if (s.warnmultifile)
diff --git a/source/blender/src/meshtools.c b/source/blender/src/meshtools.c
index 99833625baa..eed7737c26d 100644
--- a/source/blender/src/meshtools.c
+++ b/source/blender/src/meshtools.c
@@ -84,7 +84,6 @@ void sort_faces(void);
#include "BIF_toolbox.h"
#include "BIF_editconstraint.h"
-#include "BDR_drawmesh.h"
#include "BDR_editobject.h"
#include "BDR_editface.h"
#include "BDR_sculptmode.h"
@@ -107,6 +106,8 @@ void sort_faces(void);
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "GPU_draw.h"
+
#include "BLO_sys_types.h" // for intptr_t support
/* from rendercode.c */
@@ -1130,7 +1131,7 @@ void objects_bake_render(short event, char **error_msg)
if(ima->ok==IMA_OK_LOADED) {
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) {
- free_realtime_image(ima);
+ GPU_free_image(ima);
imb_freemipmapImBuf(ibuf);
}
}
diff --git a/source/blender/src/playanim.c b/source/blender/src/playanim.c
index 7a61368b4cd..8421101f66c 100644
--- a/source/blender/src/playanim.c
+++ b/source/blender/src/playanim.c
@@ -45,15 +45,6 @@
#endif
#include "MEM_guardedalloc.h"
-#ifdef WITH_QUICKTIME
-#ifdef _WIN32
-#include <QTML.h>
-#include <Movies.h>
-#elif defined(__APPLE__)
-#include <QuickTime/Movies.h>
-#endif /* __APPLE__ */
-#endif /* WITH_QUICKTIME */
-
#include "PIL_time.h"
#include <math.h>
@@ -77,6 +68,15 @@
#include "BMF_Api.h"
+#ifdef WITH_QUICKTIME
+#ifdef _WIN32
+#include <QTML.h>
+#include <Movies.h>
+#elif defined(__APPLE__)
+#include <QuickTime/Movies.h>
+#endif /* __APPLE__ */
+#endif /* WITH_QUICKTIME */
+
#include "playanim_ext.h"
#include "mydevice.h"
#include "blendef.h"
@@ -346,6 +346,7 @@ void playanim(int argc, char **argv)
int start_x= 0, start_y= 0;
int sfra= -1;
int efra= -1;
+ int totblock;
while (argc > 1) {
if (argv[1][0] == '-'){
@@ -823,6 +824,7 @@ void playanim(int argc, char **argv)
free_blender();
window_destroy(g_window);
+ totblock= MEM_get_memory_blocks_in_use();
if(totblock!=0) {
printf("Error Totblock: %d\n",totblock);
MEM_printmemlist();
diff --git a/source/blender/src/previewrender.c b/source/blender/src/previewrender.c
index 0be63197dd1..1730bb890bc 100644
--- a/source/blender/src/previewrender.c
+++ b/source/blender/src/previewrender.c
@@ -97,6 +97,8 @@
#include "RE_pipeline.h"
#include "BLO_readfile.h"
+#include "GPU_material.h"
+
#include "blendef.h" /* CLAMP */
#include "interface.h" /* ui_graphics_to_window(), SOLVE! (ton) */
#include "mydevice.h"
@@ -221,6 +223,36 @@ void BIF_preview_changed(short id_code)
}
}
}
+
+ if(ELEM4(id_code, ID_MA, ID_TE, ID_LA, ID_WO)) {
+ Object *ob;
+ Material *ma;
+
+ if(id_code == ID_WO) {
+ for(ma=G.main->mat.first; ma; ma=ma->id.next) {
+ if(ma->gpumaterial.first) {
+ GPU_material_free(ma);
+ allqueue(REDRAWVIEW3D, 0);
+ }
+ }
+ }
+ else if(id_code == ID_LA) {
+ for(ob=G.main->object.first; ob; ob=ob->id.next) {
+ if(ob->gpulamp.first) {
+ GPU_lamp_free(ob);
+ allqueue(REDRAWVIEW3D, 0);
+ }
+ }
+ } else if(OBACT) {
+ Object *ob = OBACT;
+
+ ma= give_current_material(ob, ob->actcol);
+ if(ma && ma->gpumaterial.first) {
+ GPU_material_free(ma);
+ allqueue(REDRAWVIEW3D, 0);
+ }
+ }
+ }
}
/* *************************** Preview for buttons *********************** */
diff --git a/source/blender/src/renderwin.c b/source/blender/src/renderwin.c
index 88f5f6efe15..33484500328 100644
--- a/source/blender/src/renderwin.c
+++ b/source/blender/src/renderwin.c
@@ -50,8 +50,6 @@
#endif
-#include "BLO_sys_types.h" // for intptr_t support
-
#include <limits.h>
#include "BLI_blenlib.h"
@@ -102,6 +100,8 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "GPU_draw.h"
+
#include "blendef.h"
#include "mydevice.h"
#include "winlay.h"
@@ -676,7 +676,7 @@ static void open_renderwin(int winpos[2], int winsize[2], int imagesize[2])
/* mywindow has to know about it too */
mywindow_build_and_set_renderwin(winpos[0], winpos[1], winsize[0], winsize[1]+RW_HEADERY);
/* and we should be able to draw 3d in it */
- init_gl_stuff();
+ GPU_state_init();
renderwin_draw(render_win, 1);
renderwin_draw(render_win, 1);
@@ -903,10 +903,13 @@ static void renderwin_progress_display_cb(RenderResult *rr, volatile rcti *rect)
void make_renderinfo_string(RenderStats *rs, char *str)
{
extern char info_time_str[32]; // header_info.c
- extern uintptr_t mem_in_use, mmap_in_use;
+ uintptr_t mem_in_use, mmap_in_use;
float megs_used_memory, mmap_used_memory;
char *spos= str;
+ mem_in_use= MEM_get_memory_in_use();
+ mmap_in_use= MEM_get_mapped_memory_in_use();
+
megs_used_memory= (mem_in_use-mmap_in_use)/(1024.0*1024.0);
mmap_used_memory= (mmap_in_use)/(1024.0*1024.0);
@@ -1304,10 +1307,10 @@ void do_ogl_view3d_render(Render *re, View3D *v3d, int winx, int winy)
if(v3d->persp==V3D_CAMOB && v3d->camera) {
/* in camera view, use actual render winmat */
RE_GetCameraWindow(re, v3d->camera, CFRA, winmat);
- drawview3d_render(v3d, winx, winy, winmat);
+ drawview3d_render(v3d, NULL, winx, winy, winmat, 0);
}
else
- drawview3d_render(v3d, winx, winy, NULL);
+ drawview3d_render(v3d, NULL, winx, winy, NULL, 0);
}
/* set up display, render the current area view in an image */
@@ -1336,7 +1339,7 @@ void BIF_do_ogl_render(View3D *v3d, int anim)
if(render_win)
render_win->flags &= ~RW_FLAGS_ESCAPE;
- init_gl_stuff();
+ GPU_state_init();
waitcursor(1);
diff --git a/source/blender/src/sculptmode.c b/source/blender/src/sculptmode.c
index 24f4100efdb..31d5ae4610d 100644
--- a/source/blender/src/sculptmode.c
+++ b/source/blender/src/sculptmode.c
@@ -82,7 +82,6 @@
#include "BIF_space.h"
#include "BIF_toolbox.h"
-#include "BDR_drawobject.h"
#include "BDR_sculptmode.h"
#include "BSE_drawview.h"
@@ -98,6 +97,8 @@
#include "RE_render_ext.h"
#include "RE_shader_ext.h" /*for multitex_ext*/
+#include "GPU_draw.h"
+
#include <math.h>
#include <stdlib.h>
#include <string.h>
@@ -1514,7 +1515,7 @@ void sculptmode_draw_mesh(int only_damaged)
mymultmatrix(OBACT->obmat);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
- init_gl_materials(OBACT, 0);
+ GPU_set_object_materials(G.scene, OBACT, 0, NULL);
glEnable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
@@ -1532,7 +1533,7 @@ void sculptmode_draw_mesh(int only_damaged)
int new_matnr= f->mat_nr + 1;
if(new_matnr != matnr)
- drawCurrentMat= set_gl_material(matnr = new_matnr);
+ drawCurrentMat= GPU_enable_material(matnr = new_matnr, NULL);
/* If only_damaged!=0, only draw faces that are partially
inside the area(s) modified by the brush */
diff --git a/source/blender/src/sequence.c b/source/blender/src/sequence.c
index 7e2ffc3ba63..bf24c02e723 100644
--- a/source/blender/src/sequence.c
+++ b/source/blender/src/sequence.c
@@ -2949,12 +2949,16 @@ void do_render_seq(RenderResult *rr, int cfra)
(schlaile)
*/
{
- extern int mem_in_use;
- extern int mmap_in_use;
+ uintptr_t mem_in_use;
+ uintptr_t mmap_in_use;
+ uintptr_t max;
+
+ mem_in_use= MEM_get_memory_in_use();
+ mmap_in_use= MEM_get_mapped_memory_in_use();
+ max = MEM_CacheLimiter_get_maximum();
- int max = MEM_CacheLimiter_get_maximum();
if (max != 0 && mem_in_use + mmap_in_use > max) {
- fprintf(stderr, "mem_in_use = %d, max = %d\n",
+ fprintf(stderr, "mem_in_use = %lu, max = %lu\n",
mem_in_use + mmap_in_use, max);
fprintf(stderr, "Cleaning up, please wait...\n"
"If this happens very often,\n"
diff --git a/source/blender/src/space.c b/source/blender/src/space.c
index 81b0efeef0d..88a0bf0f9b1 100644
--- a/source/blender/src/space.c
+++ b/source/blender/src/space.c
@@ -182,6 +182,9 @@
#include "SYS_System.h" /* for the user def menu ... should move elsewhere. */
+#include "GPU_extensions.h"
+#include "GPU_draw.h"
+
#include "BLO_sys_types.h" // for intptr_t support
/* maybe we need this defined somewhere else */
@@ -386,7 +389,7 @@ void space_set_commmandline_options(void) {
SYS_WriteCommandLineInt(syshandle, "noaudio", a);
a= (U.gameflags & USER_DISABLE_MIPMAP);
- set_mipmap(!a);
+ GPU_set_mipmap(!a);
SYS_WriteCommandLineInt(syshandle, "nomipmap", a);
/* File specific settings: */
@@ -415,7 +418,9 @@ void space_set_commmandline_options(void) {
a=(G.fileflags & G_FILE_GAME_MAT);
SYS_WriteCommandLineInt(syshandle, "blender_material", a);
- a=(G.fileflags & G_FILE_DIAPLAY_LISTS);
+ a=(G.fileflags & G_FILE_GAME_MAT_GLSL);
+ SYS_WriteCommandLineInt(syshandle, "blender_glsl_material", a);
+ a=(G.fileflags & G_FILE_DISPLAY_LISTS);
SYS_WriteCommandLineInt(syshandle, "displaylists", a);
@@ -432,11 +437,10 @@ static void SaveState(void)
{
glPushAttrib(GL_ALL_ATTRIB_BITS);
- init_realtime_GL();
- init_gl_stuff();
+ GPU_state_init();
if(G.f & G_TEXTUREPAINT)
- texpaint_enable_mipmap();
+ GPU_paint_set_mipmap(1);
waitcursor(1);
}
@@ -444,7 +448,7 @@ static void SaveState(void)
static void RestoreState(void)
{
if(G.f & G_TEXTUREPAINT)
- texpaint_disable_mipmap();
+ GPU_paint_set_mipmap(0);
curarea->win_swap = 0;
curarea->head_swap=0;
@@ -1024,9 +1028,9 @@ void BIF_undo(void)
}
else {
if(G.f & G_TEXTUREPAINT)
- imagepaint_undo();
+ undo_imagepaint_step(1);
else if(curarea->spacetype==SPACE_IMAGE && (G.sima->flag & SI_DRAWTOOL))
- imagepaint_undo();
+ undo_imagepaint_step(1);
else if(G.f & G_PARTICLEEDIT)
PE_undo();
else {
@@ -1048,9 +1052,9 @@ void BIF_redo(void)
}
else {
if(G.f & G_TEXTUREPAINT)
- imagepaint_undo();
+ undo_imagepaint_step(-1);
else if(curarea->spacetype==SPACE_IMAGE && (G.sima->flag & SI_DRAWTOOL))
- imagepaint_undo();
+ undo_imagepaint_step(-1);
else if(G.f & G_PARTICLEEDIT)
PE_redo();
else {
@@ -2643,10 +2647,9 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
else if(G.f & G_VERTEXPAINT)
BIF_undo();
else if(G.f & G_TEXTUREPAINT)
- imagepaint_undo();
- else {
+ undo_imagepaint_step(1);
+ else
single_user();
- }
}
break;
@@ -3259,7 +3262,7 @@ void initipo(ScrArea *sa)
/* ******************** SPACE: INFO ********************** */
void space_mipmap_button_function(int event) {
- set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
+ GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
allqueue(REDRAWVIEW3D, 0);
}
@@ -3949,20 +3952,23 @@ void drawinfospace(ScrArea *sa, void *spacedata)
uiDefBut(block, LABEL,0,"Transform:",
- (xpos+(2*edgsp)+mpref),y5label, mpref,buth,
+ (xpos+(2*edgsp)+mpref),y6label, mpref,buth,
0, 0, 0, 0, 0, "");
uiDefButBitI(block, TOG, USER_DRAGIMMEDIATE, B_DRAWINFO, "Drag Immediately",
- (xpos+edgsp+mpref+midsp),y4,mpref,buth,
+ (xpos+edgsp+mpref+midsp),y5,mpref,buth,
&(U.flag), 0, 0, 0, 0, "Moving things with a mouse drag doesn't require a click to confirm (Best for tablet users)");
uiBlockEndAlign(block);
uiDefBut(block, LABEL,0,"Undo:",
- (xpos+(2*edgsp)+mpref),y3label, mpref,buth,
+ (xpos+(2*edgsp)+mpref),y4label, mpref,buth,
0, 0, 0, 0, 0, "");
uiBlockBeginAlign(block);
uiDefButS(block, NUMSLI, B_DRAWINFO, "Steps: ",
- (xpos+edgsp+mpref+midsp),y2,mpref,buth,
+ (xpos+edgsp+mpref+midsp),y3,mpref,buth,
&(U.undosteps), 0, 64, 0, 0, "Number of undo steps available (smaller values conserve memory)");
+ uiDefButS(block, NUM, B_DRAWINFO, "Memory Limit: ",
+ (xpos+edgsp+mpref+midsp),y2,mpref,buth,
+ &(U.undomemory), 0, 32767, -1, 0, "Maximum memory usage in megabytes (0 means unlimited)");
uiDefButBitI(block, TOG, USER_GLOBALUNDO, B_DRAWINFO, "Global Undo",
(xpos+edgsp+mpref+midsp),y1,mpref,buth,
@@ -4297,6 +4303,7 @@ void drawinfospace(ScrArea *sa, void *spacedata)
uiDefButI(block, NUM, 0, "Collect Rate ",
(xpos+edgsp+(5*mpref)+(5*midsp)), y2, mpref, buth,
&U.texcollectrate, 1.0, 3600.0, 30, 2, "Number of seconds between each run of the GL texture garbage collector.");
+ uiBlockEndAlign(block);
/* *** */
uiDefBut(block, LABEL,0,"Color range for weight paint",
@@ -4533,7 +4540,7 @@ static void winqreadinfospace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(U.light[0].flag==0 && U.light[1].flag==0 && U.light[2].flag==0)
U.light[0].flag= 1;
- default_gl_light();
+ GPU_default_lights();
addqueue(sa->win, REDRAW, 1);
allqueue(REDRAWVIEW3D, 0);
}
@@ -5173,8 +5180,8 @@ static void init_seqspace(ScrArea *sa)
sseq->v2d.max[0]= MAXFRAMEF;
sseq->v2d.max[1]= MAXSEQ;
- sseq->v2d.minzoom= 0.1f;
- sseq->v2d.maxzoom= 10.0;
+ sseq->v2d.minzoom= 0.01f;
+ sseq->v2d.maxzoom= 100.0;
sseq->v2d.scroll= L_SCROLL+B_SCROLL;
sseq->v2d.keepaspect= 0;
@@ -5989,7 +5996,7 @@ static void init_oopsspace(ScrArea *sa)
soops= MEM_callocN(sizeof(SpaceOops), "initoopsspace");
BLI_addhead(&sa->spacedata, soops);
- soops->visiflag= OOPS_OB+OOPS_MA+OOPS_ME+OOPS_TE+OOPS_CU+OOPS_IP;
+ soops->visiflag= OOPS_OB|OOPS_MA|OOPS_ME|OOPS_TE|OOPS_CU|OOPS_IP;
/* new oops is default an outliner */
soops->type= SO_OUTLINER;
diff --git a/source/blender/src/toets.c b/source/blender/src/toets.c
index 5f80f14d069..efd97ed9786 100644
--- a/source/blender/src/toets.c
+++ b/source/blender/src/toets.c
@@ -104,6 +104,8 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "GPU_draw.h"
+
#include "mydevice.h"
#include "transform.h"
@@ -964,7 +966,7 @@ int blenderqread(unsigned short event, short val)
/* Reset lights
* This isn't done when reading userdef, do it now
* */
- default_gl_light();
+ GPU_default_lights();
}
return 0;
}
diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c
index e757f634a45..21bec1ec978 100644
--- a/source/blender/src/usiblender.c
+++ b/source/blender/src/usiblender.c
@@ -34,8 +34,6 @@
#include <stdio.h>
#include <string.h>
-#include "GL/glew.h"
-
#ifdef WIN32
#include <windows.h> /* need to include windows.h so _WIN32_IE is defined */
#ifndef _WIN32_IE
@@ -149,6 +147,9 @@
#include "PIL_time.h"
+#include "GPU_extensions.h"
+#include "GPU_draw.h"
+
/***/
/* define for setting colors in theme below */
@@ -577,8 +578,9 @@ void BIF_read_file(char *name)
if (retval!=0) G.relbase_valid = 1;
undo_editmode_clear();
+ undo_imagepaint_clear();
BKE_reset_undo();
- BKE_write_undo("original"); /* save current state */
+ BKE_write_undo("Original"); /* save current state */
refresh_interface_font();
}
@@ -650,8 +652,9 @@ int BIF_read_homefile(int from_memory)
init_userdef_file();
undo_editmode_clear();
+ undo_imagepaint_clear();
BKE_reset_undo();
- BKE_write_undo("original"); /* save current state */
+ BKE_write_undo("Original"); /* save current state */
/* if from memory, need to refresh python scripts */
if (from_memory) {
@@ -1049,8 +1052,9 @@ void BIF_init(void)
BIF_filelist_init_icons();
- init_gl_stuff(); /* drawview.c, after homefile */
- glewInit();
+ GPU_state_init();
+ GPU_extensions_init();
+
readBlog();
BLI_strncpy(G.lib, G.sce, FILE_MAX);
}
@@ -1063,6 +1067,7 @@ extern ListBase editelems;
void exit_usiblender(void)
{
struct TmpFont *tf;
+ int totblock;
BIF_clear_tempfiles();
@@ -1108,7 +1113,6 @@ void exit_usiblender(void)
free_ipocopybuf();
free_actcopybuf();
free_vertexpaint();
- free_imagepaint();
free_texttools();
/* editnurb can remain to exist outside editmode */
@@ -1127,6 +1131,7 @@ void exit_usiblender(void)
sound_exit_audio();
if(G.listener) MEM_freeN(G.listener);
+ GPU_extensions_exit();
libtiff_exit();
@@ -1136,6 +1141,7 @@ void exit_usiblender(void)
/* undo free stuff */
undo_editmode_clear();
+ undo_imagepaint_clear();
BKE_undo_save_quit(); // saves quit.blend if global undo is on
BKE_reset_undo();
@@ -1161,6 +1167,7 @@ void exit_usiblender(void)
BLI_freelistN(&U.themes);
BIF_preview_free_dbase();
+ totblock= MEM_get_memory_blocks_in_use();
if(totblock!=0) {
printf("Error Totblock: %d\n",totblock);
MEM_printmemlist();
diff --git a/source/blender/src/verse_image.c b/source/blender/src/verse_image.c
index fe9e6137091..4a78126e3f8 100644
--- a/source/blender/src/verse_image.c
+++ b/source/blender/src/verse_image.c
@@ -327,7 +327,7 @@ void post_bitmap_tile_set(VBitmapLayer *vblayer, unsigned int xs, unsigned int y
rect[channel] = (char)vuint8[i];
}
- free_realtime_image(image);
+ GPU_free_image(image);
/* redraw preview of image ... uncommented, because rendering
* was computed too often */