예제 #1
0
void BobDeint::filter( QQueue< FrameBuffer > &framesQueue )
{
	int insertAt = addFramesToDeinterlace( framesQueue );
	while ( internalQueue.count() >= 2 )
	{
		FrameBuffer dequeued = internalQueue.dequeue();
		QByteArray videoFrameData2;

		VideoFrame *videoFrame1 = VideoFrame::fromData( dequeued.data );
		VideoFrame *videoFrame2 = VideoFrame::create( videoFrameData2, w, h );

		for ( int p = 0 ; p < 3 ; ++p )
		{
			const int linesize = videoFrame1->linesize[ p ];
			quint8 *src  = videoFrame1->data[ p ] + linesize;
			quint8 *dst1 = videoFrame1->data[ p ];
			quint8 *dst2 = videoFrame2->data[ p ];

			memcpy( dst2, src, linesize ); //Copy second line into new frame (duplicate first line in new frame, simple deshake)
			dst2 += linesize;

			const int H = p ? h >> 2 : h >> 1;
			for ( int i = 0 ; i < H ; ++i )
			{
				const bool notLast = i != H-1;

				memcpy( dst2, src, linesize );
				dst2 += linesize;
				if ( notLast )
				{
					VideoFilters::averageTwoLines( dst2, src, src + ( linesize << 1 ), linesize );
					dst2 += linesize;
				}

				dst1 += linesize;
				if ( notLast )
					VideoFilters::averageTwoLines( dst1, src - linesize, src + linesize, linesize );
				else
					memcpy( dst1, src - linesize, linesize );
				dst1 += linesize;

				src  += linesize << 1;
			}

			if ( h & 1 ) //Duplicate last line for odd height
				memcpy( dst2, dst2 - linesize, linesize );
		}

		const bool TFF = isTopFieldFirst( videoFrame1 );
		videoFrame1->setNoInterlaced();
		framesQueue.insert( insertAt++, FrameBuffer(  TFF ? dequeued.data : videoFrameData2, dequeued.ts ) );
		framesQueue.insert( insertAt++, FrameBuffer( !TFF ? dequeued.data : videoFrameData2, dequeued.ts + halfDelay( internalQueue.first(), dequeued ) ) );
	}
}
예제 #2
0
void Vid::SetMode( int ModeValue ) {
	if ( BackBuffer ) {
		Shutdown();
	}

	WindowWidth = ModeList[ModeValue].Width;
	WindowHeight = ModeList[ModeValue].Height;

	BufferHeight = WindowHeight;
	BufferWidth = WindowWidth;

	if ( ModeList[ModeValue].Type == ModeState::WINDOWED ) {
		SetWindowedMode( ModeValue );
	} else {
		SetFullscrenMode( ModeValue );
	}

	ShowWindow( MainWindow, SW_SHOWDEFAULT );

	HDC DeviceContext = GetDC( MainWindow );
	PatBlt( DeviceContext, 0, 0, BufferWidth, BufferHeight, BLACKNESS );
	ReleaseDC( MainWindow, DeviceContext );

	// define our bitmap info
	BitMapInfo.bmiHeader.biSize = sizeof( BitMapInfo.bmiHeader );
	BitMapInfo.bmiHeader.biWidth = BufferWidth;
	BitMapInfo.bmiHeader.biHeight = -BufferHeight;
	BitMapInfo.bmiHeader.biPlanes = 1;
	BitMapInfo.bmiHeader.biBitCount = 8 * BytesPerPixel;
	BitMapInfo.bmiHeader.biCompression = BI_RGB;

	BackBuffer = FrameBuffer( BufferWidth, BufferHeight, BytesPerPixel );
}
예제 #3
0
FrameBuffer ShadowMapEntry::get_framebuffer() const
{
	if (impl->index != -1)
		return impl->shadow_maps->framebuffers[impl->index];
	else
		return FrameBuffer();
}
예제 #4
0
void LightsourceSimplePass::setup(GraphicContext &gc)
{
	Size viewport_size = viewport->get_size();
	if (fb.is_null() || !gc.is_frame_buffer_owner(fb) || final_color.updated() || zbuffer.updated() || diffuse_color_gbuffer.updated())
	{
		final_color.set(Texture2D(gc, viewport->get_width(), viewport->get_height(), tf_rgba16f));

		fb = FrameBuffer(gc);
		fb.attach_color(0, final_color.get());
		fb.attach_depth(zbuffer.get());

		BlendStateDescription blend_desc;
		blend_desc.enable_blending(true);
		blend_desc.set_blend_function(blend_one, blend_one, blend_one, blend_one);
		blend_state = BlendState(gc, blend_desc);

		DepthStencilStateDescription icosahedron_depth_stencil_desc;
		icosahedron_depth_stencil_desc.enable_depth_write(false);
		icosahedron_depth_stencil_desc.enable_depth_test(true);
		icosahedron_depth_stencil_desc.set_depth_compare_function(compare_lequal);
		icosahedron_depth_stencil_state = DepthStencilState(gc, icosahedron_depth_stencil_desc);

		RasterizerStateDescription icosahedron_rasterizer_desc;
		icosahedron_rasterizer_desc.set_culled(true);
		icosahedron_rasterizer_state = RasterizerState(gc, icosahedron_rasterizer_desc);

		DepthStencilStateDescription rect_depth_stencil_desc;
		rect_depth_stencil_desc.enable_depth_write(false);
		rect_depth_stencil_desc.enable_depth_test(false);
		rect_depth_stencil_state = DepthStencilState(gc, rect_depth_stencil_desc);

		RasterizerStateDescription rect_rasterizer_desc;
		rect_rasterizer_desc.set_culled(false);
		rect_rasterizer_state = RasterizerState(gc, rect_rasterizer_desc);

		uniforms = UniformVector<Uniforms>(gc, 1);

		icosahedron_prim_array = PrimitivesArray(gc);
		icosahedron_prim_array.set_attributes(0, icosahedron->vertices);

		Vec4f positions[6] =
		{
			Vec4f(-1.0f, -1.0f, 1.0f, 1.0f),
			Vec4f( 1.0f, -1.0f, 1.0f, 1.0f),
			Vec4f(-1.0f,  1.0f, 1.0f, 1.0f),
			Vec4f( 1.0f, -1.0f, 1.0f, 1.0f),
			Vec4f(-1.0f,  1.0f, 1.0f, 1.0f),
			Vec4f( 1.0f,  1.0f, 1.0f, 1.0f)
		};
		rect_positions = VertexArrayVector<Vec4f>(gc, positions, 6);

		rect_prim_array  = PrimitivesArray(gc);
		rect_prim_array.set_attributes(0, rect_positions);
	}
}
예제 #5
0
void BloomPass::setup_bloom_extract(GraphicContext &gc)
{
    Size viewport_size = viewport->get_size();
    Size bloom_size = viewport_size / 2;
    if (bloom_contribution->is_null() || bloom_contribution->get_size() != bloom_size || !gc.is_frame_buffer_owner(fb_bloom_extract))
    {
        bloom_contribution.set(Texture2D(gc, bloom_size.width, bloom_size.height, tf_rgba8));

        fb_bloom_extract = FrameBuffer(gc);
        fb_bloom_extract.attach_color(0, bloom_contribution.get());

        bloom_blur.output.set(fb_bloom_extract);
    }
}
예제 #6
0
void ShaderEffect_Impl::create_frame_buffer(GraphicContext &gc, const ShaderEffectDescription_Impl *description)
{
	int index = 0;
	for (const auto & elem : description->frag_data)
	{
		if (!elem.second.texture.is_null())
		{
			if (fb.is_null())
				fb = FrameBuffer(gc);

			// To do: improve this so it can attach more than just 2d textures

			fb.attach_color(index, elem.second.texture.to_texture_2d());
		}
		else if (!elem.second.buffer.is_null())
		{
			if (fb.is_null())
				fb = FrameBuffer(gc);
			fb.attach_color(index, elem.second.buffer);
		}
		index++;
	}

	if (!description->depth_texture.is_null())
	{
		if (fb.is_null())
			fb = FrameBuffer(gc);
		fb.attach_depth(description->depth_texture.to_texture_2d());
	}
	else if (!description->depth_buffer.is_null())
	{
		if (fb.is_null())
			fb = FrameBuffer(gc);
		fb.attach_depth(description->depth_buffer);
	}
}
예제 #7
0
GraphicStore::GraphicStore(GraphicContext &gc) : shader_color_geometry(gc)
{
    // Create a depth buffer
    framebuffer_depth = FrameBuffer(gc);
    texture_depth = Texture2D(gc, gc.get_size(), tf_depth_component32);
    texture_depth.set_wrap_mode(wrap_clamp_to_edge, wrap_clamp_to_edge);
    framebuffer_depth.attach_depth(texture_depth);

    // Load graphics
    texture_alpha = Texture2D(gc, "Resources/alpha_ball.png");
    texture_solid = Texture2D(gc, "Resources/alpha_ball2.png");
    texture_alpha.set_wrap_mode(wrap_clamp_to_edge, wrap_clamp_to_edge);
    texture_solid.set_wrap_mode(wrap_clamp_to_edge, wrap_clamp_to_edge);

}
예제 #8
0
void ParticleEmitterPass::setup(GraphicContext &gc)
{
	if (program.is_null())
	{
		std::string vertex_filename = PathHelp::combine(shader_path, "ParticleEmitter/vertex.hlsl");
		std::string fragment_filename = PathHelp::combine(shader_path, "ParticleEmitter/fragment.hlsl");
		program = ProgramObject::load(gc, vertex_filename, fragment_filename);
		program.bind_attribute_location(0, "AttrPosition");
		program.bind_frag_data_location(0, "FragColor");
		if (!program.link())
			throw Exception(string_format("Particle emitter program failed to link: %1", program.get_info_log()));
		program.set_uniform_buffer_index("Uniforms", 0);
		program.set_uniform1i("NormalZTexture", 0);
		program.set_uniform1i("InstanceTexture", 1);
		program.set_uniform1i("ParticleTexture", 2);
		program.set_uniform1i("ParticleSampler", 2);
		program.set_uniform1i("ColorGradientTexture", 3);
		program.set_uniform1i("ColorGradientSampler", 3);

		billboard_positions = VertexArrayVector<Vec3f>(gc, cpu_billboard_positions, 6);
	}

	Size viewport_size = viewport->get_size();
	if (fb.is_null() || !gc.is_frame_buffer_owner(fb) || final_color.updated() || zbuffer.updated())
	{
		fb = FrameBuffer(gc);
		fb.attach_color(0, final_color.get());
		fb.attach_depth(zbuffer.get());

		BlendStateDescription blend_desc;
		blend_desc.enable_blending(true);
		blend_desc.set_blend_function(blend_src_alpha, blend_one_minus_src_alpha, blend_zero, blend_zero);
		blend_state = BlendState(gc, blend_desc);

		DepthStencilStateDescription depth_stencil_desc;
		depth_stencil_desc.enable_depth_write(false);
		depth_stencil_desc.enable_depth_test(true);
		depth_stencil_desc.set_depth_compare_function(compare_lequal);
		depth_stencil_state = DepthStencilState(gc, depth_stencil_desc);

		RasterizerStateDescription rasterizer_desc;
		rasterizer_desc.set_culled(false);
		rasterizer_state = RasterizerState(gc, rasterizer_desc);

		prim_array = PrimitivesArray(gc);
		prim_array.set_attributes(0, billboard_positions);
	}
}
예제 #9
0
PhotonMapper::PhotonMapper():
    m_fbo(FrameBuffer(GL_TEXTURE_2D, 512, 512, -1, GL_RGBA32F_ARB, 1, 1, 0, "PhotonMapper FBO"))
{
    m_fbo.checkFramebufferStatus(1);
}
예제 #10
0
void GraphicContext::reset_frame_buffer()
{
	FrameBuffer null_fb = FrameBuffer();
	impl->set_frame_buffer(null_fb, null_fb);
}