OBS0.2.4基础框架
+ -

OBS主体逻辑

2026-01-16 1 0
本想着从简单的开始,但是发现核心的渲染如D3D11和新的版本基本差不多,还不如直接用新的代码调试,所以本章节放弃。
    1.初始化 obs_core
    obs_startup("en-US", const char *module_config_path, profiler_name_store_t *store)

    2.初始化图形D3D11和创建 obs_graphics_thread
    struct obs_video_info ovi;
    ovi.adapter = 0;
    ovi.base_width = rc.right;
    ovi.base_height = rc.bottom;
    ovi.fps_num = 30000;
    ovi.fps_den = 1001;
    ovi.graphics_module = DL_OPENGL;
    ovi.output_format = VIDEO_FORMAT_RGBA;
    ovi.output_width = rc.right;
    ovi.output_height = rc.bottom;
    obs_reset_video(&ovi)

    3.加载DLL
    obs_load_all_modules();

    4.InitSource();

    5.UI渲染,可以多个
    DisplayContext display = CreateDisplay(hwnd);
    obs_display_add_draw_callback(display, RenderWindow, nullptr);

//obs_graphics_thread中回调
static void RenderWindow(void *data, uint32_t cx, uint32_t cy)
{
//通过上下文传递参数DisplayContext display信息
    obs_render_main_texture();
}


void InitSource()
{
        SourceContext source = obs_source_create("random", "some randon source", NULL, nullptr);
        SourceContext filter = obs_source_create("test_filter", "a nice green filter", NULL, nullptr);
        obs_source_filter_add(source, filter);

        SceneContext scene = obs_scene_create("test scene");
        obs_sceneitem_t* item = obs_scene_add(scene, source);

        struct vec2 scale;
        vec2_set(&scale, 20.0f, 20.0f);
        obs_sceneitem_set_scale(item, &scale);

        /* set the scene as the primary draw source and go */
        obs_set_output_source(0, obs_scene_get_source(scene));
}

0 篇笔记 写笔记

作者信息
我爱内核
Windows驱动开发,网站开发
好好学习,天天向上。
取消
感谢您的支持,我会继续努力的!
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

您的支持,是我们前进的动力!