【基于obs开发推流工具教程】-opengl和Direct 11接口统计

一,平台初始化:
#if _WIN32
config_set_default_string(globalConfig, “Video”, “Renderer”,
“Direct3D 11”);
#else
config_set_default_string(globalConfig, “Video”, “Renderer”, “OpenGL”);
#endif
windows平台默认的是用Direct 进行渲染,Direct对于windows不同显卡的兼容性跟好一些。

2,源码渲染器创建流程
1,OBSBasic::OBSInit()-》ResetVideo()->obs_reset_video()->obs_init_graphics()->gs_create()->load_graphics_imports();
load_graphics_imports //是opengl和Direct 11接口函数绑定实现,重要。

3,opengl和Direct 11 实现接口

GRAPHICS_IMPORT(device_get_name); -获取渲染名称
GRAPHICS_IMPORT(device_get_type);
GRAPHICS_IMPORT_OPTIONAL(device_enum_adapters);//枚举适配器(这实际上只适用于windows)。
GRAPHICS_IMPORT(device_preprocessor_name);
//初始化功能
GRAPHICS_IMPORT(device_create);//创建图形上下文
GRAPHICS_IMPORT(device_destroy);//销毁图形上下文
GRAPHICS_IMPORT(device_enter_context);//输入并锁定图形上下文
GRAPHICS_IMPORT(device_leave_context);//离开并解锁图形上下文
GRAPHICS_IMPORT(device_get_device_obj);
//交换链
GRAPHICS_IMPORT(device_swapchain_create);//创建交换链(在本机小部件上显示视图)
GRAPHICS_IMPORT(device_resize);//调整当前活动交换链的大小
GRAPHICS_IMPORT(device_get_size);//获取当前活动交换链的大小
GRAPHICS_IMPORT(device_get_width);//获取当前活动交换链的宽度
GRAPHICS_IMPORT(device_get_height);//获取当前活动交换链的高度
//纹理功能
GRAPHICS_IMPORT(device_texture_create);//创建纹理
GRAPHICS_IMPORT(device_cubetexture_create);//立方体纹理功能
GRAPHICS_IMPORT(device_voltexture_create);
GRAPHICS_IMPORT(device_zstencil_create);//创建一个Z型模具表面对象。
GRAPHICS_IMPORT(device_stagesurface_create);//创建临时表面纹理
GRAPHICS_IMPORT(device_samplerstate_create);//创建一个采样器状态对象。
GRAPHICS_IMPORT(device_vertexshader_create);//创建一个顶点缓冲区
GRAPHICS_IMPORT(device_pixelshader_create);//像素阴影
GRAPHICS_IMPORT(device_vertexbuffer_create);//顶点缓冲
GRAPHICS_IMPORT(device_indexbuffer_create);//创建索引缓冲区
GRAPHICS_IMPORT(device_timer_create);
GRAPHICS_IMPORT(device_timer_range_create);
GRAPHICS_IMPORT(device_get_texture_type);
GRAPHICS_IMPORT(device_load_vertexbuffer);
GRAPHICS_IMPORT(device_load_indexbuffer);
GRAPHICS_IMPORT(device_load_texture);
GRAPHICS_IMPORT(device_load_samplerstate);
GRAPHICS_IMPORT(device_load_vertexshader);
GRAPHICS_IMPORT(device_load_pixelshader);
GRAPHICS_IMPORT(device_load_default_samplerstate);
GRAPHICS_IMPORT(device_get_vertex_shader);
GRAPHICS_IMPORT(device_get_pixel_shader);
GRAPHICS_IMPORT(device_get_render_target);
GRAPHICS_IMPORT(device_get_zstencil_target);
GRAPHICS_IMPORT(device_set_render_target);
GRAPHICS_IMPORT(device_set_cube_render_target);
GRAPHICS_IMPORT(device_copy_texture_region);
GRAPHICS_IMPORT(device_copy_texture);
GRAPHICS_IMPORT(device_stage_texture);
GRAPHICS_IMPORT(device_begin_frame);
GRAPHICS_IMPORT(device_begin_scene);
GRAPHICS_IMPORT(device_draw);
GRAPHICS_IMPORT(device_load_swapchain);
GRAPHICS_IMPORT(device_end_scene);
GRAPHICS_IMPORT(device_clear);
GRAPHICS_IMPORT(device_present);
GRAPHICS_IMPORT(device_flush);
GRAPHICS_IMPORT(device_set_cull_mode);
GRAPHICS_IMPORT(device_get_cull_mode);
GRAPHICS_IMPORT(device_enable_blending);
GRAPHICS_IMPORT(device_enable_depth_test);
GRAPHICS_IMPORT(device_enable_stencil_test);
GRAPHICS_IMPORT(device_enable_stencil_write);
GRAPHICS_IMPORT(device_enable_color);
GRAPHICS_IMPORT(device_blend_function);
GRAPHICS_IMPORT(device_blend_function_separate);
GRAPHICS_IMPORT(device_depth_function);
GRAPHICS_IMPORT(device_stencil_function);
GRAPHICS_IMPORT(device_stencil_op);
GRAPHICS_IMPORT(device_set_viewport);
GRAPHICS_IMPORT(device_get_viewport);
GRAPHICS_IMPORT(device_set_scissor_rect);
GRAPHICS_IMPORT(device_ortho);
GRAPHICS_IMPORT(device_frustum);
GRAPHICS_IMPORT(device_projection_push);
GRAPHICS_IMPORT(device_projection_pop);

