static inline void render_filter_bypass(obs_source_t target, 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; passes = technique_begin(tech); for (i = 0; i < passes; i++) { technique_beginpass(tech, i); obs_source_video_render(target); technique_endpass(tech); } technique_end(tech); }
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(); }
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; }
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; }
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); }
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); }
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); }
void OBSBasicPreview::DrawSceneEditing() { OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow()); effect_t solid = obs_get_solid_effect(); technique_t tech = effect_gettechnique(solid, "Solid"); vec4 color; vec4_set(&color, 1.0f, 0.0f, 0.0f, 1.0f); effect_setvec4(solid, effect_getparambyname(solid, "color"), &color); technique_begin(tech); technique_beginpass(tech, 0); OBSScene scene = main->GetCurrentScene(); if (scene) obs_scene_enum_items(scene, DrawSelectedItem, this); gs_load_vertexbuffer(nullptr); technique_endpass(tech); technique_end(tech); }
static inline void set_eparam(effect_t effect, const char *name, float val) { eparam_t param = effect_getparambyname(effect, name); effect_setfloat(effect, param, val); }