当前位置: 首页>>代码示例>>C++>>正文


C++ CrtRender::Init方法代码示例

本文整理汇总了C++中CrtRender::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ CrtRender::Init方法的具体用法?C++ CrtRender::Init怎么用?C++ CrtRender::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CrtRender的用法示例。


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

示例1: WinMain

//----------------------------------------------------------------------------------------------------
// Standard windows mainline, this is the program entry point
//
CrtInt32 WINAPI WinMain(	HINSTANCE	hInstance,		
					HINSTANCE	hPrevInstance,	
					LPSTR		lpCmdLine,			
					CrtInt32			nCmdShow)	
{
	(void)hPrevInstance; // Avoid warnings
	(void)nCmdShow; // Avoid warnings
	(void)hInstance; // Avoid warnings

#ifndef NO_DEVIL
	ilInit();
#endif

	MSG		msg;									
	BOOL	done=FALSE;								
	
	// Avoid warnings later
	msg.wParam = 0;

	// Turns on windows heap debugging
#if HEAP_DEBUG
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF /*| _CRTDBG_DELAY_FREE_MEM_DF*/);
#endif

	// Ask The User Which Screen Mode They Prefer
	//	if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
	{
		fullscreen=FALSE;							
	}

	// Set the default screen size
	_CrtRender.SetScreenWidth( 640);
	_CrtRender.SetScreenHeight( 480);

	// Create an OpenGL Window
	if (!CreateGLWindow("Collada Viewer for PC", _CrtRender.GetScreenWidth(), _CrtRender.GetScreenHeight(),32,fullscreen))
	{
		return 0;									
	}
	
	// Turn data dumping (debug) off
	//CrtBool dumpData = CrtFalse; 

	// Initialize the renderer
	// !!!GAC for compatibility with the new COLLADA_FX code, Init now forces UsingCg and UsingVBOs to
	// !!!GAC false.  It also calls CrtInitCg, creating the CG context and calling cgGLRegisterStates.
	// !!!GAC All these things are currently required for the cfx rendering path to work, changing them
	// !!!GAC may cause problems.  This is work in progress and will be much cleaner when the refactor is done.
	
	_CrtRender.Init();
	//_CrtRender.SetRenderDebug( CrtTrue ); 

	// !!!GAC kept for reference, changing these may cause problems with the cfx include path
	//_CrtRender.SetUsingCg( CrtFalse );
	// Turn off VBOs (the GL skinning path doesn't work with VBOs yet)
	_CrtRender.SetUsingVBOs( CrtTrue ); 
	_CrtRender.SetUsingNormalMaps( CrtTrue ); 	
	//_CrtRender.SetRenderDebug( CrtTrue ); 
	//_CrtRender.SetUsingShadowMaps(CrtTrue);

	// We might get a windows-style path on the command line, this can mess up the DOM which expects
	// all paths to be URI's.  This block of code does some conversion to try and make the input
	// compliant without breaking the ability to accept a properly formatted URI.  Right now this only
	// displays the first filename
	char
		file[512],
		*in = lpCmdLine,
		*out = file;
	*out = NULL;
	// If the first character is a ", skip it (filenames with spaces in them are quoted)
	if(*in == '\"')
	{
		in++;
	}
	if(*(in+1) == ':')
	{
		// Second character is a :, assume we have a path with a drive letter and add a slash at the beginning
		*(out++) = '/';
	}
	int i;
	for(i =0; i<512; i++)
	{
		// If we hit a null or a quote, stop copying.  This will get just the first filename.
		if(*in == NULL || *in == '\"')
			break;
		// Copy while swapping backslashes for forward ones
		if(*in == '\\')
		{
			*out = '/';
		}
		else
		{
			*out = *in;
		}
		in++;
		out++;
	}
//.........这里部分代码省略.........
开发者ID:mDibyo,项目名称:docker-files,代码行数:101,代码来源:mainPC.cpp

