Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
9e9c2551
O
obs-studio
项目概览
尘离序散
/
obs-studio
与 Fork 源项目一致
从无法访问的项目Fork
通知
30
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obs-studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9e9c2551
编写于
12月 23, 2013
作者:
J
jp9000
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/jp9000/obs-studio
上级
bb53a39a
74aa1c46
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
149 addition
and
0 deletion
+149
-0
libobs-opengl/CMakeLists.txt
libobs-opengl/CMakeLists.txt
+5
-0
libobs-opengl/gl-cocoa.m
libobs-opengl/gl-cocoa.m
+103
-0
libobs-opengl/gl-exports.h
libobs-opengl/gl-exports.h
+5
-0
libobs-opengl/makefile.am
libobs-opengl/makefile.am
+1
-0
libobs/graphics/graphics-imports.c
libobs/graphics/graphics-imports.c
+4
-0
libobs/graphics/graphics-internal.h
libobs/graphics/graphics-internal.h
+4
-0
libobs/graphics/graphics.c
libobs/graphics/graphics.c
+22
-0
libobs/graphics/graphics.h
libobs/graphics/graphics.h
+5
-0
未找到文件。
libobs-opengl/CMakeLists.txt
浏览文件 @
9e9c2551
...
...
@@ -6,9 +6,14 @@ elseif(APPLE AND UNIX)
set_source_files_properties
(
${
libobs_opengl_platform_objc_src
}
PROPERTIES LANGUAGE C
)
set
(
libobs_opengl_platform_src
${
libobs_opengl_platform_objc_src
}
)
find_library
(
COCOA Cocoa
)
include_directories
(
${
COCOA
}
)
link_libraries
(
${
COCOA
}
)
find_library
(
IOSURF IOSurface
)
include_directories
(
${
IOSURF
}
)
link_libraries
(
${
IOSURF
}
)
else
()
endif
()
...
...
libobs-opengl/gl-cocoa.m
浏览文件 @
9e9c2551
...
...
@@ -252,3 +252,106 @@ void gl_getclientsize(struct gs_swap_chain *swap, uint32_t *width,
if(width) *width = swap->info.cx;
if(height) *height = swap->info.cy;
}
texture_t texture_create_from_iosurface(device_t device, void *iosurf)
{
IOSurfaceRef ref = (IOSurfaceRef)iosurf;
struct gs_texture_2d *tex = bmalloc(sizeof(struct gs_texture_2d));
memset(tex, 0, sizeof(struct gs_texture_2d));
const enum gs_color_format color_format = GS_BGRA;
tex->base.device = device;
tex->base.type = GS_TEXTURE_2D;
tex->base.format = GS_BGRA;
tex->base.levels = 1;
tex->base.gl_format = convert_gs_format(color_format);
tex->base.gl_internal_format = convert_gs_internal_format(color_format);
tex->base.gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
tex->base.gl_target = GL_TEXTURE_RECTANGLE;
tex->base.is_dynamic = false;
tex->base.is_render_target = false;
tex->base.gen_mipmaps = false;
tex->width = IOSurfaceGetWidth(ref);
tex->height = IOSurfaceGetHeight(ref);
if (!gl_gen_textures(1,
&
tex->base.texture))
goto fail;
if (!gl_bind_texture(tex->base.gl_target, tex->base.texture))
goto fail;
CGLError err = CGLTexImageIOSurface2D(
[[NSOpenGLContext currentContext] CGLContextObj],
tex->base.gl_target,
tex->base.gl_internal_format,
tex->width, tex->height,
tex->base.gl_format,
tex->base.gl_type,
ref, 0);
if(err != kCGLNoError) {
blog(LOG_ERROR, "CGLTexImageIOSurface2D: %u, %s"
" (texture_create_from_iosurface)",
err, CGLErrorString(err));
gl_success("CGLTexImageIOSurface2D");
goto fail;
}
if (!gl_tex_param_i(tex->base.gl_target,
GL_TEXTURE_MAX_LEVEL, 0))
goto fail;
if (!gl_bind_texture(tex->base.gl_target, 0))
goto fail;
return (texture_t)tex;
fail:
texture_destroy((texture_t)tex);
blog(LOG_ERROR, "texture_create_from_iosurface (GL) failed");
return NULL;
}
bool texture_rebind_iosurface(texture_t texture, void *iosurf)
{
if (!texture)
return false;
if (!iosurf)
return false;
struct gs_texture_2d *tex = (struct gs_texture_2d*)texture;
IOSurfaceRef ref = (IOSurfaceRef)iosurf;
if (tex->width != IOSurfaceGetWidth(ref) ||
tex->height != IOSurfaceGetHeight(ref))
return false;
if (!gl_bind_texture(tex->base.gl_target, tex->base.texture))
return false;
CGLError err = CGLTexImageIOSurface2D(
[[NSOpenGLContext currentContext] CGLContextObj],
tex->base.gl_target,
tex->base.gl_internal_format,
tex->width, tex->height,
tex->base.gl_format,
tex->base.gl_type,
ref, 0);
if(err != kCGLNoError) {
blog(LOG_ERROR, "CGLTexImageIOSurface2D: %u, %s"
" (texture_rebind_iosurface)",
err, CGLErrorString(err));
gl_success("CGLTexImageIOSurface2D");
return false;
}
if (!gl_bind_texture(tex->base.gl_target, 0))
return false;
return true;
}
libobs-opengl/gl-exports.h
浏览文件 @
9e9c2551
...
...
@@ -188,3 +188,8 @@ EXPORT void shader_settexture(shader_t shader, sparam_t param, texture_t val);
EXPORT
void
shader_setval
(
shader_t
shader
,
sparam_t
param
,
const
void
*
val
,
size_t
size
);
EXPORT
void
shader_setdefault
(
shader_t
shader
,
sparam_t
param
);
#ifdef __APPLE__
EXPORT
texture_t
texture_create_from_iosurface
(
device_t
device
,
void
*
iosurf
);
EXPORT
bool
texture_rebind_iosurface
(
texture_t
texture
,
void
*
iosurf
);
#endif
libobs-opengl/makefile.am
浏览文件 @
9e9c2551
...
...
@@ -33,6 +33,7 @@ libobs_opengl_la_SOURCES = gl-helpers.c \
if
OS_OSX
libobs_opengl_la_SOURCES
+=
gl-cocoa.m
libobs_opengl_la_LDFLAGS
+=
-framework
Cocoa
-framework
IOSurface
endif
if
OS_WIN
...
...
libobs/graphics/graphics-imports.c
浏览文件 @
9e9c2551
...
...
@@ -165,5 +165,9 @@ bool load_graphics_imports(struct gs_exports *exports, void *module,
GRAPHICS_IMPORT
(
shader_setval
);
GRAPHICS_IMPORT
(
shader_setdefault
);
/* OSX/Cocoa specific functions */
GRAPHICS_IMPORT_OPTIONAL
(
texture_create_from_iosurface
);
GRAPHICS_IMPORT_OPTIONAL
(
texture_rebind_iosurface
);
return
success
;
}
libobs/graphics/graphics-internal.h
浏览文件 @
9e9c2551
...
...
@@ -201,6 +201,10 @@ struct gs_exports {
void
(
*
shader_setval
)(
shader_t
shader
,
sparam_t
param
,
const
void
*
val
,
size_t
size
);
void
(
*
shader_setdefault
)(
shader_t
shader
,
sparam_t
param
);
/* OSX/Cocoa specific functions */
texture_t
(
*
texture_create_from_iosurface
)(
device_t
dev
,
void
*
iosurf
);
bool
(
*
texture_rebind_iosurface
)(
texture_t
texture
,
void
*
iosurf
);
};
struct
graphics_subsystem
{
...
...
libobs/graphics/graphics.c
浏览文件 @
9e9c2551
...
...
@@ -1589,3 +1589,25 @@ enum gs_index_type indexbuffer_gettype(indexbuffer_t indexbuffer)
{
return
thread_graphics
->
exports
.
indexbuffer_gettype
(
indexbuffer
);
}
/** Platform specific functions */
texture_t
gs_create_texture_from_iosurface
(
void
*
iosurf
)
{
graphics_t
graphics
=
thread_graphics
;
if
(
!
graphics
->
exports
.
texture_create_from_iosurface
)
return
NULL
;
return
graphics
->
exports
.
texture_create_from_iosurface
(
graphics
->
device
,
iosurf
);
}
bool
texture_rebind_iosurface
(
texture_t
texture
,
void
*
iosurf
)
{
graphics_t
graphics
=
thread_graphics
;
if
(
!
graphics
->
exports
.
texture_rebind_iosurface
)
return
false
;
return
graphics
->
exports
.
texture_rebind_iosurface
(
texture
,
iosurf
);
}
libobs/graphics/graphics.h
浏览文件 @
9e9c2551
...
...
@@ -678,6 +678,11 @@ EXPORT void *indexbuffer_getdata(indexbuffer_t indexbuffer);
EXPORT
size_t
indexbuffer_numindices
(
indexbuffer_t
indexbuffer
);
EXPORT
enum
gs_index_type
indexbuffer_gettype
(
indexbuffer_t
indexbuffer
);
/** platform specific function for creating (GL_TEXTURE_RECTANGLE) textures
* from shared surface resources */
EXPORT
texture_t
gs_create_texture_from_iosurface
(
void
*
iosurf
);
EXPORT
bool
texture_rebind_iosurface
(
texture_t
texture
,
void
*
iosurf
);
/* inline functions used by modules */
static
inline
uint32_t
gs_get_format_bpp
(
enum
gs_color_format
format
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录