diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-06-30 02:08:23 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-06-30 02:08:23 +0400 |
commit | f7d704fcf9d58f5bf107bda4cb89142028d00f28 (patch) | |
tree | 700d681db624b3e5b607335558f78f11bb9f73eb | |
parent | bca0d2d3e87a573bea8b18a800cacf964ef0b39e (diff) |
svn merge -r15360:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/
40 files changed, 335 insertions, 147 deletions
diff --git a/intern/iksolver/intern/IK_QTask.h b/intern/iksolver/intern/IK_QTask.h index c291a0e7e50..4d469d737f8 100644 --- a/intern/iksolver/intern/IK_QTask.h +++ b/intern/iksolver/intern/IK_QTask.h @@ -74,7 +74,7 @@ public: virtual bool PositionTask() const { return false; } - virtual void Scale(float scale) {} + virtual void Scale(float) {} protected: int m_id; diff --git a/intern/moto/include/MT_random.h b/intern/moto/include/MT_random.h index d7da546cf03..3afe1dd1662 100644 --- a/intern/moto/include/MT_random.h +++ b/intern/moto/include/MT_random.h @@ -31,10 +31,10 @@ #include <limits.h> -#define MT_RAND_MAX ULONG_MAX +#define MT_RAND_MAX UINT_MAX -extern void MT_srand(unsigned long); -extern unsigned long MT_rand(); +extern void MT_srand(unsigned int); +extern unsigned int MT_rand(); #endif diff --git a/intern/moto/intern/MT_random.cpp b/intern/moto/intern/MT_random.cpp index 96cb394d3da..b8302e093ca 100644 --- a/intern/moto/intern/MT_random.cpp +++ b/intern/moto/intern/MT_random.cpp @@ -76,11 +76,11 @@ #define TEMPERING_SHIFT_T(y) (y << 15) #define TEMPERING_SHIFT_L(y) (y >> 18) -static unsigned long mt[N]; /* the array for the state vector */ +static unsigned int mt[N]; /* the array for the state vector */ static int mti = N+1; /* mti==N+1 means mt[N] is not initialized */ /* initializing the array with a NONZERO seed */ -void MT_srand(unsigned long seed) +void MT_srand(unsigned int seed) { /* setting initial seeds to mt[N] using */ /* the generator Line 25 of Table 1 in */ @@ -91,12 +91,12 @@ void MT_srand(unsigned long seed) mt[mti] = (69069 * mt[mti-1]) & 0xffffffff; } -unsigned long MT_rand() +unsigned int MT_rand() { - static unsigned long mag01[2] = { 0x0, MATRIX_A }; + static unsigned int mag01[2] = { 0x0, MATRIX_A }; /* mag01[x] = x * MATRIX_A for x=0,1 */ - unsigned long y; + unsigned int y; if (mti >= N) { /* generate N words at one time */ int kk; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 84e35583858..15e110f1cb7 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -859,8 +859,8 @@ void BKE_add_image_extension(char *string, int imtype) extension= ".bmp"; } else if(G.have_libtiff && (imtype==R_TIFF)) { - if(!BLI_testextensie(string, ".tif")) - extension= ".tif"; + if(!BLI_testextensie(string, ".tif") && + !BLI_testextensie(string, ".tiff")) extension= ".tif"; } #ifdef WITH_OPENEXR else if( ELEM(imtype, R_OPENEXR, R_MULTILAYER)) { diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index a32503a95c5..1a027356c8f 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1882,7 +1882,7 @@ void set_icu_vars(IpoCurve *icu) /* yafray: aperture & focal distance params */ switch(icu->adrcode) { case CAM_LENS: - icu->ymin= 5.0; + icu->ymin= 1.0; icu->ymax= 1000.0; break; case CAM_STA: diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 876547042dc..53b7bb975a3 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -942,7 +942,8 @@ char *txt_to_buf (Text *text) if (!text) return NULL; if (!text->curl) return NULL; if (!text->sell) return NULL; - + if (!text->lines.first) return NULL; + linef= text->lines.first; charf= 0; diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h index 71d35949833..7dc1f966b71 100644 --- a/source/blender/imbuf/intern/IMB_anim.h +++ b/source/blender/imbuf/intern/IMB_anim.h @@ -183,8 +183,9 @@ struct anim { AVFormatContext *pFormatCtx; AVCodecContext *pCodecCtx; AVCodec *pCodec; - AVFrame *pFrameRGB; AVFrame *pFrame; + AVFrame *pFrameRGB; + AVFrame *pFrameDeinterlaced; struct SwsContext *img_convert_ctx; int videoStream; #endif diff --git a/source/blender/imbuf/intern/anim.c b/source/blender/imbuf/intern/anim.c index 7fc8145c4a7..720f5b0f7c8 100644 --- a/source/blender/imbuf/intern/anim.c +++ b/source/blender/imbuf/intern/anim.c @@ -600,6 +600,7 @@ static int startffmpeg(struct anim * anim) { anim->videoStream = videoStream; anim->pFrame = avcodec_alloc_frame(); + anim->pFrameDeinterlaced = avcodec_alloc_frame(); anim->pFrameRGB = avcodec_alloc_frame(); if (avpicture_get_size(PIX_FMT_BGR32, anim->x, anim->y) @@ -609,10 +610,20 @@ static int startffmpeg(struct anim * anim) { avcodec_close(anim->pCodecCtx); av_close_input_file(anim->pFormatCtx); av_free(anim->pFrameRGB); + av_free(anim->pFrameDeinterlaced); av_free(anim->pFrame); return -1; } + if (anim->ib_flags & IB_animdeinterlace) { + avpicture_fill((AVPicture*) anim->pFrameDeinterlaced, + MEM_callocN(avpicture_get_size( + anim->pCodecCtx->pix_fmt, + anim->x, anim->y), + "ffmpeg deinterlace"), + anim->pCodecCtx->pix_fmt, anim->x, anim->y); + } + if (pCodecCtx->has_b_frames) { anim->preseek = 25; /* FIXME: detect gopsize ... */ } else { @@ -644,7 +655,7 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { ibuf = IMB_allocImBuf(anim->x, anim->y, 24, IB_rect, 0); - avpicture_fill((AVPicture *)anim->pFrameRGB, + avpicture_fill((AVPicture*) anim->pFrameRGB, (unsigned char*) ibuf->rect, PIX_FMT_BGR32, anim->x, anim->y); @@ -723,15 +734,29 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { } if(frameFinished && pos_found == 1) { + AVFrame * input = anim->pFrame; + + /* This means the data wasnt read properly, + this check stops crashing */ + if (input->data[0]==0 && input->data[1]==0 + && input->data[2]==0 && input->data[3]==0){ + av_free_packet(&packet); + break; + } + if (anim->ib_flags & IB_animdeinterlace) { if (avpicture_deinterlace( - anim->pFrame, + (AVPicture*) + anim->pFrameDeinterlaced, + (const AVPicture*) anim->pFrame, anim->pCodecCtx->pix_fmt, anim->pCodecCtx->width, anim->pCodecCtx->height) < 0) { filter_y = 1; + } else { + input = anim->pFrameDeinterlaced; } } @@ -748,8 +773,8 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { unsigned char* top; sws_scale(anim->img_convert_ctx, - anim->pFrame->data, - anim->pFrame->linesize, + input->data, + input->linesize, 0, anim->pCodecCtx->height, dst2, @@ -806,27 +831,25 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { int i; unsigned char* r; - /* This means the data wasnt read properly, this check stops crashing */ - if (anim->pFrame->data[0]!=0 || anim->pFrame->data[1]!=0 || anim->pFrame->data[2]!=0 || anim->pFrame->data[3]!=0) { - sws_scale(anim->img_convert_ctx, - anim->pFrame->data, - anim->pFrame->linesize, - 0, - anim->pCodecCtx->height, - dst2, - dstStride2); + sws_scale(anim->img_convert_ctx, + input->data, + input->linesize, + 0, + anim->pCodecCtx->height, + dst2, + dstStride2); - /* workaround: sws_scale - sets alpha = 0... */ + /* workaround: sws_scale + sets alpha = 0... */ - r = (unsigned char*) ibuf->rect; - - for (i = 0; i < ibuf->x * ibuf->y;i++){ - r[3] = 0xff; - r+=4; - } + r = (unsigned char*) ibuf->rect; + + for (i = 0; i < ibuf->x * ibuf->y;i++){ + r[3] = 0xff; + r+=4; } + av_free_packet(&packet); break; } @@ -851,6 +874,11 @@ static void free_anim_ffmpeg(struct anim * anim) { av_close_input_file(anim->pFormatCtx); av_free(anim->pFrameRGB); av_free(anim->pFrame); + + if (anim->ib_flags & IB_animdeinterlace) { + MEM_freeN(anim->pFrameDeinterlaced->data[0]); + } + av_free(anim->pFrameDeinterlaced); sws_freeContext(anim->img_convert_ctx); } anim->duration = 0; diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h index 20316f26804..51f03a676e4 100644 --- a/source/blender/makesdna/DNA_actuator_types.h +++ b/source/blender/makesdna/DNA_actuator_types.h @@ -192,11 +192,13 @@ typedef struct bVisibilityActuator { } bVisibilityActuator; typedef struct bTwoDFilterActuator{ - char pad[4]; - /* Tells what type of 2D Filter*/ + char pad[2]; + /* bitwise flag for enabling or disabling depth(bit 0) and luminance(bit 1) */ + short texture_flag; + /* Tells what type of 2D Filter */ short type; /* (flag == 0) means 2D filter is activate and - (flag != 0) means 2D filter is inactive*/ + (flag != 0) means 2D filter is inactive */ short flag; int int_arg; /* a float argument */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index fc03ee1a9f3..37f95fea891 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -312,7 +312,7 @@ extern UserDef U; /* from usiblender.c !!!! */ #define USER_DUP_ACT (1 << 10) /* gameflags */ -#define USER_VERTEX_ARRAYS 1 +#define USER_DEPRECATED_FLAG 1 #define USER_DISABLE_SOUND 2 #define USER_DISABLE_MIPMAP 4 diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_math.c b/source/blender/nodes/intern/CMP_nodes/CMP_math.c index d00ce18a44f..421c1343df7 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_math.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_math.c @@ -57,7 +57,7 @@ static void do_math(bNode *node, float *out, float *in, float *in2) break; case 3: /* Divide */ { - if(in[1]==0) /* We don't want to divide by zero. */ + if(in2[0]==0) /* We don't want to divide by zero. */ out[0]= 0.0; else out[0]= in[0] / in2[0]; diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index 297cde844d3..3b545697f8e 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -1703,7 +1703,7 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh } uiDefButI(block, NUM, 0, "Blendin: ", xco+30, yco-64, (width-60)/2, 19, &aa->blendin, 0.0, MAXFRAMEF, 0.0, 0.0, "Number of frames of motion blending"); - uiDefButS(block, NUM, 0, "Priority: ", xco+30+(width-60)/2, yco-64, (width-60)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers"); + uiDefButS(block, NUM, 0, "Priority: ", xco+30+(width-60)/2, yco-64, (width-60)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers, With 2 or more actions at once, the overriding clannels must be lower in the stack"); uiDefBut(block, TEX, 0, "FrameProp: ",xco+30, yco-84, width-60, 19, aa->frameProp, 0.0, 31.0, 0, 0, "Assign this property this actions current frame number"); @@ -2382,7 +2382,11 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh break; case ACT_2DFILTER_CUSTOMFILTER: uiDefButI(block, NUM, B_REDR, "Pass Number:", xco+30,yco-44,width-60,19,&tdfa->int_arg,0.0,MAX_RENDER_PASS-1,0.0,0.0,"Set motion blur value"); - uiDefIDPoinBut(block, test_scriptpoin_but, ID_SCRIPT, 1, "Script: ", xco+30,yco-64,width-60, 19, &tdfa->text, ""); + uiDefIDPoinBut(block, test_scriptpoin_but, ID_SCRIPT, 1, "Script: ", xco+30,yco-64,width/2-32, 19, &tdfa->text, ""); + uiDefButS(block, TOG|BIT|0, B_REDR, "Depth", xco+width/2+2 , yco - 64, width/4-16 , 19, + &tdfa->texture_flag, 0.0, 0.0, 0, 0, "Includes Depth Texture (bgl_DepthTexture)"); + uiDefButS(block, TOG|BIT|1, B_REDR, "Luminance", xco+3*width/4-14 , yco - 64, width/4-16 , 19, + &tdfa->texture_flag, 0.0, 0.0, 0, 0, "Includes Luminance Texture (bgl_LuminanceTexture)"); break; } diff --git a/source/blender/src/drawaction.c b/source/blender/src/drawaction.c index 8c4958a651a..89466151a39 100644 --- a/source/blender/src/drawaction.c +++ b/source/blender/src/drawaction.c @@ -474,10 +474,13 @@ static void draw_channel_names(void) indent= 0; special= -1; - if (EXPANDED_AGRP(agrp)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; + /* only show expand if there are any channels */ + if (agrp->channels.first) { + if (EXPANDED_AGRP(agrp)) + expand = ICON_TRIA_DOWN; + else + expand = ICON_TRIA_RIGHT; + } if (EDITABLE_AGRP(agrp)) protect = ICON_UNLOCKED; diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index e67633a054e..a01f24f2c3b 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -249,7 +249,8 @@ void default_gl_light(void) glDisable(GL_COLOR_MATERIAL); } -/* also called when render 'ogl' */ +/* 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 }; diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c index 40b6b7ba6fe..f93a1526e3c 100644 --- a/source/blender/src/editaction.c +++ b/source/blender/src/editaction.c @@ -390,7 +390,7 @@ static void actdata_filter_actionchannel (ListBase *act_data, bActionChannel *ac static void actdata_filter_action (ListBase *act_data, bAction *act, int filter_mode) { - bActListElem *ale; + bActListElem *ale=NULL; bActionGroup *agrp; bActionChannel *achan, *lastchan=NULL; @@ -429,6 +429,15 @@ static void actdata_filter_action (ListBase *act_data, bAction *act, int filter_ for (achan= agrp->channels.first; achan && achan->grp==agrp; achan= achan->next) { actdata_filter_actionchannel(act_data, achan, filter_mode); } + + /* remove group from filtered list if last element is group + * (i.e. only if group had channels, which were all hidden) + */ + if ( (ale) && (act_data->last == ale) && + (ale->data == agrp) && (agrp->channels.first) ) + { + BLI_freelinkN(act_data, ale); + } } } } @@ -3648,7 +3657,7 @@ static void mouse_actionchannels (short mval[]) { bActionGroup *agrp= (bActionGroup *)act_channel; - if (mval[0] < 16) { + if ((mval[0] < 16) && (agrp->channels.first)) { /* toggle expand */ agrp->flag ^= AGRP_EXPANDED; } diff --git a/source/blender/src/editfont.c b/source/blender/src/editfont.c index cb245867c89..a3b05a008c8 100644 --- a/source/blender/src/editfont.c +++ b/source/blender/src/editfont.c @@ -354,7 +354,7 @@ void txt_export_to_object(struct Text *text) // char sdir[FILE_MAXDIR]; // char sfile[FILE_MAXFILE]; - if(!text) return; + if(!text || !text->lines.first) return; id = (ID *)text; @@ -429,7 +429,7 @@ void txt_export_to_objects(struct Text *text) int linenum = 0; float offset[3] = {0.0,0.0,0.0}; - if(!text) return; + if(!text || !text->lines.first) return; id = (ID *)text; diff --git a/source/blender/src/poseobject.c b/source/blender/src/poseobject.c index dcceea971f7..cc08bf53a72 100644 --- a/source/blender/src/poseobject.c +++ b/source/blender/src/poseobject.c @@ -1627,6 +1627,8 @@ void pose_flipquats(void) pchan->quat[3]= -pchan->quat[3]; } } - + + /* do autokey */ + autokeyframe_pose_cb_func(ob, TFM_ROTATION, 0); } diff --git a/source/blender/src/space.c b/source/blender/src/space.c index d76331151b4..2b23e977902 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -381,9 +381,6 @@ void space_set_commmandline_options(void) { if ( (syshandle = SYS_GetSystem()) ) { /* User defined settings */ - a= (U.gameflags & USER_VERTEX_ARRAYS); - SYS_WriteCommandLineInt(syshandle, "vertexarrays", a); - a= (U.gameflags & USER_DISABLE_SOUND); SYS_WriteCommandLineInt(syshandle, "noaudio", a); @@ -4272,15 +4269,11 @@ void drawinfospace(ScrArea *sa, void *spacedata) uiDefButS(block, MENU, B_GLRESLIMITCHANGED, "GL Texture Clamp Off%x0|%l|GL Texture Clamp 8192%x8192|GL Texture Clamp 4096%x4096|GL Texture Clamp 2048%x2048|GL Texture Clamp 1024%x1024|GL Texture Clamp 512%x512|GL Texture Clamp 256%x256|GL Texture Clamp 128%x128", (xpos+edgsp+(5*mpref)+(5*midsp)),y4,mpref,buth, &(U.glreslimit), 0, 0, 0, 0, "Limit the texture size to save graphics memory"); - uiDefButBitI(block, TOG, USER_VERTEX_ARRAYS, 0, "Vertex Arrays", - (xpos+edgsp+(5*mpref)+(5*midsp)),y3,mpref,buth, - &(U.gameflags), 0, 0, 0, 0, "Toggles between vertex arrays on (less reliable) and off (more reliable)"); - uiDefButI(block, NUM, 0, "Time Out ", - (xpos+edgsp+(5*mpref)+(5*midsp)), y2, mpref, buth, + (xpos+edgsp+(5*mpref)+(5*midsp)), y3, mpref, buth, &U.textimeout, 0.0, 3600.0, 30, 2, "Time since last access of a GL texture in seconds after which it is freed. (Set to 0 to keep textures allocated)"); uiDefButI(block, NUM, 0, "Collect Rate ", - (xpos+edgsp+(5*mpref)+(5*midsp)), y1, mpref, buth, + (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); diff --git a/source/blender/src/view.c b/source/blender/src/view.c index e103457c700..0e7e2e5eacb 100644 --- a/source/blender/src/view.c +++ b/source/blender/src/view.c @@ -689,10 +689,6 @@ void viewmoveNDOFfly(int mode) if (G.vd->ndoffilter) filterNDOFvalues(fval); -// for(i=0;i<7;i++) printf("%f ",dval[i]); -// printf("\n"); - - // Scale input values // if(dval[6] == 0) return; // guard against divide by zero @@ -701,12 +697,6 @@ void viewmoveNDOFfly(int mode) // user scaling dval[i] = dval[i] * ndof_axis_scale[i]; - - // non-linear scaling - if(dval[i]<0.0f) - dval[i] = -1.0f * dval[i] * dval[i]; - else - dval[i] = dval[i] * dval[i]; } @@ -1334,18 +1324,16 @@ void viewmoveNDOF(int mode) // prevTime = now; // sbadjust *= 60 * frametime; /* normalize ndof device adjustments to 100Hz for framerate independence */ - /* fetch the current state of the ndof device */ + /* fetch the current state of the ndof device & enforce dominant mode if selected */ getndof(fval); - // printf(" motion command %f %f %f %f %f %f %f \n", fval[0], fval[1], fval[2], - // fval[3], fval[4], fval[5], fval[6]); - if (G.vd->ndoffilter) - filterNDOFvalues(fval); + if (G.vd->ndoffilter) + filterNDOFvalues(fval); // put scaling back here, was previously in ghostwinlay - fval[0] = fval[0] * (1.0f/1200.0f); - fval[1] = fval[1] * (1.0f/1200.0f); - fval[2] = fval[2] * (1.0f/1200.0f); + fval[0] = fval[0] * (1.0f/600.0f); + fval[1] = fval[1] * (1.0f/600.0f); + fval[2] = fval[2] * (1.0f/1100.0f); fval[3] = fval[3] * 0.00005f; fval[4] =-fval[4] * 0.00005f; fval[5] = fval[5] * 0.00005f; @@ -1373,14 +1361,16 @@ void viewmoveNDOF(int mode) VECCOPY(obofs, G.vd->ofs); } - /* calc an adjustment based on distance from camera */ - if (ob) { + /* calc an adjustment based on distance from camera + disabled per patch 14402 */ + d = 1.0f; + +/* if (ob) { VecSubf(diff, obofs, G.vd->ofs); d = VecLength(diff); } - else { - d = 1.0f; - } +*/ + reverse = (G.vd->persmat[2][1] < 0.0f) ? -1.0f : 1.0f; /*---------------------------------------------------- diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 93e75b72ab9..63eb3a328ee 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -170,20 +170,14 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, RAS_IRenderTools* rendertools = new KX_BlenderRenderTools(); RAS_IRasterizer* rasterizer = NULL; - // let's see if we want to use vertexarrays or not - int usevta = SYS_GetCommandLineInt(syshandle,"vertexarrays",1); - bool useVertexArrays = (usevta > 0); - - bool lock_arrays = (displaylists && useVertexArrays); - - if(displaylists){ - if (useVertexArrays) - rasterizer = new RAS_ListRasterizer(canvas, true, lock_arrays); + if(displaylists) { + if (GLEW_VERSION_1_1) + rasterizer = new RAS_ListRasterizer(canvas, true, true); else rasterizer = new RAS_ListRasterizer(canvas); } - else if (useVertexArrays && GLEW_VERSION_1_1) - rasterizer = new RAS_VAOpenGLRasterizer(canvas, lock_arrays); + else if (GLEW_VERSION_1_1) + rasterizer = new RAS_VAOpenGLRasterizer(canvas, false); else rasterizer = new RAS_OpenGLRasterizer(canvas); @@ -518,16 +512,14 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, RAS_IRenderTools* rendertools = new KX_BlenderRenderTools(); RAS_IRasterizer* rasterizer = NULL; - // let's see if we want to use vertexarrays or not - int usevta = SYS_GetCommandLineInt(syshandle,"vertexarrays",1); - bool useVertexArrays = (usevta > 0); - - bool lock_arrays = (displaylists && useVertexArrays); - - if(displaylists && !useVertexArrays) - rasterizer = new RAS_ListRasterizer(canvas); - else if (useVertexArrays && GLEW_VERSION_1_1) - rasterizer = new RAS_VAOpenGLRasterizer(canvas, lock_arrays); + if(displaylists) { + if (GLEW_VERSION_1_1) + rasterizer = new RAS_ListRasterizer(canvas, true, true); + else + rasterizer = new RAS_ListRasterizer(canvas); + } + else if (GLEW_VERSION_1_1) + rasterizer = new RAS_VAOpenGLRasterizer(canvas, false); else rasterizer = new RAS_OpenGLRasterizer(canvas); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 07a3649aa0f..73d2870720a 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -483,9 +483,9 @@ void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer) } } -void KX_BlenderRenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text) +void KX_BlenderRenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text, short texture_flag) { - m_filtermanager.EnableFilter(filtermode, pass, text); + m_filtermanager.EnableFilter(filtermode, pass, text, texture_flag); } void KX_BlenderRenderTools::Render2DFilters(RAS_ICanvas* canvas) diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index 31eaa14d66b..7748e31156d 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -101,7 +101,7 @@ public: virtual void MotionBlur(RAS_IRasterizer* rasterizer); - virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text); + virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text, short texture_flag); virtual void Render2DFilters(RAS_ICanvas* canvas); diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index a50c072914d..ea26c55a44e 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -944,7 +944,7 @@ void BL_ConvertActuators(char* maggiename, } tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag, - _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),rendertools); + _2dfilter->float_arg,_2dfilter->int_arg,_2dfilter->texture_flag,ketsjiEngine->GetRasterizer(),rendertools); if (_2dfilter->text) { diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp index f3b5b1fdda2..56249bb52ec 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -18,6 +18,7 @@ SCA_2DFilterActuator::SCA_2DFilterActuator( short flag, float float_arg, int int_arg, + short texture_flag, RAS_IRasterizer* rasterizer, RAS_IRenderTools* rendertools, PyTypeObject* T) @@ -25,6 +26,7 @@ SCA_2DFilterActuator::SCA_2DFilterActuator( m_type(type), m_flag(flag), m_int_arg(int_arg), + m_texture_flag(texture_flag), m_float_arg(float_arg), m_rasterizer(rasterizer), m_rendertools(rendertools) @@ -72,7 +74,7 @@ bool SCA_2DFilterActuator::Update() } else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS) { - m_rendertools->Update2DFilter(m_type, m_int_arg, m_shaderText); + m_rendertools->Update2DFilter(m_type, m_int_arg, m_shaderText, m_texture_flag); } return true; } diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h index 7b0cfff951e..451a7b9491a 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h @@ -16,6 +16,7 @@ private: short m_flag; float m_float_arg; int m_int_arg; + short m_texture_flag; STR_String m_shaderText; RAS_IRasterizer* m_rasterizer; RAS_IRenderTools* m_rendertools; @@ -28,6 +29,7 @@ public: short flag, float float_arg, int int_arg, + short texture_flag, RAS_IRasterizer* rasterizer, RAS_IRenderTools* rendertools, PyTypeObject* T=&Type diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 44cdc0a7de5..be00117cd21 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -232,6 +232,7 @@ PyMethodDef SCA_PythonController::Methods[] = { METH_VARARGS, SCA_PythonController::GetSensor_doc}, {"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_VARARGS}, {"setScript", (PyCFunction) SCA_PythonController::sPySetScript, METH_VARARGS}, + {"getState", (PyCFunction) SCA_PythonController::sPyGetState, METH_VARARGS}, {NULL,NULL} //Sentinel }; @@ -442,4 +443,12 @@ PyObject* SCA_PythonController::PySetScript(PyObject* self, Py_Return; } +/* 1. getScript */ +PyObject* SCA_PythonController::PyGetState(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + return PyInt_FromLong(m_statemask); +} + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h index 63975234da9..f3af54f402f 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.h +++ b/source/gameengine/GameLogic/SCA_PythonController.h @@ -81,6 +81,7 @@ class SCA_PythonController : public SCA_IController KX_PYMETHOD_DOC(SCA_PythonController,GetActuators); KX_PYMETHOD(SCA_PythonController,SetScript); KX_PYMETHOD(SCA_PythonController,GetScript); + KX_PYMETHOD(SCA_PythonController,GetState); }; diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index 44eeccedbd1..a5017574873 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -602,9 +602,9 @@ void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer) } } -void GPC_RenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text) +void GPC_RenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text, short texture_flag) { - m_filtermanager.EnableFilter(filtermode, pass, text); + m_filtermanager.EnableFilter(filtermode, pass, text, texture_flag); } void GPC_RenderTools::Render2DFilters(RAS_ICanvas* canvas) diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index f7230cb0865..cb7193f3513 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -142,7 +142,7 @@ public: virtual void MotionBlur(RAS_IRasterizer* rasterizer); - virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text); + virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text, short texture_flag); virtual void Render2DFilters(RAS_ICanvas* canvas); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 1bedc00cb71..015d7473532 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -497,7 +497,6 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) bool fixed_framerate= (SYS_GetCommandLineInt(syshandle, "fixed_framerate", fixedFr) != 0); bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0); - bool useVertexArrays = SYS_GetCommandLineInt(syshandle,"vertexarrays",1) != 0; bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", G.fileflags & G_FILE_DIAPLAY_LISTS) != 0); if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) { @@ -521,16 +520,17 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) if (!m_rendertools) goto initFailed; - if(useLists) - if (useVertexArrays) { + if(useLists) { + if(GLEW_VERSION_1_1) m_rasterizer = new RAS_ListRasterizer(m_canvas, true); - } else { + else m_rasterizer = new RAS_ListRasterizer(m_canvas); - } - else if (useVertexArrays && GLEW_VERSION_1_1) + } + else if (GLEW_VERSION_1_1) m_rasterizer = new RAS_VAOpenGLRasterizer(m_canvas); else m_rasterizer = new RAS_OpenGLRasterizer(m_canvas); + m_rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) stereoMode); if (!m_rasterizer) goto initFailed; diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index bc80c0a7612..8222e5c8bac 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -187,11 +187,10 @@ void usage(char* program) printf(" show_framerate 0 Show the frame rate\n"); printf(" show_properties 0 Show debug properties\n"); printf(" show_profile 0 Show profiling information\n"); - printf(" vertexarrays 1 Enable vertex arrays\n"); printf(" blender_material 0 Enable material settings\n"); printf("\n"); printf("example: %s -p 10 10 320 200 -g noaudio c:\\loadtest.blend\n", program); - printf("example: %s -g vertexarrays = 0 c:\\loadtest.blend\n", program); + printf("example: %s -g show_framerate = 0 c:\\loadtest.blend\n", program); } char *get_filename(int argc, char **argv) { diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 374a43741b6..a8f2394b760 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -804,6 +804,8 @@ void KX_GameObject::Suspend(void) PyMethodDef KX_GameObject::Methods[] = { {"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_VARARGS}, {"getVisible",(PyCFunction) KX_GameObject::sPyGetVisible, METH_VARARGS}, + {"setState",(PyCFunction) KX_GameObject::sPySetState, METH_VARARGS}, + {"getState",(PyCFunction) KX_GameObject::sPyGetState, METH_VARARGS}, {"alignAxisToVect",(PyCFunction) KX_GameObject::sPyAlignAxisToVect, METH_VARARGS}, {"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_VARARGS}, {"getPosition", (PyCFunction) KX_GameObject::sPyGetPosition, METH_VARARGS}, @@ -825,6 +827,7 @@ PyMethodDef KX_GameObject::Methods[] = { {"getMesh", (PyCFunction)KX_GameObject::sPyGetMesh,METH_VARARGS}, {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_VARARGS}, {"getPropertyNames", (PyCFunction)KX_GameObject::sPyGetPropertyNames,METH_VARARGS}, + {"endObject",(PyCFunction) KX_GameObject::sPyEndObject, METH_VARARGS}, KX_PYMETHODTABLE(KX_GameObject, getDistanceTo), KX_PYMETHODTABLE(KX_GameObject, rayCastTo), KX_PYMETHODTABLE(KX_GameObject, rayCast), @@ -858,6 +861,18 @@ PyObject* KX_GameObject::sPySetPosition(PyObject* self, } +PyObject* KX_GameObject::PyEndObject(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + + KX_Scene *scene = PHY_GetActiveScene(); + scene->DelayedRemoveObject(this); + + return Py_None; + +} + PyObject* KX_GameObject::PyGetPosition(PyObject* self, PyObject* args, @@ -1104,6 +1119,39 @@ PyObject* KX_GameObject::PyGetVisible(PyObject* self, return PyInt_FromLong(m_bVisible); } +PyObject* KX_GameObject::PyGetState(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + int state = 0; + state |= GetState(); + return PyInt_FromLong(state); +} + +PyObject* KX_GameObject::PySetState(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + int state_i; + unsigned int state = 0; + + if (PyArg_ParseTuple(args,"i",&state_i)) + { + state |= state_i; + if ((state & ((1<<30)-1)) == 0) { + PyErr_SetString(PyExc_AttributeError, "The state bitfield was not between 0 and 30 (1<<0 and 1<<29)"); + return NULL; + } + SetState(state); + } + else + { + return NULL; + } + Py_Return; +} + + PyObject* KX_GameObject::PyGetVelocity(PyObject* self, PyObject* args, diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 796cb4a161f..89f4cb396d1 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -710,7 +710,7 @@ public: PyObject* args, PyObject* kwds ); - + KX_PYMETHOD(KX_GameObject,GetPosition); KX_PYMETHOD(KX_GameObject,GetLinearVelocity); KX_PYMETHOD(KX_GameObject,GetVelocity); @@ -720,6 +720,8 @@ public: KX_PYMETHOD(KX_GameObject,SetOrientation); KX_PYMETHOD(KX_GameObject,GetVisible); KX_PYMETHOD(KX_GameObject,SetVisible); + KX_PYMETHOD(KX_GameObject,GetState); + KX_PYMETHOD(KX_GameObject,SetState); KX_PYMETHOD(KX_GameObject,AlignAxisToVect); KX_PYMETHOD(KX_GameObject,SuspendDynamics); KX_PYMETHOD(KX_GameObject,RestoreDynamics); @@ -733,6 +735,7 @@ public: KX_PYMETHOD(KX_GameObject,RemoveParent); KX_PYMETHOD(KX_GameObject,GetPhysicsId); KX_PYMETHOD(KX_GameObject,GetPropertyNames); + KX_PYMETHOD(KX_GameObject,EndObject); KX_PYMETHOD_DOC(KX_GameObject,rayCastTo); KX_PYMETHOD_DOC(KX_GameObject,rayCast); KX_PYMETHOD_DOC(KX_GameObject,getDistanceTo); diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 572ac2d42ae..ec7496daa75 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -25,6 +25,11 @@ class KX_GameObject: @ivar timeOffset: adjust the slowparent delay at runtime. @type timeOffset: float """ + def endObject(visible): + """ + Delete this object, can be used inpace of the EndObject Actuator. + The actual removal of the object from the scene is delayed. + """ def getVisible(visible): """ Gets the game object's visible flag. @@ -37,6 +42,20 @@ class KX_GameObject: @type visible: boolean """ + def getState(): + """ + Gets the game object's state bitmask. + + @rtype: int + @return: the objects state. + """ + def setState(): + """ + Sets the game object's visible flag. + The bitmasks for states from 1 to 30 can be set with (1<<0, 1<<1, 1<<2 ... 1<<29) + + @type visible: boolean + """ def setPosition(pos): """ Sets the game object's position. diff --git a/source/gameengine/PyDoc/SCA_PythonController.py b/source/gameengine/PyDoc/SCA_PythonController.py index eb9e57c0819..6d91736d636 100644 --- a/source/gameengine/PyDoc/SCA_PythonController.py +++ b/source/gameengine/PyDoc/SCA_PythonController.py @@ -46,4 +46,12 @@ class SCA_PythonController(SCA_IController): @type script: string. """ + def getState(): + """ + Get the controllers state bitmask, this can be used with the GameObject's state to test if the the controller is active. + This for instance will always be true however you could compare with a previous state to see when the state was activated. + GameLogic.getCurrentController().getState() & GameLogic.getCurrentController().getOwner().getState() + + @rtype: int + """ diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index e9ab4ccca8d..23153fcd86c 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -54,7 +54,7 @@ RAS_2DFilterManager::RAS_2DFilterManager(): -texname(-1), texturewidth(-1), textureheight(-1), +texturewidth(-1), textureheight(-1), canvaswidth(-1), canvasheight(-1), numberoffilters(0) { @@ -72,8 +72,9 @@ numberoffilters(0) { m_filters[passindex] = 0; m_enabled[passindex] = 0; + texflag[passindex] = 0; } - + texname[0] = texname[1] = texname[2] = -1; } RAS_2DFilterManager::~RAS_2DFilterManager() @@ -150,30 +151,54 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(int filtermode) return 0; } -void RAS_2DFilterManager::StartShaderProgram(unsigned int shaderprogram) +void RAS_2DFilterManager::StartShaderProgram(int passindex) { GLint uniformLoc; - glUseProgramObjectARB(shaderprogram); - uniformLoc = glGetUniformLocationARB(shaderprogram, "bgl_RenderedTexture"); + glUseProgramObjectARB(m_filters[passindex]); + uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTexture"); glActiveTextureARB(GL_TEXTURE0); - //glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, texname); + glBindTexture(GL_TEXTURE_2D, texname[0]); if (uniformLoc != -1) { glUniform1iARB(uniformLoc, 0); } - uniformLoc = glGetUniformLocationARB(shaderprogram, "bgl_TextureCoordinateOffset"); + + /* send depth texture to glsl program if it needs */ + if(texflag[passindex] & 0x1){ + uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_DepthTexture"); + glActiveTextureARB(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, texname[1]); + + if (uniformLoc != -1) + { + glUniform1iARB(uniformLoc, 1); + } + } + + /* send luminance texture to glsl program if it needs */ + if(texflag[passindex] & 0x1){ + uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_LuminanceTexture"); + glActiveTextureARB(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_2D, texname[2]); + + if (uniformLoc != -1) + { + glUniform1iARB(uniformLoc, 2); + } + } + + uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_TextureCoordinateOffset"); if (uniformLoc != -1) { glUniform2fvARB(uniformLoc, 9, textureoffsets); } - uniformLoc = glGetUniformLocationARB(shaderprogram, "bgl_RenderedTextureWidth"); + uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTextureWidth"); if (uniformLoc != -1) { glUniform1fARB(uniformLoc,texturewidth); } - uniformLoc = glGetUniformLocationARB(shaderprogram, "bgl_RenderedTextureHeight"); + uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTextureHeight"); if (uniformLoc != -1) { glUniform1fARB(uniformLoc,textureheight); @@ -187,14 +212,33 @@ void RAS_2DFilterManager::EndShaderProgram() void RAS_2DFilterManager::SetupTexture() { - if(texname!=-1) + if(texname[0]!=-1 || texname[1]!=-1) { - glDeleteTextures(1,(const GLuint *)&texname); + glDeleteTextures(2, (GLuint*)texname); } - glGenTextures(1, (GLuint *)&texname); - glBindTexture(GL_TEXTURE_2D, texname); + glGenTextures(3, (GLuint*)texname); + + glBindTexture(GL_TEXTURE_2D, texname[0]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texturewidth, textureheight, 0, GL_RGB, - GL_UNSIGNED_BYTE, 0); + GL_UNSIGNED_BYTE, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + + glBindTexture(GL_TEXTURE_2D, texname[1]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, texturewidth,textureheight, 0, GL_DEPTH_COMPONENT, + GL_FLOAT,NULL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, + GL_NONE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + + glBindTexture(GL_TEXTURE_2D, texname[2]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE16, texturewidth, textureheight, 0, GL_LUMINANCE, + GL_UNSIGNED_BYTE, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); @@ -246,12 +290,27 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) int passindex; bool first = true; + for(passindex =0; passindex<MAX_RENDER_PASS; passindex++) { if(m_filters[passindex] && m_enabled[passindex]) { if(first) { + /* this pass needs depth texture*/ + if(texflag[passindex] & 0x1){ + glActiveTextureARB(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, texname[1]); + glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, 0,0, texturewidth,textureheight, 0); + } + + /* this pass needs luminance texture*/ + if(texflag[passindex] & 0x2){ + glActiveTextureARB(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_2D, texname[2]); + glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, 0,0, texturewidth,textureheight, 0); + } + glGetIntegerv(GL_VIEWPORT,(GLint *)viewport); glViewport(0, 0, texturewidth, textureheight); @@ -263,11 +322,13 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) first = false; } - StartShaderProgram(m_filters[passindex]); + StartShaderProgram(passindex); - glBindTexture(GL_TEXTURE_2D, texname); - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, texturewidth, textureheight, 0); + glActiveTextureARB(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, texname[0]); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, texturewidth, textureheight, 0); + glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_QUADS); @@ -288,7 +349,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) } } -void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_String& text) +void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_String& text, short tflag) { if(!isshadersupported) return; @@ -313,11 +374,13 @@ void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_Str glDeleteObjectARB(m_filters[pass]); m_enabled[pass] = 0; m_filters[pass] = 0; + texflag[pass] = 0; return; } if(mode == RAS_2DFILTER_CUSTOMFILTER) { + texflag[pass] = tflag; if(m_filters[pass]) glDeleteObjectARB(m_filters[pass]); m_filters[pass] = CreateShaderProgram(text.Ptr()); diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h index cff868556e0..faf7c652388 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h @@ -37,17 +37,21 @@ class RAS_2DFilterManager private: unsigned int CreateShaderProgram(char* shadersource); unsigned int CreateShaderProgram(int filtermode); - void StartShaderProgram(unsigned int shaderprogram); + void StartShaderProgram(int passindex); void EndShaderProgram(); float textureoffsets[18]; float view[4]; - unsigned int texname; + /* texname[0] contains render to texture, texname[1] contains depth texture, texname[2] contains luminance texture*/ + unsigned int texname[3]; int texturewidth; int textureheight; int canvaswidth; int canvasheight; int numberoffilters; + /* bit 0: enable/disable depth texture + * bit 1: enable/disable luminance texture*/ + short texflag[MAX_RENDER_PASS]; bool isshadersupported; public: @@ -83,6 +87,6 @@ public: void RenderFilters(RAS_ICanvas* canvas); - void EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_String& text); + void EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_String& text, short tflag); }; #endif diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h index bcbf907741b..781f90d4124 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.h +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h @@ -185,7 +185,7 @@ public: virtual void - Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)=0; + Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text, short textureflag)=0; virtual void diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 3487291e0f1..c69a6810459 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -125,6 +125,9 @@ static void Myinit_gl_stuff(void) glDisable(GL_TEXTURE_1D); glDisable(GL_TEXTURE_2D); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + glPixelTransferi(GL_MAP_COLOR, GL_FALSE); glPixelTransferi(GL_RED_SCALE, 1); glPixelTransferi(GL_RED_BIAS, 0); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp index fb74f5a2c21..4bfe623f637 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp @@ -92,9 +92,10 @@ void RAS_VAOpenGLRasterizer::SetDrawingMode(int drawingmode) void RAS_VAOpenGLRasterizer::Exit() { - glDisableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); EnableTextures(false); RAS_OpenGLRasterizer::Exit(); |