示例2: onInit

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;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例3: main

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
int main(int LArgC, char** LArgV)
{
    atexit(DestroyCrt);		// Need this, because old GLUT never returns from glutMainLoop()

    // Create an OpenGL Window
    if (!CreateGLWindow(LArgC, LArgV, (char*)"COLLADA_DOM Sample Viewer", _CrtRender.GetScreenWidth(), _CrtRender.GetScreenHeight()))
    {
        return 0;
    }

    // Initialize the renderer
    // !!!GAC for compatibility with the new COLLADA_FX code, Init now forces UsingCg and UsingVBOs to
    // !!!GAC false.  It also calls CrtInitCg, creating the CG context and calling cgGLRegisterStates.
    // !!!GAC All these things are currently required for the cfx rendering path to work, changing them
    // !!!GAC may cause problems.  This is work in progress and will be much cleaner when the refactor is done.

    _CrtRender.Init();

    _CrtRender.SetUsingVBOs( CrtTrue );
    _CrtRender.SetUsingNormalMaps( CrtTrue );

    // Load the file name provided on the command line
    if(LArgC > 1 && LArgV[1])
    {
        printf("%s(): Loading %s...\n", __FUNCTION__, LArgV[1]);
        fflush(stdout);
        if ( !_CrtRender.Load( LArgV[1] ))
        {
            exit(0);
        }
    }
    else
    {
        printf("%s(): Loading default document cage.dae... \n", __FUNCTION__);
        fflush(stdout);
        if ( !_CrtRender.Load( "cage.dae" ))
        {
            exit(0);
        }
    }

    // This block of code shows how to enumerate all the effects, get their parameters and then
    // get their UI information.
#if 1
    if(_CrtRender.GetScene())
    {
        // Get the scene and setup to iterate over all the effects stored in the cfxLoader
        CrtScene *scene = _CrtRender.GetScene();


        std::map<std::string, cfxEffect*>::iterator effectIterator;
        effectIterator = scene->cfxEffects.begin();
        // Iterate over all the effects
        while(effectIterator != scene->cfxEffects.end())
        {
            // This is the effect name you would use in a UI
            CrtPrint("Effect name %s\n", effectIterator->first.c_str());
            cfxEffect *thiscfxEffect = effectIterator->second;
            CGeffect thisCGEffect = thiscfxEffect->getEffect();
            CGparameter thisCGParameter = cgGetFirstEffectParameter(thisCGEffect);
            while(thisCGParameter != NULL)
            {
                // This is the parameter name you would use in the UI
                const char *parameterName = cgGetParameterName(thisCGParameter);
                // This is for the example of how to tweek a parameter (doesn't work yet)
                if(CrtCmp(parameterName, "Amplitude"))
                {
                    // Capture the parameter and save it in a global, in a GUI you would
                    // save this handle in the widget so it would know what to tweek.
                    amplitudeGlobalParameter = thisCGParameter;
                }
#if 0
                // This is here for debugging, it iterates over all the annotations and prints them out
                // so you can see what's in them.  Normally this code will be turned off.
                CrtPrint("  Parameter name %s\n",parameterName);
                CGannotation dbgCGAnnotation = cgGetFirstParameterAnnotation(thisCGParameter);
                while(dbgCGAnnotation != NULL)
                {
                    const char *annotationName = cgGetAnnotationName(dbgCGAnnotation);
                    CrtPrint("      Annotation: %s",annotationName);
                    if(cgGetAnnotationType(dbgCGAnnotation) == CG_STRING)
                    {
                        const char *annotationString = cgGetStringAnnotationValue(dbgCGAnnotation);
                        CrtPrint(" value: %s\n",annotationString);
                    }
                    else if(cgGetAnnotationType(dbgCGAnnotation) == CG_FLOAT)
                    {
                        int nvalues;
                        const float *value = cgGetFloatAnnotationValues(dbgCGAnnotation, &nvalues);
                        CrtPrint(" value: %f\n",*value);  // Assume there is one value
                    }
                    else
                    {
                        CrtPrint("\n");
                    }
                    dbgCGAnnotation = cgGetNextAnnotation(dbgCGAnnotation);
                }
#endif
//.........这里部分代码省略.........
开发者ID:sbarthelemy,项目名称:collada-dom,代码行数:101,代码来源:main.cpp


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