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


C++ ObjectManager::Draw方法代码示例

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


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

示例1: main_loop_function

    void main_loop_function()
    {
	    ObjectManager * objManager = ObjectManager::Inst(); //create object manager




	    Cube CubeTest = Cube(1.0f,Vertex(0,0,0)); //create cube and push to object manager
	    objManager->GameObjects.push_back(CubeTest);
/*
	    GLfloat ambient[] = { .5f, .5f, .5f, 1.f };
	    GLfloat diffuse[] = { .5f, .5f, .5f, .6f };
	    GLfloat litepos[] = { 0, 2, 3, 1 };
	    GLfloat litepos2[] = { 0, -2, 5, 1 };

	    glPushMatrix();
	 		    	glLoadIdentity();
	 		    	glEnable(GL_LIGHTING);
	 		    	glLightfv(GL_LIGHT0, GL_AMBIENT,  ambient);
	 		    	glLightfv(GL_LIGHT0, GL_DIFFUSE,  diffuse);
	 		    	glLightfv(GL_LIGHT0, GL_POSITION, litepos);
	 		    	glEnable(GL_LIGHT0);

	 		    	glLightfv(GL_LIGHT1, GL_DIFFUSE,  diffuse);
	 		    	glLightfv(GL_LIGHT1, GL_POSITION, litepos2);
	 		    	glEnable(GL_LIGHT1);
	 		    	glPopMatrix();
*/

	    signed int buttonPause, wireframe, CurrentObj;
	    float RotationX, RotationY, RotationZ, Zoom, Size;
	    RotationX = RotationY = RotationZ = buttonPause = wireframe = CurrentObj = 0;
	    Zoom = -3;
	    Size = 5;
	    while( events() )
	    {
		    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		    glLoadIdentity();
		    glTranslatef(0,0, Zoom);
		    glRotatef(RotationX,RotationY, 45,45);
		    glPointSize(Size);


		    objManager->Draw();
		    glEnd();


		    SDL_GL_SwapBuffers();

		    // Check keypresses
		    buttonPause = buttonPause > 0 ? --buttonPause : buttonPause; //buffer to stop method being spammed cheap but it works...

		    if( key[SDLK_RIGHT] ){ RotationX-=0.5; }
		    if( key[SDLK_LEFT ] ){ RotationX+=0.5; }
		    if( key[SDLK_UP] ){ RotationY-=0.5; }
		    if( key[SDLK_DOWN ] ){ RotationY+=0.5; }
		    //if( key[SDLK_l] ) { glRotatef(45,4,0,0); } //>
		    if( key[SDLK_k] ) { RotationZ +=0.5; }
		    if( key[SDLK_i]) { Zoom += 0.1;}
		    if( key[SDLK_o]) { Zoom -= 0.1;}
		    if( key[SDLK_0]){RotationX = RotationY = RotationZ == 0;} //reset to center
		    if( key[SDLK_w])
		    {
		    	if( buttonPause == 0)
			    {
					switch(wireframe)
					{
					case 0:
						glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
						++wireframe;
						break;
					case 1:
						glPolygonMode( GL_FRONT_AND_BACK, GL_POINT );
						++wireframe;
						break;
					default:
						glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
						wireframe = 0;
						break;
					}
					buttonPause = 30;
			    }
		    }
		    if( key[SDLK_c])
			{
		    	if(buttonPause == 0)
			    {
#ifdef PrintToConsole
		    		cout << "Catnell clark called";
#endif
					objManager->GameObjects[CurrentObj].visible = false;
					GameObject _ngobj = CatmullClarkSubDivision().Subdivide(objManager->GameObjects[CurrentObj]);
					GameObject* ngobj = new GameObject(_ngobj);
					ngobj->init();
					objManager->GameObjects.push_back(*ngobj);
					++CurrentObj;
					buttonPause = 30;
			    }
			}
		    if( key[SDLK_a])
//.........这里部分代码省略.........
开发者ID:jps,项目名称:CI312-3DGraphicsAlgo,代码行数:101,代码来源:main.cpp


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