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


C++ Texture::create方法代码示例

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


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

示例1: main

int main() {
    sf::RenderWindow App(sf::VideoMode(imageWidth, imageHeight), 
        "SFML Graphics",sf::Style::Fullscreen);
    // This is the SFML application initialization with the app's parameters
    cx[0] = 255; cx[1] = 0; cx[2] = 0;
    // The initial colors for the shifting
    kradius = 0.1;
    imagen.create(imageWidth,imageHeight);
    mandtex.create(imageWidth,imageHeight);
    // The scaling factor, defined by the ranges in Real and Imaginary axis,
    // divided by the respective axis real length.
    mandelb.setOrigin(imageWidth/2,imageHeight/2);
    mandelb.setPosition(640,400);
    mandelb.scale(1.5,1.5);
    // Set the image positioning, centering and scaling.
    k.real = 0;
    k.imag = 0;
    // Original K seed values.
    dir = false;
    // Direction of scan over the complex plane
    mandel = false;
    // false if painting Julia Set, true if Mandelbrot Set.
    draw = true;
    // To tell the application to pause or continue drawing, its switched by
    // pressing the right click.
    while (App.isOpen()) {
        sf::Event Event;
        while (App.pollEvent(Event)) {
           // SFML works with an event loop
            if (Event.type == sf::Event::Closed){
            // If the window is closed, close the application
                App.close();
            }
            if( Event.type == Event.MouseButtonReleased
                && Event.mouseButton.button == sf::Mouse::Left){
            // If the left mouse is pressed and released, close the application
                App.close();
            }
            if( Event.type == Event.MouseButtonReleased
                && Event.mouseButton.button == sf::Mouse::Right){
            // If the right mouse is pressed and released, toggle randomness.
                draw = !draw;
            }
        }
        App.clear();
        if(!draw) continue;
        // If false, then stop animating and freeze in the last generated frame.
        resolve();
        //radialScan();
        horizontalScan();
        mandelb.setColor(sf::Color(cx[0], cx[1], cx[2]));
        // Shift the image hue.
        App.draw(mandelb);
        App.display();
    }
    return EXIT_SUCCESS;
}
开发者ID:zubie7a,项目名称:Shine_On_You_Crazy_Fractal,代码行数:57,代码来源:main.cpp

示例2: fillTexture

	void Texture::fillTexture(sf::Texture& texture, int width, int height, sf::Color color)
	{
		texture.create(width, height);

		int length = width * height * 4;
		sf::Uint8* buffer = new sf::Uint8[length];

		for(int i = 0; i < length; i += 4)
		{
			buffer[i] = color.r;
			buffer[i + 1] = color.g;
			buffer[i + 2] = color.b;
			buffer[i + 3] = color.a;
		}

		texture.update(buffer);

		delete buffer;
	}
开发者ID:WakaJawaka,项目名称:platformer,代码行数:19,代码来源:Texture.cpp

示例3: main

int main()
{
	//check if top and bottom flipped
	sf::RenderWindow window = sf::RenderWindow(sf::VideoMode(640, 640, 32), "Perlin Noise", sf::Style::Titlebar | sf::Style::Close);
	sf::RenderTexture renderTexture;
	glewExperimental = GL_TRUE;
	glewInit();
	srand(time(NULL));
	texture.create(640,640);
	const float PERSISTENCE = .5;
	float i = 0;
	int count = 0;
	for( i = 2; i < 129; i /= PERSISTENCE){
		std::cout << i;
		sf::Vector2f** gradients;
		gradients = new sf::Vector2f* [1 + (int)i];
		for(int j = 0; j < (int)i + 1; j++){
			gradients[j] = new sf::Vector2f[(int)i + 1];
		}
		genRandom(gradients, i, 1 / i);
		drawNoise(window, gradients, i, 1 / i);
		for(int j = 0; j < (int)i + 1; j++){
			delete[] gradients[j];
		}
		delete[] gradients;
		
		//std::cin.get();
	}

	display(window);
	
	std::cout << "draw";
	window.display();
	
	std::cin.get();
	return 0;
}
开发者ID:15kingben,项目名称:ChallengeProject,代码行数:37,代码来源:FractalPerlinNoise.cpp

示例4: Tile

 Tile() : map_x(0), map_y(0)
 {
   image.create(Tile::WIDTH, Tile::HEIGHT);
   texture.create(Tile::WIDTH, Tile::HEIGHT);
   sprite.setTexture(texture);
 }
开发者ID:abolibibelot,项目名称:biomes,代码行数:6,代码来源:main.cpp


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