Exemple #1
0
void finishVita2dLib() {
	vita2d_free_texture(battery_bar_green_image);
	vita2d_free_texture(battery_bar_red_image);
	vita2d_free_texture(battery_image);
	vita2d_free_pgf(font);
	vita2d_fini();

	battery_bar_green_image = NULL;
	battery_bar_red_image = NULL;
	battery_image = NULL;
	font = NULL;
}
Exemple #2
0
Psp2Ui::~Psp2Ui() {
	sceKernelWaitSema(GPU_Cleanup_Mutex, 1, NULL);
	for (int i = 0; i < SHADERS_NUM; i++){
		vita2d_free_shader(shaders[i]);
	}
	vita2d_free_texture(main_texture);
	main_texture = NULL;
	sceKernelSignalSema(GPU_Cleanup_Mutex, 1);
	sceKernelWaitThreadEnd(GPU_Thread, NULL, NULL);
	vita2d_free_texture(next_texture);
	vita2d_free_texture(gpu_texture);
	sceKernelDeleteSema(GPU_Mutex);
	sceKernelDeleteSema(GPU_Cleanup_Mutex);
	vita2d_fini();
}
Exemple #3
0
static void end(void)
{
	SafeDeleteArray(theFrameBuffer);
	SafeDelete(theGearboyCore);
	vita2d_fini();
	vita2d_free_texture(gb_texture);
}
Exemple #4
0
void VID_ChangeRes(float scale){

	// Freeing texture
	vita2d_free_texture(tex_buffer);
	
	int idx = (scale / 0.333);
	
	// Changing renderer resolution
	int width = widths[idx];
	int height = heights[idx];
	tex_buffer = vita2d_create_empty_texture_format(width, height, SCE_GXM_TEXTURE_BASE_FORMAT_P8);
	vid.maxwarpwidth = vid.width = vid.conwidth = width;
	vid.maxwarpheight = vid.height = vid.conheight = height;
	vid.rowbytes = vid.conrowbytes = width;	
	vid.buffer = vid.conbuffer = vid.direct = vita2d_texture_get_datap(tex_buffer);
	sprintf(res_string,"Current Resolution: %ld x %ld", widths[idx], heights[idx]);
	
	// Forcing a palette restoration
	fixpalette = v_gamma.value;
	Cvar_SetValue ("v_gamma", 0.1);
	
	// Changing scale value
	rend_scale = scales[idx];
	
}
Exemple #5
0
void texture_atlas_free(texture_atlas *atlas)
{
	vita2d_free_texture(atlas->tex);
	bp2d_free(atlas->bp_root);
	int_htab_free(atlas->htab);
	free(atlas);
}
Exemple #6
0
static void vita_set_texture_frame(void *data, const void *frame, bool rgb32,
      unsigned width, unsigned height, float alpha)
{
   int i, j;
   void *tex_p;
   unsigned int stride;
   vita_video_t *vita = (vita_video_t*)data;

   (void)alpha;

   if (width != vita->menu.width && height != vita->menu.height && vita->menu.texture)
   {
      vita2d_free_texture(vita->menu.texture);
      vita->menu.texture = NULL;
   }

   if (!vita->menu.texture)
   {
      if (rgb32)
      {
         vita->menu.texture = vita2d_create_empty_texture(width, height);
         RARCH_LOG("Creating Frame RGBA8 texture: w: %i  h: %i\n", width, height);
      }
      else
      {
         vita->menu.texture = vita2d_create_empty_texture_format(width, height, SCE_GXM_TEXTURE_FORMAT_U4U4U4U4_RGBA);
         RARCH_LOG("Creating Frame R5G6B5 texture: w: %i  h: %i\n", width, height);
      }
      vita->menu.width  = width;
      vita->menu.height = height;
   }

   vita2d_texture_set_filters(vita->menu.texture,SCE_GXM_TEXTURE_FILTER_LINEAR,SCE_GXM_TEXTURE_FILTER_LINEAR);

   tex_p  = vita2d_texture_get_datap(vita->menu.texture);
   stride = vita2d_texture_get_stride(vita->menu.texture);

   if (rgb32)
   {
      uint32_t         *tex32 = tex_p;
      const uint32_t *frame32 = frame;

      stride                 /= 4;

      for (i = 0; i < height; i++)
         for (j = 0; j < width; j++)
            tex32[j + i*stride] = frame32[j + i*width];
   }
   else
   {
      uint16_t               *tex16 = tex_p;
      const uint16_t       *frame16 = frame;

      stride                       /= 2;

      for (i = 0; i < height; i++)
         for (j = 0; j < width; j++)
            tex16[j + i*stride] = frame16[j + i*width];
   }
}
Exemple #7
0
static bool vita_get_current_sw_framebuffer(void *data,
      struct retro_framebuffer *framebuffer)
{
   vita_video_t *vita = (vita_video_t*)data;

