Exemplo n.º 1
0
MESSAGE_BUTTON::MESSAGE_BUTTON(QGraphicsItem *parent):QGraphicsObject(parent)
{
    icon.load(":/message_button/icon");
    bg.load(":/message_button/bg");

    anim_init();
    anim_show();
}
Exemplo n.º 2
0
int		main(int ac, char **av)
{
	t_gen			gen;
	int				f_level, error;
	t_pj			pj;
	SDL_Surface		*back = NULL, *grd = NULL, *hit_box = NULL;
	SDL_Texture		*b_tex, *g_tex, *hb;
	SDL_Rect		pj_box;
	
	SDL_Init(SDL_INIT_VIDEO);
	gen.win = SDL_CreateWindow(
		"test",
		SDL_WINDOWPOS_UNDEFINED,
		SDL_WINDOWPOS_UNDEFINED,
		940, 680,
		SDL_WINDOW_RESIZABLE);
	gen.screen = SDL_GetWindowSurface(gen.win);
	gen.render = SDL_CreateRenderer(gen.win, -1, SDL_RENDERER_ACCELERATED);

	gen.gold = 0;
	gen.cmod = 0;
	gen.cflag = 0;
	gen.rgb = (unsigned int *)malloc(sizeof(unsigned int) * 3);
	gen.rgb[0] = 100;
	gen.rgb[1] = 100;
	gen.rgb[2] = 100;
		
	gen.pj = load_pj(&pj);
	pj.ani = anim_init(2, 2, IDLE_FLEN);

//    back = IMG_Load("img/forest.gif");
//	b_tex = SDL_CreateTextureFromSurface(gen.render, back);
//	draw_backg(b_tex, back, gen.render, gen.screen, -1);
	
	grd = IMG_Load("img/ground.jpg");
	g_tex = SDL_CreateTextureFromSurface(gen.render, grd);

	pj_init(&gen, &pj, "img/pj/");
	ft_putendl("#### PJ_TEXT_DONE");

	pj.box = &pj_box;
	f_level = gen.screen->h * 0.75;
	pj.box->x = gen.screen->w / 2 - 50;
	pj.box->y = f_level - 140;
	pj.box->w = 100;
	pj.box->h = 140;
	
	hit_box = SDL_CreateRGBSurface(0, 100, 140, 32, 0, 0, 0, 0);
	SDL_FillRect(hit_box, NULL, SDL_MapRGB(gen.screen->format, 0, 0, 255));
	hb = SDL_CreateTextureFromSurface(gen.render, hit_box);
	SDL_SetTextureBlendMode(hb,SDL_BLENDMODE_BLEND);
	if ((error = SDL_SetTextureAlphaMod(hb, 100)))
		printf("Alpha for HB problem -> ERR_CODE = %d\n", error);

//	pausing();
	(void)b_tex;
	(void)g_tex;
	(void)pj_box;

	// ##############################################################"

	float	i = 0;
	char	maj = 0;
	int		continuer = 1;
	int		orient = 0;
	int		act = 0;
 	
	clock_t clok;
	clok = clock();
	SDL_Event event;

	get_key();
	
	while (continuer)
	{
		SDL_PollEvent(&event);
			switch(event.type)
			{
			case SDL_QUIT:
				continuer = 0;
				break;
			case SDL_KEYUP:
				switch(event.key.keysym.sym)
				{
				case 1073742049:
					maj = 0;
					break;
				case 27:
					continuer = 0;
					break;
				case 1073741904:
					i = act = 0;
					break;
				case 1073741903:
					i = act = 0;
					break;
				}
				break;
			case SDL_KEYDOWN:
				switch(event.key.keysym.sym)
				{
				case 1073742049:
					maj = 1;
					break;
				case 1073741904:
					orient = 1;
					if (act!=1)
						i = 0;
					act = 1;
					break;
				case 1073741903:
					orient = 0;
					if (act!=1)
						i = 0;
					act = 1;
					break;
				case 49:
					if (maj)
					{gen.gold = (gen.gold + 1) % 2;pj_init(&gen, &pj, "img/pj/");}
					else {
					pj.state[1][2]++;
					if (pj.state[1][2] > 2) pj.state[1][2] = 0;
					pj_init(&gen, &pj, "img/pj/");}
					break;
				case 50:
					pj.state[1][3]++;
					if (pj.state[1][3] > 2)
						pj.state[1][3] = 0;
					pj_init(&gen, &pj, "img/pj/");
					break;
				case 114:
					gen.cmod = 0;
					break;
				case 103:
					gen.cmod = 1;
					break;
				case 98:
					gen.cmod = 2;
					break;
				case 1073741899:
					if(gen.rgb[gen.cmod] <= 250){
						gen.rgb[gen.cmod] += 5;
						gen.cflag = 1;
						pj_init(&gen, &pj, "img/pj/");
						gen.cflag = 0;
					}
					break;
				case 1073741902:
					if(gen.rgb[gen.cmod] >= 5){
						gen.rgb[gen.cmod] -= 5;
						gen.cflag = 1;
						pj_init(&gen, &pj, "img/pj/");
						gen.cflag = 0;
					}
					break;
				}
				break;
			}

		if (clock() > clok + 100)
		{
//			printf("i = %d\n",(int)i);
			clok = clock();
			draw_backg(gen.render, gen.screen);
			draw_floor(g_tex, grd, f_level, gen.render, gen.screen,(act)? orient : -1);
			SDL_RenderCopy(gen.render, pj.ani[act][orient][(int)i], NULL, pj.box);
			SDL_RenderPresent(gen.render);
			i += (act) ? 0.50 : 0.04;
//			printf("i = %f ===> %d\n",i,(int)i);
			if (i > 1.30 && !act)
				i = 0;
			else if (i > 5)
				i = 0;
//			Pausing ();
		}
		event.key.keysym.sym = 0;
	}

	SDL_Quit();
	(void)ac;
	(void)av;
	(void)act;
	(void)back;
	(void)gfxPrimitivesFontdata;
	return (0);
}
Exemplo n.º 3
0
/*
 * Init charging animation version , drawing method and other parameters
 *
 */
