예제 #1
0
int vita2d_pgf_draw_textf(vita2d_pgf *font, int x, int y, unsigned int color, float scale, const char *text, ...)
{
	char buf[1024];
	va_list argptr;
	va_start(argptr, text);
	vsnprintf(buf, sizeof(buf), text, argptr);
	va_end(argptr);
	return vita2d_pgf_draw_text(font, x, y, color, scale, buf);
}
예제 #2
0
파일: main.c 프로젝트: DavisDev/libvita2d
int main()
{
	SceCtrlData pad;
	vita2d_pgf *pgf;
	vita2d_texture *image;
	float rad = 0.0f;

	vita2d_init();
	vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));

	pgf = vita2d_load_default_pgf();

	/*
	 * Load the statically compiled image.png file.
	 */
	image = vita2d_load_PNG_buffer(&_binary_image_png_start);

	memset(&pad, 0, sizeof(pad));

	while (1) {
		sceCtrlPeekBufferPositive(0, &pad, 1);

		if (pad.buttons & SCE_CTRL_START)
			break;

		vita2d_start_drawing();
		vita2d_clear_screen();

		vita2d_draw_rectangle(20, 20, 400, 250, RGBA8(255, 0, 0, 255));
		vita2d_draw_rectangle(680, 350, 100, 150, RGBA8(0, 0, 255, 255));
		vita2d_draw_fill_circle(200, 420, 100, RGBA8(0, 255,0 ,255));

		vita2d_draw_texture_rotate(image, 940/2, 544/2, rad);

		vita2d_draw_line(500, 30, 800, 300, RGBA8(255, 0, 255, 255));

		vita2d_pgf_draw_text(pgf, 700, 30, RGBA8(0,255,0,255), 1.0f, "PGF Font sample!");

		vita2d_end_drawing();
		vita2d_swap_buffers();

		rad += 0.1f;
	}

	/*
	 * vita2d_fini() waits until the GPU has finished rendering,
	 * then we can free the assets freely.
	 */
	vita2d_fini();
	vita2d_free_texture(image);
	vita2d_free_pgf(pgf);

	sceKernelExitProcess(0);
	return 0;
}
예제 #3
0
int main()
{
	vita2d_init();
	vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));

	vita2d_pgf *pgf = vita2d_load_default_pgf();

	vita2d_texture *tex = vita2d_create_empty_texture(128, 128);
	unsigned int *tex_data = vita2d_texture_get_datap(tex);

	SceCtrlData pad;
	memset(&pad, 0, sizeof(pad));

	float rad = 0.0f;

	while (1) {
		sceCtrlPeekBufferPositive(0, &pad, 1);
		if (pad.buttons & SCE_CTRL_START) break;

		vita2d_start_drawing();
		vita2d_clear_screen();

		vita2d_draw_rectangle(20, 20, 400, 250, RGBA8(255, 0, 0, 255));
		vita2d_draw_rectangle(680, 350, 100, 150, RGBA8(0, 0, 255, 255));
		vita2d_draw_fill_circle(200, 420, 100, RGBA8(0, 255,0 ,255));

		/* Fill the texture with random data */
		int i, j;
		for (i = 0; i < 128; i++) {
			for (j = 0; j < 128; j++) {
				tex_data[j + i*128] = rand();
			}
		}

		vita2d_draw_texture_rotate(tex, 940/2, 544/2, rad);

		vita2d_draw_line(500, 30, 800, 300, RGBA8(255, 0, 255, 255));

		vita2d_pgf_draw_text(pgf, 700, 30, RGBA8(0,255,0,255), 1.0f, "PGF Font sample!");

		vita2d_end_drawing();
		vita2d_swap_buffers();

		rad += 0.1f;
	}

	vita2d_fini();
	vita2d_free_texture(tex);
	vita2d_free_pgf(pgf);

	sceKernelExitProcess(0);
	return 0;
}
예제 #4
0
int main() {
	SceCtrlData pad;
	vita2d_pgf *pgf;
	vita2d_texture *image;
	float rad = 0.0f;
  
	vita2d_init();
	vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));
  
	pgf = vita2d_load_default_pgf();
  
	image = vita2d_load_PNG_buffer(&_binary_image_png_start);
  
	memset(&pad, 0, sizeof(pad));
  
	while (1) {
		sceCtrlPeekBufferPositive(0, &pad, 1);
	
		if (pad.buttons & SCE_CTRL_START)
			break;
	
		vita2d_start_drawing();
		vita2d_clear_screen();
	
		vita2d_draw_texture_rotate(image, 940/2, 544/2, rad);
	
		vita2d_pgf_draw_text(pgf, 50, 50, RGBA8(255,255,255,255), 1.0f, "ミクのおっぱい柔かぁい。柔軟剤使ったのか?");
	
		vita2d_end_drawing();
		vita2d_swap_buffers();
	
		rad += 0.1f;
	}
  
	vita2d_fini();
	vita2d_free_texture(image);
	vita2d_free_pgf(pgf);
  
	sceKernelExitProcess(0);
	return 0;
}
예제 #5
0
파일: main.c 프로젝트: barooney/pkg
int main()
{
	vita2d_init();
	vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));

	vita2d_pgf *pgf = vita2d_load_default_pgf();

	SceCtrlData pad;
	memset(&pad, 0, sizeof(pad));

        vu_rectangle *r = vu_rectangle_new();
        vu_rectangle_set_color(r, (vec4){0xFF, 0x00, 0x00, 0xFF});
        vu_rectangle_resize(r, (vec2){200, 200});

	while (1) {
		sceCtrlPeekBufferPositive(0, &pad, 1);

		if (pad.buttons & SCE_CTRL_START)
			break;

		vita2d_start_drawing();
		vita2d_clear_screen();

                vu_rectangle_render(r);

		vita2d_pgf_draw_text(pgf, 20, 30, RGBA8(0xFF,0xFF,0xFF,0xFF), 1.0f, "PS Vita Package Manager");

		vita2d_end_drawing();
		vita2d_swap_buffers();
	}

	vita2d_free_pgf(pgf);
	//vita2d_fini(); crashes

	sceKernelExitProcess(0);
	return 0;
}
예제 #6
0
void MOD_SelectModMenu(char *basedir){

	SceCtrlData pad, oldpad;
	sceCtrlPeekBufferPositive(0, &pad, 1);

	// Ch0wW: Enable the mod menu once the R trigger is hold on startup.
	if (!(pad.buttons & SCE_CTRL_RTRIGGER))
	{
		// Reading current used mod
		char cur_mod[64];
		modname = malloc(64);
		FILE* f;
		if ((f = fopen( va("%s/%s", basedir, MOD_FILE), "r")) != NULL) {
			char tmp[256];
			fseek(f, 0, SEEK_END);
			int len = ftell(f);
			fseek(f, 0, SEEK_SET);
			fread(tmp, 1, len, f);
			fclose(f);
			tmp[len] = 0;
			sprintf(modname, "%s", tmp);
		}
		else
			modname = NULL;
		return;
	}

	// Initializing empty ModList
	ModsList* mods = NULL;
	int i = 0;
	int max_idx = -1;
	
	// Scanning main folder in search of mods
	int dd = sceIoDopen(basedir);
	SceIoDirent entry;
	int res;
	while (sceIoDread(dd, &entry) > 0){
		if (SCE_S_ISDIR(entry.d_stat.st_mode)){
			if (CheckForMod( va("%s/%s", basedir, entry.d_name))){
				mods = addMod(entry.d_name, mods);
				max_idx++;
			}
		}
	}
	sceIoDclose(dd);
	
	// Reading current used mod
	char cur_mod[64];
	modname = malloc(64);
	FILE* f;
	if ((f = fopen(va("%s/%s", basedir, MOD_FILE), "r")) != NULL) {
		char tmp[256];
		fseek(f, 0, SEEK_END);
		int len = ftell(f);
		fseek(f, 0, SEEK_SET);
		fread(tmp, 1, len, f);
		fclose(f);
		tmp[len] = 0;
		sprintf(modname, "%s", tmp);
		sprintf(cur_mod, "Current in use mod: %s - Press START to launch vitaQuake core", tmp);
	}else strcpy(cur_mod,"Current in use mod: id1 - Press START to launch vitaQuake core");
	
	// Initializing graphics stuffs
	vita2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF));
	vita2d_pgf* debug_font = vita2d_load_default_pgf();
	uint32_t white = RGBA8(0xFF, 0xFF, 0xFF, 0xFF);
	uint32_t green = RGBA8(0x00, 0xFF, 0x00, 0xFF);
	uint32_t red = RGBA8(0xFF, 0x00, 0x00, 0xFF);
	
	// Main loop
	while (max_idx >= 0){
		vita2d_start_drawing();
		vita2d_clear_screen();
		vita2d_pgf_draw_text(debug_font, 2, 20, red, 1.0, cur_mod);
		
		// Drawing menu
		int y = 40;
		int d = 0;
		ModsList* ptr = mods;
		while (ptr != NULL && y < 540){
			uint32_t color = white;
			if (d++ == i) color = green;
			vita2d_pgf_draw_text(debug_font, 2, y, color, 1.0, ptr->name);
			ptr = ptr->next;
			y += 20;
		}
		
		// Controls checking
		sceCtrlPeekBufferPositive(0, &pad, 1);
		if ((pad.buttons & SCE_CTRL_CROSS) && (!(oldpad.buttons & SCE_CTRL_CROSS))){
			int z = 0;
			ModsList* tmp = mods;
			while (z < i){
				tmp = tmp->next;
				z++;
			}
			sprintf(cur_mod,"Current in use mod: %s - Press START to launch vitaQuake core", tmp->name);
			if (!strcmp(tmp->name, "id1"))
			{
				sceIoRemove( va("%s/%s", basedir, MOD_FILE) );
				modname = NULL;
			}
			else{
				f = fopen(va("%s/%s", basedir, MOD_FILE), "w");
				fwrite(tmp->name,1,strlen(tmp->name),f);
				fclose(f);
				strcpy(modname, tmp->name);	// Refresh the mod directory.
			}
		}else if ((pad.buttons & SCE_CTRL_UP) && (!(oldpad.buttons & SCE_CTRL_UP))){
			i--;
			if (i < 0) i = max_idx;
		}else if ((pad.buttons & SCE_CTRL_DOWN) && (!(oldpad.buttons & SCE_CTRL_DOWN))){
			i++;
			if (i > max_idx) i = 0;
		}else if (pad.buttons & SCE_CTRL_START) break;
		oldpad = pad;
		
		vita2d_end_drawing();
		vita2d_wait_rendering_done();
		vita2d_swap_buffers();
	}
	
	// Freeing stuffs
	ModsList* tmp = mods;
	ModsList* tmp2;
	while (tmp != NULL){
		tmp2 = tmp->next;
		free(tmp);
		tmp = tmp2;
	}

	return;
}