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


C++ Cube::draw方法代码示例

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


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

示例1: RenderSceneCB

/**
* Acts as the display function for the window.
*/
static void RenderSceneCB()
{
	vector<glm::vec4> transformedVertices;

	// Clear the color buffer
	colorBuffer.clearColorBuffer();

	static float angle = glm::radians(45.0f);

	angle += glm::radians(0.1f);

	// Set Modeling transformation for the reference plane
	modelingTransformation = glm::translate(glm::vec3(0.0f, -3.0f, 0.0f));
	gameBoard.draw();




	// Set modeling transformation for the back right pyramid on top of cube
	modelingTransformation = glm::translate(glm::vec3(3.5f, -1.5f, -3.5f));
	pyramid.draw(color(0.502f, 0.0f, 0.502f, 1.0f));

	//cube under pyramid
	modelingTransformation = glm::translate(glm::vec3(3.5f, -2.5f, -3.5f));
	cube.draw(color(0.502f, 0.0f, 0.502f, 1.0f));




	// Set modeling transformation for the center pyramid
	modelingTransformation = glm::translate(glm::vec3(-0.5f, -2.5f, -0.5f));
	cube.draw(color(0.0f, 1.0f, 0.0f, 1.0f));

	// Set modeling transformation for the center pyramid
	modelingTransformation = glm::translate(glm::vec3(0.5f, -2.5f, -0.5f));
	cube.draw(color(1.0f, 1.0f, 0.0f, 1.0f));

	// red cube
	modelingTransformation = glm::translate(glm::vec3(0.0f, -2.5f, 0.5f));
	cube.draw(color(1.0f, 0.0f, 0.0f, 1.0f));

	// Set modeling transformation for the center pyramid
	modelingTransformation = glm::translate(glm::vec3(0.0f, -1.5f, 0.0f))*glm::rotate(4.0f, glm::vec3(0.0f, 1.0f, 0.0f));;
	cube.draw(color(0.0f, 0.0f, 1.0f, 1.0f));

	// Display the color buffer
	colorBuffer.showColorBuffer();

} // end RenderSceneCB
开发者ID:frazeeat,项目名称:CSE287,代码行数:52,代码来源:Lab9.cpp

示例2: display

	// *******************************************************	
	// display(): called once per frame, whenever OpenGL decides it's time to redraw.
	virtual void display( float animation_delta_time, Vector2d &window_steering )
	{		
		if( animate ) animation_time += animation_delta_time;

		update_camera( animation_delta_time , window_steering );

		int basis_id = 0;

		float atime = animation_time * 10;
		Matrix4d model_transform = Matrix4d::Identity();
		Matrix4d std_model = model_transform;

		*m_tree = Tree(Matrix4d::Identity(), atime);
		// Start coding here!!!! 
		m_bee->timepassby(atime);

		// Plane
		model_transform = std_model * Affine3d(Translation3d(5, -5, -60)).matrix();				// Position
		glUniform4fv(g_addrs->color_loc, 1, Vector4f(.0f, .7f, .9f, 1).data());			// Color
		m_plane->draw ( projection_transform, camera_transform, model_transform, "" );

		// Tree
		model_transform = std_model * Affine3d(Translation3d(4, -5, -40)).matrix();				// Position
		glUniform4fv( g_addrs->color_loc, 1, Vector4f( .0f, .6f ,.2f ,1 ).data());			// Color
		m_tree->draw( basis_id++, projection_transform, camera_transform, model_transform, "");

		// Leg
		model_transform = std_model * Affine3d(Translation3d(4, 1+2*(abs(20.0 - ((int)atime % 41)))/10, -40)).matrix();				// Position
		model_transform *= Affine3d(AngleAxisd((-PI / 60 * atime), Vector3d(0, 1, 0))).matrix();
		model_transform *= Affine3d(Translation3d(20, 0, 0)).matrix();
		m_bee->draw(basis_id++, projection_transform, camera_transform, model_transform, "");
	}
开发者ID:VincentUCLA,项目名称:Bee-demo-gl,代码行数:34,代码来源:Animation.cpp

示例3: exit_f

