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


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

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


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

示例1: resolve

void resolve() {
    shifter(cx);
    // Shift the palette for this iteration.
    for(int y = 0; y < imageHeight; ++y) {
    // In the imaginary axis...
        double c_im = MaxIm - (y * Im_factor);
        // The current imaginary is the max value minus the scaled vertical iterator.
        for(int x=0; x<imageWidth; ++x) {
        // In the real axis...
            double c_re = MinRe + (x * Re_factor);
            // The current real is the min value plus the scaled horizontal iterator.
            c.real = c_re;
            c.imag = c_im;
            // Change the real and imaginary components of the global complex variable c.
            int iters = fractal();
            // The returned value is the escape iterations for the current coordinate
            col = sf::Color(iters * 4, iters * 4, iters * 4, 255);
            // Create a color based on the current scape iterations.
            imagen.setPixel(x, y, col);
            // Set the image pixel at this current location to that color.
        }
    }
    mandtex.update(imagen);
    // Update the texture.
    mandelb.setTexture(mandtex);
    // Set the texture to the window.
}
开发者ID:zubie7a,项目名称:Shine_On_You_Crazy_Fractal,代码行数:27,代码来源:main.cpp

示例2: update_image

 void update_image(int x, int y)
 {
   map_x = x;
   map_y = y;
   details::generate_noise(image, (float)map_x * Tile::WIDTH, (float)map_y * Tile::HEIGHT);
   texture.update(image);
 }
开发者ID:abolibibelot,项目名称:biomes,代码行数:7,代码来源:main.cpp

示例3: updateGraphics

void updateGraphics(sgb::Chip8 &c8) {
	//window.clear();
	for (int i = 0; i < 64; i++) {
		for (int j = 0; j < 32; j++) {
			int currpos = i + j*64;
			int on = c8.gfx[currpos];
			if (on == 1)
				back.setPixel(i, j, sf::Color::Green);
			else
				back.setPixel(i, j, sf::Color::Black);
		}
	}
	c8.drawFlag = false;
	backtext.update(back);
	window.draw(backshape);
	window.display();
}
开发者ID:SGBon,项目名称:emu-chip8,代码行数:17,代码来源:Main.cpp

示例4: 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

示例5: preload

void FeVideoImp::preload()
{
	{
		sf::Lock l( image_swap_mutex );

		if (rgba_buffer[0])
			av_freep(&rgba_buffer[0]);

		int ret = av_image_alloc(rgba_buffer, rgba_linesize,
				disptex_width, disptex_height,
				AV_PIX_FMT_RGBA, 1);
		if (ret < 0)
		{
			std::cerr << "Error allocating image during preload" << std::endl;
			return;
		}
	}

	bool keep_going = true;
	while ( keep_going )
	{
		AVPacket *packet = pop_packet();
		if ( packet == NULL )
		{
			if ( !m_parent->end_of_file() )
				m_parent->read_packet();
			else
				keep_going = false;
		}
		else
		{
			//
			// decompress packet and put it in our frame queue
			//
			int got_frame = 0;
#if (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 55, 45, 0 ))
			AVFrame *raw_frame = av_frame_alloc();
			codec_ctx->refcounted_frames = 1;
#else
			AVFrame *raw_frame = avcodec_alloc_frame();
#endif

			int len = avcodec_decode_video2( codec_ctx, raw_frame,
				&got_frame, packet );

			if ( len < 0 )
			{
				std::cerr << "Error decoding video" << std::endl;
				keep_going=false;
			}

			if ( got_frame )
			{
				if ( (codec_ctx->width & 0x7) || (codec_ctx->height & 0x7) )
					sws_flags |= SWS_ACCURATE_RND;

				sws_ctx = sws_getCachedContext( NULL,
					codec_ctx->width, codec_ctx->height, codec_ctx->pix_fmt,
					disptex_width, disptex_height, AV_PIX_FMT_RGBA,
					sws_flags, NULL, NULL, NULL );

				if ( !sws_ctx )
				{
					std::cerr << "Error allocating SwsContext during preload" << std::endl;
					free_frame( raw_frame );
					free_packet( packet );
					return;
				}

				sf::Lock l( image_swap_mutex );
				sws_scale( sws_ctx, raw_frame->data, raw_frame->linesize,
							0, codec_ctx->height, rgba_buffer,
							rgba_linesize );

				display_texture->update( rgba_buffer[0] );

				keep_going = false;
			}

			free_frame( raw_frame );
			free_packet( packet );
		}
	}
}
开发者ID:chris-vg,项目名称:attract,代码行数:84,代码来源:media.cpp

示例6: update

	//iterate function draw
	sf::Sprite& update() {
		graphTx.update(graph);
		graphSpr.rotate(rotation * 180. / pi);
		return graphSpr;
	}
开发者ID:huseinz,项目名称:polargrapher,代码行数:6,代码来源:polargrapher.cpp


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