GRAPHICS_IMPORT(gs_swapchain_destroy);

创建图形上下文
GRAPHICS_IMPORT(gs_texture_destroy);//破坏纹理
GRAPHICS_IMPORT(gs_texture_get_width);//纹理宽度
GRAPHICS_IMPORT(gs_texture_get_height);//纹理的高度
GRAPHICS_IMPORT(gs_texture_get_color_format);//获取纹理的颜色格式
GRAPHICS_IMPORT(gs_texture_map);//映射纹理。
GRAPHICS_IMPORT(gs_texture_unmap);//取消映射纹理,取消贴图
GRAPHICS_IMPORT_OPTIONAL(gs_texture_is_rect);
GRAPHICS_IMPORT(gs_texture_get_obj);
//立方体纹理功能
GRAPHICS_IMPORT(gs_cubetexture_destroy);// 立方体纹理销毁
GRAPHICS_IMPORT(gs_cubetexture_get_size);//获取立方体纹理的宽度/高度/深度值
GRAPHICS_IMPORT(gs_cubetexture_get_color_format);//获取立方体纹理的颜色格式
//容积纹理或体积纹理 26.0.2 最新版本没有介绍
GRAPHICS_IMPORT(gs_voltexture_destroy);
GRAPHICS_IMPORT(gs_voltexture_get_width);
GRAPHICS_IMPORT(gs_voltexture_get_height);
GRAPHICS_IMPORT(gs_voltexture_get_depth);
GRAPHICS_IMPORT(gs_voltexture_get_color_format);
//创建临时表面纹理
GRAPHICS_IMPORT(gs_stagesurface_destroy);//销毁临时表面纹理
GRAPHICS_IMPORT(gs_stagesurface_get_width);
GRAPHICS_IMPORT(gs_stagesurface_get_height);
GRAPHICS_IMPORT(gs_stagesurface_get_color_format);
GRAPHICS_IMPORT(gs_stagesurface_map);//纹理读取数据到rgba
GRAPHICS_IMPORT(gs_stagesurface_unmap);
//创建一个Z型模具表面对象。
GRAPHICS_IMPORT(gs_zstencil_destroy);
//创建一个采样器状态对象。
GRAPHICS_IMPORT(gs_samplerstate_destroy);
//创建一个顶点缓冲区
GRAPHICS_IMPORT(gs_vertexbuffer_destroy); //销毁一个顶点缓冲区
GRAPHICS_IMPORT(gs_vertexbuffer_flush); //将顶点缓冲区刷新到其间隔顶点数据对象。 要修改其内部顶点数据,请调用gs_vertexbuffer_get_data()。只能与动态顶点缓冲区对象一起使用。
GRAPHICS_IMPORT(gs_vertexbuffer_flush_direct);//直接将顶点缓冲区刷新为指定的顶点缓冲区数据。只能与动态顶点缓冲区对象一起使用。
GRAPHICS_IMPORT(gs_vertexbuffer_get_data);//获取与顶点缓冲区对象关联的顶点缓冲区数据。 可以使用gs_vertexbuffer_flush()更改此数据并更新顶点缓冲区。只能与动态顶点缓冲区对象一起使用。
//创建索引缓冲区
GRAPHICS_IMPORT(gs_indexbuffer_destroy); //销毁索引缓冲区
GRAPHICS_IMPORT(gs_indexbuffer_flush);//将索引缓冲区刷新到其间隔索引数据对象。 要修改其内部索引数据,请调用gs_indexbuffer_get_data()只能与动态索引缓冲区对象一起使用。
GRAPHICS_IMPORT(gs_indexbuffer_flush_direct);//将索引缓冲区刷新到指定的索引缓冲区数据,只能与动态索引缓冲区对象一起使用。
GRAPHICS_IMPORT(gs_indexbuffer_get_data);//获取与索引缓冲区对象关联的索引缓冲区数据。 可以使用gs_indexbuffer_flush()更改此数据并更新索引缓冲区,只能与动态索引缓冲区对象一起使用。
GRAPHICS_IMPORT(gs_indexbuffer_get_num_indices);//获取与此索引缓冲区关联的索引数。
GRAPHICS_IMPORT(gs_indexbuffer_get_type);//获取索引缓冲区的类型。
//最新OBS26.0.2没有介绍
GRAPHICS_IMPORT(gs_timer_destroy);
GRAPHICS_IMPORT(gs_timer_begin);
GRAPHICS_IMPORT(gs_timer_end);
GRAPHICS_IMPORT(gs_timer_get_data);
GRAPHICS_IMPORT(gs_timer_range_destroy);
GRAPHICS_IMPORT(gs_timer_range_begin);
GRAPHICS_IMPORT(gs_timer_range_end);
GRAPHICS_IMPORT(gs_timer_range_get_data);
//着色器功能
GRAPHICS_IMPORT(gs_shader_destroy);
GRAPHICS_IMPORT(gs_shader_get_num_params);
GRAPHICS_IMPORT(gs_shader_get_param_by_idx);
GRAPHICS_IMPORT(gs_shader_get_param_by_name);
GRAPHICS_IMPORT(gs_shader_get_viewproj_matrix);
GRAPHICS_IMPORT(gs_shader_get_world_matrix);
GRAPHICS_IMPORT(gs_shader_get_param_info);
GRAPHICS_IMPORT(gs_shader_set_bool);
GRAPHICS_IMPORT(gs_shader_set_float);
GRAPHICS_IMPORT(gs_shader_set_int);
GRAPHICS_IMPORT(gs_shader_set_matrix3);
GRAPHICS_IMPORT(gs_shader_set_matrix4);
GRAPHICS_IMPORT(gs_shader_set_vec2);
GRAPHICS_IMPORT(gs_shader_set_vec3);
GRAPHICS_IMPORT(gs_shader_set_vec4);
GRAPHICS_IMPORT(gs_shader_set_texture);
GRAPHICS_IMPORT(gs_shader_set_val);
GRAPHICS_IMPORT(gs_shader_set_default);
GRAPHICS_IMPORT(gs_shader_set_next_sampler);

