• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cgGetError函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cgGetError函数的典型用法代码示例。如果您正苦于以下问题:C++ cgGetError函数的具体用法?C++ cgGetError怎么用?C++ cgGetError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了cgGetError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: cgDestroyProgram

    //
    // Link
    //
    void CCgShadingProgram::Link()
    {
        m_UniformCache.clear();
        m_SamplerUniformCache.clear();
        m_BindableUniformCache.clear();
    
        //m_Samplers.clear();

        if (cgIsProgram( m_Program ))
            cgDestroyProgram( m_Program );
            
        if (m_Shaders.size() == 1)
            m_Program = m_Shaders[ 0 ]->m_Program;
        else
        {
            vector<CGprogram> Programs;

            for (CONST_VECTOR_ITERATION( Ptr<const CCgShader>, m_Shaders, i ))
                Programs.push_back( (*i)->m_Program );
                
            m_Program = cgCombinePrograms( static_cast<int>( Programs.size() ), &Programs[ 0 ] );
            CGerror Error = cgGetError();
            if (Error != CG_NO_ERROR)
                throw CCgException( this, Error, "::Link() : Failed to combine Cg program." );
        }

        cgGLLoadProgram( m_Program );
        CGerror Error = cgGetError();
        if (Error != CG_NO_ERROR)
            throw CCgException( this, Error, "::Link() : Failed to load Cg program. Program may fails to load for any reason." );

         sort( m_Profiles.begin(), m_Profiles.end() );
    }
开发者ID:fourthskyinteractive,项目名称:oglshell,代码行数:36,代码来源:ProgramCg.cpp


示例2: main

int main( int argc, char **argv )
{
    glutInit( &argc, argv );
    glutInitWindowSize(1000, 1000);
    glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
    glutCreateWindow("Fractal Shader");
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutMotionFunc(mouseMove);
    glutMouseFunc(mouseAction);
    glutIdleFunc(OnIdle);
    glutKeyboardFunc(keyAction);
    glutKeyboardUpFunc(keyUp);
    glClearColor(0, 0, 0, 1);
    CGcontext context = cgCreateContext();
    if(context == NULL){
        printf("Failed to create CGcontext\n");
        return 1;
    }
	f_prof = cgGLGetLatestProfile(CG_GL_FRAGMENT); 
	v_prof = cgGLGetLatestProfile(CG_GL_VERTEX);
	printf("%d, %d\n", f_prof, v_prof);
    chdir("/Users/peter/Desktop/CG/cgtest");
    julia = cgCreateProgramFromFile(context, CG_SOURCE, "Julia.cg", f_prof, "main", NULL);
    newton = cgCreateProgramFromFile(context, CG_SOURCE, "Newton.cg", f_prof, "main", NULL);
    mandel = cgCreateProgramFromFile(context, CG_SOURCE, "Mandel.cg", f_prof, "main", NULL);
    ship = cgCreateProgramFromFile(context, CG_SOURCE, "Ship.cg", f_prof, "main", NULL);
    pass = cgCreateProgramFromFile(context, CG_SOURCE, "Pass.cg", v_prof, "main", NULL);
	gen = cgCreateProgramFromFile(context, CG_SOURCE, "GenIter.cg", f_prof, "main", NULL);
    printf("%s\n", cgGetErrorString(cgGetError()));
    cgGLLoadProgram(julia);
    cgGLLoadProgram(newton);
    cgGLLoadProgram(mandel);
    cgGLLoadProgram(ship);
	cgGLLoadProgram(gen);
    cgGLLoadProgram(pass);
    //printf("%s\n", cgGetErrorString(cgGetError()));
    cgGLEnableProfile(f_prof);
    cgGLEnableProfile(v_prof);
    printf("%s\n", cgGetErrorString(cgGetError()));
	
	Position demoList[7];
	fillPoint(&demoList[0], 0.297205, 0.063085, 0.001157, 1.012991, 15.0, 7);
	fillPoint(&demoList[1], 0.134370, 0.042840, 0.043976, 1.008928, 15.0, 7);
	fillPoint(&demoList[2], -0.129831, -0.637758, 0.507148, 1.103996, 15.0, 7);
	fillPoint(&demoList[3], -0.162030, -1.02009, 0.041826, 0.983991, 15.0, 7);
	fillPoint(&demoList[4], -0.139263, -1.846086, 0.002345, 0.516934, 15.0, 7);
	fillPoint(&demoList[5], -0.138215, -1.910406, 0.001638, 0.495934, 15.0, 7);
	fillPoint(&demoList[6], -0.138215, -3.552904, 0.302149, 0.149937, 15.0, 7);
	
	posList = demoList;
	zoom = 0.001157;
	
    glutMainLoop();
    return 0;
}
开发者ID:peterlew,项目名称:cgtest,代码行数:56,代码来源:main.cpp


