A simple test application is given in OBS to create a scene and display it in windows:
int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdLine, int numCmd) { HWND hwnd = NULL; base_set_log_handler(do_log, nullptr); try { hwnd = CreateTestWindow(instance); if (!hwnd) throw "Couldn't create main window"; /* ------------------------------------------------------ */ /* create OBS */ CreateOBS(hwnd); /* ------------------------------------------------------ */ /* load modules */ obs_load_all_modules(); /* ------------------------------------------------------ */ /* create source */ SourceContext source = obs_source_create("random", "some randon source", NULL, nullptr); if (!source) throw "Couldn't create random test source"; /* ------------------------------------------------------ */ /* create filter */ SourceContext filter = obs_source_create("test_filter", "a nice green filter", NULL, nullptr); if (!filter) throw "Couldn't create test filter"; obs_source_filter_add(source, filter); /* ------------------------------------------------------ */ /* create scene and add source to scene (twice) */ SceneContext scene = obs_scene_create("test scene"); if (!scene) throw "Couldn't create scene"; AddTestItems(scene, source); /* ------------------------------------------------------ */ /* set the scene as the primary draw source and go */ obs_set_output_source(0, obs_scene_get_source(scene)); /* ------------------------------------------------------ */ /* create display for output and set the output render callback */ DisplayContext display = CreateDisplay(hwnd); obs_display_add_draw_callback(display, RenderWindow, nullptr); MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } } catch (char *error) { MessageBoxA(NULL, error, NULL, 0); } obs_shutdown(); blog(LOG_INFO, "Number of memory leaks: %ld", bnum_allocs()); DestroyWindow(hwnd); UNUSED_PARAMETER(prevInstance); UNUSED_PARAMETER(cmdLine); UNUSED_PARAMETER(numCmd); return 0; }
About the call of obs:
1.CreateOBS calls obs_reset_video and passes in a parameter obs_video_info, which is a structure:
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;
Includes the size of the display device and the rendering device DL_OPENGL used
2.obs_load_all_modules Load obs-related modules including plug-ins
3.obs_source_createc creates a source
4.obs_scene_create creates a scene
5.obs_scene_add binds source and scene
6.obs_set_output_source sets the source as the output object
7.DisplayContext display = CreateDisplay(hwnd);
obs_display_create draws the rendering result to the window
8.obs_display_add_draw_callback(display, RenderWindow, nullptr); can take over the drawing process of OBS