コード例 #1
0
ファイル: sdl_driver.c プロジェクト: Libvisual/DroidVisuals
static int native_updaterect (SADisplay *display, VisRectangle *rect)
{
        SDLNative *native = SDL_NATIVE (display->native);
        SDL_Surface *sdlscreen = native->screen;

        if (sdlscreen->format->BitsPerPixel == 8) {
                SDL_Color colors[256];
                VisPalette *pal = display->screen->pal;

                visual_mem_set (colors, 0, sizeof (colors));

                if (pal != NULL && pal->ncolors <= 256) {
                        int i;

                        for (i = 0; i < pal->ncolors; i++) {
                                colors[i].r = pal->colors[i].r;
                                colors[i].g = pal->colors[i].g;
                                colors[i].b = pal->colors[i].b;
                        }

                        SDL_SetColors (sdlscreen, colors, 0, 256);
                }
        }

        if (native->requested_depth == VISUAL_VIDEO_DEPTH_GL)
                SDL_GL_SwapBuffers ();
        else
                SDL_UpdateRect (sdlscreen, rect->x, rect->y, rect->width, rect->height);

        return 0;
}
コード例 #2
0
VISUAL_C_LINKAGE
int lv_gforce_init (VisPluginData *plugin)
{
    GForcePrivate *priv;
    Rect r;

#if ENABLE_NLS
    bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
#endif

    priv = new GForcePrivate;
    visual_mem_set (priv, 0, sizeof (GForcePrivate));

    visual_object_set_private (VISUAL_OBJECT (plugin), priv);

    priv->pal = new LV::Palette (256);

    EgOSUtils::Initialize (0);
    ScreenDevice::sMinDepth = 8;

    /* Randomize the seed */
    srand (EgOSUtils::CurTimeMS ());


    priv->gGF = new GForce;

    SetRect (&r, 0, 0, 64, 64);

    priv->gGF->SetWinPort (0, &r);
    priv->gGF->StoreWinRect ();

    return 0;
}
コード例 #3
0
/* This function is called before we really start rendering, it's the init function */
extern "C" int lv_projectm_init (VisPluginData *plugin)
{
        char projectM_data[1024];
	ProjectmPrivate *priv;
	 std::string config_file;
 config_file = read_config();

 ConfigFile config(config_file);
        wvw = config.read<int>( "Window Width", 512 );
  wvh = config.read<int>( "Window Height", 512 );
 fullscreen = 0;
	/* Allocate the projectm private data structure, and register it as a private */

	priv = new ProjectmPrivate;
	visual_mem_set (priv, 0, sizeof (ProjectmPrivate));


	//priv = visual_mem_new0 (ProjectmPrivate, 1);
	visual_object_set_private (VISUAL_OBJECT (plugin), priv);

	//FIXME
	priv->PM = new projectM(config_file);
	//globalPM = (projectM *)wipemalloc( sizeof( projectM ) );



	return 0;
}
コード例 #4
0
ファイル: nebulus.c プロジェクト: Libvisual/LibVisualAndroid
static int nebulus_detect_beat (int loudness)
{
	static int    aged;
	static int    lowest;
	static int elapsed;
	static int isquiet;
	static int prevbeat;
	int i, j;
	int total;
	int sensitivity;
	int detected_beat;

	aged = (aged * 7 + loudness) >> 3;
	elapsed++;

	if (aged < 2000 || elapsed > BEAT_MAX) {
		elapsed = 0;
		lowest = aged;
		visual_mem_set(beathistory, 0, sizeof beathistory);
	}
	else if (aged < lowest)
		lowest = aged;

	j = (beatbase + elapsed) % BEAT_MAX;
	beathistory[j] = loudness - aged;
	detected_beat = FALSE;
	if (elapsed > 15 && aged > 2000 && loudness * 4 > aged * 5) {
		for (i = BEAT_MAX / elapsed, total = 0;
				--i > 0;
				j = (j + BEAT_MAX - elapsed) % BEAT_MAX)
		{
			total += beathistory[j];
		}
		total = total * elapsed / BEAT_MAX;
		sensitivity = 6;
		i = 3 - abs(elapsed - prevbeat)/2;
		if (i > 0)
			sensitivity += i;
		if (total * sensitivity > aged) {
			prevbeat = elapsed;
			beatbase = (beatbase + elapsed) % BEAT_MAX;
			lowest = aged;
			elapsed = 0;
			detected_beat = TRUE;
		}
	}
	if (aged < (isquiet ? 1500 : 500))
		isquiet = TRUE;
	else
		isquiet = FALSE;

	return detected_beat;
}
コード例 #5
0
ファイル: lv_actor.c プロジェクト: Starlon/StarVisuals-And
/**
 * Initializes a VisActor, this will set the allocated flag for the object to FALSE. Should not
 * be used to reset a VisActor, or on a VisActor created by visual_actor_new().
 *
 * @see visual_actor_new
 *
 * @param actor Pointer to the VisActor that is initialized.
 * @param actorname
 *	The name of the plugin to load, or NULL to simply initialize a new actor.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_ACTOR_NULL or -VISUAL_ERROR_PLUGIN_NO_LIST on failure.
 */