void
vox::RenderTask::main_() {
    //Set the state to STARTED
    {//lock
        boost::lock_guard<boost::mutex> lock(mutex_);
            
        state_ = STATE_STARTED;
        stateCondition_.notify_all();
    }//unlock

    auto context = window_->acquireGl();
    
    //This thread needs to be the one to clean up opengl -- do it after main_() ends
    util::on_scope_exit exit_f([this]() -> void {
        boost::lock_guard<boost::mutex> lock(mutex_);
            
        glProgram_.release();
        state_ = STATE_STOPPED;
        stateCondition_.notify_all();
    });
        
    //Setup opengl shaders, variables, etc
    initProgram_();

    Scene testScene;
    testScene.prepareScene(*glProgram_);
    testScene.bufferData(*glProgram_);

    Cube cube;
    cube.bufferData(*glProgram_);

    while (state_ == STATE_STARTED) {
        while (!tasks_.isEmpty()) {
            tasks_.dequeue()();
        }
        
        ::glClear( GL_COLOR_BUFFER_BIT   |
                   GL_DEPTH_BUFFER_BIT   |
                   GL_STENCIL_BUFFER_BIT
        );

       
 	    mvMatrix_.set(
		    Eigen::Affine3f(Eigen::Translation3f(1.0, 1.0, -5.0)).matrix()
	    );

        projMatrix_.set(projPersp_);      
        cube.draw();

 	    mvMatrix_.set(
		    (Eigen::Translation3f(10.0f, 10.0f, 0.0f)*
             Eigen::Scaling(100.0f, 100.0f, 1.0f)).matrix()
	    );

        projMatrix_.set(projOrtho_);
        testScene.drawScene();

        window_->swap();
    }
}
开发者ID:bkentel,项目名称:Vox,代码行数:60,代码来源:renderer.cpp

示例4: DrawHand

// This is used to draw both hands, but a different callback could be
// provided for each hand if desired.
void DrawHand(
    void* userData //< Passed into AddRenderCallback
    , osvr::renderkit::GraphicsLibrary library //< Graphics library context to use
    , osvr::renderkit::RenderBuffer buffers //< Buffers to use
    , osvr::renderkit::OSVR_ViewportDescription
        viewport //< Viewport we're rendering into
    , OSVR_PoseState pose //< OSVR ModelView matrix set by RenderManager
    , osvr::renderkit::OSVR_ProjectionMatrix
        projection //< Projection matrix set by RenderManager
    , OSVR_TimeValue deadline //< When the frame should be sent to the screen
    ) {
    // Make sure our pointers are filled in correctly.  The config file selects
    // the graphics library to use, and may not match our needs.
    if (library.OpenGL == nullptr) {
        std::cerr
            << "DrawHand: No OpenGL GraphicsLibrary, this should not happen"
            << std::endl;
        return;
    }
    if (buffers.OpenGL == nullptr) {
        std::cerr << "DrawHand: No OpenGL RenderBuffer, this should not happen"
                  << std::endl;
        return;
    }

    osvr::renderkit::GraphicsLibraryOpenGL* glLibrary = library.OpenGL;

    double projectionGL[16];
    osvr::renderkit::OSVR_Projection_to_OpenGL(projectionGL, projection);

    double viewGL[16];
    osvr::renderkit::OSVR_PoseState_to_OpenGL(viewGL, pose);
    handsCube.draw(projectionGL, viewGL);
}
开发者ID:ChristophHaag,项目名称:OSVR-RenderManager,代码行数:36,代码来源:RenderManagerOpenGLES2Example.cpp

示例5: myFinger

void myFinger(SDL_Event &ev)
{
	//finger1.draw();
	//finger2.draw();
	//finger3.draw();
	//poignet.draw();
	//avantPoignet.draw();
	bras.draw();

	if (ev.type == SDL_KEYDOWN)
		{
			switch(ev.key.keysym.sym)
			{
			case SDLK_LEFT:
				bras.rotate(Vector3d(0.0f, 0.0f, 1.0f));
				break;
			case SDLK_RIGHT:
				bras.rotate(Vector3d(0.0f, 0.0f, -1.0f));
				break;
			case SDLK_UP:
				avantPoignet.rotate(Vector3d(0.0f, 0.0f, 1.0f));
				break;
			case SDLK_DOWN:
				avantPoignet.rotate(Vector3d(0.0f, 0.0f, -1.0f));
				break;
			default:
				break;
			}

	}
}
开发者ID:cesarl,项目名称:GameDevLab-preselection,代码行数:31,代码来源:gdl-j1-2.cpp