示例3: InitCG

void InitCG()
{

    if( cgGLIsProfileSupported(CG_PROFILE_ARBVP1) )
        g_CGprofile_vertex = CG_PROFILE_ARBVP1;
    else if( cgGLIsProfileSupported(CG_PROFILE_VP40) )
        g_CGprofile_vertex = CG_PROFILE_VP40;
    else
    {
		ShaderWater=false;
        return;
    }

	
	if( cgGLIsProfileSupported(CG_PROFILE_ARBFP1) )
        g_CGprofile_pixel = CG_PROFILE_ARBFP1;
    else if( cgGLIsProfileSupported(CG_PROFILE_FP30) )
        g_CGprofile_pixel = CG_PROFILE_FP30;
	else if( cgGLIsProfileSupported(CG_PROFILE_FP20) )
        g_CGprofile_pixel = CG_PROFILE_FP20;
    else
    {
		ShaderWater=false;
		return;
    }
	g_CGcontext = cgCreateContext();
	
	g_Sea_vertex = cgCreateProgramFromFile( g_CGcontext,
												CG_SOURCE,
												"Sea_vertex.cg",
												g_CGprofile_vertex,
												NULL,
												NULL );
	cgGLLoadProgram(g_Sea_vertex);
	CGerror GetCGerror=cgGetError();
	if(GetCGerror!=CG_NO_ERROR)
		MessageBox (HWND_DESKTOP, "vertex shader Error!", "Error", MB_OK | MB_ICONEXCLAMATION);
	g_Sea_pixel = cgCreateProgramFromFile( g_CGcontext,
												CG_SOURCE,
												"Sea_pixel.cg",
												g_CGprofile_pixel,
												NULL,
												NULL );

	cgGLLoadProgram(g_Sea_pixel);
	GetCGerror=cgGetError();
	if(GetCGerror!=CG_NO_ERROR)
		MessageBox (HWND_DESKTOP, "pixel shader Error!", "Error", MB_OK | MB_ICONEXCLAMATION);
} 
开发者ID:SHIYUENING,项目名称:topace,代码行数:49,代码来源:Shader.cpp


示例4: load_program

static bool load_program(
      cg_shader_data_t *cg,
      unsigned idx,
      const char *prog,
      bool path_is_file)
{
   bool ret = true;
   char *listing_f = NULL;
   char *listing_v = NULL;

   unsigned i, argc = 0;
   const char *argv[2 + GFX_MAX_SHADERS];

   argv[argc++] = "-DPARAMETER_UNIFORM";
   for (i = 0; i < GFX_MAX_SHADERS; i++)
   {
      if (*(cg->cg_alias_define[i]))
         argv[argc++] = cg->cg_alias_define[i];
   }
   argv[argc] = NULL;

   if (path_is_file)
   {
      cg->prg[idx].fprg = cgCreateProgramFromFile(cg->cgCtx, CG_SOURCE,
            prog, cg->cgFProf, "main_fragment", argv);
      SET_LISTING(cg, f);
      cg->prg[idx].vprg = cgCreateProgramFromFile(cg->cgCtx, CG_SOURCE,
            prog, cg->cgVProf, "main_vertex", argv);
      SET_LISTING(cg, v);
   }
   else
   {
      cg->prg[idx].fprg = cgCreateProgram(cg->cgCtx, CG_SOURCE,
            prog, cg->cgFProf, "main_fragment", argv);
      SET_LISTING(cg, f);
      cg->prg[idx].vprg = cgCreateProgram(cg->cgCtx, CG_SOURCE,
            prog, cg->cgVProf, "main_vertex", argv);
      SET_LISTING(cg, v);
   }

   if (!cg->prg[idx].fprg || !cg->prg[idx].vprg)
   {
      RARCH_ERR("CG error: %s\n", cgGetErrorString(cgGetError()));
      if (listing_f)
         RARCH_ERR("Fragment:\n%s\n", listing_f);
      else if (listing_v)
         RARCH_ERR("Vertex:\n%s\n", listing_v);

      ret = false;
      goto end;
   }

   cgGLLoadProgram(cg->prg[idx].fprg);
   cgGLLoadProgram(cg->prg[idx].vprg);

end:
   free(listing_f);
   free(listing_v);
   return ret;
}
开发者ID:mak77,项目名称:RetroArch,代码行数:60,代码来源:shader_gl_cg.c


示例5: cgErrorCallback