int visual_actor_init (VisActor *actor, const char *actorname)
{
	VisPluginRef *ref;
	VisPluginEnviron *enve;
	VisActorPluginEnviron *actenviron;

	visual_log_return_val_if_fail (actor != NULL, -VISUAL_ERROR_ACTOR_NULL);

	if (__lv_plugins_actor == NULL && actorname != NULL) {
		visual_log (VISUAL_LOG_CRITICAL, _("the plugin list is NULL"));

		return -VISUAL_ERROR_PLUGIN_NO_LIST;
	}

	/* Do the VisObject initialization */
	visual_object_clear (VISUAL_OBJECT (actor));
	visual_object_set_dtor (VISUAL_OBJECT (actor), actor_dtor);
	visual_object_set_allocated (VISUAL_OBJECT (actor), FALSE);

	/* Reset the VisActor data */
	actor->plugin = NULL;
	actor->video = NULL;
	actor->transform = NULL;
	actor->fitting = NULL;
	actor->ditherpal = NULL;

	visual_mem_set (&actor->songcompare, 0, sizeof (VisSongInfo));

	if (actorname == NULL)
		return VISUAL_OK;

	ref = visual_plugin_find (__lv_plugins_actor, actorname);

	actor->plugin = visual_plugin_load (ref);

	/* Adding the VisActorPluginEnviron */
	actenviron = visual_mem_new0 (VisActorPluginEnviron, 1);

	visual_object_initialize (VISUAL_OBJECT (actenviron), TRUE, NULL);

	enve = visual_plugin_environ_new (VISUAL_ACTOR_PLUGIN_ENVIRON, VISUAL_OBJECT (actenviron));
	visual_plugin_environ_add (actor->plugin, enve);

	return VISUAL_OK;
}
コード例 #6
0
AVSElement *avs_parse_trans_movement (AVSTree *avstree)
{
        AVSElement *movement;
        int len = avstree->cur_section_length;
        int pos=0;

        int effect;
        int rectangular;
        int blend;
        int sourcemapped;
        int subpixel;
        int wrap;
        int REFFECT_MAX = 23;
        int effect_exp_ch;

        char buf[257];

        VisParamContainer *pcont;

        static VisParamEntry params[] = {
                VISUAL_PARAM_LIST_ENTRY_INTEGER ("effect", 0),
                VISUAL_PARAM_LIST_ENTRY_INTEGER ("rectangular", 0),
                VISUAL_PARAM_LIST_ENTRY_INTEGER ("blend", 0),
                VISUAL_PARAM_LIST_ENTRY_INTEGER ("sourcemapped", 0),
                VISUAL_PARAM_LIST_ENTRY_INTEGER ("subpixel", 0),
                VISUAL_PARAM_LIST_ENTRY_INTEGER ("wrap", 0),
                VISUAL_PARAM_LIST_ENTRY_STRING ("code", ""),
                VISUAL_PARAM_LIST_END
        };

        visual_mem_set (buf, 0, sizeof (buf));

        pcont = visual_param_container_new ();

        visual_param_container_add_many(pcont, params);

        movement = visual_mem_new0 (AVSElement, 1);

        /* Do the VisObject initialization */
        visual_object_initialize (VISUAL_OBJECT (movement), TRUE, avs_element_dtor);

        AVS_ELEMENT (movement)->pcont = pcont;
        AVS_ELEMENT (movement)->type = AVS_ELEMENT_TYPE_TRANS_MOVEMENT;

        /* Deserialize without using the container, too complex (borked) serialization */
        if (len - pos >= 4) {
                effect=AVS_SERIALIZE_GET_INT (avstree->cur);
                AVS_SERIALIZE_SKIP_INT (avstree->cur);
                pos += 4;
        }
        if (effect == 32767)
        {
                if (!memcmp(avstree->cur,"!rect ",6))
                {
                        AVS_SERIALIZE_SKIP_LENGTH (avstree->cur, 6);
                        rectangular=1;
                }
                if (AVS_SERIALIZE_GET_BYTE (avstree->cur) == 1)
                {
                        AVS_SERIALIZE_SKIP_BYTE (avstree->cur);
                        pos++;

                        int l=AVS_SERIALIZE_GET_INT(avstree->cur); AVS_SERIALIZE_SKIP_INT (avstree->cur); pos += 4;
                        if (l > 0 && len-pos >= l)
                        {
//                              effect_exp.resize(l);
                                memcpy(buf, avstree->cur, l);
                                buf[l] = 0;

//                              memcpy(effect_exp.get(), data+pos, l);
                                AVS_SERIALIZE_SKIP_LENGTH (avstree->cur, l);
                                pos+=l;
                        }
                        else
                        {
//                              effect_exp.resize(1);
//                              effect_exp.get()[0]=0;
                        }
                }
                else if (len-pos >= 256)
                {
                        int l = 256 - (rectangular ? 6 : 0);
                        memcpy(buf,avstree->cur,l);
                        buf[l]=0;
//                      effect_exp.assign(buf);
                        AVS_SERIALIZE_SKIP_LENGTH (avstree->cur, l);
                        pos+=l;
                        printf ("trans_movement buf %s\n", buf);
                }
        }
        if (len-pos >= 4) { blend=AVS_SERIALIZE_GET_INT(avstree->cur); AVS_SERIALIZE_SKIP_INT (avstree->cur);pos+=4; }
        if (len-pos >= 4) { sourcemapped=AVS_SERIALIZE_GET_INT(avstree->cur); AVS_SERIALIZE_SKIP_INT (avstree->cur);pos+=4; }
        if (len-pos >= 4) { rectangular=AVS_SERIALIZE_GET_INT(avstree->cur); AVS_SERIALIZE_SKIP_INT (avstree->cur);pos+=4; }
        if (len-pos >= 4) { subpixel=AVS_SERIALIZE_GET_INT(avstree->cur); AVS_SERIALIZE_SKIP_INT (avstree->cur);pos+=4; }
        else subpixel=0;
        if (len-pos >= 4) { wrap=AVS_SERIALIZE_GET_INT(avstree->cur); AVS_SERIALIZE_SKIP_INT (avstree->cur);pos+=4; }
        else wrap=0;
        if (!effect && len-pos >= 4)
        {
                effect=AVS_SERIALIZE_GET_INT(avstree->cur); AVS_SERIALIZE_SKIP_INT (avstree->cur);pos+=4;
        }

        if (effect != 32767 && (effect > REFFECT_MAX || effect < 0))
                effect=0;
        effect_exp_ch=1;

        visual_param_entry_set_integer (visual_param_container_get (pcont, "effect"), effect);
        visual_param_entry_set_integer (visual_param_container_get (pcont, "rectangular"), rectangular);
        visual_param_entry_set_integer (visual_param_container_get (pcont, "blend"), blend);
        visual_param_entry_set_integer (visual_param_container_get (pcont, "sourcemapped"), sourcemapped);
        visual_param_entry_set_integer (visual_param_container_get (pcont, "subpixel"), subpixel);
        visual_param_entry_set_integer (visual_param_container_get (pcont, "wrap"), wrap);
        visual_param_entry_set_string (visual_param_container_get (pcont, "code"), buf);

        printf ("effect: %d, rectangular: %d, blend %d, sourcemapped %d, subpixel %d, wrap %d\n",
                        effect, rectangular, blend, sourcemapped, subpixel, wrap);

        return movement;
}
コード例 #7
0
ファイル: lv_bin.c プロジェクト: Denyufka/LibVisual
int visual_bin_switch_actor (VisBin *bin, VisActor *actor)
{
	VisVideo *privvid;

	visual_log_return_val_if_fail (bin != NULL, -1);
	visual_log_return_val_if_fail (actor != NULL, -1);

	/* Set the new actor */
	bin->actmorph = actor;

	visual_log (VISUAL_LOG_DEBUG, "entering...");
	
	/* Free the private video */
	if (bin->privvid != NULL) {
		visual_object_unref (VISUAL_OBJECT (bin->privvid));
		
		bin->privvid = NULL;
	}

	visual_log (VISUAL_LOG_INFO, _("depth of the main actor: %d"), bin->actor->video->depth);

	/* Starting the morph, but first check if we don't have anything todo with openGL */
	if (bin->morphstyle == VISUAL_SWITCH_STYLE_MORPH &&
			bin->actor->video->depth != VISUAL_VIDEO_DEPTH_GL &&
			bin->actmorph->video->depth != VISUAL_VIDEO_DEPTH_GL &&
			bin->depthfromGL != TRUE) {

		if (bin->morph != NULL && bin->morph->plugin != NULL) {
			visual_morph_set_rate (bin->morph, 0);
		
			visual_morph_set_video (bin->morph, bin->actvideo);

			if (bin->morphautomatic == TRUE)
				visual_morph_set_mode (bin->morph, bin->morphmode);
			else
				visual_morph_set_mode (bin->morph, VISUAL_MORPH_MODE_SET);
			
			visual_morph_set_time (bin->morph, &bin->morphtime);
			visual_morph_set_steps (bin->morph, bin->morphsteps);
		}

		bin->morphrate = 0;
		bin->morphstepsdone = 0;

		visual_log (VISUAL_LOG_DEBUG, "phase 1");
		/* Allocate a private video for the main actor, so the morph
		 * can draw to the framebuffer */
		privvid = visual_video_new ();

		visual_log (VISUAL_LOG_DEBUG, "actvideo->depth %d actmorph->video->depth %d",
				bin->actvideo->depth, bin->actmorph->video->depth);

		visual_log (VISUAL_LOG_DEBUG, "phase 2");
		visual_video_clone (privvid, bin->actvideo);
		visual_log (VISUAL_LOG_DEBUG, "phase 3 pitch privvid %d actvideo %d", privvid->pitch, bin->actvideo->pitch);

		visual_video_allocate_buffer (privvid);

		visual_log (VISUAL_LOG_DEBUG, "phase 4");
		/* Initial privvid initialize */
	
		visual_log (VISUAL_LOG_DEBUG, "actmorph->video->depth %d %p", bin->actmorph->video->depth,
				visual_video_get_pixels (bin->actvideo));
		
		if (visual_video_get_pixels (bin->actvideo) != NULL && visual_video_get_pixels (privvid) != NULL)
			visual_mem_copy (visual_video_get_pixels (privvid), visual_video_get_pixels (bin->actvideo),
					visual_video_get_size (privvid));
		else if (visual_video_get_pixels (privvid) != NULL)
			visual_mem_set (visual_video_get_pixels (privvid), 0, visual_video_get_size (privvid));

		visual_actor_set_video (bin->actor, privvid);
		bin->privvid = privvid;
	} else {
		visual_log (VISUAL_LOG_DEBUG, "Pointer actvideo->pixels %p", visual_video_get_pixels (bin->actvideo));
		if (bin->actor->video->depth != VISUAL_VIDEO_DEPTH_GL &&
				visual_video_get_pixels (bin->actvideo) != NULL) {
			visual_mem_set (visual_video_get_pixels (bin->actvideo), 0, visual_video_get_size (bin->actvideo));
		}
	}

	visual_log (VISUAL_LOG_DEBUG, "Leaving, actor->video->depth: %d actmorph->video->depth: %d",
			bin->actor->video->depth, bin->actmorph->video->depth);

	bin->morphing = TRUE;

	return 0;
}