示例6: drawCube

// draws solid cube and wire cube together. The wire color is always black
void drawCube(vec4 color)
{
    glUniform4fv( model_color, 1, color );
    myCube.draw();
    glUniform4fv( model_color, 1, vec4(0,0,0,1) );
    myWireCube.draw();
}
开发者ID:tepidry,项目名称:PastWork,代码行数:8,代码来源:main.cpp

示例7: RenderView

// Callbacks to draw things in world space, left-hand space, and right-hand
// space.
void RenderView(
    size_t eye //< Which eye we are rendering
    ,
    const osvr::renderkit::RenderInfo& renderInfo //< Info needed to render
    ,
    ID3D11RenderTargetView* renderTargetView,
    ID3D11DepthStencilView* depthStencilView) {
    // Make sure our pointers are filled in correctly.  The config file selects
    // the graphics library to use, and may not match our needs.
    if (renderInfo.library.D3D11 == nullptr) {
        std::cerr
            << "SetupDisplay: No D3D11 GraphicsLibrary, this should not happen"
            << std::endl;
        return;
    }

    auto context = renderInfo.library.D3D11->context;
    auto device = renderInfo.library.D3D11->device;
    float projectionD3D[16];
    float viewD3D[16];
    XMMATRIX identity = XMMatrixIdentity();

    // Set up to render to the textures for this eye
    context->OMSetRenderTargets(1, &renderTargetView, depthStencilView);

    // Set the viewport to cover the fraction of our render buffer that
    // this eye is responsible for.  This is always the same width and
    // height but shifts over by one width for each eye.
    CD3D11_VIEWPORT viewport(
        static_cast<float>(eye * renderInfo.viewport.width), 0,
        static_cast<float>(renderInfo.viewport.width),
        static_cast<float>(renderInfo.viewport.height));
    context->RSSetViewports(1, &viewport);

    // Make a grey background.  Only clear for the first eye,
    // because clear in DirectX 10 and 11 does not respect the
    // boundaries of the viewport.
    FLOAT colorRgba[4] = {0.3f, 0.3f, 0.3f, 1.0f};
    if (eye == 0) {
        context->ClearRenderTargetView(renderTargetView, colorRgba);
        context->ClearDepthStencilView(
            depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);
    }

    osvr::renderkit::OSVR_PoseState_to_D3D(viewD3D, renderInfo.pose);
    osvr::renderkit::OSVR_Projection_to_D3D(projectionD3D,
                                            renderInfo.projection);

    XMMATRIX _projectionD3D(projectionD3D), _viewD3D(viewD3D);

    // draw room
    simpleShader.use(device, context, _projectionD3D, _viewD3D, identity);
    roomCube.draw(device, context);
}
开发者ID:Armada651,项目名称:OSVR-RenderManager,代码行数:56,代码来源:RenderManagerD3DPresentSideBySideExample.cpp

示例8: draw

void ClockHand::draw() {
	Cube *chand = new Cube();
	glPushMatrix();
	
	switch (_tt) {
	case kTimeTypeSeconds:
			glRotated(_angle,1,0,0);
			glScaled(0.025,0.42,0.05);
			glTranslated(2.4,0,0);
			chAppearance->apply();
			chand->draw();
		break;

	case kTimeTypeMinutes:
			glRotated(_angle,1,0,0);
			glScaled(0.025,0.6,0.05);
			glTranslated(2.2,0,0);
			chAppearance->apply();
			chand->draw();
		break;

	case kTimeTypeHours:
		
			glRotated(_angle,1,0,0);
			glScaled(0.025,0.69,0.01);
			glTranslated(2.8,0,0);
			chAppearance->apply();
			chand->draw();
		
		break;

	default:

		break;
	}

	glPopMatrix();
}
开发者ID:joaodealmeida,项目名称:CGRA,代码行数:38,代码来源:ClockHand.cpp

示例9: DrawRightHand