GRAPHICS_IMPORT_OPTIONAL(device_nv12_available);

GRAPHICS_IMPORT(device_debug_marker_begin);
GRAPHICS_IMPORT(device_debug_marker_end);

/* OSX/Cocoa specific functions */

#ifdef APPLE
GRAPHICS_IMPORT_OPTIONAL(device_texture_create_from_iosurface);
GRAPHICS_IMPORT_OPTIONAL(gs_texture_rebind_iosurface);

/* win32 specific functions */

#elif _WIN32
//windows特有的功能
GRAPHICS_IMPORT(device_gdi_texture_available);
GRAPHICS_IMPORT(device_shared_texture_available);
GRAPHICS_IMPORT_OPTIONAL(device_get_duplicator_monitor_info);
GRAPHICS_IMPORT_OPTIONAL(device_duplicator_create);
GRAPHICS_IMPORT_OPTIONAL(gs_duplicator_destroy); //复写器
GRAPHICS_IMPORT_OPTIONAL(gs_duplicator_update_frame);
GRAPHICS_IMPORT_OPTIONAL(gs_duplicator_get_texture);
GRAPHICS_IMPORT_OPTIONAL(device_texture_create_gdi);
GRAPHICS_IMPORT_OPTIONAL(gs_texture_get_dc);
GRAPHICS_IMPORT_OPTIONAL(gs_texture_release_dc);
GRAPHICS_IMPORT_OPTIONAL(device_texture_open_shared);
GRAPHICS_IMPORT_OPTIONAL(device_texture_get_shared_handle);
GRAPHICS_IMPORT_OPTIONAL(device_texture_acquire_sync);
GRAPHICS_IMPORT_OPTIONAL(device_texture_release_sync);
GRAPHICS_IMPORT_OPTIONAL(device_texture_create_nv12);
GRAPHICS_IMPORT_OPTIONAL(device_stagesurface_create_nv12);
GRAPHICS_IMPORT_OPTIONAL(device_register_loss_callbacks);
GRAPHICS_IMPORT_OPTIONAL(device_unregister_loss_callbacks);
#endif

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值