void  Cg::Term(void){
	cgDestroyProgram(vertexProgram);
	cgDestroyProgram(fragmentProgram);
	cgDestroyProgram(vertex_sliceProgram);
	cgDestroyContext(context);

}
Esempio n. 2
0
void FilterBox::Destroy()
{
//    glDeleteRenderbuffersEXT(1, &depth_rb);
  glDeleteTextures(2, textureID);
//    glDeleteFramebuffersEXT(2, fb);
  cgDestroyContext(cgContext); 
}
 //-----------------------------------------------------------------------
 CgProgramFactory::~CgProgramFactory()
 {
     cgDestroyContext(mCgContext);
     // Check for errors
     checkForCgError("CgProgramFactory::~CgProgramFactory", 
         "Unable to destroy Cg context: ", mCgContext);
 }
Esempio n. 4
0
INT WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	g_cgContext = cgCreateContext();
	checkForCgError("creating context");
	cgSetParameterSettingMode(g_cgContext, CG_DEFERRED_PARAMETER_SETTING);

	DXUTSetCallbackDeviceReset(OnResetDevice);
	DXUTSetCallbackDeviceLost(OnLostDevice);
	DXUTSetCallbackFrameRender(OnFrameRender);

	/* Parse  command line, handle  default hotkeys, and show messages. */
	DXUTInit();

	DXUTCreateWindow(g_strWindowTitleW);

	/* Display 400x400 window. */
	DXUTCreateDevice(D3DADAPTER_DEFAULT, true, 400, 400);

	DXUTMainLoop();

	cgDestroyProgram(g_cgVertexProgram);
	checkForCgError("destroying vertex program");
	cgDestroyContext(g_cgContext);

	return DXUTGetExitCode();
}
Esempio n. 5
0
GLWindow::~GLWindow(){
	if( mUseCG ){
#ifdef COMPILE_CG
		cgDestroyProgram( cgProgram );
		cgDestroyContext( cgContext );
#endif
	}
}
Esempio n. 6
0
void sShaderCompilerExit()
{
#if sCOMP_CG_ENABLE
  cgDestroyContext(CGC);
  CGC = 0;
#endif
  CompilerCount = 0;
}
Esempio n. 7
0
CShaderLoader::~CShaderLoader()
{
    // Destruction du context
    if (m_context)
    {
        cgDestroyContext(m_context);
    }
}
Esempio n. 8
0
/* Final deinit. */
static void gl_cg_deinit_context_state(cg_shader_data_t *cg)
{
   if (cg->cgCtx)
   {
      RARCH_LOG("CG: Destroying context.\n");
      cgDestroyContext(cg->cgCtx);
   }
   cg->cgCtx = NULL;
}
Esempio n. 9
0
/* Final deinit. */
static void gl_cg_deinit_context_state(void *data)
{
   cg_shader_data_t *cg = (cg_shader_data_t*)data;
   if (cg->cgCtx)
   {
      RARCH_LOG("[CG]: Destroying context.\n");
      cgDestroyContext(cg->cgCtx);
   }
   cg->cgCtx = NULL;
}
Esempio n. 10
0
static void d3d9_cg_deinit_context_state(void *data)
{
   cg_renderchain_t *cg_data = (cg_renderchain_t*)data;
   if (cg_data->cgCtx)
   {
      RARCH_LOG("CG: Destroying context.\n");
      cgDestroyContext(cg_data->cgCtx);
   }
   cg_data->cgCtx = NULL;
}
Esempio n. 11
0
void DestroyCg()
{
	cgDestroyProgram(VP_DrawSites);
	cgDestroyProgram(FP_DrawSites);
	cgDestroyProgram(VP_Flood);
	cgDestroyProgram(FP_Flood);
	cgDestroyProgram(VP_FinalRender);
	cgDestroyProgram(FP_FinalRender);
	cgDestroyContext(Context);
}
static void d3d9_cg_deinit_context_state(cg_renderchain_t *chain)
{
   if (chain->cgCtx)
   {
      RARCH_LOG("[D3D9 Cg]: Destroying context.\n");
      cgDestroyContext(chain->cgCtx);
   }

   chain->cgCtx = NULL;
}
Esempio n. 13
0
GPUProgram::~GPUProgram(void)
{
	for (unsigned int i=0; i<m_shaders.size(); i++){
		delete m_shaders[i];
		m_shaders[i] = NULL;
	}
	m_shaders.clear();

	cgDestroyContext(context); 
}
Esempio n. 14
0
static void cg_d3d9_renderchain_deinit_shader(cg_renderchain_t *chain)
{
   if (!chain || !chain->cgCtx)
      return;

   cgD3D9UnloadAllPrograms();
   cgD3D9SetDevice(NULL);
   cgDestroyContext(chain->cgCtx);
   chain->cgCtx = NULL;
}
Esempio n. 15
0
 void GLRenderer::Shutdown()
 {
     for (auto it = this->_shutdownCallbacks.begin(), ite = this->_shutdownCallbacks.end(); it != ite; ++it)
         (*it)();
     if (--_cgGlobalNbReferences == 0)
     {
         cgDestroyContext(this->_cgContext);
         _cgGlobalContext = 0;
     }
 }
