本文整理汇总了C++中ObjectDesc函数的典型用法代码示例。如果您正苦于以下问题:C++ ObjectDesc函数的具体用法?C++ ObjectDesc怎么用?C++ ObjectDesc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectDesc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: make
static Program make(void)
{
Program prog;
prog << VertexShader(ObjectDesc("Mesh"),
"#version 330\n"
"uniform mat4 ProjectionMatrix, CameraMatrix, ModelMatrix;"
"in vec4 Position;"
"void main(void)"
"{"
" gl_Position = "
" ProjectionMatrix*CameraMatrix*ModelMatrix*Position;"
"}"
);
prog << FragmentShader(ObjectDesc("Mesh"),
"#version 330\n"
"out vec3 fragColor;"
"void main(void)"
"{"
" fragColor = vec3(0.1);"
"}"
);
prog.Link();
return prog;
}
示例2: make_prog
static Program make_prog(FBTexExample& example)
{
Program prog(ObjectDesc("Thread"));
prog.AttachShader(example.vertex_shader);
FragmentShader fs(ObjectDesc("Thread fragment"));
fs.Source(
"#version 330\n"
"in vec3 vertNormal;"
"in vec3 vertLight;"
"in vec2 vertTexCoord;"
"out vec3 fragColor;"
"void main(void)"
"{"
" float d = max(dot("
" vertNormal, "
" normalize(vertLight)"
" ), 0.0);"
" float i = int("
" vertTexCoord.x*18.0+"
" vertTexCoord.y*14.0 "
" ) % 2;"
" vec3 Red = vec3(1.0, 0.2, 0.2);"
" vec3 White = vec3(1.0, 1.0, 1.0);"
" fragColor = (0.4+0.8*d)*mix(Red, White, i);"
"}"
);
fs.Compile();
prog.AttachShader(fs);
prog.Link().Use();
return std::move(prog);
}
示例3: ShapeVertShader
ShapeVertShader(void)
: VertexShader(
ObjectDesc("Shape vertex shader"),
StrCRef("#version 330\n"
"uniform mat4 ProjectionMatrix, CameraMatrix, ModelMatrix;"
"uniform vec3 CameraPosition;"
"in vec4 Position;"
"in vec3 Normal;"
"in vec3 Tangent;"
"in vec2 TexCoord;"
"out vec3 vertPosition;"
"out vec3 vertViewDir;"
"out vec3 vertNormal;"
"out vec3 vertTangent;"
"out vec3 vertBitangent;"
"out vec2 vertTexCoord;"
"void main(void)"
"{"
" gl_Position = ModelMatrix * Position;"
" vertPosition = gl_Position.xyz;"
" vertViewDir = CameraPosition - gl_Position.xyz;"
" vertNormal = (ModelMatrix * vec4(Normal, 0.0)).xyz;"
" vertTangent = (ModelMatrix * vec4(Tangent, 0.0)).xyz;"
" vertBitangent = cross(vertNormal, vertTangent);"
" vertTexCoord = mat2(0.0, 2.0, 1.0, 0.0) * TexCoord;"
" gl_Position = "
" ProjectionMatrix * "
" CameraMatrix * "
" gl_Position;"
"}")
)
{ }
示例4: make
static Program make() {
Program prog(ObjectDesc("Shape program"));
prog.AttachShader(ShapeVertShader());
prog.AttachShader(ShapeFragShader());
prog.Link().Use();
return prog;
}
示例5: make
static Program make(void)
{
Program prog(ObjectDesc("Sketch"));
prog.AttachShader(SketchFragShader());
prog.MakeSeparable().Link().Use();
return prog;
}
示例6: PointVertShader
PointVertShader()
: VertexShader(
ObjectDesc("Vertex shader"),
"#version 140\n"
"uniform mat4 ProjectionMatrix, CameraMatrix, ModelMatrix;"
"uniform vec3 Color1, Color2;"
"uniform float Status;"
"in vec4 Position1, Position2;"
"in float Radiance1, Radiance2;"
"out vec3 vertColor;"
"void main()"
"{"
" gl_Position = "
" ProjectionMatrix * "
" CameraMatrix * "
" ModelMatrix * "
" mix(Position1, Position2, Status);"
" gl_PointSize = (2.0 + 3.0 * mix("
" Radiance1, "
" Radiance2, "
" Status"
" ));"
" vertColor = mix("
" (0.2 + Radiance1) * Color1,"
" (0.2 + Radiance2) * Color2,"
" Status"
" );"
"}") {}
示例7: CubeVertShader
CubeVertShader(void)
: VertexShader(
ObjectDesc("Cube vertex"),
"#version 400\n"
"uniform vec3 LightPosition;"
"uniform vec3 CameraPosition;"
"uniform mat4 ProjectionMatrix, CameraMatrix, ModelMatrix;"
"in vec4 Position;"
"in vec3 Normal;"
"in vec3 TexCoord;"
"out vec3 vertNormal;"
"out vec3 vertLightDir;"
"out vec3 vertLightRefl;"
"out vec3 vertViewDir;"
"out vec2 vertTexCoord;"
"void main(void)"
"{"
" gl_Position = ModelMatrix* Position;"
" vertNormal = mat3(ModelMatrix)*Normal;"
" vertLightDir = normalize(LightPosition - gl_Position.xyz);"
" vertLightRefl = reflect(-vertLightDir, vertNormal);"
" vertViewDir = normalize(CameraPosition - gl_Position.xyz);"
" gl_Position = ProjectionMatrix * CameraMatrix * gl_Position;"
" vertTexCoord = TexCoord.xy;"
"}"
)
{ }
示例8: make
static Program make(void)
{
Program prog(ObjectDesc("Metal"));
prog.AttachShader(MetalFragmentShader());
prog.MakeSeparable().Link().Use();
return prog;
}
示例9: make
static Program make() {
Program prog(ObjectDesc("Point program"));
prog.AttachShader(PointVertShader());
prog.AttachShader(PointFragShader());
prog.Link().Use();
return prog;
}
示例10: make
static Program make() {
Program prog(ObjectDesc("Metal program"));
prog.AttachShader(MetalVertShader());
prog.AttachShader(MetalFragShader());
prog.Link().Use();
return prog;
}
示例11: make_prog
Program make_prog(void)
{
Program result(ObjectDesc("Main"));
vertex_shader.Source(
"#version 330\n"
"uniform mat4 ProjectionMatrix, CameraMatrix, ModelMatrix;"
"in vec4 Position;"
"in vec3 Normal;"
"in vec2 TexCoord;"
"out vec3 vertNormal;"
"out vec3 vertLight;"
"out vec2 vertTexCoord;"
"uniform vec3 LightPos;"
"void main(void)"
"{"
" vertNormal = mat3(ModelMatrix)*Normal;"
" gl_Position = ModelMatrix * Position;"
" vertLight = LightPos-gl_Position.xyz;"
" vertTexCoord = TexCoord;"
" gl_Position = ProjectionMatrix * CameraMatrix * gl_Position;"
"}"
).Compile();
result.AttachShader(vertex_shader);
FragmentShader fs(ObjectDesc("Main fragment"));
fs.Source(
"#version 330\n"
"uniform sampler2D TexUnit;"
"in vec3 vertNormal;"
"in vec3 vertLight;"
"in vec2 vertTexCoord;"
"out vec4 fragColor;"
"void main(void)"
"{"
" float d = dot(vertNormal, normalize(vertLight));"
" float i = 0.6 + max(d, 0.0);"
" fragColor = texture(TexUnit, vertTexCoord)*i;"
"}"
);
fs.Compile();
result.AttachShader(fs);
result.Link().Use();
return std::move(result);
}
示例12: make
static Program make(const VertexShader& vs)
{
Program prog;
FragmentShader fs(ObjectDesc("Draw"));
fs.Source(
"#version 140\n"
"const vec3 LightColor = vec3(0.6, 0.6, 1.0);"
"const vec3 Up = normalize(vec3(0.1, 1.0, 0.1));"
"uniform vec3 LightScreenPos;"
"uniform vec2 ScreenSize;"
"uniform sampler2DRect LightMap;"
"uniform sampler2DShadow ShadowMap;"
"in vec3 vertNormal;"
"in vec3 vertLightDir;"
"in vec4 vertShadowCoord;"
"out vec3 fragColor;"
"void main(void)"
"{"
" vec3 ShadowCoord = (vertShadowCoord.xyz/vertShadowCoord.w)*0.5 + 0.5;"
" float s = 0.0f;"
" if("
" ShadowCoord.x >= 0.0 && "
" ShadowCoord.x <= 1.0 && "
" ShadowCoord.y >= 0.0 && "
" ShadowCoord.y <= 1.0 && "
" ShadowCoord.z <= 1.0"
" ) s = texture(ShadowMap, ShadowCoord);"
" float a = 0.1*(max(dot(vertNormal, Up)+0.1, 0.0)+0.1);"
" float d = max(dot(vertNormal, vertLightDir)+0.1, 0.0)+a;"
" vec2 LMCoord = gl_FragCoord.xy;"
" vec2 LPos = (LightScreenPos.xy*0.5+0.5)*ScreenSize;"
" vec2 Ray = LMCoord - LPos;"
" float Len = length(Ray);"
" int NSampl = int(max(abs(Ray.x), abs(Ray.y)))+1;"
" vec2 RayStep = Ray / NSampl;"
" float r = texture(LightMap, LMCoord).r;"
" NSampl = min(NSampl, int(min(ScreenSize.x, ScreenSize.y)*0.25));"
" for(int s=0; s!=NSampl;++s)"
" {"
" r += texture(LightMap, LPos+RayStep*s).r;"
" }"
" r /= NSampl;"
" r = min(r, 1.0);"
" fragColor = LightColor * (mix(a, d, s) + r);"
"}"
).Compile();
prog.AttachShader(vs).AttachShader(fs);
prog.Link().Use();
return prog;
}
示例13: make
static Program make(void)
{
Program prog(ObjectDesc("Light program"));
prog.AttachShader(LightVertShader());
prog.AttachShader(LightFragShader());
prog.Link().Use();
return prog;
}
示例14: make
static Program make(void)
{
Program prog(ObjectDesc("Cube program"));
prog.AttachShader(CubeVertShader());
prog.AttachShader(CubeFragShader());
prog.Link().Use();
return prog;
}
示例15: make_fs
// makes a fragment shader from the prologe, custom part and epilogue
static Shader make_fs(const char* color_fs, const char* desc)
{
Shader shader(ShaderType::Fragment, ObjectDesc(desc));
const GLchar* src[3] = {fs_prologue(), color_fs, fs_epilogue()};
shader.Source(src);
shader.Compile();
return shader;
}