Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
0781670b
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,发现更多精彩内容 >>
提交
0781670b
编写于
12月 20, 2013
作者:
J
jp9000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add handling of GL_TEXTURE_RECTANGLE target, and add automatic handling if using it as a sprite
上级
f41bb4b7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
75 addition
and
7 deletion
+75
-7
libobs-opengl/gl-exports.h
libobs-opengl/gl-exports.h
+1
-0
libobs-opengl/gl-texture2d.c
libobs-opengl/gl-texture2d.c
+11
-0
libobs/graphics/graphics-imports.c
libobs/graphics/graphics-imports.c
+6
-0
libobs/graphics/graphics-internal.h
libobs/graphics/graphics-internal.h
+1
-0
libobs/graphics/graphics.c
libobs/graphics/graphics.c
+52
-7
libobs/graphics/graphics.h
libobs/graphics/graphics.h
+4
-0
未找到文件。
libobs-opengl/gl-exports.h
浏览文件 @
0781670b
...
...
@@ -129,6 +129,7 @@ EXPORT uint32_t texture_getheight(texture_t tex);
EXPORT
enum
gs_color_format
texture_getcolorformat
(
texture_t
tex
);
EXPORT
bool
texture_map
(
texture_t
tex
,
void
**
ptr
,
uint32_t
*
row_bytes
);
EXPORT
void
texture_unmap
(
texture_t
tex
);
EXPORT
bool
texture_isrect
(
texture_t
tex
);
EXPORT
void
cubetexture_destroy
(
texture_t
cubetex
);
EXPORT
uint32_t
cubetexture_getsize
(
texture_t
cubetex
);
...
...
libobs-opengl/gl-texture2d.c
浏览文件 @
0781670b
...
...
@@ -223,3 +223,14 @@ failed:
gl_bind_texture
(
GL_TEXTURE_2D
,
0
);
blog
(
LOG_ERROR
,
"texture_unmap (GL) failed"
);
}
bool
texture_isrect
(
texture_t
tex
)
{
struct
gs_texture_2d
*
tex2d
=
(
struct
gs_texture_2d
*
)
tex
;
if
(
!
is_texture_2d
(
tex
,
"texture_unmap"
))
{
blog
(
LOG_ERROR
,
"texture_isrect (GL) failed"
);
return
false
;
}
return
tex2d
->
base
.
gl_target
==
GL_TEXTURE_RECTANGLE
;
}
libobs/graphics/graphics-imports.c
浏览文件 @
0781670b
...
...
@@ -30,6 +30,11 @@
} \
} while (false)
#define GRAPHICS_IMPORT_OPTIONAL(func) \
do { \
exports->func = os_dlsym(module, #func); \
} while (false)
bool
load_graphics_imports
(
struct
gs_exports
*
exports
,
void
*
module
,
const
char
*
module_name
)
{
...
...
@@ -108,6 +113,7 @@ bool load_graphics_imports(struct gs_exports *exports, void *module,
GRAPHICS_IMPORT
(
texture_getcolorformat
);
GRAPHICS_IMPORT
(
texture_map
);
GRAPHICS_IMPORT
(
texture_unmap
);
GRAPHICS_IMPORT_OPTIONAL
(
texture_isrect
);
GRAPHICS_IMPORT
(
cubetexture_destroy
);
GRAPHICS_IMPORT
(
cubetexture_getsize
);
...
...
libobs/graphics/graphics-internal.h
浏览文件 @
0781670b
...
...
@@ -140,6 +140,7 @@ struct gs_exports {
bool
(
*
texture_map
)(
texture_t
tex
,
void
**
ptr
,
uint32_t
*
row_bytes
);
void
(
*
texture_unmap
)(
texture_t
tex
);
bool
(
*
texture_isrect
)(
texture_t
tex
);
void
(
*
cubetexture_destroy
)(
texture_t
cubetex
);
uint32_t
(
*
cubetexture_getsize
)(
texture_t
cubetex
);
...
...
libobs/graphics/graphics.c
浏览文件 @
0781670b
...
...
@@ -644,6 +644,18 @@ texture_t gs_create_volumetexture_from_file(const char *file, uint32_t flags)
return
NULL
;
}
static
inline
void
assign_sprite_rect
(
float
*
start
,
float
*
end
,
float
size
,
bool
flip
)
{
if
(
!
flip
)
{
*
start
=
0
.
0
f
;
*
end
=
size
;
}
else
{
*
start
=
size
;
*
end
=
0
.
0
f
;
}
}
static
inline
void
assign_sprite_uv
(
float
*
start
,
float
*
end
,
bool
flip
)
{
if
(
!
flip
)
{
...
...
@@ -655,15 +667,11 @@ static inline void assign_sprite_uv(float *start, float *end, bool flip)
}
}
static
inline
void
build_sprite
(
struct
vb_data
*
data
,
float
fcx
,
float
fcy
,
static
void
build_sprite
(
struct
vb_data
*
data
,
float
fcx
,
float
fcy
,
float
start_u
,
float
end_u
,
float
start_v
,
float
end_v
,
uint32_t
flip
)
{
struct
vec2
*
tvarray
=
data
->
tvarray
[
0
].
array
;
float
start_u
,
end_u
;
float
start_v
,
end_v
;
assign_sprite_uv
(
&
start_u
,
&
end_u
,
(
flip
&
GS_FLIP_U
)
!=
0
);
assign_sprite_uv
(
&
start_v
,
&
end_v
,
(
flip
&
GS_FLIP_V
)
!=
0
);
vec3_zero
(
data
->
points
);
vec3_set
(
data
->
points
+
1
,
fcx
,
0
.
0
f
,
0
.
0
f
);
...
...
@@ -675,6 +683,30 @@ static inline void build_sprite(struct vb_data *data, float fcx, float fcy,
vec2_set
(
tvarray
+
3
,
end_u
,
end_v
);
}
static
inline
void
build_sprite_norm
(
struct
vb_data
*
data
,
float
fcx
,
float
fcy
,
uint32_t
flip
)
{
float
start_u
,
end_u
;
float
start_v
,
end_v
;
assign_sprite_uv
(
&
start_u
,
&
end_u
,
(
flip
&
GS_FLIP_U
)
!=
0
);
assign_sprite_uv
(
&
start_v
,
&
end_v
,
(
flip
&
GS_FLIP_V
)
!=
0
);
build_sprite
(
data
,
fcx
,
fcy
,
start_u
,
end_u
,
start_v
,
end_v
,
flip
);
}
static
inline
void
build_sprite_rect
(
struct
vb_data
*
data
,
texture_t
tex
,
float
fcx
,
float
fcy
,
uint32_t
flip
)
{
float
start_u
,
end_u
;
float
start_v
,
end_v
;
float
width
=
(
float
)
texture_getwidth
(
tex
);
float
height
=
(
float
)
texture_getheight
(
tex
);
assign_sprite_rect
(
&
start_u
,
&
end_u
,
width
,
(
flip
&
GS_FLIP_U
)
!=
0
);
assign_sprite_rect
(
&
start_v
,
&
end_v
,
height
,
(
flip
&
GS_FLIP_V
)
!=
0
);
build_sprite
(
data
,
fcx
,
fcy
,
start_u
,
end_u
,
start_v
,
end_v
,
flip
);
}
void
gs_draw_sprite
(
texture_t
tex
,
uint32_t
flip
,
uint32_t
width
,
uint32_t
height
)
{
...
...
@@ -693,7 +725,11 @@ void gs_draw_sprite(texture_t tex, uint32_t flip, uint32_t width,
fcy
=
height
?
(
float
)
height
:
(
float
)
texture_getheight
(
tex
);
data
=
vertexbuffer_getdata
(
graphics
->
sprite_buffer
);
build_sprite
(
data
,
fcx
,
fcy
,
flip
);
if
(
texture_isrect
(
tex
))
build_sprite_rect
(
data
,
tex
,
fcx
,
fcy
,
flip
);
else
build_sprite_norm
(
data
,
fcx
,
fcy
,
flip
);
vertexbuffer_flush
(
graphics
->
sprite_buffer
,
false
);
gs_load_vertexbuffer
(
graphics
->
sprite_buffer
);
gs_load_indexbuffer
(
NULL
);
...
...
@@ -1408,6 +1444,15 @@ void texture_unmap(texture_t tex)
graphics
->
exports
.
texture_unmap
(
tex
);
}
bool
texture_isrect
(
texture_t
tex
)
{
graphics_t
graphics
=
thread_graphics
;
if
(
graphics
->
exports
.
texture_isrect
)
return
graphics
->
exports
.
texture_isrect
(
tex
);
else
return
false
;
}
void
cubetexture_destroy
(
texture_t
cubetex
)
{
graphics_t
graphics
=
thread_graphics
;
...
...
libobs/graphics/graphics.h
浏览文件 @
0781670b
...
...
@@ -641,6 +641,10 @@ EXPORT uint32_t texture_getheight(texture_t tex);
EXPORT
enum
gs_color_format
texture_getcolorformat
(
texture_t
tex
);
EXPORT
bool
texture_map
(
texture_t
tex
,
void
**
ptr
,
uint32_t
*
row_bytes
);
EXPORT
void
texture_unmap
(
texture_t
tex
);
/** special-case function (GL only) - specifies whether the texture is a
* GL_TEXTURE_RECTANGLE type, which doesn't use normalized texture
* coordinates */
EXPORT
bool
texture_isrect
(
texture_t
tex
);
EXPORT
void
cubetexture_destroy
(
texture_t
cubetex
);
EXPORT
uint32_t
cubetexture_getsize
(
texture_t
cubetex
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录