示例#1
0
文件: demo.c 项目: marcan/openlase
void render_fire(float left)
{
	int x,y,i;
	int w = 256;
	int h = 256;

	for(i=0; i<2; i++) {
		int *p = &mbuf[h-1][0];

		for (x=0;x<256;x++) {
			if (left > 0.7 && (random() % 100) > 60)
				*p++ = 1024;
			else
				*p++ = 0;
		}

		if (left > 2.0 && random() % 32 == 0)
			mbuf[h-1][random()%w] = random()%120000;


		for (y=254;y>=0;y--) {
			p = &mbuf[y][0];
			*p++ = 0;
			for (x=1;x<255;x++) {
				*p = (*p + p[w-1] + p[w] + p[w+1]) / 4;
				if (*p)
					(*p)--;
				p++;
			}
			*p++ = 0;
		}
	}

	olPushMatrix();
	olScale(1, -1);
	olTranslate(-1.0f, -1.0f);
	olScale(2.0f/256.0f, 2.0f/256.0f);

	olPushColor();
	olMultColor(C_RED+C_GREEN_I(150));
	trace(&mbuf[0][0], &mtmp[0][0], 200, 256, 235, 2);
	olPopColor();
	olPushColor();
	olMultColor(C_RED+C_GREEN_I(100));
	trace(&mbuf[0][0], &mtmp[0][0], 250, 256, 235, 2);
	olPopColor();
	olPushColor();
	olMultColor(C_RED+C_GREEN_I(50));
	trace(&mbuf[0][0], &mtmp[0][0], 300, 256, 235, 2);
	olPopColor();
	olPushColor();
	olMultColor(C_RED+C_GREEN_I(0));
	trace(&mbuf[0][0], &mtmp[0][0], 400, 256, 235, 2);
	olPopColor();
	olPopMatrix();

}
示例#2
0
文件: demo.c 项目: marcan/openlase
void DoEuskal(void)
{
	IldaFile *ild;
	ild = olLoadIlda("euskal18.ild");

	params.off_speed = 2.0/20.0;
	params.start_wait = 8;
	params.end_wait = 1;
	params.render_flags |= RENDER_NOREORDER;
	olSetRenderParams(&params);

	include_dark_points = 0;
	int count = count_active_points(ild);
	float cur_draw = 0;

	olSetVertexShader(cutoff);

	while(1) {
		int obj;
		float w;

		points_left = cur_draw;
		olDrawIlda(ild);
		render();

		cur_draw += ftime * count / 5.0;

		if (cur_draw > count) {
			break;
		}
	}

	olSetVertexShader(NULL);

	float bright = 300.0f;

	while(1) {
		uint32_t col;
		if (bright > 255.0f)
			col = C_WHITE;
		else
			col = C_GREY((int)bright);
		olPushColor();
		olMultColor(col);
		olDrawIlda(ild);
		olPopColor();

		render();

		bright -= ftime * 40.0;
		if (bright < 0)
			break;
	}

}
示例#3
0
void circle(float x, float y, float r, uint32_t color)
{
	olPushMatrix();
	olPushColor();
	olMultColor(color);
	olTranslate(x, y);
	olRotate((x+y)*123);
	/*olBegin(OL_BEZIERSTRIP);
	olVertex(0, r, color);
	int i;
	for (i=0; i<2; i++) {
		olVertex(CP*r, r, C_WHITE);
		olVertex(r, CP*r, C_WHITE);
		olVertex(r, 0, C_WHITE);
		olVertex(r, -CP*r, C_WHITE);
		olVertex(CP*r, -r, C_WHITE);
		olVertex(0, -r, C_WHITE);
		olVertex(-CP*r, -r, C_WHITE);
		olVertex(-r, -CP*r, C_WHITE);
		olVertex(-r, 0, C_WHITE);
		olVertex(-r, CP*r, C_WHITE);
		olVertex(-CP*r, r, C_WHITE);
		olVertex(0, r, C_WHITE);
	}*/
/*	olVertex(0, r, color);
	olVertex(0, r, color);
	olVertex(r*0.1, r, color);
	olVertex(r*0.1, r, color);*/

	float circum = 2 * M_PI * r;
	int segments = circum / (1/30.0);
	if (segments < 50)
		segments = 50;
	int i;
	olBegin(OL_POINTS);
	olVertex(r, 0);
	for (i=0; i<=(2*segments+10); i++) {
		float w = i * M_PI * 2.0 / segments;
		uint32_t c = C_WHITE;
		if (i > 2*segments)
			c = C_GREY((10-(i-segments)) * 28);
		else if (i < 3)
			c = C_GREY(i * 85);
		olVertex(r*cosf(w), r*sinf(w));
	}
	olEnd();
	olPopColor();
	olPopMatrix();
}
示例#4
0
文件: demo.c 项目: marcan/openlase
void DoTitle(float limit)
{
	IldaFile *ild;
	ild = olLoadIlda("lase_title.ild");

	include_dark_points = 1;

	int count = count_active_points(ild);
	float cur_draw = 0;
	float ctime = 0;

	olSetVertexShader(cutoff);

	params.render_flags |= RENDER_NOREORDER;
	olSetRenderParams(&params);

	while(1) {
		int obj;
		float w;

		points_left = cur_draw;
		olDrawIlda(ild);
		ctime += render();

		cur_draw += ftime * count / 3.0;

		if (cur_draw > count) {
			break;
		}
	}

	olSetVertexShader(NULL);

	while(AB*ctime < 8) {
		olDrawIlda(ild);
		ctime += render();
	}

	wipe_center = -1.0;
	wipe_w = 0.4;
	wipe_inv = 1;

	const char *s="A realtime laser demo";

	float s_x = -olGetStringWidth(font, 0.2, s) / 2;
	float s_y = -0.5;
	float s_h = 0.2;

	while(1) {
		olDrawIlda(ild);
		olSetPixelShader(hwipe);
		olDrawString(font, s_x, s_y, s_h, C_WHITE, s);
		olSetPixelShader(NULL);
		ctime += render();
		wipe_center += 1.7*ftime;

		if(wipe_center > 1.0f)
			break;
	}

	float bright = 300.0f;
	while(audiotime < limit) {
		uint32_t col;
		if (bright > 255.0f)
			col = C_WHITE;
		else
			col = C_GREY((int)bright);
		olPushColor();
		olMultColor(col);
		olDrawIlda(ild);
		olDrawString(font, s_x, s_y, s_h, C_WHITE, s);
		olPopColor();
		render();

		bright -= ftime * 130.0;
		if (bright < 0)
			bright = 0;
	}

}
示例#5
0
文件: demo.c 项目: marcan/openlase
int main (int argc, char *argv[])
{

	void *mod_data;
	FILE *mod_fd;
	size_t mod_size;

	mod_fd = fopen("GLOS-pope.xm","r");
	fseek(mod_fd, 0, SEEK_END);
	mod_size = ftell(mod_fd);
	fseek(mod_fd, 0, SEEK_SET);
	mod_data = malloc(mod_size);
	fread(mod_data, 1, mod_size, mod_fd);
	fclose(mod_fd);

	ModPlug_Settings cfg;
	ModPlug_GetSettings(&cfg);
	cfg.mChannels = 2;
	cfg.mBits = 16;
	cfg.mFrequency = 48000;
	cfg.mResamplingMode = MODPLUG_RESAMPLE_SPLINE;
	cfg.mFlags = MODPLUG_ENABLE_OVERSAMPLING;
	ModPlug_SetSettings(&cfg);

	module = ModPlug_Load(mod_data, mod_size);

	srandom(0);

	memset(&params, 0, sizeof params);
	params.rate = 48000;
	params.on_speed = 2.0/100.0;
	params.off_speed = 2.0/30.0;
	params.start_wait = 8;
	params.start_dwell = 2;
	params.curve_dwell = 0;
	params.corner_dwell = 2;
	params.curve_angle = cosf(30.0*(M_PI/180.0)); // 30 deg
	params.end_dwell = 2;
	params.end_wait = 1;
	params.snap = 1/100000.0;
	params.flatness = 0.000005;
	params.max_framelen = params.rate / 24;
	params.render_flags = RENDER_GRAYSCALE;

	if(olInit(10, 30000) < 0)
		return 1;
	olSetRenderParams(&params);

	olSetAudioCallback(gen_audio);

	float time = 0;
	float ftime;
	int i,j;

	int frames = 0;

	memset(mbuf, 0, sizeof mbuf);

	font = olGetDefaultFont();

	float xpos = 1.0;

	DoStars(96);
	DoTitle(111);

	DoMetaballs(143);
	DoFire(174);

	DoTunnel(175+32);
	DoCubes(175+32+64);


	DoEuskal();

#if 0

	while(1) {
		int obj;
		float w;

		points_left = cur_draw;
		olPushColor();
		//olMultColor(C_GREY((int)(255.0f * cur_draw / count)));
		olSetVertexShader(cutoff);
		olDrawIlda(ild);
		olSetVertexShader(NULL);
		olPopColor();
/*
		olSetVertexShader(sinescroller);

		w = olDrawString(font, xpos, 0.35, 0.4, C_WHITE, "Hello, World! This is a test message displayed using the OpenLase text functions. Sine scrollers FTW!");
		if (xpos < (-w-1.5))
			xpos = 1.0;

		olSetVertexShader(NULL);*/

/*
		olDrawString(font, -1, 0.35, 0.4, C_WHITE, "Hello, World!");
		olDrawString(font, -1, -0, 0.4, C_WHITE, "How are you?");
		olDrawString(font, -1, -0.35, 0.4, C_WHITE, "    (-;   :-)");*/

		//render_cubes(time);
		//render_metaballs(time);
		//ender_fire();
		/*
		olBegin(OL_BEZIERSTRIP);
		olVertex(0,1,C_WHITE);
		olVertex(1,1,C_WHITE);
		olVertex(1,1,C_WHITE);
		olVertex(1,0,C_WHITE);

		olVertex(1,-1,C_WHITE);
		olVertex(1,-1,C_WHITE);
		olVertex(0,-1,C_WHITE);
		olEnd();*/

		ftime = olRenderFrame(150);
		frames++;
		gbl_time += ftime;
		xpos -= ftime;
		cur_draw += ftime * count / 5.0;
		if (cur_draw > count)
			cur_draw = count;
		printf("Frame time: %f, FPS:%f\n", ftime, frames/time);
	}

#endif

	olShutdown();
	exit (0);
}