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


C++ RenderTexture::clear方法代码示例

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


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

示例1: draw

	void draw(sf::RenderTarget &tg)
	{
		if (first)
		{
			rt.clear();
			rt.draw(sprite);
			rt.draw(logo);
			if (logo.getPosition().y == 0.0)rt.draw(press);

			if (check && timer.getElapsedTime().asSeconds() < 1)
			{
				if ((int)(rand() % 10) == 3) rt.clear(sf::Color::White);
			}
		}
		else
		{
			rt.clear(sf::Color::White);
			rt.draw(system);
			rt.draw(back2);
			rt.draw(pointer);
		}
		rt.display();
		sm.draw(rt, tg);
		if (first) tg.draw(v);
	};
开发者ID:TideSofDarK,项目名称:grief-trigger,代码行数:25,代码来源:c_main.cpp

示例2: run

	void run()
	{
		while (m_window.isOpen())
		{
			sf::Event event;
			while (m_window.pollEvent(event))
			{
				if (event.type == sf::Event::Closed)
					m_window.close();
			}

			// Update the position of the 'flashlight' to the current mouse position
			m_pos = static_cast<sf::Vector2f>(sf::Mouse::getPosition(m_window));
			m_flashlight.setPosition(m_pos);

			// Stance-out the 'flashlight' circle
			m_layer.clear();
			m_layer.draw(m_flashlight, sf::BlendMultiply);
			m_layer.display();

			m_window.clear(sf::Color::Blue);

			// Draw the layer sprite on top of the 'scene'
			m_window.draw(m_rect);
			m_window.draw(m_sprite);

			m_window.display();
		}
	}
开发者ID:saurabh1907,项目名称:2D-RPG-Game,代码行数:29,代码来源:lights.cpp

示例3: render

bool AppState::render(sf::RenderTexture& texture, int frame)
{
  texture.clear();

  if (m_preDesktopRenderFunctor) m_preDesktopRenderFunctor(texture, frame);
  the_desktop.render(texture, frame);
  if (m_postDesktopRenderFunctor) m_postDesktopRenderFunctor(texture, frame);

  texture.display();
  return true;
}
开发者ID:glindsey,项目名称:MetaHack,代码行数:11,代码来源:AppState.cpp

示例4: generateSpot

	void generateSpot()
	{
		m_flashlightTexture.clear();

		// Draw 6 circles with increasing transparency
		for (unsigned int i = 0; i < 6; ++i)
		{
			sf::CircleShape temp(30.f - (i*2.f));
			temp.setOrigin(sf::Vector2f(30.f - (i*2.f), 30.f - (i*2.f)));
			temp.setFillColor(sf::Color(255, 255, 255, 101 - (i * 20)));
			temp.setPosition(sf::Vector2f(30.f, 30.f));

			m_flashlightTexture.draw(temp, sf::BlendNone);
		}

		//m_flashlightTexture.display();
	}
开发者ID:saurabh1907,项目名称:2D-RPG-Game,代码行数:17,代码来源:lights.cpp

示例5: vertices

		void        draw      (sf::RenderTarget & target, sf::RenderStates states = sf::RenderStates::Default) const
		{
			lightBuffer.clear();
			texture.display();
			states.texture = &texture.getTexture();
			for (const auto & light : lights)
			{
				light.draw(lightBuffer, getView(), states);
			}
			sf::Vector2f dimensions = sf::Vector2f(texture.getSize());
			sf::VertexArray vertices(sf::Quads, 4);
			vertices[0] = sf::Vertex(sf::Vector2f(0.f, 0.f), sf::Color(255, 255, 255, minAlpha), sf::Vector2f(0.f, 0.f));
			vertices[1] = sf::Vertex(sf::Vector2f(dimensions.x, 0.f), sf::Color(255, 255, 255, minAlpha), sf::Vector2f(dimensions.x, 0.f));
			vertices[2] = sf::Vertex(dimensions, sf::Color(255, 255, 255, minAlpha), dimensions);
			vertices[3] = sf::Vertex(sf::Vector2f(0.f, dimensions.y), sf::Color(255, 255, 255, minAlpha), sf::Vector2f(0.f, dimensions.y));
			lightBuffer.draw(vertices, states);
			lightBuffer.display();
			target.draw(sf::Sprite(lightBuffer.getTexture()));
		}
开发者ID:DeMoully,项目名称:SFML_Extensions,代码行数:19,代码来源:LightMap.hpp

示例6:

		void        clear     (const sf::Color & color = sf::Color::Black)
		{
			texture.clear(color);
		}
开发者ID:DeMoully,项目名称:SFML_Extensions,代码行数:4,代码来源:LightMap.hpp

示例7: onRender

  void onRender(sf::RenderWindow &window, double time, double deltaTime)
  {
    double thermalViewYawRange = thermalViewPitchRange/windowHeight*windowWidth;
    double vxmin = 0.0;//viewYaw-thermalViewYawRange/2.0;
    double vxmax = 360.0;//viewYaw+thermalViewYawRange/2.0;
    double vymin = 0;//viewPitch-thermalViewPitchRange/2.0;
    double vymax = thermalObservedPitchRange;//viewPitch+thermalViewPitchRange/2.0;

    double cursorTemp = 0.0;
    double cursorOverlap = 0.0;

    window.clear(sf::Color::Black);

    sf::RectangleShape pixel;
    //pixel.setSize(sf::Vector2f(thermalViewPixelSize, thermalViewPixelSize));

    if(sf::Keyboard::isKeyPressed(sf::Keyboard::P)) {
      viewImage.clear();
      for(int px = 0; px < windowWidth; px += thermalViewPixelSize) {
        for(int py = 0; py < windowHeight; py += thermalViewPixelSize) {
          updatedPixels.push_back(sf::Vector2<int>(px, py));
        }
      }
    } else if(sf::Keyboard::isKeyPressed(sf::Keyboard::C)) {
      /*std::vector<RectTree<SensorReading>::RectResult> resList;
      readingsTree.retrieveAllRects(resList);
      readingsTree.removeResults(resList);*/
      viewImage.clear();
      readingsTree.reset(0.0, 0.0, 360.0, thermalObservedPitchRange, 4);
    }

    //std::deque< sf::Vector2<int> >::iterator iter = updatedPixels.begin();
    auto iter = updatedPixels.begin();
    for(; iter != updatedPixels.end(); iter++) {
      int px = iter->x, py = iter->y;

      double vx = vxmin+(vxmax-vxmin)*((double)px/(double)windowWidth );
      double vy = vymin+(vymax-vymin)*((double)py/(double)windowHeight);
      double vw = thermalPixelSizeYaw;
      double vh = thermalPixelSizePitch;

      std::vector<RectTree<SensorReading>::RectResult> resList;
      readingsTree.findRectsAtPoint(vx, vy, resList);

      std::vector<RectTree<SensorReading>::RectResult> delList;

      pixel.setPosition(sf::Vector2f(px, py));
      pixel.setSize(sf::Vector2f(
        thermalViewPixelSize,
        thermalViewPixelSize //(double)thermalViewPixelSize/(double)windowWidth*(double)windowHeight
      ));

      double temp = 0.0; int count = 0; double sum = 0;
      RectTree<SensorReading>::RectResult *oldestRes = NULL; double oldestTime = 0.0;
      std::vector<RectTree<SensorReading>::RectResult>::iterator iter = resList.begin();
      for(; iter != resList.end(); iter++) {
        RectTree<SensorReading>::RectResult &res = *iter;
        double age = time-res.rect->value.time;
        /*if(res.rect->value.time < oldestTime || oldestRes == NULL) {
          oldestTime = res.rect->value.time;
          oldestRes = &res;
        }*/
        double ageScalar = 1.0/(1.0+age);
        temp += res.rect->value.temp*ageScalar;
        sum += ageScalar;
        count++;
      }
      if(count > 40) {
        delList.insert(delList.end(), resList.begin(), resList.begin()+10);
      }
      temp /= sum;
      if(count > 0) {
        pixel.setFillColor(getThermalPixelColor(temp));
      } else {
        pixel.setFillColor(sf::Color::Black);
      }
      viewImage.draw(pixel);
      if(
            cursorX > px && cursorX < px+thermalViewPixelSize
        &&  cursorY > py && cursorY < py+thermalViewPixelSize
      ) {
        cursorTemp = temp;
      }

      readingsTree.removeResults(delList);
    }
    int updatedPixelCount = updatedPixels.size();
    updatedPixels.clear();

    viewImage.display();
    sf::Sprite sprite(viewImage.getTexture());
    window.draw(sprite);


    if(0) {
      std::vector<RectTree<SensorReading>::RectResult> resList;
      readingsTree.retrieveAllRects(resList);

      std::vector<RectTree<SensorReading>::RectResult>::iterator iter = resList.begin();
      for(; iter != resList.end(); iter++) {
//.........这里部分代码省略.........
开发者ID:Deco,项目名称:SEP-CTs,代码行数:101,代码来源:main.cpp

示例8: main


//.........这里部分代码省略.........
		if(!anyEvent){
			leftPress = false;
			rightPress = false;
			upPress = false;
			downPress = false;
		}
		anyEvent = false;


		//for(int x = 0; x < 64; ++x){
		//	for(int y = 0; y < 64; ++y){
		sf::Time t = clock.getElapsedTime();
		if(t.asMilliseconds() > speed){
			updatePos(*head);
			updateDir(*head);
			soundCount++;
			if(soundCount > 5){
				sound.play();
				soundCount = 0;
			}
			clock.restart();
			if(!gameOver)
				gameOver = !checkBounds(*head);
			checkIntersect(*head);//gen blacklist
			if(addCount > 0){
				--addCount;
				Node* end = getEnd(*head);
				switch(end->dir){
				case UP:
					end->next = new Node(end->x, end->y - 1, end->dir);//backwards
					break;
				case DOWN:
					end->next = new Node(end->x, end->y + 1, end->dir);//backwards
					break;
				case LEFT:
					end->next = new Node(end->x + 1, end->y, end->dir);//backwards
					break;
				case RIGHT:
					end->next = new Node(end->x - 1, end->y, end->dir);//backwards
					break;}
				end->next->next = nullptr;
			}

			if(newFood){
				addCount = 4;
				if(speed >100){
				speed *= .95;
				//sound.setPitch(sound.getPitch()*1.1);
				}
				foodX = rand() % SIZE;
				foodY = rand() % SIZE;
				while(blacklist[foodX][foodY] == true){
					foodX = rand() % SIZE;
					foodY = rand() % SIZE;
				}

				newFood = false;
			}
		}
		if(gameOver){
			window.draw(sprite);
			window.display();
			gameOver = false;
			sf::Time t = sf::seconds(.5);
			for(int i = 0; i < 6; ++i)
			sf::sleep(t);
			delete head->next;
			head->x = SIZE/2;
			head->y = SIZE/2;
			head->next = new Node(SIZE/2,SIZE/2-1,UP);
			head->next->next = new Node(SIZE/2,SIZE/2 - 2,UP);
			head->next->next->next = new Node(SIZE/2,SIZE/2-3,UP);
			head->next->next->next->next = new Node(SIZE/2,SIZE/2-4,UP);
			head->next->next->next->next->next = nullptr;
			float speed = 150;
			foodX = SIZE*.75;
			foodY = SIZE*.75;
			newFood = false;
		}
		if(!gameOver){
			displaySnake(*head);
			
			sf::RectangleShape draw1 = sf::RectangleShape(sf::Vector2f(640/SIZE,640/SIZE));
			draw1.setPosition(sf::Vector2f(foodX * (640/SIZE), foodY * (640/SIZE)));
			draw1.setFillColor(sf::Color::White);
			renderTexture.draw(draw1);
		}
		sf::Texture texture = renderTexture.getTexture();
		// draw it to the window
		sf::Sprite sprite(texture);
		window.draw(sprite);
		window.display();
		renderTexture.clear();
		for(int x = 0; x < SIZE; x++){
			for( int y = 0; y < SIZE; y++){
				blacklist[x][y] = false;
			}
		}
	}
}
开发者ID:15kingben,项目名称:ChallengeProject,代码行数:101,代码来源:Snake.cpp


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