void DrawRightHand(
    void* userData //< Passed into AddRenderCallback
    ,
    osvr::renderkit::GraphicsLibrary library //< Graphics library context to use
    ,
    osvr::renderkit::RenderBuffer buffers //< Buffers to use
    ,
    osvr::renderkit::OSVR_ViewportDescription
        viewport //< Viewport we're rendering into
    ,
    OSVR_PoseState pose //< OSVR ModelView matrix set by RenderManager
    ,
    osvr::renderkit::OSVR_ProjectionMatrix
        projection //< Projection matrix set by RenderManager
    ,
    OSVR_TimeValue deadline //< When the frame should be sent to the screen
    ) {
    // Make sure our pointers are filled in correctly.  The config file selects
    // the graphics library to use, and may not match our needs.
    if (library.D3D11 == nullptr) {
        std::cerr
            << "DrawRightHand: No D3D11 GraphicsLibrary, this should not happen"
            << std::endl;
        return;
    }
    if (buffers.D3D11 == nullptr) {
        std::cerr
            << "DrawRightHand: No D3D11 RenderBuffer, this should not happen"
            << std::endl;
        return;
    }

    auto context = library.D3D11->context;
    auto device = library.D3D11->device;
    auto renderTargetView = buffers.D3D11->colorBufferView;
    float projectionD3D[16];
    float viewD3D[16];
    XMMATRIX identity = XMMatrixIdentity();

    osvr::renderkit::OSVR_PoseState_to_D3D(viewD3D, pose);
    osvr::renderkit::OSVR_Projection_to_D3D(projectionD3D, projection);

    XMMATRIX _projectionD3D(projectionD3D), _viewD3D(viewD3D);

    // draw right hand
    simpleShader.use(device, context, _projectionD3D, _viewD3D, identity);
    handCube.draw(device, context);
}
开发者ID:Armada651,项目名称:OSVR-RenderManager,代码行数:48,代码来源:RenderManagerD3DExample3D.cpp

示例10: RenderView

// Callbacks to draw things in world space, left-hand space, and right-hand
// space.
void RenderView(
    const osvr::renderkit::RenderInfo& renderInfo //< Info needed to render
    ,
    ID3D11RenderTargetView* renderTargetView,
    ID3D11DepthStencilView* depthStencilView) {
    // Make sure our pointers are filled in correctly.  The config file selects
    // the graphics library to use, and may not match our needs.
    if (renderInfo.library.D3D11 == nullptr) {
        std::cerr
            << "SetupDisplay: No D3D11 GraphicsLibrary, this should not happen"
            << std::endl;
        return;
    }

    auto context = renderInfo.library.D3D11->context;
    auto device = renderInfo.library.D3D11->device;
    float projectionD3D[16];
    float viewD3D[16];
    XMMATRIX identity = XMMatrixIdentity();

    // Set up to render to the textures for this eye
    context->OMSetRenderTargets(1, &renderTargetView, depthStencilView);

    // Set up the viewport we're going to draw into.
    CD3D11_VIEWPORT viewport(static_cast<float>(renderInfo.viewport.left),
                             static_cast<float>(renderInfo.viewport.lower),
                             static_cast<float>(renderInfo.viewport.width),
                             static_cast<float>(renderInfo.viewport.height));
    context->RSSetViewports(1, &viewport);

    // Make a grey background
    FLOAT colorRgba[4] = {0.3f, 0.3f, 0.3f, 1.0f};
    context->ClearRenderTargetView(renderTargetView, colorRgba);
    context->ClearDepthStencilView(
        depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);

    osvr::renderkit::OSVR_PoseState_to_D3D(viewD3D, renderInfo.pose);
    osvr::renderkit::OSVR_Projection_to_D3D(projectionD3D,
                                            renderInfo.projection);

    XMMATRIX xm_projectionD3D(projectionD3D), xm_viewD3D(viewD3D);

    // draw room
    simpleShader.use(device, context, xm_projectionD3D, xm_viewD3D, identity);
    roomCube.draw(device, context);
}
开发者ID:ReliaSolve,项目名称:OSVR-RenderManager,代码行数:48,代码来源:SpinCubeD3D.cpp

示例11: render

