Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
e159fc4f
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,发现更多精彩内容 >>
提交
e159fc4f
编写于
10月 09, 2013
作者:
J
jp9000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fill in shader parameter functions
上级
fda2ee11
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
89 addition
and
1 deletion
+89
-1
libobs-d3d11/GS_D3D11Shader.cpp
libobs-d3d11/GS_D3D11Shader.cpp
+3
-1
libobs-opengl/gl-shader.c
libobs-opengl/gl-shader.c
+86
-0
未找到文件。
libobs-d3d11/GS_D3D11Shader.cpp
浏览文件 @
e159fc4f
...
@@ -295,7 +295,9 @@ void shader_setint(shader_t shader, sparam_t param, int val)
...
@@ -295,7 +295,9 @@ void shader_setint(shader_t shader, sparam_t param, int val)
void
shader_setmatrix3
(
shader_t
shader
,
sparam_t
param
,
void
shader_setmatrix3
(
shader_t
shader
,
sparam_t
param
,
const
struct
matrix3
*
val
)
const
struct
matrix3
*
val
)
{
{
shader_setval_inline
(
shader
,
param
,
val
,
sizeof
(
matrix3
));
struct
matrix4
mat
;
matrix4_from_matrix3
(
&
mat
,
val
);
shader_setval_inline
(
shader
,
param
,
&
mat
,
sizeof
(
matrix4
));
}
}
void
shader_setmatrix4
(
shader_t
shader
,
sparam_t
param
,
void
shader_setmatrix4
(
shader_t
shader
,
sparam_t
param
,
...
...
libobs-opengl/gl-shader.c
浏览文件 @
e159fc4f
...
@@ -16,6 +16,11 @@
...
@@ -16,6 +16,11 @@
******************************************************************************/
******************************************************************************/
#include <assert.h>
#include <assert.h>
#include "graphics/vec2.h"
#include "graphics/vec3.h"
#include "graphics/vec4.h"
#include "graphics/matrix3.h"
#include "graphics/matrix4.h"
#include "gl-subsystem.h"
#include "gl-subsystem.h"
#include "gl-shaderparser.h"
#include "gl-shaderparser.h"
...
@@ -243,50 +248,131 @@ sparam_t shader_getworldmatrix(shader_t shader)
...
@@ -243,50 +248,131 @@ sparam_t shader_getworldmatrix(shader_t shader)
void
shader_setbool
(
shader_t
shader
,
sparam_t
param
,
bool
val
)
void
shader_setbool
(
shader_t
shader
,
sparam_t
param
,
bool
val
)
{
{
glProgramUniform1i
(
shader
->
program
,
param
->
param
,
(
GLint
)
val
);
gl_success
(
"glProgramUniform1i"
);
}
}
void
shader_setfloat
(
shader_t
shader
,
sparam_t
param
,
float
val
)
void
shader_setfloat
(
shader_t
shader
,
sparam_t
param
,
float
val
)
{
{
glProgramUniform1f
(
shader
->
program
,
param
->
param
,
val
);
gl_success
(
"glProgramUniform1f"
);
}
}
void
shader_setint
(
shader_t
shader
,
sparam_t
param
,
int
val
)
void
shader_setint
(
shader_t
shader
,
sparam_t
param
,
int
val
)
{
{
glProgramUniform1i
(
shader
->
program
,
param
->
param
,
val
);
gl_success
(
"glProgramUniform1i"
);
}
}
void
shader_setmatrix3
(
shader_t
shader
,
sparam_t
param
,
void
shader_setmatrix3
(
shader_t
shader
,
sparam_t
param
,
const
struct
matrix3
*
val
)
const
struct
matrix3
*
val
)
{
{
struct
matrix4
mat
;
matrix4_from_matrix3
(
&
mat
,
val
);
glProgramUniformMatrix4fv
(
shader
->
program
,
param
->
param
,
1
,
true
,
mat
.
x
.
ptr
);
gl_success
(
"glProgramUniformMatrix4fv"
);
}
}
void
shader_setmatrix4
(
shader_t
shader
,
sparam_t
param
,
void
shader_setmatrix4
(
shader_t
shader
,
sparam_t
param
,
const
struct
matrix4
*
val
)
const
struct
matrix4
*
val
)
{
{
glProgramUniformMatrix4fv
(
shader
->
program
,
param
->
param
,
1
,
true
,
val
->
x
.
ptr
);
gl_success
(
"glProgramUniformMatrix4fv"
);
}
}
void
shader_setvec2
(
shader_t
shader
,
sparam_t
param
,
void
shader_setvec2
(
shader_t
shader
,
sparam_t
param
,
const
struct
vec2
*
val
)
const
struct
vec2
*
val
)
{
{
glProgramUniform2fv
(
shader
->
program
,
param
->
param
,
1
,
val
->
ptr
);
gl_success
(
"glProgramUniform2fv"
);
}
}
void
shader_setvec3
(
shader_t
shader
,
sparam_t
param
,
void
shader_setvec3
(
shader_t
shader
,
sparam_t
param
,
const
struct
vec3
*
val
)
const
struct
vec3
*
val
)
{
{
glProgramUniform3fv
(
shader
->
program
,
param
->
param
,
1
,
val
->
ptr
);
gl_success
(
"glProgramUniform3fv"
);
}
}
void
shader_setvec4
(
shader_t
shader
,
sparam_t
param
,
void
shader_setvec4
(
shader_t
shader
,
sparam_t
param
,
const
struct
vec4
*
val
)
const
struct
vec4
*
val
)
{
{
glProgramUniform4fv
(
shader
->
program
,
param
->
param
,
1
,
val
->
ptr
);
gl_success
(
"glProgramUniform4fv"
);
}
}
void
shader_settexture
(
shader_t
shader
,
sparam_t
param
,
texture_t
val
)
void
shader_settexture
(
shader_t
shader
,
sparam_t
param
,
texture_t
val
)
{
{
}
}
static
void
shader_setval_data
(
shader_t
shader
,
sparam_t
param
,
const
void
*
val
,
int
count
)
{
if
(
param
->
type
==
SHADER_PARAM_BOOL
||
param
->
type
==
SHADER_PARAM_INT
)
{
glProgramUniform1iv
(
shader
->
program
,
param
->
param
,
count
,
val
);
gl_success
(
"glProgramUniform1iv"
);
}
else
if
(
param
->
type
==
SHADER_PARAM_FLOAT
)
{
glProgramUniform1fv
(
shader
->
program
,
param
->
param
,
count
,
val
);
gl_success
(
"glProgramUniform1fv"
);
}
else
if
(
param
->
type
==
SHADER_PARAM_VEC2
)
{
glProgramUniform2fv
(
shader
->
program
,
param
->
param
,
count
,
val
);
gl_success
(
"glProgramUniform2fv"
);
}
else
if
(
param
->
type
==
SHADER_PARAM_VEC3
)
{
glProgramUniform3fv
(
shader
->
program
,
param
->
param
,
count
,
val
);
gl_success
(
"glProgramUniform3fv"
);
}
else
if
(
param
->
type
==
SHADER_PARAM_VEC4
)
{
glProgramUniform4fv
(
shader
->
program
,
param
->
param
,
count
,
val
);
gl_success
(
"glProgramUniform4fv"
);
}
else
if
(
param
->
type
==
SHADER_PARAM_MATRIX4X4
)
{
glProgramUniformMatrix4fv
(
shader
->
program
,
param
->
param
,
count
,
false
,
val
);
gl_success
(
"glProgramUniformMatrix4fv"
);
}
}
void
shader_setval
(
shader_t
shader
,
sparam_t
param
,
const
void
*
val
,
void
shader_setval
(
shader_t
shader
,
sparam_t
param
,
const
void
*
val
,
size_t
size
)
size_t
size
)
{
{
int
count
=
param
->
array_count
;
size_t
expected_size
=
0
;
if
(
!
count
)
count
=
1
;
switch
(
param
->
type
)
{
case
SHADER_PARAM_FLOAT
:
expected_size
=
sizeof
(
float
);
break
;
case
SHADER_PARAM_BOOL
:
case
SHADER_PARAM_INT
:
expected_size
=
sizeof
(
int
);
break
;
case
SHADER_PARAM_VEC2
:
expected_size
=
sizeof
(
float
)
*
2
;
break
;
case
SHADER_PARAM_VEC3
:
expected_size
=
sizeof
(
float
)
*
3
;
break
;
case
SHADER_PARAM_VEC4
:
expected_size
=
sizeof
(
float
)
*
4
;
break
;
case
SHADER_PARAM_MATRIX3X3
:
expected_size
=
sizeof
(
float
)
*
3
*
3
;
break
;
case
SHADER_PARAM_MATRIX4X4
:
expected_size
=
sizeof
(
float
)
*
4
*
4
;
break
;
}
expected_size
*=
count
;
if
(
!
expected_size
)
return
;
if
(
expected_size
!=
size
)
{
blog
(
LOG_ERROR
,
"shader_setval (GL): Size of shader param does "
"not match the size of the input"
);
return
;
}
shader_setval_data
(
shader
,
param
,
val
,
count
);
}
}
void
shader_setdefault
(
shader_t
shader
,
sparam_t
param
)
void
shader_setdefault
(
shader_t
shader
,
sparam_t
param
)
{
{
shader_setval
(
shader
,
param
,
param
->
def_value
.
array
,
param
->
def_value
.
num
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录