   if (!vita->texture || vita->width != framebuffer->width ||
         vita->height != framebuffer->height)
   {
      if(vita->texture)
      {
         vita2d_wait_rendering_done();
         vita2d_free_texture(vita->texture);
         vita->texture = NULL;
      }

      vita->width = framebuffer->width;
      vita->height = framebuffer->height;
      vita->texture = vita2d_create_empty_texture_format(
            vita->width, vita->height, vita->format);
      vita2d_texture_set_filters(vita->texture,
            vita->tex_filter,vita->tex_filter);
   }

   framebuffer->data         = vita2d_texture_get_datap(vita->texture);
   framebuffer->pitch        = vita2d_texture_get_stride(vita->texture);
   framebuffer->format       = vita->rgb32 
      ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565;
   framebuffer->memory_flags = 0;

   return true;
}
Exemple #8
0
static void vita2d_free_overlay(vita_video_t *vita)
{
   unsigned i;
   for (i = 0; i < vita->overlays; i++)
      vita2d_free_texture(vita->overlay[i].tex);
   free(vita->overlay);
   vita->overlay = NULL;
   vita->overlays = 0;
}
Exemple #9
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();

	/*
	 * 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;
}
Exemple #10
0
static void vita2d_gfx_free(void *data)
{
   vita_video_t *vita = (vita_video_t *)data;

   vita2d_fini();

   if (vita->menu.texture)
   {
      vita2d_free_texture(vita->menu.texture);
      vita->menu.texture = NULL;
   }

   if (vita->texture)
   {
      vita2d_free_texture(vita->texture);
      vita->texture = NULL;
   }

   font_driver_free_osd();
}
Exemple #11
0
static void vita2d_free_overlay(vita_video_t *vita)
{
   for (unsigned i = 0; i < vita->overlays; i++)
   {
      vita2d_free_texture(vita->overlay[i].tex);
   }
   free(vita->overlay);
   vita->overlay = NULL;
   vita->overlays = 0;
   //GX_InvalidateTexAll();
}
Exemple #12
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;
}
Exemple #13
0
static void vita2d_gfx_free(void *data)
{
   vita_video_t *vita = (vita_video_t *)data;

   RARCH_LOG("vita2d_gfx_free()\n");

   vita2d_fini();

   if (vita->menu.texture)
   {
      vita2d_free_texture(vita->menu.texture);
      vita->menu.texture = NULL;
   }

   if (vita->texture)
   {
      vita2d_free_texture(vita->texture);
      vita->texture = NULL;
   }

   RARCH_LOG("vita2d_gfx_free() done\n");
}
Exemple #14
0
static void vita_unload_texture(void *data, uintptr_t handle)
{
   struct vita2d_texture *texture = (struct vita2d_texture*)handle;
   if (!texture)
      return;

   /* TODO: We really want to defer this deletion instead,
    * but this will do for now. */
   vita2d_wait_rendering_done();
   vita2d_free_texture(texture);

   //free(texture);
}
Exemple #15
0
static void vita2d_font_free_font(void *data)
{
	 vita_font_t *font = (vita_font_t*)data;
	 if (!font)
			return;

	 if (font->font_driver && font->font_data)
			font->font_driver->free(font->font_data);

	 //vita2d_wait_rendering_done();
   vita2d_free_texture(font->texture);

	 free(font);
}
Exemple #16
0
void show_splash()
{
	vita2d_start_drawing();
	vita2d_clear_screen();

	vita2d_texture *splash = vita2d_create_empty_texture(960, 544);

	splash = vita2d_load_PNG_buffer(revitalize);

	vita2d_draw_texture(splash, 0, 0);

	vita2d_end_drawing();
	vita2d_swap_buffers();

	sceKernelDelayThread(5000000); // Delay 5 seconds

	vita2d_free_texture(splash);
}
Exemple #17
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;
}
Exemple #18
0
static bool vita2d_gfx_frame(void *data, const void *frame,
      unsigned width, unsigned height, uint64_t frame_count,
      unsigned pitch, const char *msg, video_frame_info_t *video_info)
{
   void *tex_p;
   vita_video_t *vita = (vita_video_t *)data;

   if (frame)
   {
      if(!(vita->texture&&vita2d_texture_get_datap(vita->texture)==frame))
      {
         unsigned i;
         unsigned int stride;

         if ((width != vita->width || height != vita->height) && vita->texture)
         {
            vita2d_free_texture(vita->texture);
            vita->texture = NULL;
         }

         if (!vita->texture)
         {
            RARCH_LOG("Creating texture: %ix%i\n", width, height);
            vita->width = width;
            vita->height = height;
            vita->texture = vita2d_create_empty_texture_format(width, height, vita->format);
            vita2d_texture_set_filters(vita->texture,vita->tex_filter,vita->tex_filter);
         }
         tex_p = vita2d_texture_get_datap(vita->texture);
         stride = vita2d_texture_get_stride(vita->texture);

         if (vita->format == SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1RGB)
         {
            stride                     /= 4;
            pitch                      /= 4;
            uint32_t             *tex32 = tex_p;
            const uint32_t     *frame32 = frame;

            for (i = 0; i < height; i++)
               memcpy_neon(&tex32[i*stride],&frame32[i*pitch],pitch*sizeof(uint32_t));
         }
         else
         {
            stride                 /= 2;
            pitch                  /= 2;
            uint16_t *tex16         = tex_p;
            const uint16_t *frame16 = frame;

            for (i = 0; i < height; i++)
               memcpy_neon(&tex16[i*stride],&frame16[i*pitch],width*sizeof(uint16_t));
         }
      }
   }

   if (vita->should_resize)
      vita2d_gfx_update_viewport(vita);

   vita2d_start_drawing();

   vita2d_draw_rectangle(0,0,PSP_FB_WIDTH,PSP_FB_HEIGHT,vita2d_get_clear_color());

   if (vita->texture)
   {
      if (vita->fullscreen)
         vita2d_draw_texture_scale(vita->texture,
               0, 0,
               PSP_FB_WIDTH  / (float)vita->width,
               PSP_FB_HEIGHT / (float)vita->height);
      else
      {
         const float radian = 90 * 0.0174532925f;
         const float rad = vita->rotation * radian;
         float scalex = vita->vp.width / (float)vita->width;
         float scaley = vita->vp.height / (float)vita->height;
         vita2d_draw_texture_scale_rotate(vita->texture,vita->vp.x,
               vita->vp.y, scalex, scaley, rad);
      }
   }

#ifdef HAVE_OVERLAY
   if (vita->overlay_enable)
      vita2d_render_overlay(vita);
#endif

   if (vita->menu.active)
   {
#ifdef HAVE_MENU
      menu_driver_frame(video_info);
#endif

      if(vita->menu.texture)
      {
         if (vita->fullscreen)
            vita2d_draw_texture_scale(vita->menu.texture,
                  0, 0,
                  PSP_FB_WIDTH  / (float)vita->menu.width,
                  PSP_FB_HEIGHT / (float)vita->menu.height);
         else
         {
            if (vita->menu.width > vita->menu.height)
            {
               float scale = PSP_FB_HEIGHT / (float)vita->menu.height;
               float w = vita->menu.width * scale;
               vita2d_draw_texture_scale(vita->menu.texture,
                     PSP_FB_WIDTH / 2.0f - w/2.0f, 0.0f,
                     scale, scale);
            }
            else
            {
               float scale = PSP_FB_WIDTH / (float)vita->menu.width;
               float h = vita->menu.height * scale;
               vita2d_draw_texture_scale(vita->menu.texture,
                     0.0f, PSP_FB_HEIGHT / 2.0f - h/2.0f,
                     scale, scale);
            }
         }
      }
   }

   if(!string_is_empty(msg))
      font_driver_render_msg(video_info, NULL, msg, NULL);

   vita2d_end_drawing();
   vita2d_swap_buffers();

   return true;
}
Exemple #19
0
static bool vita2d_gfx_frame(void *data, const void *frame,
      unsigned width, unsigned height, uint64_t frame_count,
      unsigned pitch, const char *msg)
{
   int i, j;
   void *tex_p;
   unsigned int stride;
   vita_video_t *vita = (vita_video_t *)data;

   (void)frame;
   (void)width;
   (void)height;
   (void)pitch;
   (void)msg;

   if (frame)
   {
      if ((width != vita->width || height != vita->height) && vita->texture)
      {
         vita2d_free_texture(vita->texture);
         vita->texture = NULL;
      }

      if (!vita->texture)
      {
         RARCH_LOG("Creating texture: %ix%i\n", width, height);
         vita->width = width;
         vita->height = height;
         vita->texture = vita2d_create_empty_texture_format(width, height, vita->format);
         vita2d_texture_set_filters(vita->texture,vita->tex_filter,vita->tex_filter);
      }
      tex_p = vita2d_texture_get_datap(vita->texture);
      stride = vita2d_texture_get_stride(vita->texture);

      if (vita->format == SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1RGB)
      {
         stride                     /= 4;
         pitch                      /= 4;
         uint32_t             *tex32 = tex_p;
         const uint32_t     *frame32 = frame;

         for (i = 0; i < height; i++)
            for (j = 0; j < width; j++)
               tex32[j + i*stride] = frame32[j + i*pitch];
      }
      else
      {
         stride                 /= 2;
         pitch                  /= 2;
         uint16_t *tex16         = tex_p;
         const uint16_t *frame16 = frame;

         for (i = 0; i < height; i++)
            for (j = 0; j < width; j++)
               tex16[j + i*stride] = frame16[j + i*pitch];
      }
   }

   if (vita->should_resize)
      vita2d_gfx_update_viewport(vita);

   vita2d_start_drawing();
   vita2d_clear_screen();

   if (vita->texture)
   {
      if (vita->fullscreen)
         vita2d_draw_texture_scale(vita->texture,
               0, 0,
               PSP_FB_WIDTH  / (float)vita->width,
               PSP_FB_HEIGHT / (float)vita->height);
      else
      {
         const float radian = 90 * 0.0174532925f;
         const float rad = vita->rotation * radian;
         float scalex = vita->vp.width / (float)vita->width;
         float scaley = vita->vp.height / (float)vita->height;
         vita2d_draw_texture_scale_rotate(vita->texture, vita->vp.x,
               vita->vp.y, scalex, scaley, rad);
      }
   }

   if (vita->menu.active && vita->menu.texture)
   {
      if (vita->fullscreen)
         vita2d_draw_texture_scale(vita->menu.texture,
               0, 0,
               PSP_FB_WIDTH  / (float)vita->menu.width,
               PSP_FB_HEIGHT / (float)vita->menu.height);
      else
      {
         if (vita->menu.width > vita->menu.height)
         {
            float scale = PSP_FB_HEIGHT / (float)vita->menu.height;
            float w = vita->menu.width * scale;
            vita2d_draw_texture_scale(vita->menu.texture,
                  PSP_FB_WIDTH / 2.0f - w/2.0f, 0.0f,
                  scale, scale);
         }
         else
         {
            float scale = PSP_FB_WIDTH / (float)vita->menu.width;
            float h = vita->menu.height * scale;
            vita2d_draw_texture_scale(vita->menu.texture,
                  0.0f, PSP_FB_HEIGHT / 2.0f - h/2.0f,
                  scale, scale);
         }
      }
   }

   vita2d_end_drawing();
   vita2d_swap_buffers();

   return true;
}
Exemple #20
0
void video_Exit(){
	vita2d_fini();
	if (fb) {
		vita2d_free_texture(fb);
	}
}
Exemple #21
0
int main()
{
	char vita_ip[16];
	unsigned short int vita_port = 0;
	vita2d_init();
	vita2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF));
	clr_color = 0x000000FF;
	vita2d_texture* texture_splash = vita2d_load_JPEG_buffer(splash, size_splash);
	vita2d_start_drawing();
	vita2d_draw_texture(texture_splash, 0, 0);
	vita2d_end_drawing();
	vita2d_swap_buffers();
	sceKernelDelayThread(4000000);
	vita2d_start_drawing();
	vita2d_clear_screen();
	vita2d_end_drawing();
	vita2d_swap_buffers();
	vita2d_free_texture(texture_splash);
	SceCtrlData pad;
	SceCtrlData oldpad;
	while (1) {
		
		// Load main script
		SceUID id = sceIoDopen("cache0:/lpp");
		SceIoDirent entry;
		memset(&entry, 0, sizeof(SceIoDirent));
		while (sceIoDread(id, &entry) > 0){
			script_files++;
			memset(&entry, 0, sizeof(SceIoDirent));
		}
		sceIoDclose(id);
		if (script_files>1) errMsg = runScript((const char*)main_menu, true);
		else{
			SceUID main_file = sceIoOpen("cache0:/lpp/index.lua", PSP2_O_RDONLY, 0777);
			if (main_file < 0) errMsg = "index.lua not found.";
			else{
				SceOff size = sceIoLseek(main_file, 0, SEEK_END);
				if (size < 1) errMsg = "Invalid main script.";
				else{
					sceIoLseek(main_file, 0, SEEK_SET);
					script = (unsigned char*)malloc(size + 1);
					sceIoRead(main_file, script, size);
					script[size] = 0;
					sceIoClose(main_file);
					errMsg = runScript((const char*)script, true);
					free(script);
				}
			}
		}
		
		if (errMsg != NULL){
			if (strstr(errMsg, "lpp_shutdown")) break;
			else{
				int restore = 0;
				bool s = true;
				while (restore == 0){
					vita2d_start_drawing();
					vita2d_clear_screen();
					font_draw_string(10, 10, RGBA8(255, 255, 255, 255), "An error occurred:");
					font_draw_string(10, 30, RGBA8(255, 255, 255, 255), errMsg);
					font_draw_string(10, 70, RGBA8(255, 255, 255, 255), "Press X to restart.");
					font_draw_string(10, 90, RGBA8(255, 255, 255, 255), "Press O to enable/disable FTP.");
					if (vita_port != 0){
						font_draw_stringf(10, 150, RGBA8(255, 255, 255, 255), "PSVITA listening on IP %s , Port %u", vita_ip, vita_port);
					}
					vita2d_end_drawing();
					vita2d_swap_buffers();
					if (s){
						sceKernelDelayThread(800000);
						s = false;
					}
					sceCtrlPeekBufferPositive(0, &pad, 1);
					if (pad.buttons & PSP2_CTRL_CROSS) {
						errMsg = NULL;
						restore = 1;
						if (vita_port != 0){
							ftp_fini();
							vita_port = 0;
						}
						sceKernelDelayThread(800000);
					}else if ((pad.buttons & PSP2_CTRL_CIRCLE) && (!(oldpad.buttons & PSP2_CTRL_CIRCLE))){
						if (vita_port == 0) ftp_init(vita_ip, &vita_port);
						else{
							ftp_fini();
							vita_port = 0;
						}
					}
					oldpad = pad;
				}
			}
		}
	}

	vita2d_fini();
	sceKernelExitProcess(0);
	return 0;
}
Exemple #22
0
void	VID_Shutdown (void)
{
	vita2d_free_texture(tex_buffer);
	vita2d_fini();
	free(surfcache);
}
Exemple #23
0
void GUIFontDestroy(struct GUIFont* font) {
	vita2d_free_texture(font->tex);
	vita2d_free_texture(font->icons);
	free(font);
}
Psp2Ui::~Psp2Ui() {
	vita2d_free_texture(main_texture);
	vita2d_fini();
}