void render()
{
	setWindow(-2.0 * 64.0/48.0, 2.0 * 64.0/48.0, -2.0, 2.0, 2, -100);
	setViewport(0,0,640,480);
	setCamera(0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

	glEnable( GL_DEPTH_TEST );
	glDepthFunc( GL_LEQUAL );
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

	glClear(GL_COLOR_BUFFER_BIT);
	glClear(GL_DEPTH_BUFFER_BIT);
	glColor3d(0, 0, 0);

	cube.draw();

	glFlush();
}
开发者ID:pkbigmarsh,项目名称:tic-tac-toe-cubed,代码行数:18,代码来源:main.cpp

示例12: drawSkybox

void GraphicsSubsystem::drawSkybox(const Cube &cube)
{
	GLuint skyboxpr = shaders["skybox"];
	glCullFace(GL_FRONT);
	glUseProgram(skyboxpr);

	glm::mat4 modelToWorld = cube.getModelToWorldMat();

	glUniformMatrix4fv(programUniforms[skyboxpr]["modelToWorldMatrix"], 1, GL_FALSE, glm::value_ptr(modelToWorld));

	glActiveTexture(GL_TEXTURE0 + texUnits["room"]);  
	glBindTexture(GL_TEXTURE_CUBE_MAP, textures["room"]);
	
	cube.draw();
	
	glBindTexture(GL_TEXTURE_CUBE_MAP, 0);

	glUseProgram(0);
	glCullFace(GL_BACK);
}
开发者ID:Darkxiv,项目名称:master,代码行数:20,代码来源:graphicsSubsytem.cpp

示例13: RenderView

// Callbacks to draw things in world space, left-hand space, and right-hand
// space.
void RenderView(
    const OSVR_RenderInfoD3D11& renderInfo //< Info needed to render
    ,
    ID3D11RenderTargetView* renderTargetView,
    ID3D11DepthStencilView* depthStencilView) {

    auto context = renderInfo.library.context;
    auto device = renderInfo.library.device;
    float projectionD3D[16];
    float viewD3D[16];
    XMMATRIX identity = XMMatrixIdentity();

    // Set up to render to the textures for this eye
    context->OMSetRenderTargets(1, &renderTargetView, depthStencilView);

    // Set up the viewport we're going to draw into.
    CD3D11_VIEWPORT viewport(static_cast<float>(renderInfo.viewport.left),
                             static_cast<float>(renderInfo.viewport.lower),
                             static_cast<float>(renderInfo.viewport.width),
                             static_cast<float>(renderInfo.viewport.height));
    context->RSSetViewports(1, &viewport);

    // Make a grey background
    FLOAT colorRgba[4] = {0.3f, 0.3f, 0.3f, 1.0f};
    context->ClearRenderTargetView(renderTargetView, colorRgba);
    context->ClearDepthStencilView(
        depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);

    OSVR_PoseState_to_D3D(viewD3D, renderInfo.pose);
    OSVR_Projection_to_D3D(projectionD3D,
      renderInfo.projection);

    XMMATRIX xm_projectionD3D(projectionD3D), xm_viewD3D(viewD3D);

    // draw room
    simpleShader.use(device, context, xm_projectionD3D, xm_viewD3D, identity);
    roomCube.draw(device, context);
}
开发者ID:sensics,项目名称:OSVR-RenderManager,代码行数:40,代码来源:RenderManagerD3DCAPIExample.cpp

示例14: draw

void DockLayout::draw(){

	glPushMatrix();
	{
		glViewport(x, ScreenH - y - LayoutH, LayoutW, LayoutH); 
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();

		glFrustumf(-1.0f, 1.0f, -1.0f * Aspect_Ratio, 1.0f * Aspect_Ratio, 1.0f, 20.0f);   

		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();


		//this->drawLayoutLine();   // 레이아웃 범위 선 그리기


		// 바닥을 그려준다.
		floor->setTexture(0,floorTexture);		
		floor->setPosition(0.0f, -0.7, -4.3);
		floor->setScale(7.0f, 0.2f, 1.5f);
		floor->setRotate(0.0f,0.0f,0.0f);
		floor->draw();





		std::vector<Object*>::iterator it;
		std::vector<int>::iterator it_order;


		if(objectLen == 1){		
			it = objectData.begin();
			(*it)->setPosition( 0.0f, 0.0f, -5.0f);
			(*it)->setScale(1.0f,1.0f,1.0f);
			(*it)->setRotate(0.0f, non_targetAngleY, 0.0f);

			(*it)->draw();

		}else{
			int i = 0;
			float interval = (6 / ((float)objectLen - 1.0f));
			for(it = objectData.begin(), it_order = order.begin() ; it != objectData.end() ;i++, it++,it_order++ ){
				(*it)->setRotate(10.0f,0,0);

				if((*it_order) == 0){                            // 선택되지 않은 것
					(*it)->setScale(1.0f, 1.0f, 1.0f);
					(*it)->setPosition( -3.0f + interval * i, 0.0f, -4.3f);
					
					non_targetAngleY+=0.1f;
					
					if((*it)->getObjectType() == 0 || (*it)->getObjectType() == 2 || (*it)->getObjectType() == 3)
						(*it)->setRotate(0.0f, non_targetAngleY, 0.0f);
					else if((*it)->getObjectType() == 1)
						(*it)->setRotate(0.0f, 0.0f, non_targetAngleY);
				}
				else if((*it_order) == 1){                       // 선택된 것
					focusedObjectType = (*it)->getObjectType();
					focusedObjectId = (*it)->getObjectId();

					touchManager->getClickedObject(	(*it)->getObjectType());
					float* temp = this->jumpAni();
					(*it)->setScale(temp[3], temp[4], temp[5]);
					(*it)->setPosition( -3.0f + interval * i, temp[1], -4.3f);
					if((*it)->getObjectType() == 0)
						(*it)->setRotate(0.0f, 0, 0.0f);
					else
						(*it)->setRotate(0, 0, 0);

				}else if((*it_order) == 2){
	

					touchManager->getClickedObject(	(*it)->getObjectType());
					(*it)->setScale(1.0f, 1.0f, 1.0f);
					(*it)->setPosition( targetX, targetY, targetZ);
					(*it)->setRotate(targetAngleX, targetAngleY, targetAngleZ);
					//LOG(" target %f,%f,%f,",targetX, targetY, targetZ);
				}

				(*it)->draw();
			}
		}
	}
	glPopMatrix();
}
开发者ID:Kang3498,项目名称:auidt,代码行数:86,代码来源:DockLayout.cpp

示例15: main


//.........这里部分代码省略.........
    // Preserve OpenGl States
    App.PreserveOpenGLStates(true);

    // Create Cube
    Cube c;

    // Create design
    ygui::DesignButton d(200.0, 50.0);
    ygui::DesignButton d1(200.0, 50.0);
    ygui::DesignButton d2(50.0, 200.0);
    ygui::DesignButton d3(50.0, 200.0);

    // Create Button
    CubeButtonUp	test(d, &c);
    CubeButtonDown	test1(d1, &c);
    CubeButtonLeft	test2(d2, &c);
    CubeButtonRight	test3(d3, &c);

    // Create scene
    ygui::Scene	scene;

    // Set button setting
    test.setX(300.0);
    test.setY(50.0);
    test.setText("Up");
    test.setTextColor(0, 0, 0);
    test.setTextY(3.0);
    test.setTextX(80.0);

    test1.setX(300.0);
    test1.setY(500.0);
    test1.setText("Down");
    test1.setTextColor(0, 0, 0);
    test1.setTextY(3.0);
    test1.setTextX(65.0);

    test2.setX(50.0);
    test2.setY(200.0);
    test2.setText("Left");
    test2.setTextColor(0, 0, 0);
    test2.setTextX(5.0);
    test2.setTextY(125.0);
    test2.setTextRotation(90.0f);

    test3.setX(700.0);
    test3.setY(200.0);
    test3.setText("Right");
    test3.setTextColor(0, 0, 0);
    test3.setTextX(45.0);
    test3.setTextY(55.0);
    test3.setTextRotation(270.0f);

    scene.addObject("1", &test);
    scene.addObject("2", &test1);
    scene.addObject("3", &test2);
    scene.addObject("4", &test3);

    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();

            // Resize event : adjust viewport
            if (Event.Type == sf::Event::Resized)
                glViewport(0, 0, Event.Size.Width, Event.Size.Height);
        }

        // Set the active window before using OpenGL commands
        // It's useless here because active window is always the same,
        // but don't forget it if you use multiple windows or controls
        App.Clear();
	App.SetActive();
       
        // Clear color and depth buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
           
        // Apply some transformations
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(0.f, 0.f, -200.f);
	c.draw(Clock);

	scene.draw(App);

        // Finally, display rendered frame on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}
开发者ID:azokal,项目名称:YAOSGUI,代码行数:101,代码来源:window-opengl.cpp


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