Beispiel #1
0
int32_t PS3Graphics::InitCg()
{
	cgRTCgcInit();

	_cgContext = cgCreateContext();
	if (_cgContext == NULL)
		return 1;
	if (strlen(_curFragmentShaderPath.c_str()) > 0)
		return LoadFragmentShader(_curFragmentShaderPath.c_str());
	else
	{
		_curFragmentShaderPath = DEFAULT_SHADER_FILE;
		return LoadFragmentShader(_curFragmentShaderPath.c_str());
	}
}
Beispiel #2
0
int32_t FceuGraphics::InitCg()
{
	LOG_DBG("FceuGraphics::InitCg()\n");

	cgRTCgcInit();

	LOG_DBG("FceuGraphics::InitCg() - About to create CgContext\n");
	_cgContext = cgCreateContext();
	if (_cgContext == NULL)
	{
		LOG_DBG("Error Creating Cg Context\n");
		return 1;
	}
	if (strlen(_curFragmentShaderPath.c_str()) > 0)
	{
		return LoadFragmentShader(_curFragmentShaderPath.c_str());
	}
	else
	{
		_curFragmentShaderPath = DEFAULT_SHADER_FILE;
		return LoadFragmentShader(_curFragmentShaderPath.c_str());
	}
}
void										ESVideoPlatform::Initialize				(uint32_t& aWidth, uint32_t& aHeight)
{
    //Init PSGL
    PSGLinitOptions initOpts = {PSGL_INIT_MAX_SPUS | PSGL_INIT_HOST_MEMORY_SIZE, 1, false, 0, 0, 0, 0, 32 * 1024 * 1024};
    psglInit(&initOpts);

    Device = psglCreateDeviceAuto(GL_ARGB_SCE, GL_NONE, GL_MULTISAMPLING_NONE_SCE);
    Context = psglCreateContext();
    psglMakeCurrent(Context, Device);
    psglResetCurrentContext();

    //Get Screen Info
    psglGetRenderBufferDimensions(Device, &aWidth, &aHeight);
    psglGetDeviceDimensions(Device, &DefaultWidth, &DefaultHeight);
//	WideScreen = psglGetDeviceAspectRatio(Device) > 1.5f;

    //Some settings
    glEnable(GL_VSYNC_SCE);
    VSyncOn = true;

    //Init shaders
    cgRTCgcInit();
    LibESGL::Presenter::Initialize();
}
Beispiel #4
0
static void *gl_cg_init(void *data, const char *path)
{
   unsigned i;
   cg_shader_data_t *cg_data = (cg_shader_data_t*)
      calloc(1, sizeof(cg_shader_data_t));

   if (!cg_data)
      return NULL;

#ifdef HAVE_CG_RUNTIME_COMPILER
   cgRTCgcInit();
#endif

   cg_data->cgCtx = cgCreateContext();

   if (!cg_data->cgCtx)
   {
      RARCH_ERR("Failed to create Cg context.\n");
      goto error;
   }

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

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

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

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

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

   if (path && string_is_equal(path_get_extension(path), "cgp"))
   {
      if (!gl_cg_load_preset(cg_data, path))
         goto error;
   }
   else
   {
      if (!gl_cg_load_plain(cg_data, path))
         goto error;
   }

   cg_data->prg[0].mvp = cgGetNamedParameter(cg_data->prg[0].vprg, "IN.mvp_matrix");
   for (i = 1; i <= cg_data->shader->passes; i++)
      gl_cg_set_program_attributes(cg_data, 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_data->prg[cg_data->shader->passes + 1] = cg_data->prg[0]; 

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

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

   return cg_data;

error:
   gl_cg_destroy_resources(cg_data);
   if (!cg_data)
      free(cg_data);
   return NULL;
}
Beispiel #5
0
bool COLLADA_Viewer::onInit(int argc, char **ppArgv)
{
	FWGLApplication::onInit(argc, ppArgv);

    glClearColor(0.3f,0.3f,0.7f, 0.0f);
	glClearDepthf(1.0f);
	glEnable(GL_DEPTH_TEST);

	FWDebugFont::setColor(1.f, 1.f, 1.f, 1.f);  

	InitFS();
	Browser.Init();

	psglLoadShaderLibrary("/app_home/shaders.bin");

	// Initialize the renderer
	_CrtRender.Init();
	_CrtRender.SetUsingVBOs(CrtTrue);
	_CrtRender.SetShowHiearchy(CrtTrue);
	glEnable(GL_TEXTURE_2D);							
	glShadeModel(GL_SMOOTH);							
	glClearColor(0.0f, 0.0f, 1.0f, 0.5f);				
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	
	glEnable(GL_LIGHT0);
	glEnable(GL_LIGHTING);
	glEnable( GL_CULL_FACE );
	glCullFace( GL_BACK ); 

    cgRTCgcInit();
	ParseDir("/app_home/");

  // Load the target file
	Browser.onUpdate();
	if (argc > 0)
	{
		char path_name[1024];
		mCurrentFile = ppArgv[0];
		sprintf(path_name, "%s%s", "/app_home/", ppArgv[0]);
		printf(path_name);
		load_ok  = _CrtRender.Load(path_name, NULL);
		if ( !load_ok )
   			return false;  
	}
	else if (Browser.GetSize() > 0)
	{
		mCurrentFile = Browser.GetThumbnail(0)->GetDocument();
		load_ok  = _CrtRender.Load(mCurrentFile, NULL);
		if ( !load_ok )
   			return false;  
	}
	// Get the gamepad so we can read it later 
	mpPad = FWInput::getDevice(FWInput::DeviceType_Pad,0);
	if(mpPad==NULL)
	{
	  printf("Error, couldn't get a pad\n");
	  exit(0);
	}

	mpInputX0 = mpPad->bindFilter();
	mpInputX0->setChannel(FWInput::Channel_XAxis_0);
	mpInputX0->setGain( 1.0f );
	mpInputX0->setDeadzone( 0.3f );

	mpInputY0 = mpPad->bindFilter();
	mpInputY0->setChannel(FWInput::Channel_YAxis_0);
	mpInputY0->setGain( 1.0f );
	mpInputY0->setDeadzone( 0.3f );

	mpInputX1 = mpPad->bindFilter();
	mpInputX1->setChannel(FWInput::Channel_XAxis_1);
	mpInputX1->setGain( 1.0f );
	mpInputX1->setDeadzone( 0.3f );

	mpInputY1 = mpPad->bindFilter();
	mpInputY1->setChannel(FWInput::Channel_YAxis_1);
	mpInputY1->setGain( 1.0f );
	mpInputY1->setDeadzone( 0.3f );


  	// initialize debug font library, then open console.
	int ret;
	CellDbgFontConfig cfg;
	memset(&cfg, 0, sizeof(CellDbgFontConfig));
	cfg.bufSize      = 512;
	cfg.screenWidth  = mDispInfo.mWidth;
	cfg.screenHeight = mDispInfo.mHeight;
	ret = cellDbgFontInit(&cfg);
	if (ret != CELL_OK) {
		printf("cellDbgFontInit() failed %x\n", ret);
		return true;
	}

	CellDbgFontConsoleConfig ccfg;
	memset(&ccfg, 0, sizeof(CellDbgFontConsoleConfig));
	ccfg.posLeft     = 0.1f;
	ccfg.posTop      = 0.6f;
	ccfg.cnsWidth    = 16;
	ccfg.cnsHeight   = 4;
	ccfg.scale       = 1.5f;
	ccfg.color       = 0xffffffff;
	mDbgFontID       = cellDbgFontConsoleOpen(&ccfg);
	if (mDbgFontID < 0) {
		printf("cellDbgFontConsoleOpen() failed %x\n", mDbgFontID);
		return true;
	}

	return true;
}
Beispiel #6
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;
}