libobs: Add obs_render_main_texture
(Note: This commit also modifies UI and test) This makes it so that main preview panes are rendered with the main output texture rather than re-rendering the main view. The view will render all objects again, whereas the output texture will be a single texture render of the same exact thing. Also fixes some abnormal artifacting when scaling the main preview pane.
This commit is contained in:
parent
2f577c1b71
commit
7f6cf97bd7
@ -1222,7 +1222,7 @@ void OBSBasic::RenderProgram(void *data, uint32_t cx, uint32_t cy)
|
||||
|
||||
window->DrawBackdrop(float(ovi.base_width), float(ovi.base_height));
|
||||
|
||||
obs_render_main_view();
|
||||
obs_render_main_texture();
|
||||
gs_load_vertexbuffer(nullptr);
|
||||
|
||||
/* --------------------------------------- */
|
||||
|
@ -2968,7 +2968,7 @@ void OBSBasic::RenderMain(void *data, uint32_t cx, uint32_t cy)
|
||||
if (source)
|
||||
obs_source_video_render(source);
|
||||
} else {
|
||||
obs_render_main_view();
|
||||
obs_render_main_texture();
|
||||
}
|
||||
gs_load_vertexbuffer(nullptr);
|
||||
|
||||
|
@ -408,7 +408,7 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy)
|
||||
if (studioMode) {
|
||||
obs_source_video_render(previewSrc);
|
||||
} else {
|
||||
obs_render_main_view();
|
||||
obs_render_main_texture();
|
||||
}
|
||||
|
||||
resetRegion();
|
||||
@ -453,7 +453,7 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy)
|
||||
gs_matrix_scale3f(hiScaleX, hiScaleY, 1.0f);
|
||||
|
||||
setRegion(halfCX + 2.0f, 2.0f, hiCX, hiCY);
|
||||
obs_render_main_view();
|
||||
obs_render_main_texture();
|
||||
resetRegion();
|
||||
|
||||
gs_matrix_pop();
|
||||
@ -540,7 +540,7 @@ void OBSProjector::OBSRender(void *data, uint32_t cx, uint32_t cy)
|
||||
if (source) {
|
||||
obs_source_video_render(source);
|
||||
} else {
|
||||
obs_render_main_view();
|
||||
obs_render_main_texture();
|
||||
}
|
||||
|
||||
gs_projection_pop();
|
||||
|
@ -57,7 +57,7 @@ display, then you must assign a draw callback with
|
||||
callback, call :c:func:`obs_display_remove_draw_callback()` similarly.
|
||||
|
||||
When drawing, to draw the main preview window (if any), call
|
||||
:c:func:`obs_render_main_view()`. If you need to render a specific
|
||||
:c:func:`obs_render_main_texture()`. If you need to render a specific
|
||||
source on a secondary display, you can increment its "showing" state
|
||||
with :c:func:`obs_source_inc_showing()` while it's showing in the
|
||||
secondary display, draw it with :c:func:`obs_source_video_render()` in
|
||||
|
@ -380,6 +380,15 @@ Video, Audio, and Graphics
|
||||
|
||||
Renders the main view.
|
||||
|
||||
Note: This function is deprecated.
|
||||
|
||||
---------------------
|
||||
|
||||
.. function:: void obs_render_main_texture(void)
|
||||
|
||||
Renders the main output texture. Useful for rendering a preview pane
|
||||
of the main output.
|
||||
|
||||
---------------------
|
||||
|
||||
.. function:: void obs_set_master_volume(float volume)
|
||||
|
@ -614,14 +614,14 @@ void *obs_graphics_thread(void *param)
|
||||
last_time = tick_sources(obs->video.video_time, last_time);
|
||||
profile_end(tick_sources_name);
|
||||
|
||||
profile_start(render_displays_name);
|
||||
render_displays();
|
||||
profile_end(render_displays_name);
|
||||
|
||||
profile_start(output_frame_name);
|
||||
output_frame();
|
||||
profile_end(output_frame_name);
|
||||
|
||||
profile_start(render_displays_name);
|
||||
render_displays();
|
||||
profile_end(render_displays_name);
|
||||
|
||||
frame_time_ns = os_gettime_ns() - frame_start;
|
||||
|
||||
profile_end(video_thread_name);
|
||||
|
26
libobs/obs.c
26
libobs/obs.c
@ -1430,6 +1430,32 @@ void obs_render_main_view(void)
|
||||
obs_view_render(&obs->data.main_view);
|
||||
}
|
||||
|
||||
void obs_render_main_texture(void)
|
||||
{
|
||||
struct obs_core_video *video = &obs->video;
|
||||
gs_texture_t *tex;
|
||||
gs_effect_t *effect;
|
||||
gs_eparam_t *param;
|
||||
int last_tex;
|
||||
|
||||
if (!obs) return;
|
||||
|
||||
last_tex = video->cur_texture == 0
|
||||
? NUM_TEXTURES - 1
|
||||
: video->cur_texture - 1;
|
||||
|
||||
if (!video->textures_rendered[last_tex])
|
||||
return;
|
||||
|
||||
tex = video->render_textures[last_tex];
|
||||
effect = obs_get_base_effect(OBS_EFFECT_DEFAULT);
|
||||
param = gs_effect_get_param_by_name(effect, "image");
|
||||
gs_effect_set_texture(param, tex);
|
||||
|
||||
while (gs_effect_loop(effect, "Draw"))
|
||||
gs_draw_sprite(tex, 0, 0, 0);
|
||||
}
|
||||
|
||||
void obs_set_master_volume(float volume)
|
||||
{
|
||||
struct calldata data = {0};
|
||||
|
@ -550,8 +550,12 @@ EXPORT signal_handler_t *obs_get_signal_handler(void);
|
||||
EXPORT proc_handler_t *obs_get_proc_handler(void);
|
||||
|
||||
/** Renders the main view */
|
||||
DEPRECATED
|
||||
EXPORT void obs_render_main_view(void);
|
||||
|
||||
/** Renders the last main output texture */
|
||||
EXPORT void obs_render_main_texture(void);
|
||||
|
||||
/** Sets the master user volume */
|
||||
EXPORT void obs_set_master_volume(float volume);
|
||||
|
||||
|
@ -146,7 +146,7 @@ static SceneContext SetupScene()
|
||||
|
||||
obs_display_add_draw_callback(display.get(),
|
||||
[](void *, uint32_t, uint32_t) {
|
||||
obs_render_main_view();
|
||||
obs_render_main_texture();
|
||||
}, nullptr);
|
||||
|
||||
} catch (char const *error) {
|
||||
|
@ -150,7 +150,7 @@ static HWND CreateTestWindow(HINSTANCE instance)
|
||||
|
||||
static void RenderWindow(void *data, uint32_t cx, uint32_t cy)
|
||||
{
|
||||
obs_render_main_view();
|
||||
obs_render_main_texture();
|
||||
|
||||
UNUSED_PARAMETER(data);
|
||||
UNUSED_PARAMETER(cx);
|
||||
|
Loading…
x
Reference in New Issue
Block a user