void bootlogo_init()
{
    KPOC_LOGI("[ChargingAnimation: %s %d]\n",__FUNCTION__,__LINE__);
    sync_anim_version();
    anim_init();
}
Exemplo n.º 4
0
//extern void drawModelSetMax(void);
int glInit(void){
	cvar_register(&cvar_gl_MSAA_Samples);
	cvar_pset(&cvar_gl_MSAA_Samples, "0");
//	console_printf("cvar id is %i\n", cvar_gl_MSAA_Samples.myid);
//	console_printf("cvar name is %s\n", cvar_gl_MSAA_Samples.name);
//	console_printf("cvar value is %s\n", cvar_gl_MSAA_Samples.valuestring);
	glewExperimental = TRUE;
	GLenum glewError = glewInit();
	CHECKGLERROR
	if(glewError != GLEW_OK){
		console_printf("ERROR with the glew: %s\n", glewGetErrorString(glewError));
		return FALSE;
	}
	shader_init();
	CHECKGLERROR
	if(!shader_ok){
		//todo call some sort of shutdown of everything
		 return FALSE;
	}
	texture_init();
	CHECKGLERROR
	if(!texture_ok){
		//todo call some sort of shutdown of everything
		 return FALSE;
	}
	framebuffer_init();
	CHECKGLERROR
	if(!framebuffer_ok){
		//todo call some sort of shutdown of everything
		 return FALSE;
	}
	vbo_init();
	CHECKGLERROR
	if(!vbo_ok){
		return FALSE;
		//todo call some sort of shutdown of everything
	}
	ubo_init();
	CHECKGLERROR
	if(!ubo_ok){
		return FALSE;
		//todo call some sort of shutdown of everything
	}
	anim_init();
	CHECKGLERROR
	if(!anim_ok){
		//todo call some sort of shutdown of everything
		return FALSE;
	}
	model_init();
	CHECKGLERROR
	if(!model_ok){
		//todo call some sort of shutdown of everything
		 return FALSE;
	}
/*
	initParticleSystem(128);
	if(!particlesOK){
		//todo call some sort of shutdown of everything
		 return FALSE;
	}
*/
	light_init();
	CHECKGLERROR
	if(!light_ok){
		//todo call some sort of shutdown of everything
		return FALSE;
	}
	lighttile_init();
	CHECKGLERROR
	if(!lighttile_ok){
		//todo call some sort of shutdown of everything
		return FALSE;
	}
	viewport_init();
	CHECKGLERROR
	if(!viewport_ok){
		//todo call some sort of shutdown of everything
		return FALSE;
	}
	text_init();
	CHECKGLERROR
	if(!text_ok){
		//todo call some sort of shutdown of everything
		return FALSE;
	}
	rendermodel_init();
	CHECKGLERROR
	//todo errorcheck
	drawbb_init();
	CHECKGLERROR
	//todo errorcheck

	states_enableForce(GL_MULTISAMPLE);
	glClearDepth(1.0);
	glClearColor(0.0, 0.0, 0.0, 0.0);
	CHECKGLERROR
//	states_disableForce(GL_FOG);
	states_enableForce(GL_DEPTH_TEST);
	CHECKGLERROR
//	glDepthFunc(GL_LESS);
	states_depthFunc(GL_LESS);
	states_enableForce(GL_CULL_FACE);
	states_cullFace(GL_BACK);
//	states_depthMask(GL_TRUE);

	int maxSamples = 0, maxIntSamples = 0, maxColorTextureSamples = 0, maxDepthTextureSamples = 0;
	glGetIntegerv(GL_MAX_SAMPLES, &maxSamples);
	glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &maxIntSamples);
	glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &maxColorTextureSamples);
	glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &maxDepthTextureSamples);
	maxMSAASamples = maxSamples;
	if(maxIntSamples < maxMSAASamples) maxMSAASamples = maxIntSamples;
	if(maxColorTextureSamples < maxMSAASamples) maxMSAASamples = maxColorTextureSamples;
	if(maxDepthTextureSamples < maxMSAASamples) maxMSAASamples = maxDepthTextureSamples;
	console_printf("Max multisample samples: %i\n", maxMSAASamples);


	cam = createAndAddViewportRPOINT("cam", 1);
	camid = cam->myid;
	cam->outfbid = findFramebufferByNameRINT("screen");

	unsigned char dflags[] = {3, 7, 3};
//	unsigned char drb = FRAMEBUFFERRBFLAGSDEPTH| 2;
	unsigned char drb = FRAMEBUFFERRBFLAGSDEPTH;
	unsigned char dcount = 3;
	cam->dfbid = createAndAddFramebufferRINT("screend", dcount, drb, dflags);
	resizeViewport(cam, 800, 600);
	screenWidth = 800;
	screenHeight = 600;

	glGenBuffers(1, &instancevbo);
	glGenBuffers(1, &instancevbo2);

	//temporary
	CHECKGLERROR
	vbo_t * tvbo = createAndAddVBORPOINT("text", 2);
	textvbo = tvbo->myid;
	textshaderid = shader_createAndAddRINT("text");
	fsblendshaderid = shader_createAndAddRINT("fsblend");
	depthonlyid = shader_createAndAddRINT("depthmodel");
	forwardmodelid = shader_createAndAddRINT("forwardmodel");
	fsquadmodel = model_findByNameRINT("fsquad");

	readyRenderQueueBuffers();



	return TRUE; // so far so good
}