void cgErrorCallback(void){
#ifdef COMPILE_CG
	CGerror LastError = cgGetError();
	if(LastError)
		printf("%s\n\n", cgGetErrorString(LastError));
#endif
}
开发者ID:EntityFXCode,项目名称:arsenalsuite,代码行数:7,代码来源:glwindow.cpp


示例6: handleCgError

static void handleCgError(void) 
{
    CGerror err = cgGetError();
    fprintf(stderr, "Cg error: %s\n", cgGetErrorString(err));
    fflush(stderr);
    exit(0);
}
开发者ID:nanzhang790,项目名称:View3dn,代码行数:7,代码来源:Shader.cpp


示例7: d3d9_cg_load_program

static bool d3d9_cg_load_program(void *data,
      void *fragment_data, void *vertex_data, const char *prog, bool path_is_file)
{
   bool ret                   = true;
   const char *list           = NULL;
   char *listing_f            = NULL;
   char *listing_v            = NULL;
   CGprogram *fPrg            = (CGprogram*)fragment_data;
   CGprogram *vPrg            = (CGprogram*)vertex_data;
   CGprofile vertex_profile   = cgD3D9GetLatestVertexProfile();
   CGprofile fragment_profile = cgD3D9GetLatestPixelProfile();
   const char **fragment_opts = cgD3D9GetOptimalOptions(fragment_profile);
   const char **vertex_opts   = cgD3D9GetOptimalOptions(vertex_profile);
   cg_renderchain_t *cg_data  = (cg_renderchain_t*)data;

   RARCH_LOG("[D3D Cg]: Vertex profile: %s\n", cgGetProfileString(vertex_profile));
   RARCH_LOG("[D3D Cg]: Fragment profile: %s\n", cgGetProfileString(fragment_profile));

   if (path_is_file && !string_is_empty(prog))
      *fPrg = cgCreateProgramFromFile(cg_data->cgCtx, CG_SOURCE,
            prog, fragment_profile, "main_fragment", fragment_opts);
   else
      *fPrg = cgCreateProgram(cg_data->cgCtx, CG_SOURCE, stock_cg_d3d9_program,
            fragment_profile, "main_fragment", fragment_opts);

   list = cgGetLastListing(cg_data->cgCtx);
   if (list)
      listing_f = strdup(list);

   if (path_is_file && !string_is_empty(prog))
      *vPrg = cgCreateProgramFromFile(cg_data->cgCtx, CG_SOURCE,
            prog, vertex_profile, "main_vertex", vertex_opts);
   else
      *vPrg = cgCreateProgram(cg_data->cgCtx, CG_SOURCE, stock_cg_d3d9_program,
            vertex_profile, "main_vertex", vertex_opts);

   list = cgGetLastListing(cg_data->cgCtx);
   if (list)
      listing_v = strdup(list);

   if (!fPrg || !vPrg)
   {
      RARCH_ERR("CG error: %s\n", cgGetErrorString(cgGetError()));
      if (listing_f)
         RARCH_ERR("Fragment:\n%s\n", listing_f);
      else if (listing_v)
         RARCH_ERR("Vertex:\n%s\n", listing_v);
      ret = false;
      goto end;
   }

   cgD3D9LoadProgram(*fPrg, true, 0);
   cgD3D9LoadProgram(*vPrg, true, 0);

end:
   free(listing_f);
   free(listing_v);
   return ret;
}
开发者ID:CrypticGator,项目名称:RetroArch,代码行数:59,代码来源:render_chain_cg.cpp


示例8: GL_REPORT_ERROR

bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrprogram)
{
	// Reset GL error before compiling shaders. Yeah, we need to investigate the causes of these.
	GLenum err = GL_REPORT_ERROR();
	if (err != GL_NO_ERROR)
	{
		ERROR_LOG(VIDEO, "glError %08x before VS!", err);
	}

#if defined HAVE_CG && HAVE_CG
	char stropt[64];
	sprintf(stropt, "MaxLocalParams=256,MaxInstructions=%d", s_nMaxVertexInstructions);
	const char *opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
	CGprogram tempprog = cgCreateProgram(g_cgcontext, CG_SOURCE, pstrprogram, g_cgvProf, "main", opts);
	if (!cgIsProgram(tempprog)) {
        if (s_displayCompileAlert) {
            PanicAlert("Failed to create vertex shader");
            s_displayCompileAlert = false;
        }
        cgDestroyProgram(tempprog);
		ERROR_LOG(VIDEO, "Failed to load vs %s:", cgGetLastListing(g_cgcontext));
		ERROR_LOG(VIDEO, "%s", pstrprogram);
		return false;
	}

	if (cgGetError() != CG_NO_ERROR)
	{
		WARN_LOG(VIDEO, "Failed to load vs %s:", cgGetLastListing(g_cgcontext));
		WARN_LOG(VIDEO, "%s", pstrprogram);
	}

	// This looks evil - we modify the program through the const char * we got from cgGetProgramString!
	// It SHOULD not have any nasty side effects though - but you never know...
	char *pcompiledprog = (char*)cgGetProgramString(tempprog, CG_COMPILED_PROGRAM);
	char *plocal = strstr(pcompiledprog, "program.local");
	while (plocal != NULL) {
		const char* penv = "  program.env";
		memcpy(plocal, penv, 13);
		plocal = strstr(plocal + 13, "program.local");
	}
	glGenProgramsARB(1, &vs.glprogid);
	SetCurrentShader(vs.glprogid);

	glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pcompiledprog), pcompiledprog);	
	err = GL_REPORT_ERROR();
	if (err != GL_NO_ERROR) {
		ERROR_LOG(VIDEO, "%s", pstrprogram);
		ERROR_LOG(VIDEO, "%s", pcompiledprog);
	}

	cgDestroyProgram(tempprog);
#endif

#if defined(_DEBUG) || defined(DEBUGFAST) 
	vs.strprog = pstrprogram;
#endif

	return true;
}
开发者ID:NullNoname,项目名称:dolphin,代码行数:59,代码来源:VertexShaderCache.cpp


示例9: checkCgError

void checkCgError() {
  CGerror error = cgGetError();
  if ( error ) {
    std::cout << "CG error: ";
    std::cout << cgGetErrorString( error ) << std::endl;
    std::cout << cgGetLastListing( context ) << std::endl;
  }
}
开发者ID:Fadis,项目名称:assimp_collada_sample_20111121,代码行数:8,代码来源:common.cpp


示例10: ErrorCheck

void ErrorCheck()
{
#ifdef HAS_CG
  CGerror error = cgGetError();
  if (error)
    printf("CG Error: %s\n", cgGetErrorString(error));
#endif //HAS_CG
}
开发者ID:gaoyakun,项目名称:atom3d,代码行数:8,代码来源:shader_cg.cpp


示例11: ZZshLoadShadeEffect

FRAGMENTSHADER* ZZshLoadShadeEffect(int type, int texfilter, int fog, int testaem, int exactcolor, const clampInfo& clamp, int context, bool* pbFailed)
{
	int texwrap;

	assert( texfilter < NUM_FILTERS );
	//assert( g_nPixelShaderVer == SHADER_30 );
	if( clamp.wms == clamp.wmt ) {
		switch( clamp.wms ) {
			case 0: texwrap = TEXWRAP_REPEAT; break;
			case 1: texwrap = TEXWRAP_CLAMP; break;
			case 2: texwrap = TEXWRAP_CLAMP; break;
			default:
				texwrap = TEXWRAP_REGION_REPEAT; break;
		}
	}
	else if( clamp.wms==3||clamp.wmt==3)
		texwrap = TEXWRAP_REGION_REPEAT;
	else
		texwrap = TEXWRAP_REPEAT_CLAMP;

	int index = GET_SHADER_INDEX(type, texfilter, texwrap, fog, s_bWriteDepth, testaem, exactcolor, context, 0);

	if( pbFailed != NULL ) *pbFailed = false;

	FRAGMENTSHADER* pf = ppsTexture+index;

	if( pf->prog != NULL )
		return pf;

	pf->prog = LoadShaderFromType(EFFECT_DIR, EFFECT_NAME, type, texfilter, texwrap, fog, s_bWriteDepth, testaem, exactcolor, g_nPixelShaderVer, context);

	if( pf->prog != NULL ) {
#ifdef _DEBUG
		char str[255];
		sprintf(str, "Texture%s%d_%sPS", fog?"Fog":"", texfilter, g_pTexTypes[type]);
		pf->filename = str;
#endif
		SetupFragmentProgramParameters(pf, context, type);
		cgGLLoadProgram(pf->prog);
		if( cgGetError() != CG_NO_ERROR ) {
			// try again
//			cgGLLoadProgram(pf->prog);
//			if( cgGetError() != CG_NO_ERROR ) {
				ZZLog::Error_Log("Failed to load shader %d,%d,%d,%d", type, fog, texfilter, 4*clamp.wms+clamp.wmt);
				if( pbFailed != NULL ) *pbFailed = true;
				//assert(0);
				// NULL makes things crash
				return pf;
//			}
		}
		return pf;
	}

	ZZLog::Error_Log("Failed to create shader %d,%d,%d,%d", type, fog, texfilter, 4*clamp.wms+clamp.wmt);
	if( pbFailed != NULL ) *pbFailed = true;

	return NULL;
}
开发者ID:tsiru,项目名称:pcsx2,代码行数:58,代码来源:ZZoglShaders.cpp