Esempio n. 16
0
void d3d_deinit_shader(void *data)
{
   D3DVideo *d3d = reinterpret_cast<D3DVideo*>(data);
   if (!d3d->cgCtx)
      return;

   cgD3D9UnloadAllPrograms();
   cgD3D9SetDevice(NULL);
   cgDestroyContext(d3d->cgCtx);
   d3d->cgCtx = NULL;
}
Esempio n. 17
0
// Final deinit.
static void gl_cg_deinit_context_state(void)
{
   // Destroying context breaks on PS3 for some unknown reason.
#ifndef __CELLOS_LV2__
   if (cgCtx)
   {
      RARCH_LOG("CG: Destroying context.\n");
      cgDestroyContext(cgCtx);
      cgCtx = NULL;
   }
#endif
}
Esempio n. 18
0
static void keyboard(unsigned char c, int x, int y)
{
	switch (c) {
	case 27:  /* Esc key */
		/* Demonstrate proper deallocation of Cg runtime data structures.
		Not strictly necessary if we are simply going to exit. */
		cgDestroyProgram(myCgVertexProgram);
		cgDestroyContext(myCgContext);
		exit(0);
		break;
	}
}
Esempio n. 19
0
//
// Release
//
void CCgContext::Release()
{
    if (m_RefCount == 0)
        return;

    if (--m_RefCount == 0)
    {
        cgDestroyContext( m_Context );
        CGerror Error = cgGetError();
        if (Error != CG_NO_ERROR)
            throw CCgException( "GL::CCgContext", Error, "::Release() : Failed to destroy Cg context." );

        m_Context = NULL;
    }
}
Esempio n. 20
0
static void d3d_deinit_shader(void *data)
{
   d3d_video_t *d3d = (d3d_video_t*)data;
   (void)d3d;
   (void)data;

#ifdef HAVE_CG
   if (!d3d->cgCtx)
      return;

   cgD3D9UnloadAllPrograms();
   cgD3D9SetDevice(NULL);
   cgDestroyContext(d3d->cgCtx);
   d3d->cgCtx = NULL;
#endif
}
Esempio n. 21
0
void CDirect3D::DeInitialize()
{
	DestroyDrawSurface();
	SetShader(NULL);

	if(cgShader) {
		delete cgShader;
		cgShader = NULL;
	}
	if(cgContext) {
		cgDestroyContext(cgContext);
		cgContext = NULL;
	}
	if(cgAvailable)
		cgD3D9SetDevice(NULL);

	if(vertexBuffer) {
		vertexBuffer->Release();
		vertexBuffer = NULL;
	}

	if(vertexDeclaration) {
		vertexDeclaration->Release();
		vertexDeclaration = NULL;
	}

	if( pDevice ) {
		pDevice->Release();
		pDevice = NULL;
	}

	if( pD3D ) {
		pD3D->Release();
		pD3D = NULL;
	}

	init_done = false;
	afterRenderWidth = 0;
	afterRenderHeight = 0;
	quadTextureSize = 0;
	fullscreen = false;
	filterScale = 0;
	if(cgAvailable)
		unloadCgLibrary();
	cgAvailable = false;
}
Esempio n. 22
0
// keyboard callback
void keyboard(unsigned char key, int x, int y) {

  static bool animation = false;

  switch (key) {
  case 27: 		// Escape
  case 'q':
    cgDestroyProgram(cg_vertex_program);
    cgDestroyContext(cg_context);
    exit(0);
  break;
  case ' ':
    animation = !animation;
    if(animation) glutIdleFunc(idle);
    else glutIdleFunc(NULL); 
  break;
  }
}
Esempio n. 23
0
/* THE MAIN */
int main( int argc, char** argv ) {
	
	if( argc == 2 ){
		char *a = argv[1];
		readfile( a );
	}else{
		printf( "Usage: shader <filename>\n" );
		exit(0);
	}
	
	init(argc, argv);
	CgInit();
	glutMainLoop();
	
	cgDestroyProgram( CgProg );
	cgDestroyContext( CgCtxt );

	return 0;
}
Esempio n. 24
0
void ObjMeshGPUDeformer::DeleteCGShaders()
{
  if (VertexPass2Program) 
    cgDestroyProgram(VertexPass2Program);
  
  if (VertexPass2ProgramShadow)
    cgDestroyProgram(VertexPass2ProgramShadow);

  //if (VertexPass2ProgramDeformedNormals)
    //cgDestroyProgram(VertexPass2ProgramDeformedNormals);

  if (VertexPass2ProgramPoints) 
    cgDestroyProgram(VertexPass2ProgramPoints);
    
  if (VertexPass2ProgramEdges)
    cgDestroyProgram(VertexPass2ProgramEdges);

  if (FragmentPass2Program)
    cgDestroyProgram(FragmentPass2Program);
    
  if (Context)
    cgDestroyContext(Context);
}
ParticleShaderVoronoi::~ParticleShaderVoronoi()
{
	if (pbufferOne) delete pbufferOne;
	gluDeleteQuadric(quad);
	cgDestroyContext(cgContext);
}
Esempio n. 26
0
cCgShaderHelper::cCgShaderHelper(const zsString& shaderPath) {

	cFileUtil::ReplaceIncludeDirectives(shaderPath, cgFileLines, includedFilesPaths);

	// Setup context, for creation (Yeah silly, but use OpenGL cg state and params) because equal with dx...
	CGcontext con = cgCreateContext();
	cgGLRegisterStates(con);
	cgGLSetManageTextureParameters(con, CG_TRUE);
	
	// Create cg effect from file (load)
	assert(shaderPath.size() <= 256);
	char ansiShaderPath[256];
	cStrUtil::ToAnsi(shaderPath, ansiShaderPath, 256);
	CGeffect effect = cgCreateEffectFromFile(con, ansiShaderPath, nullptr);
	if (effect == nullptr) {
		lastErrorMsg = cgGetLastListing(con);

		// Free up
		cgDestroyEffect(effect);
		cgDestroyContext(con);
		return;
	}

	// Tech creation
	CGtechnique tech = cgGetFirstTechnique(effect);
	if (tech == nullptr) {
		lastErrorMsg = L"There is no Technique in shader: " + shaderPath;

		// Free up
		cgDestroyEffect(effect);
		cgDestroyContext(con);
		return;
	}

	// Pass creation
	CGpass pass = cgGetFirstPass(tech);
	if (pass == nullptr) {
		lastErrorMsg = L"There is no pass in shader: " + shaderPath;
		// Free up
		cgDestroyEffect(effect);
		cgDestroyContext(con);
		return;
	}

	CGprogram shaderPrograms[NDOMAINS];
		shaderPrograms[VS] = cgGetPassProgram(pass, CGdomain::CG_VERTEX_DOMAIN);
		shaderPrograms[HS] = cgGetPassProgram(pass, CGdomain::CG_TESSELLATION_CONTROL_DOMAIN);
		shaderPrograms[DS] = cgGetPassProgram(pass, CGdomain::CG_TESSELLATION_EVALUATION_DOMAIN);
		shaderPrograms[GS] = cgGetPassProgram(pass, CGdomain::CG_GEOMETRY_DOMAIN);
		shaderPrograms[PS] = cgGetPassProgram(pass, CGdomain::CG_FRAGMENT_DOMAIN);


	// Domain infos
	for (uint8_t i = 0; i < NDOMAINS; i++) {
		// Domain existence
		info.domainsExist[i] = shaderPrograms[i] != nullptr;

		// if exist save entry name
		if (info.domainsExist[i]) 
			info.domainsEntry[i] = cgGetProgramString(shaderPrograms[i], CGenum::CG_PROGRAM_ENTRY);
	}

	// Free up
	cgDestroyEffect(effect);
	cgDestroyContext(con);
}
Esempio n. 27
0
static void keyboard(unsigned char c, int x, int y)
{
  

  switch (c) {
  case ' ':
    animating = !animating; /* Toggle */
    if (animating) {
	  enablestick=0;
	  moving=0;
	    w.xspeed=power*cos(2*angle*myPi/360); 
		w.zspeed=power*sin(2*angle*myPi/360);
      glutIdleFunc(idle);
    } else {
      reset();
      glutIdleFunc(NULL);
    }    
    break;
  case '1':
	  camera[0]=0; camera[1]=200; camera[2]=400;
  	  angle = -90;
	  stickangle = 0;

	glutPostRedisplay();
	  break;
  case  '2':
	  camera[0]=500; camera[1]=200; camera[2]=0;
	  angle = 180;
	  stickangle = 270;
	glutPostRedisplay();
	  break;
  case '3':
	  camera[0]=-500; camera[1]=200; camera[2]=0;
	  angle = 0;
	  stickangle = 90;
	  glutPostRedisplay();
	  break;
  case '4':
	  camera[0]=0; camera[1]=200; camera[2]=-400;
	  angle = 90;
	  stickangle=180;
	  glutPostRedisplay();
	break;
  case 'z':
	 angle = angle + 2;
	 stickangle=90+angle;
	  glutPostRedisplay();
      break;
  case 'x':
	angle = angle - 2;
	stickangle=90+angle;
	  glutPostRedisplay();
       break;
  case 'n':
		  if (camera[0]==0 && camera[1]<=200 && camera[1]>=50 && camera[2]<=400 && camera[2]>100)
	  {
		 camera[1]-=25;
		 camera[2]-=50;
		 glutPostRedisplay();
	  }
	  	  if (camera[0]==0 && camera[1]<=200 && camera[1]>=50 && camera[2]>=-400 && camera[2]<100)
	  {
		 camera[1]-=25;
		 camera[2]+=50;
		 glutPostRedisplay();
	  }
		  if (camera[0]<=500 && camera[0]>100 && camera[1]<=200 && camera[1]>50 && camera[2]==0)
	  {
		 camera[0]-=50;
		 camera[1]-=25;
		 glutPostRedisplay();
	  }
		  if (camera[0]>=-500 && camera[0]<=-100 && camera[1]<=200 && camera[1]>50 && camera[2]==0)
	  {
		 camera[0]+=50;
		 camera[1]-=25;
		 glutPostRedisplay();
	  }
      break;
 case 'm':

	  if (camera[0]==0 && camera[1]<=175 && camera[1]>=25 && camera[2]<=350 && camera[2]>75)
	  {
		 camera[1]+=25;
		 camera[2]+=50;
		 glutPostRedisplay();
	  }
	  	  if (camera[0]==0 && camera[1]<=175 && camera[1]>=25 && camera[2]>=-350 && camera[2]<50)
	  {
		 camera[1]+=25;
		 camera[2]-=50;
		 glutPostRedisplay();
	  }
		  if (camera[0]<=450 && camera[0]>=50 && camera[1]<=175 && camera[1]>25 && camera[2]==0)
	  {
		 camera[0]+=50;
		 camera[1]+=25;
		 glutPostRedisplay();
	  }
		  if (camera[0]>=-450 && camera[0]<=-50 && camera[1]<=175 && camera[1]>25 && camera[2]==0)
	  {
		 camera[0]-=50;
		 camera[1]+=25;
		 glutPostRedisplay();
	  }
      break;
  case 27:  /* Esc key */
    /* Demonstrate proper deallocation of Cg runtime data structures.
       Not strictly necessary if we are simply going to exit. */
    cgDestroyProgram(myCgVertexProgram);
    cgDestroyContext(myCgContext);
    exit(0);
    break;
  }
}
	void CCGShaderSystem::Destroy()
	{
		cgDestroyContext( m_CGContext );
		m_CGContext = xst_null;
	}
Esempio n. 29
0
 CgDxEffect::~CgDxEffect() {
     if(mContext) {
         cgDestroyContext(mContext);
     }
 }
Esempio n. 30
0
GLCgShaderContext::~GLCgShaderContext()
{
	cgDestroyContext(m_cgContext);
	m_cgContext = 0;
}