Example #1
0
/**
* 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
Example #2
0
	// *******************************************************	
	// 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, "");
	}
Example #3
0
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();
    }
}
// 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);
}
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;
			}

	}
}
Example #6
0
// 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();
}
// 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);
}
Example #8
0
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();
}
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);
}
// 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);
}
Example #11
0
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();
}
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);
}
// 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);
}
Example #14
0
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();
}
Example #15
0
////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
    // Create the main window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML OpenGL");

    // Create a clock for measuring time elapsed
    sf::Clock Clock;

    // Set color and depth clear value
    glClearDepth(1.f);
    glClearColor(0.f, 0.f, 0.f, 0.f);

    // Enable Z-buffer read and write
    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);

    // Setup a perspective projection
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(90.f, 800.0f/600.0f, 1.f, 500.f);

    // set FPS limit to 60
    App.SetFramerateLimit(60);

    // 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;
}
Example #16
0
//--------------------------------------------------------------
void ofApp::draw() {
	#pragma region Gestion - Interface
	//////////////////////////////////////////////////
	m_selectedMenu.draw();

	ofSetColor(0, 0, 0);
	ofDrawBitmapString("F1 - Afficher l'interface", 10, (ofGetHeight() - 35));
	ofDrawBitmapString("Clic droit - Afficher le menu (et sous-menu)", 10, (ofGetHeight() - 15));
	//////////////////////////////////////////////////
	#pragma endregion

	//Primitives
	list<Primitive*>::iterator it = this->primitives.begin();

	for (it = this->primitives.begin(); it != this->primitives.end(); ++it)
	{
		string nomClasse = typeid(**it).name();

		if(nomClasse == "class _Line")
		{
			Primitive *Lparent = (*it);
			_Line *Lenfant = (dynamic_cast<_Line *>(Lparent));
			Lenfant->draw();
		}
		else if(nomClasse == "class Triangle")
		{
			Primitive *Tparent = (*it);
			Triangle *Tenfant = (dynamic_cast<Triangle *>(Tparent));
			Tenfant->draw();
		}
		else
			cout << "Mauvais typage sur Primitive";
	}

	//Formes
	list<Form*>::iterator it2 = this->forms.begin();

	for (it2 = this->forms.begin(); it2 != this->forms.end(); ++it2)
	{
		string nomClasse = typeid(**it2).name();

		if (nomClasse == "class Cube")
		{
			Form *Cparent = (*it2);
			Cube *Cenfant = (dynamic_cast<Cube *>(Cparent));
			if (Cenfant->GetTexture() != NULL)
			{
				Cenfant->drawOnCube();
			}
			else
			{
				Cenfant->draw();
			}
			
		}
		else if (nomClasse == "class Sphere")
		{
			Form *Sparent = (*it2);
			Sphere *Senfant = (dynamic_cast<Sphere *>(Sparent));
			if (Senfant->GetTexture() != NULL)
			{
				Senfant->drawWithTexture();
			}
			else
			{
				Senfant->draw();
			}
		}
		else if (nomClasse == "class Modele3D")
		{
			Form *Mparent = (*it2);
			Modele3D *Menfant = (dynamic_cast<Modele3D *>(Mparent));
			Menfant->draw();
		}
		else
			cout << "Mauvais typage sur Forme";
	}
}