示例12: cgErrorCallback

void cgErrorCallback ()
{
	CGerror cerror = cgGetError();
	if ( cerror ) {
		const char *listing = cgGetLastListing ( cgContext );		
		printf ( "CG: %s\n%s\n", cgGetErrorString( cerror ), listing );
		exit (-1);
	}
}
开发者ID:MrMagne,项目名称:fluids_v3,代码行数:9,代码来源:gl_helper.cpp


示例13: cgGetError

	//[-------------------------------------------------------]
	//[ Private static Cg callback functions                  ]
	//[-------------------------------------------------------]
	void ShaderLanguageCg::cgErrorCallback()
	{
		const CGerror lastCgError = cgGetError();
		if (CG_NO_ERROR != lastCgError)
		{
			// Output error message
			RENDERER_OUTPUT_DEBUG_PRINTF("OpenGL Cg error: %s\n", cgGetErrorString(lastCgError))
		}
	}
开发者ID:0x4E69676874466F78,项目名称:unrimp,代码行数:12,代码来源:ShaderLanguageCg.cpp


示例14: cgErrorCallback

void cgErrorCallback()
{
    CGerror lastError = cgGetError();
    if(lastError)
    {
        printf("%s\n", cgGetErrorString(lastError));
        printf("%s\n", cgGetLastListing(context));
    }
}
开发者ID:haolly,项目名称:fluid3dsjtu,代码行数:9,代码来源:Fluid.cpp


示例15: cgGetError

void  Cg::CheckCgError(void){
	CGerror err = cgGetError();

	if (err != CG_NO_ERROR) {
		printf("CG error: %s\n", cgGetErrorString(err));
		abort();
	}

}
开发者ID:miffysora,项目名称:LODRayCastingVolumeRendering,代码行数:9,代码来源:cg.cpp


示例16: cgGetError

void cgfxTechnique::validate() const
{
    fValid = (cgValidateTechnique(fTechnique) == CG_TRUE);
    if (fValid) {
        fErrorString = "";
    }
    else {
        CGerror error = cgGetError();
        if (error != CG_NO_ERROR) {
            fErrorString = cgGetErrorString(cgGetError());
        }
        fErrorString += "\nCg compilation errors for technique \"";
        fErrorString += fName;
        fErrorString += "\":\n";
        fErrorString += cgGetLastListing(cgfxShaderNode::sCgContext);
        fErrorString += "\n";
    }
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:18,代码来源:cgfxEffectDef.cpp


示例17: cgGetErrorString

  void Video::print_errors() {
#if !defined(DISABLE_GL) && !defined(REQUIRE_GL_ES)
    std::cerr << "OpenGL    : " << Zeni::gluErrorString(glGetError()) << std::endl;
#endif

#ifndef DISABLE_CG
    std::cerr << "Cg        : " << cgGetErrorString(cgGetError()) << std::endl;
#endif
  }
开发者ID:Sonophoto,项目名称:Soar-SC,代码行数:9,代码来源:Video.cpp


示例18: cgGetErrorString

void cgtk::cgErrorCallback()
{
	CGerror lastError=cgGetError();
	if(lastError)
	{
		cout<< cgGetErrorString(lastError) <<endl;
		if(context!=NULL)
			cout<<cgGetLastListing(context) <<endl;
		exit(0);
	}
}
开发者ID:sqhe,项目名称:Airpollution,代码行数:11,代码来源:cgtk.cpp


示例19: CheckCgError

CGerror CheckCgError(int line)
{
	CGerror err = cgGetError ();

	if (err != CG_NO_ERROR)
	{
		LOG ("CG error:%d at line %d %s\n", err, line, cgGetErrorString (err));
	}

	return err;
}
开发者ID:cdenix,项目名称:fceu-ps3,代码行数:11,代码来源:FceuGraphics.cpp


示例20: cfxCgErrorCallback

// this is a handy callback for the cg errors
void cfxCgErrorCallback()
{
		CGerror error = cgGetError();
			
#ifndef _LIB
		const char* report = cgGetErrorString(error);
		printf("CG Error Detected:  %s\n", report);

		assert(0 && report);
#endif
}
开发者ID:mDibyo,项目名称:docker-files,代码行数:12,代码来源:cfxError.cpp



注:本文中的cgGetError函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cgGetNamedParameter函数代码示例发布时间:2022-05-30
下一篇:
C++ cfw_send_message函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap