本文整理汇总了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;
}
示例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;
}
示例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;
}
示例4: Tile
Tile() : map_x(0), map_y(0)
{
image.create(Tile::WIDTH, Tile::HEIGHT);
texture.create(Tile::WIDTH, Tile::HEIGHT);
sprite.setTexture(texture);
}