Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
0a4592a4
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,发现更多精彩内容 >>
提交
0a4592a4
编写于
10月 11, 2013
作者:
J
jp9000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
finish up GL vertex buffer code
上级
1b3b1775
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
199 addition
and
24 deletion
+199
-24
libobs-opengl/gl-helpers.c
libobs-opengl/gl-helpers.c
+16
-0
libobs-opengl/gl-helpers.h
libobs-opengl/gl-helpers.h
+15
-0
libobs-opengl/gl-stagesurf.c
libobs-opengl/gl-stagesurf.c
+5
-9
libobs-opengl/gl-subsystem.h
libobs-opengl/gl-subsystem.h
+2
-4
libobs-opengl/gl-texture2d.c
libobs-opengl/gl-texture2d.c
+4
-8
libobs-opengl/gl-vertexbuffer.c
libobs-opengl/gl-vertexbuffer.c
+153
-3
vs/2010/libobs-opengl/libobs-opengl.vcxproj
vs/2010/libobs-opengl/libobs-opengl.vcxproj
+1
-0
vs/2010/libobs-opengl/libobs-opengl.vcxproj.filters
vs/2010/libobs-opengl/libobs-opengl.vcxproj.filters
+3
-0
未找到文件。
libobs-opengl/gl-helpers.c
浏览文件 @
0a4592a4
...
...
@@ -79,3 +79,19 @@ bool gl_copy_texture(struct gs_device *device,
return
success
;
}
bool
gl_create_buffer
(
GLuint
*
buffer
,
GLsizeiptr
size
,
const
GLvoid
*
data
,
GLenum
usage
)
{
bool
success
;
if
(
!
gl_gen_buffers
(
1
,
buffer
))
return
false
;
if
(
!
gl_bind_buffer
(
GL_ARRAY_BUFFER
,
*
buffer
))
return
false
;
glBufferData
(
GL_ARRAY_BUFFER
,
size
,
data
,
usage
);
success
=
gl_success
(
"glBufferData"
);
gl_bind_buffer
(
GL_ARRAY_BUFFER
,
0
);
return
success
;
}
libobs-opengl/gl-helpers.h
浏览文件 @
0a4592a4
...
...
@@ -48,6 +48,12 @@ static inline bool gl_bind_texture(GLenum target, GLuint texture)
return
gl_success
(
"glBindTexture"
);
}
static
inline
void
gl_delete_textures
(
GLsizei
num_buffers
,
GLuint
*
buffers
)
{
glDeleteTextures
(
num_buffers
,
buffers
);
gl_success
(
"glDeleteTextures"
);
}
static
inline
bool
gl_gen_buffers
(
GLsizei
num_buffers
,
GLuint
*
buffers
)
{
glGenBuffers
(
num_buffers
,
buffers
);
...
...
@@ -60,6 +66,12 @@ static inline bool gl_bind_buffer(GLenum target, GLuint buffer)
return
gl_success
(
"glBindBuffer"
);
}
static
inline
void
gl_delete_buffers
(
GLsizei
num_buffers
,
GLuint
*
buffers
)
{
glDeleteBuffers
(
num_buffers
,
buffers
);
gl_success
(
"glDeleteBuffers"
);
}
static
inline
bool
gl_bind_renderbuffer
(
GLenum
target
,
GLuint
buffer
)
{
glBindRenderbuffer
(
target
,
buffer
);
...
...
@@ -75,4 +87,7 @@ extern bool gl_copy_texture(struct gs_device *device,
GLuint
dst
,
GLenum
dst_target
,
uint32_t
width
,
uint32_t
height
);
extern
bool
gl_create_buffer
(
GLuint
*
buffer
,
GLsizeiptr
size
,
const
GLvoid
*
data
,
GLenum
usage
);
#endif
libobs-opengl/gl-stagesurf.c
浏览文件 @
0a4592a4
...
...
@@ -90,15 +90,11 @@ stagesurf_t device_create_stagesurface(device_t device, uint32_t width,
void
stagesurface_destroy
(
stagesurf_t
stagesurf
)
{
if
(
stagesurf
)
{
if
(
stagesurf
->
pack_buffer
)
{
glDeleteBuffers
(
1
,
&
stagesurf
->
pack_buffer
);
gl_success
(
"glDeleteBuffers"
);
}
if
(
stagesurf
->
texture
)
{
glDeleteTextures
(
1
,
&
stagesurf
->
texture
);
gl_success
(
"glDeleteTextures"
);
}
if
(
stagesurf
->
pack_buffer
)
gl_delete_buffers
(
1
,
&
stagesurf
->
pack_buffer
);
if
(
stagesurf
->
texture
)
gl_delete_textures
(
1
,
&
stagesurf
->
texture
);
bfree
(
stagesurf
);
}
...
...
libobs-opengl/gl-subsystem.h
浏览文件 @
0a4592a4
...
...
@@ -228,10 +228,8 @@ struct gs_vertex_buffer {
DARRAY
(
GLuint
)
uv_buffers
;
device_t
device
;
bool
dyanmic
;
struct
vb_data
*
vbd
;
size_t
num_verts
;
DARRAY
(
size_t
)
uv_sizes
;
bool
dynamic
;
struct
vb_data
*
data
;
};
struct
gs_texture
{
...
...
libobs-opengl/gl-texture2d.c
浏览文件 @
0a4592a4
...
...
@@ -116,15 +116,11 @@ void texture_destroy(texture_t tex)
if
(
!
is_texture_2d
(
tex
,
"texture_destroy"
))
return
;
if
(
tex
->
is_dynamic
&&
tex2d
->
unpack_buffer
)
{
glDeleteBuffers
(
1
,
&
tex2d
->
unpack_buffer
);
gl_success
(
"glDeleteBuffers"
);
}
if
(
tex
->
is_dynamic
&&
tex2d
->
unpack_buffer
)
gl_delete_buffers
(
1
,
&
tex2d
->
unpack_buffer
);
if
(
tex
->
texture
)
{
glDeleteTextures
(
1
,
&
tex
->
texture
);
gl_success
(
"glDeleteTextures"
);
}
if
(
tex
->
texture
)
gl_delete_textures
(
1
,
&
tex
->
texture
);
bfree
(
tex
);
}
...
...
libobs-opengl/gl-vertexbuffer.c
浏览文件 @
0a4592a4
...
...
@@ -15,21 +15,171 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include "graphics/vec3.h"
#include "gl-subsystem.h"
static
bool
update_buffer
(
GLuint
buffer
,
void
*
data
,
size_t
size
)
{
void
*
ptr
;
bool
success
=
true
;
if
(
!
gl_bind_buffer
(
GL_ARRAY_BUFFER
,
buffer
))
return
false
;
ptr
=
glMapBuffer
(
GL_ARRAY_BUFFER
,
GL_WRITE_ONLY
);
success
=
gl_success
(
"glMapBuffer"
);
if
(
success
&&
ptr
)
{
memcpy
(
ptr
,
data
,
size
);
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
}
gl_bind_buffer
(
GL_ARRAY_BUFFER
,
0
);
return
success
;
}
static
bool
init_vb
(
struct
gs_vertex_buffer
*
vb
)
{
GLenum
usage
=
vb
->
dynamic
?
GL_DYNAMIC_COPY
:
GL_STATIC_DRAW
;
size_t
i
;
if
(
!
gl_create_buffer
(
&
vb
->
vertex_buffer
,
vb
->
data
->
num
*
sizeof
(
struct
vec3
),
vb
->
data
->
points
,
usage
))
return
false
;
if
(
vb
->
data
->
normals
)
{
if
(
!
gl_create_buffer
(
&
vb
->
normal_buffer
,
vb
->
data
->
num
*
sizeof
(
struct
vec3
),
vb
->
data
->
normals
,
usage
))
return
false
;
}
if
(
vb
->
data
->
tangents
)
{
if
(
!
gl_create_buffer
(
&
vb
->
tangent_buffer
,
vb
->
data
->
num
*
sizeof
(
struct
vec3
),
vb
->
data
->
tangents
,
usage
))
return
false
;
}
if
(
vb
->
data
->
colors
)
{
if
(
!
gl_create_buffer
(
&
vb
->
color_buffer
,
vb
->
data
->
num
*
sizeof
(
uint32_t
),
vb
->
data
->
colors
,
usage
))
return
false
;
}
da_reserve
(
vb
->
uv_buffers
,
vb
->
data
->
num_tex
);
for
(
i
=
0
;
i
<
vb
->
data
->
num_tex
;
i
++
)
{
GLuint
tex_buffer
;
struct
tvertarray
*
tv
=
vb
->
data
->
tvarray
+
i
;
size_t
size
=
vb
->
data
->
num
*
sizeof
(
float
)
*
tv
->
width
;
if
(
!
gl_create_buffer
(
&
tex_buffer
,
size
,
tv
->
array
,
usage
))
return
false
;
da_push_back
(
vb
->
uv_buffers
,
&
tex_buffer
);
}
if
(
!
vb
->
dynamic
)
{
vbdata_destroy
(
vb
->
data
);
vb
->
data
=
NULL
;
}
return
true
;
}
vertbuffer_t
device_create_vertexbuffer
(
device_t
device
,
struct
vb_data
*
data
,
uint32_t
flags
)
{
struct
gs_vertex_buffer
*
vb
=
bmalloc
(
sizeof
(
struct
gs_vertex_buffer
));
memset
(
vb
,
0
,
sizeof
(
struct
gs_vertex_buffer
));
vb
->
data
=
data
;
vb
->
dynamic
=
flags
&
GS_DYNAMIC
;
if
(
!
init_vb
(
vb
))
{
blog
(
LOG_ERROR
,
"device_create_vertexbuffer (GL) failed"
);
vertexbuffer_destroy
(
vb
);
return
NULL
;
}
return
vb
;
}
void
vertexbuffer_destroy
(
vertbuffer_t
v
ertbuffer
)
void
vertexbuffer_destroy
(
vertbuffer_t
v
b
)
{
if
(
vb
)
{
if
(
vb
->
vertex_buffer
)
gl_delete_buffers
(
1
,
&
vb
->
vertex_buffer
);
if
(
vb
->
normal_buffer
)
gl_delete_buffers
(
1
,
&
vb
->
normal_buffer
);
if
(
vb
->
tangent_buffer
)
gl_delete_buffers
(
1
,
&
vb
->
tangent_buffer
);
if
(
vb
->
color_buffer
)
gl_delete_buffers
(
1
,
&
vb
->
color_buffer
);
if
(
vb
->
uv_buffers
.
num
)
gl_delete_buffers
((
GLsizei
)
vb
->
uv_buffers
.
num
,
vb
->
uv_buffers
.
array
);
da_free
(
vb
->
uv_buffers
);
vbdata_destroy
(
vb
->
data
);
bfree
(
vb
);
}
}
void
vertexbuffer_flush
(
vertbuffer_t
v
ertbuffer
,
bool
rebuild
)
void
vertexbuffer_flush
(
vertbuffer_t
v
b
,
bool
rebuild
)
{
size_t
i
;
if
(
!
vb
->
dynamic
)
{
blog
(
LOG_ERROR
,
"vertex buffer is not dynamic"
);
goto
failed
;
}
if
(
!
update_buffer
(
vb
->
vertex_buffer
,
vb
->
data
->
points
,
vb
->
data
->
num
*
sizeof
(
struct
vec3
)))
goto
failed
;
if
(
vb
->
normal_buffer
)
{
if
(
!
update_buffer
(
vb
->
normal_buffer
,
vb
->
data
->
normals
,
vb
->
data
->
num
*
sizeof
(
struct
vec3
)))
goto
failed
;
}
if
(
vb
->
tangent_buffer
)
{
if
(
!
update_buffer
(
vb
->
tangent_buffer
,
vb
->
data
->
tangents
,
vb
->
data
->
num
*
sizeof
(
struct
vec3
)))
goto
failed
;
}
if
(
vb
->
color_buffer
)
{
if
(
!
update_buffer
(
vb
->
color_buffer
,
vb
->
data
->
colors
,
vb
->
data
->
num
*
sizeof
(
uint32_t
)))
goto
failed
;
}
for
(
i
=
0
;
i
<
vb
->
data
->
num_tex
;
i
++
)
{
GLuint
buffer
=
vb
->
uv_buffers
.
array
[
i
];
struct
tvertarray
*
tv
=
vb
->
data
->
tvarray
+
i
;
size_t
size
=
vb
->
data
->
num
*
tv
->
width
*
sizeof
(
float
);
if
(
!
update_buffer
(
buffer
,
tv
->
array
,
size
))
goto
failed
;
}
return
;
failed:
blog
(
LOG_ERROR
,
"vertexbuffer_flush (GL) failed"
);
}
struct
vb_data
*
vertexbuffer_getdata
(
vertbuffer_t
v
ertbuffer
)
struct
vb_data
*
vertexbuffer_getdata
(
vertbuffer_t
v
b
)
{
return
vb
->
data
;
}
vs/2010/libobs-opengl/libobs-opengl.vcxproj
浏览文件 @
0a4592a4
...
...
@@ -168,6 +168,7 @@
<ClCompile
Include=
"..\..\..\libobs-opengl\gl-subsystem.c"
/>
<ClCompile
Include=
"..\..\..\libobs-opengl\gl-texture2d.c"
/>
<ClCompile
Include=
"..\..\..\libobs-opengl\gl-texturecube.c"
/>
<ClCompile
Include=
"..\..\..\libobs-opengl\gl-vertexbuffer.c"
/>
<ClCompile
Include=
"..\..\..\libobs-opengl\gl-windows.c"
/>
<ClCompile
Include=
"..\..\..\libobs-opengl\gl-zstencil.c"
/>
</ItemGroup>
...
...
vs/2010/libobs-opengl/libobs-opengl.vcxproj.filters
浏览文件 @
0a4592a4
...
...
@@ -56,5 +56,8 @@
<ClCompile
Include=
"..\..\..\libobs-opengl\gl-stagesurf.c"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\..\libobs-opengl\gl-vertexbuffer.c"
>
<Filter>
Source Files
</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录