*/ REBINT Effect_Gob(void *effects, REBSER *block) /* ** Handles all commands for the EFFECT dialect as specified ** in the system/dialects/effect object. ** ** This function calls the REBOL_Dialect interpreter to ** parse the dialect and build and return the command number ** (the index offset in the draw object above) and a block ** of arguments. (For now, just a REBOL block, but this could ** be changed to isolate it from changes in REBOL's internals). ** ** Each arg will be of the specified datatype (given in the ** dialect) or NONE when no argument of that type was given ** and this code must determine the proper default value. ** ** If the cmd result is zero, then it is either the end of ** the block, or an error has occurred. If the error value ** is non-zero, then it was an error. ** ***********************************************************************/ { // REBSER *block; REBCNT index = 0; REBINT cmd; REBSER *args = 0; REBVAL *arg; REBCNT nargs; //default values REBYTE def_color1[4] = {0,0,0,0}; REBYTE def_color2[4] = {255,255,255,0}; REBPAR def_pair = {1,0}; do { cmd = Reb_Dialect(DIALECTS_EFFECT, block, &index, &args); if (cmd == 0) return 0; if (cmd < 0) { // Reb_Print("ERROR: %d, Index %d", -cmd, index); return -((REBINT)index+1); } // else // Reb_Print("EFFECT: Cmd %d, Index %d, Args %m", cmd, index, args); arg = BLK_HEAD(args); nargs = SERIES_TAIL(args); // Reb_Print("Number of args: %d", nargs); switch (cmd) { case EW_ADD: FX_Add(effects, ARG_OPT_IMAGE(0), ARG_OPT_IMAGE(1)); break; case EW_ALPHAMUL: if (IS_IMAGE(arg)) FX_Alphamul(effects, ARG_IMAGE(0), IS_NONE(arg+1) ? 127 : ARG_INTEGER(1)); break; case EW_ASPECT: { REBINT type = 1, mode = 2; if (ARG_WORD(0) == EW_RESAMPLE){ type = 2; mode = 1; } FX_Fit(effects,ARG_OPT_IMAGE(0), ARG_WORDS(type,EW_NEAREST,EW_GAUSSIAN), ARG_WORD(mode) == EW_RESAMPLE, IS_NONE(arg+3) ? 1.0 : ARG_DECIMAL(3), TRUE); } break; case EW_BLUR: // FX_Blur(effects, ARG_OPT_IMAGE(0)); { REBDEC filter[9] = {0, 1, 0, 1, 1, 1, 0, 1, 0}; FX_Convolve(effects, ARG_OPT_IMAGE(0),filter , 5.0, 0, FALSE); } break; case EW_COLORIFY: FX_Colorify(effects, IS_NONE(arg+1) ? def_color2 : ARG_TUPLE(1) , IS_NONE(arg+2) ? 255 : max(0, min(255,ARG_INTEGER(2))), ARG_OPT_IMAGE(0)); break; case EW_COLORIZE: FX_Colorize(effects, IS_NONE(arg+1) ? def_color2 : ARG_TUPLE(1) , ARG_OPT_IMAGE(0)); break; case EW_CONTRAST: FX_Contrast(effects, IS_NONE(arg+1) ? 127 : ARG_INTEGER(1), ARG_OPT_IMAGE(0)); break; case EW_CONVOLVE: //[image! block! decimal! decimal! logic!] if (IS_BLOCK(arg+1)) { REBDEC filter[9]; REBSER* mtx = (REBSER*)ARG_BLOCK(1); REBVAL* slot = BLK_HEAD(mtx); REBCNT len = SERIES_TAIL(mtx) ,i, num = 0; for (i = 0;i<len;i++){ if (IS_DECIMAL(slot+i)) filter[i] = VAL_DECIMAL(slot+i); else if (IS_INTEGER(slot+i)) filter[i] = VAL_INT32(slot+i); else return -cmd; num++; } if (num != 9) return -cmd; FX_Convolve(effects, ARG_OPT_IMAGE(0),filter , ARG_DECIMAL(2), ARG_INTEGER(3), ARG_LOGIC(4)); } break; case EW_CROP: FX_Crop(effects,ARG_OPT_IMAGE(0), IS_NONE(arg+1) ? 0 : &ARG_PAIR(1), IS_NONE(arg+2) ? 0 : &ARG_PAIR(2)); break; case EW_DIFFERENCE: FX_Difference(effects, IS_NONE(arg+2) ? def_color2 : ARG_TUPLE(2), ARG_OPT_IMAGE(0), ARG_OPT_IMAGE(1), (IS_NONE(arg+2)) ? 1 : 0); break; case EW_EMBOSS: { REBDEC filter[9] = {-1, 0, 1, -2, 0, 2, -1, 0, 1}; FX_Convolve(effects, ARG_OPT_IMAGE(0),filter , 6.0, 127, FALSE); } break; case EW_EXTEND: FX_Extend(effects,ARG_OPT_IMAGE(0), IS_NONE(arg+1) ? 0 : &ARG_PAIR(1), IS_NONE(arg+2) ? 0 : &ARG_PAIR(2)); break; case EW_FIT: if (IS_IMAGE(arg)){ REBINT type = 1, mode = 2; if (ARG_WORD(0) == EW_RESAMPLE){ type = 2; mode = 1; } FX_Fit(effects,ARG_IMAGE(0), ARG_WORDS(type,EW_NEAREST,EW_GAUSSIAN), ARG_WORD(mode) == EW_RESAMPLE, IS_NONE(arg+3) ? 1.0 : ARG_DECIMAL(3), FALSE); } break; case EW_FLIP: FX_Flip(effects, IS_NONE(arg+1) ? &def_pair : &ARG_PAIR(1), ARG_OPT_IMAGE(0)); break; case EW_GRADCOL: FX_Gradcol(effects, &ARG_PAIR(1), IS_NONE(arg+2) ? def_color1 : ARG_TUPLE(2), IS_NONE(arg+3) ? def_color2 : ARG_TUPLE(3),ARG_OPT_IMAGE(0)); break; case EW_GRADIENT: FX_Gradient(effects, &ARG_PAIR(1), IS_NONE(arg+2) ? def_color1 : ARG_TUPLE(2), IS_NONE(arg+3) ? def_color2 : ARG_TUPLE(3), ARG_OPT_IMAGE(0)); break; case EW_GRADMUL: FX_Gradmul(effects, &ARG_PAIR(1), IS_NONE(arg+2) ? def_color1 : ARG_TUPLE(2), IS_NONE(arg+3) ? def_color2 : ARG_TUPLE(3), ARG_OPT_IMAGE(0)); break; case EW_GRAYSCALE: FX_Grayscale(effects,ARG_OPT_IMAGE(0)); break; case EW_HSV: FX_HSV(effects, IS_NONE(arg+1) ? def_color2 : ARG_TUPLE(1), ARG_OPT_IMAGE(0)); break; case EW_INVERT: FX_Invert(effects,ARG_OPT_IMAGE(0)); break; case EW_KEY: if (IS_IMAGE(arg)) FX_Key(effects, IS_NONE(arg+1) ? def_color1 : ARG_TUPLE(1), ARG_IMAGE(0)); break; case EW_LUMA: FX_Luma(effects, IS_NONE(arg+1) ? 127 : ARG_INTEGER(1),ARG_OPT_IMAGE(0)); break; case EW_MIX: FX_Mix(effects, ARG_OPT_IMAGE(0), ARG_OPT_IMAGE(1)); break; case EW_MULTIPLY: { REBINT i = 0x00FFFFFF; REBYTE* color = (REBYTE*)&i; if (IS_INTEGER(arg+3)) { i = ARG_INTEGER(3); i = i + (i << 8) + (i << 16); } else if (IS_TUPLE(arg+2)) color = ARG_TUPLE(2); FX_Multiply(effects, color ,ARG_OPT_IMAGE(0), ARG_OPT_IMAGE(1), (IS_NONE(arg+2) && IS_NONE(arg+3)) ? 1 : 0); } break; case EW_REFLECT: FX_Reflect(effects, IS_NONE(arg+1) ? &def_pair : &ARG_PAIR(1), ARG_OPT_IMAGE(0)); break; case EW_ROTATE: FX_Rotate(effects, IS_NONE(arg+1) ? 90 : ARG_INTEGER(1), ARG_OPT_IMAGE(0)); break; case EW_SHADOW: if (IS_IMAGE(arg)) FX_Shadow(effects, ARG_IMAGE(0), IS_NONE(arg+1) ? 0 : &ARG_PAIR(1), IS_NONE(arg+2) ? 0 : &ARG_PAIR(2), IS_NONE(arg+3) ? 0 : ARG_TUPLE(3), IS_NONE(arg+4) ? 0 : ARG_DECIMAL(4), IS_NONE(arg+5) ? 0 : ARG_WORD(5) == EW_ONLY); break; case EW_SHARPEN: // FX_Sharpen(effects, ARG_OPT_IMAGE(0)); { REBDEC filter[9] = {0, -1, 0, -1, 8, -1, 0, -1, 0}; FX_Convolve(effects, ARG_OPT_IMAGE(0),filter , 4.0, 0, FALSE); } break; case EW_TILE: if (IS_IMAGE(arg)) FX_Tile(effects, ARG_IMAGE(0), &ARG_PAIR(1)); break; case EW_TILE_VIEW: if (IS_IMAGE(arg)) { REBPAR p; Effect_Offset(effects, &p); FX_Tile(effects, ARG_IMAGE(0), &p); } break; case EW_TINT: FX_Tint(effects, IS_NONE(arg+1) ? 127 : ARG_INTEGER(1),ARG_OPT_IMAGE(0)); break; } } while (TRUE); }
void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) { qboolean inwater = qfalse; cg.time = serverTime; CG_BuildSolidList(); // update cvars CG_UpdateCvars(); // if we are only updating the screen as a loading // pacifier, don't even try to read snapshots if ( cg.infoScreenText[0] != 0 ) { CG_DrawInformation(); return; } // any looped sounds will be respecified as entities // are added to the render list cgi_S_ClearLoopingSounds(); // clear all the render lists cgi_R_ClearScene(); // set up cg.snap and possibly cg.nextSnap CG_ProcessSnapshots(); // if we haven't received any snapshots yet, all // we can draw is the information screen if ( !cg.snap ) { CG_DrawInformation(); return; } // let the client system know what our weapon and zoom settings are cgi_SetUserCmdValue( cg.weaponSelect, cg.refdef.fov_y / 75.0 ); // this counter will be bumped for every valid scene we generate cg.clientFrame++; // update cg.predicted_player_state CG_PredictPlayerState(); // decide on third person view cg.renderingThirdPerson = cg_thirdPerson.integer || (cg.snap->ps.stats[STAT_HEALTH] <= 0); if ( in_camera ) { // The camera takes over the view CGCam_RenderScene(); } else { //Finish any fading that was happening CGCam_UpdateFade(); // build cg.refdef inwater = CG_CalcViewValues(); } //This is done from the vieworg to get origin for non-attenuated sounds cgi_S_UpdateAmbientSet( CG_ConfigString( CS_AMBIENT_SET ), cg.refdef.vieworg ); // first person blend blobs, done after AnglesToAxis if ( !cg.renderingThirdPerson ) { CG_DamageBlendBlob(); } // build the render lists if ( !cg.hyperspace ) { CG_AddPacketEntities(); // adter calcViewValues, so predicted player state is correct CG_AddMarks(); CG_AddLocalEntities(); } // Don't draw the in-view weapon when in camera mode if ( !in_camera && !cg_pano.integer ) CG_AddViewWeapon( &cg.predicted_player_state ); // finish up the rest of the refdef if ( cg.testModelEntity.hModel ) { CG_AddTestModel(); } cg.refdef.time = cg.time; memcpy( cg.refdef.areamask, cg.snap->areamask, sizeof( cg.refdef.areamask ) ); // update audio positions cgi_S_Respatialize( cg.snap->ps.clientNum, cg.refdef.vieworg, cg.refdef.viewaxis, inwater ); // warning sounds when powerup is wearing off CG_PowerupTimerSounds(); // make sure the lagometerSample and frame timing isn't done twice when in stereo if ( stereoView != STEREO_RIGHT ) { cg.frametime = cg.time - cg.oldTime; cg.oldTime = cg.time; } //Add all effects if (cg.frametime >= 0) { FX_Add(); } if ( cg_pano.integer ) { // let's grab a panorama! cg.levelShot = qtrue; //hide the 2d VectorClear(cg.refdefViewAngles); cg.refdefViewAngles[YAW] = -360 * cg_pano.integer/cg_panoNumShots.integer; //choose angle AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis ); CG_DrawActive( stereoView ); cg.levelShot = qfalse; } else { // actually issue the rendering calls CG_DrawActive( stereoView ); } }