Ejemplo n.º 1
0
static bool hlsl_init(const char *path)
{
   xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;

   if (path && strcmp(path_get_extension(path), ".cgp") == 0)
   {
      if (!load_preset(path))
         return false;
   }
   else
   {
      if (!load_plain(path))
         return false;
   }

   for(unsigned i = 1; i <= cg_shader->passes; i++)
      set_program_attributes(i);

   d3d_device_ptr = d3d->d3d_render_device;
   d3d->d3d_render_device->SetVertexShader(prg[1].vprg);
   d3d->d3d_render_device->SetPixelShader(prg[1].fprg);

   hlsl_active = true;
   return true;
}
Ejemplo n.º 2
0
int
select_preset (const gchar *preset)
{
  int ret = SELECT_PRESET_OK;
  /* I'm copying this behavior as is. As it seems applying the
   * factory_defaults preset does nothing, which I'm not sure
   * if that was what the author intended.
   *              -- Shlomi Fish
   */
  if (strcmp (preset, factory_defaults))
    {
      gchar *rel = g_build_filename ("Presets", preset, NULL);
      gchar *abs = findfile (rel);

      g_free (rel);

      if (abs)
        {
          if (load_preset (abs))
            ret = SELECT_PRESET_LOAD_FAILED;

          g_free (abs);
        }
      else
        {
          ret = SELECT_PRESET_FILE_NOT_FOUND;
        }
    }
  if (ret == SELECT_PRESET_OK)
    {
      /* This is so the colorbrushes param (that is not stored in the
       * preset will be set correctly upon the preset loading.
       * */
      set_colorbrushes (pcvals.selected_brush);
    }

  return ret;
}
Ejemplo n.º 3
0
bool hlsl_init(const char *path, IDirect3DDevice9 * device_ptr)
{
   if (!device_ptr)
      return false;

   d3d_device_ptr = device_ptr;

   if (strstr(path, ".cgp"))
   {
      if (!load_preset(path))
         return false;
   }
   else
   {
      if (!load_plain(path))
         return false;
   }

   set_program_attributes(0);

   active_index = 0;
   hlsl_active = true;
   return true;
}
Ejemplo n.º 4
0
static bool hlsl_init(void *data, const char *path)
{
   d3d_video_t *d3d = (d3d_video_t*)data;

   if (path && strcmp(path_get_extension(path), ".cgp") == 0)
   {
      if (!load_preset(d3d, path))
         return false;
   }
   else
   {
      if (!load_plain(d3d, path))
         return false;
   }

   for(unsigned i = 1; i <= cg_shader->passes; i++)
      set_program_attributes(i);

   d3d->dev->SetVertexShader(prg[1].vprg);
   d3d->dev->SetPixelShader(prg[1].fprg);

   hlsl_active = true;
   return true;
}
Ejemplo n.º 5
0
static bool hlsl_init(void *data, const char *path)
{
   d3d_video_t *d3d = (d3d_video_t*)data;
   hlsl_shader_data_t *hlsl = (hlsl_shader_data_t*)
	   calloc(1, sizeof(hlsl_shader_data_t));
   driver_t *driver = driver_get_ptr();

   if (!hlsl)
	   return false;

   if (path && !strcmp(path_get_extension(path), ".cgp"))
   {
      if (!load_preset(hlsl, d3d, path))
         goto error;
   }
   else
   {
      if (!load_plain(hlsl, d3d, path))
         goto error;
   }

   for(unsigned i = 1; i <= hlsl->cg_shader->passes; i++)
      set_program_attributes(hlsl, i);

   d3d_set_vertex_shader(d3d->dev, 1, hlsl->prg[1].vprg);
   d3d->dev->SetPixelShader(hlsl->prg[1].fprg);

   driver->video_shader_data = hlsl;

   return true;

error:
   if (hlsl)
	   free(hlsl);
   return false;
}
Ejemplo n.º 6
0
/* Loads a specific preset by absolute path */
int loadPresetByFile(char * filename) {

  preset_t * new_preset;
 
  /* Finally, load the preset using its actual path */
  if ((new_preset = load_preset(filename)) == NULL) {
	if (PRESET_DEBUG) printf("loadPresetByFile: failed to load preset!\n");
	return ERROR;	  
  }

  /* Closes a preset currently loaded, if any */
  if ((active_preset != NULL) && (active_preset != idle_preset))
    close_preset(active_preset); 

  /* Sets active preset global pointer */
  active_preset = new_preset;

  /* Reinitialize engine variables */
  reset_engine_vars();

 
  /* Add any missing initial conditions for each wave */
  load_custom_wave_init_conditions();

 /* Add any missing initial conditions for each wave */
  load_custom_shape_init_conditions();

  /* Add any missing initial conditions */
  load_init_conditions();
  
  /* Need to do this once for menu */
  evalInitConditions();
  //  evalPerFrameInitEquations();
  return SUCCESS;

}
Ejemplo n.º 7
0
static bool gl_cg_init(const char *path)
{
   unsigned i;
#ifdef HAVE_CG_RUNTIME_COMPILER
   cgRTCgcInit();
#endif

   if (!cgCtx)
      cgCtx = cgCreateContext();

   if (cgCtx == NULL)
   {
      RARCH_ERR("Failed to create Cg context\n");
      return false;
   }

#ifdef RARCH_CG_DEBUG
   cgGLSetDebugMode(CG_TRUE);
   cgSetErrorHandler(cg_error_handler, NULL);
#endif

   cgFProf = cgGLGetLatestProfile(CG_GL_FRAGMENT);
   cgVProf = cgGLGetLatestProfile(CG_GL_VERTEX);
   if (cgFProf == CG_PROFILE_UNKNOWN || cgVProf == CG_PROFILE_UNKNOWN)
   {
      RARCH_ERR("Invalid profile type\n");
      goto error;
   }
#ifndef HAVE_RGL
   RARCH_LOG("[Cg]: Vertex profile: %s\n", cgGetProfileString(cgVProf));
   RARCH_LOG("[Cg]: Fragment profile: %s\n", cgGetProfileString(cgFProf));
#endif
   cgGLSetOptimalOptions(cgFProf);
   cgGLSetOptimalOptions(cgVProf);
   cgGLEnableProfile(cgFProf);
   cgGLEnableProfile(cgVProf);

   if (path && strcmp(path_get_extension(path), "cgp") == 0)
   {
      if (!load_preset(path))
         goto error;
   }
   else
   {
      if (!load_plain(path))
         goto error;
   }

   prg[0].mvp = cgGetNamedParameter(prg[0].vprg, "IN.mvp_matrix");
   for (i = 1; i <= cg_shader->passes; i++)
      set_program_attributes(i);

   // If we aren't using last pass non-FBO shader, 
   // this shader will be assumed to be "fixed-function".
   // Just use prg[0] for that pass, which will be
   // pass-through.
   prg[cg_shader->passes + 1] = prg[0]; 

   // No need to apply Android hack in Cg.
   prg[GL_SHADER_STOCK_BLEND] = prg[0];

   cgGLBindProgram(prg[1].fprg);
   cgGLBindProgram(prg[1].vprg);

   cg_active = true;
   return true;

error:
   gl_cg_deinit();
   return false;
}
Ejemplo n.º 8
0
static bool gl_cg_init(void *data, const char *path)
{
   cg_shader_data_t *cg = NULL;
   driver_t *driver     = NULL;
   unsigned i;

   (void)data;

   cg     = (cg_shader_data_t*)calloc(1, sizeof(cg_shader_data_t));
   driver = driver_get_ptr();

   if (!cg)
      return false;

#ifdef HAVE_CG_RUNTIME_COMPILER
   cgRTCgcInit();
#endif

   cg->cgCtx = cgCreateContext();

   if (!cg->cgCtx)
   {
      RARCH_ERR("Failed to create Cg context\n");
      free(cg);
      return false;
   }

#ifdef RARCH_CG_DEBUG
   cgGLSetDebugMode(CG_TRUE);
   cgSetErrorHandler(cg_error_handler, NULL);
#endif

   cg->cgFProf = cgGLGetLatestProfile(CG_GL_FRAGMENT);
   cg->cgVProf = cgGLGetLatestProfile(CG_GL_VERTEX);

   if (
         cg->cgFProf == CG_PROFILE_UNKNOWN ||
         cg->cgVProf == CG_PROFILE_UNKNOWN)
   {
      RARCH_ERR("Invalid profile type\n");
      free(cg);
      goto error;
   }

   RARCH_LOG("[Cg]: Vertex profile: %s\n",   cgGetProfileString(cg->cgVProf));
   RARCH_LOG("[Cg]: Fragment profile: %s\n", cgGetProfileString(cg->cgFProf));
   cgGLSetOptimalOptions(cg->cgFProf);
   cgGLSetOptimalOptions(cg->cgVProf);
   cgGLEnableProfile(cg->cgFProf);
   cgGLEnableProfile(cg->cgVProf);

   memset(cg->cg_alias_define, 0, sizeof(cg->cg_alias_define));

   if (path && !strcmp(path_get_extension(path), "cgp"))
   {
      if (!load_preset(cg, path))
         goto error;
   }
   else
   {
      if (!load_plain(cg, path))
         goto error;
   }

   cg->prg[0].mvp = cgGetNamedParameter(cg->prg[0].vprg, "IN.mvp_matrix");
   for (i = 1; i <= cg->shader->passes; i++)
      set_program_attributes(cg, i);

   /* If we aren't using last pass non-FBO shader, 
    * this shader will be assumed to be "fixed-function".
    *
    * Just use prg[0] for that pass, which will be
    * pass-through. */
   cg->prg[cg->shader->passes + 1] = cg->prg[0]; 

   /* No need to apply Android hack in Cg. */
   cg->prg[GL_SHADER_STOCK_BLEND] = cg->prg[0];

   cgGLBindProgram(cg->prg[1].fprg);
   cgGLBindProgram(cg->prg[1].vprg);

   driver->video_shader_data = cg;

   return true;

error:
   gl_cg_destroy_resources(cg);
   if (!cg)
      free(cg);
   return false;
}
Ejemplo n.º 9
0
int switchPreset(switch_mode_t switch_mode, int cut_type) {

  preset_t * new_preset;
	
  int switch_index;
	
  /* Make sure a preset directory list is in the buffer */
  if (chrono_order_preset_name_tree == NULL) {
    if (PRESET_DEBUG) printf("switchPreset: it helps if you open a directory first with a loadPresetDir() call\n");
    return ERROR;
  }
  
  
  switch (switch_mode) {
	  
  case ALPHA_NEXT:
  /* An index variable that iterates through the directory
     buffer, doing wrap around when it reaches the end of
  	 the buffer */
  
  if (preset_index == (preset_name_buffer_size - 1))
		switch_index = preset_index = 0;
  else	
	  	switch_index = ++preset_index;
  break;

  case ALPHA_PREVIOUS:
	  
  if (preset_index == 0)
		switch_index = preset_index = preset_name_buffer_size - 1;
  else	
	  	switch_index = --preset_index;
  break;
  
  case RANDOM_NEXT:
	switch_index = (int) (preset_name_buffer_size*(rand()/(RAND_MAX+1.0)));
	break;
  case RESTART_ACTIVE:
	switch_index = preset_index;
	break;
  default:
  	return FAILURE;
  }
  
    
  /* Finally, load the preset using its actual path */
  if ((new_preset = load_preset((char*)splay_find(&switch_index, chrono_order_preset_name_tree))) == NULL) {
	if (PRESET_DEBUG) printf("switchPreset: failed to load preset\n");
	return ERROR;
  }

  /* Closes a preset currently loaded, if any */
  if ((active_preset != NULL) && (active_preset != idle_preset))
    close_preset(active_preset);

  /* Sets global active_preset pointer */
  active_preset = new_preset;

 
  /* Reinitialize the engine variables to sane defaults */
  reset_engine_vars();

  /* Add any missing initial conditions */
  load_init_conditions();

  /* Add any missing initial conditions for each wave */
  load_custom_wave_init_conditions();

/* Add any missing initial conditions for each shape */
  load_custom_shape_init_conditions();

  /* Need to evaluate the initial conditions once */
  evalInitConditions();

 
  //  evalInitPerFrameEquations();
  return SUCCESS;
}