Ejemplo n.º 1
0
static inline void obs_source_draw_texture(struct obs_source *source,
		effect_t effect, float *color_matrix,
		float const *color_range_min, float const *color_range_max)
{
	texture_t tex = source->async_texture;
	eparam_t  param;

	if (source->async_convert_texrender)
		tex = texrender_gettexture(source->async_convert_texrender);

	if (color_range_min) {
		size_t const size = sizeof(float) * 3;
		param = effect_getparambyname(effect, "color_range_min");
		effect_setval(effect, param, color_range_min, size);
	}
	
	if (color_range_max) {
		size_t const size = sizeof(float) * 3;
		param = effect_getparambyname(effect, "color_range_max");
		effect_setval(effect, param, color_range_max, size);
	}
	
	if (color_matrix) {
		param = effect_getparambyname(effect, "color_matrix");
		effect_setval(effect, param, color_matrix, sizeof(float) * 16);
	}

	param = effect_getparambyname(effect, "image");
	effect_settexture(effect, param, tex);

	gs_draw_sprite(tex, source->async_flip ? GS_FLIP_V : 0, 0, 0);
}
Ejemplo n.º 2
0
static void random_video_render(void *data, effect_t effect)
{
	struct random_tex *rt = data;
	eparam_t image = effect_getparambyname(effect, "image");
	effect_settexture(effect, image, rt->texture);
	gs_draw_sprite(rt->texture, 0, 0, 0);
}
Ejemplo n.º 3
0
static void obs_source_draw_texture(texture_t tex, struct source_frame *frame)
{
    effect_t    effect = obs->video.default_effect;
    bool        yuv    = is_yuv(frame->format);
    const char  *type  = yuv ? "DrawYUV" : "DrawRGB";
    technique_t tech;
    eparam_t    param;

    if (!upload_frame(tex, frame))
        return;

    tech = effect_gettechnique(effect, type);
    technique_begin(tech);
    technique_beginpass(tech, 0);

    if (yuv) {
        param = effect_getparambyname(effect, "yuv_matrix");
        effect_setval(effect, param, frame->yuv_matrix,
                      sizeof(float) * 16);
    }

    param = effect_getparambyname(effect, "diffuse");
    effect_settexture(effect, param, tex);

    gs_draw_sprite(tex, frame->flip ? GS_FLIP_V : 0, 0, 0);

    technique_endpass(tech);
    technique_end(tech);
}
Ejemplo n.º 4
0
static void image_source_render(void *data, effect_t effect)
{
	struct image_source *context = data;
	if (!context->tex)
		return;

	gs_reset_blend_state();
	effect_settexture(effect_getparambyname(effect, "image"), context->tex);
	gs_draw_sprite(context->tex, 0, context->cx, context->cy);
}
Ejemplo n.º 5
0
void XCompcapMain::render(effect_t effect)
{
	PLock lock(&p->lock, true);

	if (!lock.isLocked() || !p->tex)
		return;

	eparam_t image = effect_getparambyname(effect, "image");
	effect_settexture(image, p->tex);

	gs_enable_blending(false);
	gs_draw_sprite(p->tex, 0, 0, 0);

	gs_reset_blend_state();
}
Ejemplo n.º 6
0
void xcursor_render(xcursor_t *data) {
	/* TODO: why do i need effects ? */
	effect_t effect  = gs_geteffect();
	eparam_t image = effect_getparambyname(effect, "image");

	effect_settexture(image, data->tex);

	gs_matrix_push();

	gs_matrix_translate3f(-data->pos_x, -data->pos_y, 0);

	gs_enable_blending(True);
	gs_blendfunction(GS_BLEND_ONE, GS_BLEND_INVSRCALPHA);
	gs_draw_sprite(data->tex, 0, 0, 0);

	gs_matrix_pop();
}
Ejemplo n.º 7
0
static bool update_async_texrender(struct obs_source *source,
		const struct source_frame *frame)
{
	texture_t   tex       = source->async_texture;
	texrender_t texrender = source->async_convert_texrender;

	texrender_reset(texrender);

	upload_raw_frame(tex, frame);

	uint32_t cx = source->async_width;
	uint32_t cy = source->async_height;

	effect_t conv = obs->video.conversion_effect;
	technique_t tech = effect_gettechnique(conv,
			select_conversion_technique(frame->format));

	if (!texrender_begin(texrender, cx, cy))
		return false;

	technique_begin(tech);
	technique_beginpass(tech, 0);

	effect_settexture(conv, effect_getparambyname(conv, "image"),
			tex);
	set_eparam(conv, "width",  (float)cx);
	set_eparam(conv, "height", (float)cy);
	set_eparam(conv, "width_i",  1.0f / cx);
	set_eparam(conv, "height_i", 1.0f / cy);
	set_eparam(conv, "width_d2",  cx  * 0.5f);
	set_eparam(conv, "height_d2", cy * 0.5f);
	set_eparam(conv, "width_d2_i",  1.0f / (cx  * 0.5f));
	set_eparam(conv, "height_d2_i", 1.0f / (cy * 0.5f));
	set_eparam(conv, "input_height", (float)cy);

	gs_ortho(0.f, (float)cx, 0.f, (float)cy, -100.f, 100.f);

	gs_draw_sprite(tex, 0, cx, cy);

	technique_endpass(tech);
	technique_end(tech);

	texrender_end(texrender);

	return true;
}
Ejemplo n.º 8
0
static void render_convert_texture(struct obs_core_video *video,
		int cur_texture, int prev_texture)
{
	texture_t   texture = video->output_textures[prev_texture];
	texture_t   target  = video->convert_textures[cur_texture];
	float       fwidth  = (float)video->output_width;
	float       fheight = (float)video->output_height;
	size_t      passes, i;

	effect_t    effect  = video->conversion_effect;
	eparam_t    image   = effect_getparambyname(effect, "image");
	technique_t tech    = effect_gettechnique(effect,
			video->conversion_tech);

	if (!video->textures_output[prev_texture])
		return;

	set_eparam(effect, "u_plane_offset", (float)video->plane_offsets[1]);
	set_eparam(effect, "v_plane_offset", (float)video->plane_offsets[2]);
	set_eparam(effect, "width",  fwidth);
	set_eparam(effect, "height", fheight);
	set_eparam(effect, "width_i",  1.0f / fwidth);
	set_eparam(effect, "height_i", 1.0f / fheight);
	set_eparam(effect, "width_d2",  fwidth  * 0.5f);
	set_eparam(effect, "height_d2", fheight * 0.5f);
	set_eparam(effect, "width_d2_i",  1.0f / (fwidth  * 0.5f));
	set_eparam(effect, "height_d2_i", 1.0f / (fheight * 0.5f));
	set_eparam(effect, "input_height", (float)video->conversion_height);

	effect_settexture(effect, image, texture);

	gs_setrendertarget(target, NULL);
	set_render_size(video->output_width, video->conversion_height);

	passes = technique_begin(tech);
	for (i = 0; i < passes; i++) {
		technique_beginpass(tech, i);
		gs_draw_sprite(texture, 0, video->output_width,
				video->conversion_height);
		technique_endpass(tech);
	}
	technique_end(tech);

	video->textures_converted[cur_texture] = true;
}
Ejemplo n.º 9
0
static inline void render_filter_tex(texture_t tex, effect_t effect,
                                     uint32_t width, uint32_t height, bool yuv)
{
    const char  *tech_name = yuv ? "DrawYUV" : "DrawRGB";
    technique_t tech       = effect_gettechnique(effect, tech_name);
    eparam_t    diffuse    = effect_getparambyname(effect, "diffuse");
    size_t      passes, i;

    effect_settexture(effect, diffuse, tex);

    passes = technique_begin(tech);
    for (i = 0; i < passes; i++) {
        technique_beginpass(tech, i);
        gs_draw_sprite(tex, width, height, 0);
        technique_endpass(tech);
    }
    technique_end(tech);
}
Ejemplo n.º 10
0
static inline void render_filter_tex(texture_t tex, effect_t effect,
		uint32_t width, uint32_t height, bool use_matrix)
{
	const char  *tech_name = use_matrix ? "DrawMatrix" : "Draw";
	technique_t tech       = effect_gettechnique(effect, tech_name);
	eparam_t    image      = effect_getparambyname(effect, "image");
	size_t      passes, i;

	effect_settexture(effect, image, tex);

	passes = technique_begin(tech);
	for (i = 0; i < passes; i++) {
		technique_beginpass(tech, i);
		gs_draw_sprite(tex, width, height, 0);
		technique_endpass(tech);
	}
	technique_end(tech);
}
Ejemplo n.º 11
0
static inline void render_output_texture(struct obs_core_video *video,
		int cur_texture, int prev_texture)
{
	texture_t   texture = video->render_textures[prev_texture];
	texture_t   target  = video->output_textures[cur_texture];
	uint32_t    width   = texture_getwidth(target);
	uint32_t    height  = texture_getheight(target);

	/* TODO: replace with actual downscalers or unpackers */
	effect_t    effect  = video->default_effect;
	technique_t tech    = effect_gettechnique(effect, "DrawMatrix");
	eparam_t    image   = effect_getparambyname(effect, "image");
	eparam_t    matrix  = effect_getparambyname(effect, "color_matrix");
	size_t      passes, i;

	if (!video->textures_rendered[prev_texture])
		return;

	gs_setrendertarget(target, NULL);
	set_render_size(width, height);

	/* TODO: replace with programmable code */
	const float mat_val[16] =
	{
		-0.100644f, -0.338572f,  0.439216f,  0.501961f,
		 0.182586f,  0.614231f,  0.062007f,  0.062745f,
		 0.439216f, -0.398942f, -0.040274f,  0.501961f,
		 0.000000f,  0.000000f,  0.000000f,  1.000000f
	};

	effect_setval(effect, matrix, mat_val, sizeof(mat_val));
	effect_settexture(effect, image, texture);

	passes = technique_begin(tech);
	for (i = 0; i < passes; i++) {
		technique_beginpass(tech, i);
		gs_draw_sprite(texture, 0, width, height);
		technique_endpass(tech);
	}
	technique_end(tech);

	video->textures_output[cur_texture] = true;
}
Ejemplo n.º 12
0
static void draw_texture(struct dc_capture *capture, int id, effect_t effect)
{
	texture_t   texture = capture->textures[id];
	technique_t tech    = effect_gettechnique(effect, "Draw");
	eparam_t    image   = effect_getparambyname(effect, "image");
	size_t      passes;

	effect_settexture(effect, image, texture);

	passes = technique_begin(tech);
	for (size_t i = 0; i < passes; i++) {
		if (technique_beginpass(tech, i)) {
			if (capture->compatibility)
				gs_draw_sprite(texture, GS_FLIP_V, 0, 0);
			else
				gs_draw_sprite(texture, 0, 0, 0);

			technique_endpass(tech);
		}
	}
	technique_end(tech);
}