本文整理汇总了C++中shapes::ShapeWrapper类的典型用法代码示例。如果您正苦于以下问题:C++ ShapeWrapper类的具体用法?C++ ShapeWrapper怎么用?C++ ShapeWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ShapeWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void Render(double time) {
const double day_duration = 67.0;
auto sun =
Vec3f(0.000, 1.000, 0.000) * 1e10 * SineWave(time / day_duration) +
Vec3f(0.000, 0.000, -1.000) * 1e10 * CosineWave(time / day_duration);
auto camera = CamMatrixf::Orbiting(
Vec3f(),
5.0,
FullCircles(-0.10 - time / 27.0),
Degrees(-20 - SineWave(time / 17.0) * 30));
auto model = ModelMatrixf::RotationA(
Vec3f(1.0, 1.0, 1.0), FullCircles(time / 13.0));
gl.Clear().ColorBuffer().DepthBuffer();
sky_box.Use();
sky_box_prog.Use();
sky_box_camera_matrix.Set(camera);
sky_box_sun_position.Set(sun);
sky_box.Draw();
shape.Use();
shape_prog.Use();
shape_model_matrix.Set(model);
shape_camera_matrix.Set(camera);
shape_camera_position.Set(camera.Position());
shape_sun_position.Set(sun);
shape.Draw();
}
示例2: gl
LightRayExample(void)
: gl()
, mesh_loader(
mesh_input.stream,
shapes::ObjMesh::LoadingOptions(false).Normals()
), meshes(List("Position")("Normal").Get(), mesh_loader)
, fan_index(mesh_loader.GetMeshIndex("Fan"))
, light_position(0.0, 0.0, -100.0)
, vert_shader()
, mask_prog(vert_shader)
, mask_vao(meshes.VAOForProgram(mask_prog))
, draw_prog(vert_shader)
, draw_vao(meshes.VAOForProgram(draw_prog))
, shadow_tex_unit(0)
, light_tex_unit(1)
{
mesh_input.stream.close();
gl.ClearDepth(1.0f);
gl.Enable(Capability::DepthTest);
RenderShadowMap(512);
SetupLightMask();
mask_prog.Use();
mask_prog.light_position.Set(light_position);
draw_prog.Use();
draw_prog.light_position.Set(light_position);
gl.ClearColor(1.0f, 1.0f, 1.0f, 0.0f);
}
示例3: Update
void Update(double time)
{
gl.Viewport(size, size);
fbo.Bind(Framebuffer::Target::Draw);
Framebuffer::AttachColorTexture(
Framebuffer::Target::Draw,
1,
holder.CurrentHeightMap(),
0
);
Context::ColorBuffer draw_buffs[2] = {
FramebufferColorAttachment::_0,
FramebufferColorAttachment::_1
};
gl.DrawBuffers(draw_buffs);
prog.Use();
prog.hmap_1.Set(holder.HMapUnit1());
prog.hmap_2.Set(holder.HMapUnit2());
prog.time.Set(time);
screen.Use();
gl.Disable(Capability::DepthTest);
screen.Draw();
gl.Enable(Capability::DepthTest);
holder.Swap();
}
示例4: Render
void Render(double time)
{
auto camera =
CamMatrixf::Roll(Degrees(SineWave(time / 11.0)*7+SineWave(time/13.0)*5))*
CamMatrixf::Orbiting(
Vec3f(),
40.0f,
Degrees(SineWave(time / 11.0)*10+CosineWave(time/19.0)*10-90),
Degrees(SineWave(time / 17.0)*10+SineWave(time/13.0)*10)
);
auto mm_identity = ModelMatrixf();
auto mm_rotation = ModelMatrixf::RotationZ(FullCircles(time / 7.0));
Uniform<Mat4f>* model_matrix = nullptr;
GLuint drawing_fan = fan_index;
auto drawing_driver =
[
&model_matrix,
&mm_identity,
&mm_rotation,
&drawing_fan
](GLuint phase) -> bool
{
if(phase == drawing_fan)
model_matrix->Set(mm_rotation);
else model_matrix->Set(mm_identity);
return true;
};
// render the light mask
light_fbo.Bind(Framebuffer::Target::Draw);
gl.Clear().ColorBuffer().DepthBuffer();
mask_vao.Bind();
mask_prog.Use();
mask_prog.camera_matrix.Set(camera);
model_matrix = &mask_prog.model_matrix;
meshes.Draw(drawing_driver);
// render the final image
DefaultFramebuffer().Bind(Framebuffer::Target::Draw);
gl.Clear().ColorBuffer().DepthBuffer();
draw_vao.Bind();
draw_prog.Use();
Vec4f lsp = projection * camera * Vec4f(light_position, 1.0);
draw_prog.light_screen_pos = lsp.xyz()/lsp.w();
draw_prog.camera_matrix.Set(camera);
model_matrix = &draw_prog.model_matrix;
meshes.Draw(drawing_driver);
}
示例5: Render
void Render(double time)
{
flow.Update(time);
Framebuffer::BindDefault(Framebuffer::Target::Draw);
gl.DrawBuffer(ColorBuffer::BackLeft);
gl.Viewport(width, height);
gl.Clear().ColorBuffer().DepthBuffer();
screen_prog.Use();
screen.Use();
screen.Draw();
}
示例6: Render
void Render(double time)
{
gl.Clear().ColorBuffer().DepthBuffer();
camera_matrix.Set(
CamMatrixf::Orbiting(
Vec3f(),
4.0,
Degrees(time * 25),
Degrees(SineWave(time / 30.0) * 90)
)
);
model_matrix.Set(
ModelMatrixf::RotationA(
Vec3f(1.0f, 1.0f, 1.0f),
FullCircles(time * 0.5)
)
);
shape.Draw();
thread_ready.Signal();
parent_ready.Wait();
}
示例7: gl
ObjMeshExample(void)
: gl()
, objects(load_objects())
, depth_prog()
, draw_prog()
, depth_vao(objects.VAOForProgram(depth_prog))
, draw_vao(objects.VAOForProgram(draw_prog))
{
UniformSampler(draw_prog, "DepthTex").Set(0);
Texture::Active(0);
depth_tex.Bind(Texture::Target::Rectangle);
gl.ClearColor(0.8f, 0.8f, 0.7f, 0.0f);
gl.Enable(Capability::DepthTest);
gl.Enable(Capability::CullFace);
}
示例8: Draw
void Draw(double time, double fade)
{
// Shadow map
shadows_fbo.Bind(FramebufferTarget::Draw);
gl.Viewport(shadow_size, shadow_size);
gl.Clear().DepthBuffer();
auto light = CamMatrixf::Orbiting(
Vec3f(0, side*0.25, 0),
side*1.5,
Degrees(-time * 27),
Degrees(SineWave(time / 19.0)*25 + 45)
);
shadow_prog.fade.Set(fade);
shadow_prog.camera_matrix.Set(light);
shadow_prog.Use();
shadow_vao.Bind();
gl.Enable(Capability::PolygonOffsetFill);
cube.Draw(side*side);
gl.Disable(Capability::PolygonOffsetFill);
gl.Finish();
// On-screen
default_fb.Bind(Framebuffer::Target::Draw);
gl.Viewport(width, height);
gl.Clear().ColorBuffer().DepthBuffer();
auto camera = CamMatrixf::Orbiting(
Vec3f(),
side*1.1,
Degrees(time * 19),
Degrees(SineWave(time / 20.0) * 39 + 50)
);
display_prog.fade.Set(fade);
display_prog.light_pos.Set(light.Position());
display_prog.camera_pos.Set(camera.Position());
display_prog.light_matrix.Set(light);
display_prog.camera_matrix.Set(camera);
display_prog.Use();
display_vao.Bind();
cube.Draw(side*side);
}
示例9: Render
void Render(double time)
{
gl.ClearDepth(0.0f);
gl.Clear().DepthBuffer();
auto camera =
CamMatrixf::Orbiting(
objects.BoundingSphere().Center(),
objects.BoundingSphere().Radius()*2.8,
FullCircles(time / 19.0),
Degrees(SineWave(time / 17.0) * 90)
);
depth_prog.Use();
gl.DepthFunc(CompareFn::Greater);
gl.CullFace(Face::Front);
depth_prog.camera_matrix.Set(camera);
depth_prog.model_matrix.Set(Mat4f());
objects.Draw();
Texture::CopyImage2D(
Texture::Target::Rectangle,
0,
PixelDataInternalFormat::DepthComponent,
0, 0,
width,
height,
0
);
gl.ClearDepth(1.0f);
gl.Clear().ColorBuffer().DepthBuffer();
draw_prog.Use();
gl.DepthFunc(CompareFn::Less);
gl.CullFace(Face::Back);
draw_prog.camera_matrix.Set(camera);
draw_prog.model_matrix.Set(Mat4f());
objects.Draw();
}
示例10: ParallaxExample
ParallaxExample()
: prog(make_prog())
, projection_matrix(prog, "ProjectionMatrix")
, camera_matrix(prog, "CameraMatrix")
, camera_position(prog, "CameraPosition")
, light_position(prog, "LightPosition")
, shape(
List("Position")("TexCoord").Get(),
shapes::Plane(
Vec3f(),
Vec3f(1.0f, 0.0f, 0.0f),
Vec3f(0.0f, 0.0f, -1.0f),
32,
32)) {
shape.UseInProgram(prog);
auto tex_image = images::LoadTexture("stones_color_hmap");
Texture::Active(0);
try {
UniformSampler(prog, "ColorMap").Set(0);
gl.Bound(Texture::Target::_2D, color_tex)
.MinFilter(TextureMinFilter::LinearMipmapLinear)
.MagFilter(TextureMagFilter::Linear)
.WrapS(TextureWrap::Repeat)
.WrapT(TextureWrap::Repeat)
.Image2D(tex_image)
.GenerateMipmap();
} catch(Error&) {
}
Texture::Active(1);
try {
UniformSampler(prog, "BumpMap").Set(1);
gl.Bound(Texture::Target::_2D, bump_tex)
.MinFilter(TextureMinFilter::LinearMipmapLinear)
.MagFilter(TextureMagFilter::Linear)
.WrapS(TextureWrap::Repeat)
.WrapT(TextureWrap::Repeat)
.Image2D(
images::NormalMap(tex_image, images::NormalMap::FromAlpha()))
.GenerateMipmap();
} catch(Error&) {
}
gl.ClearColor(0.1f, 0.1f, 0.1f, 0.0f);
gl.ClearDepth(1.0f);
(Capability::DepthTest) << true;
(Capability::CullFace) << false;
(Functionality::ClipDistance | 0) << true;
(Functionality::ClipDistance | 1) << true;
(Functionality::ClipDistance | 2) << true;
}
示例11: Render
void Render(double time)
{
float o = 2;
float s = 24;
prog.offset.Set(
GLfloat(CosineWave(time/59.0)*o),
GLfloat(SineWave(time/61.0)*o)
);
prog.scale.Set(GLfloat(s + 1 + SineWave(time / 19.0)*s));
screen.Draw();
}
示例12: gl
BarDisplay(void)
: gl()
, side(128)
, shadow_size(512)
, cube(
List("Position")("Normal").Get(),
shapes::Cube(0.95, 1.0, 0.95, 0.0, 0.5, 0.0)
), display_vao(cube.VAOForProgram(display_prog))
, shadow_vao(cube.VAOForProgram(shadow_prog))
{
init_shadows();
init_heights();
init_offsets();
auto light_proj = CamMatrixf::PerspectiveX(
Degrees(74),
1.0,
1, 3*side
);
display_prog.light_proj_matrix.Set(light_proj);
shadow_prog.projection_matrix.Set(light_proj);
gl.PolygonOffset(4.0, 4.0);
}
示例13: ParallaxMapExample
ParallaxMapExample()
: prog(make())
, projection_matrix(prog, "ProjectionMatrix")
, camera_matrix(prog, "CameraMatrix")
, model_matrix(prog, "ModelMatrix")
, camera_position(prog, "CameraPosition")
, light_position(prog, "LightPosition")
, shape(
List("Position")("Normal")("Tangent")("TexCoord").Get(),
shapes::Torus(1.0f, 0.5, 72, 48)) {
shape.UseInProgram(prog);
auto tex_image = images::LoadTexture("bricks_color_hmap");
Texture::Active(0);
try {
UniformSampler(prog, "ColorMap").Set(0);
gl.Bound(Texture::Target::_2D, color_tex)
.MinFilter(TextureMinFilter::LinearMipmapLinear)
.MagFilter(TextureMagFilter::Linear)
.WrapS(TextureWrap::Repeat)
.WrapT(TextureWrap::Repeat)
.Image2D(tex_image)
.GenerateMipmap();
} catch(Error&) {
}
Texture::Active(1);
try {
UniformSampler(prog, "BumpMap").Set(1);
gl.Bound(Texture::Target::_2D, bump_tex)
.MinFilter(TextureMinFilter::LinearMipmapLinear)
.MagFilter(TextureMagFilter::Linear)
.WrapS(TextureWrap::Repeat)
.WrapT(TextureWrap::Repeat)
.Image2D(
images::NormalMap(tex_image, images::NormalMap::FromAlpha()))
.GenerateMipmap();
} catch(Error&) {
}
gl.ClearColor(0.1f, 0.1f, 0.1f, 0.0f);
gl.ClearDepth(1.0f);
gl.Enable(Capability::DepthTest);
gl.Disable(Capability::CullFace);
gl.Enable(Functionality::ClipDistance, 0);
gl.Enable(Functionality::ClipDistance, 1);
gl.Enable(Functionality::ClipDistance, 2);
}
示例14: Render
void Render(ExampleClock& clock) {
gl.Clear().ColorBuffer().DepthBuffer();
double time = clock.Now().Seconds();
auto langle = FullCircles(time / 23.0);
light_position.Set(
GLfloat(Cos(langle) * 20.0),
GLfloat((1.2 + Sin(langle)) * 15.0),
GLfloat(Sin(langle) * 20.0));
double x = SineWave(time / 13.0);
if(x + 0.93 < 0.0)
clock.Pace(0.2);
else
clock.Pace(1.0);
auto camera = CamMatrixf::Orbiting(
Vec3f(),
GLfloat(9.5 + x * 5.1),
FullCircles(time / 17.0),
Degrees(SineWave(time / 20.0) * 89));
camera_matrix.Set(camera);
camera_position.Set(camera.Position());
model_matrix.Set(
ModelMatrixf::TranslationX(+2.0f) *
ModelMatrixf::RotationX(FullCircles(time / 13.0)));
shape.Draw();
model_matrix.Set(
ModelMatrixf::TranslationX(-2.0f) *
ModelMatrixf::RotationZ(FullCircles(time / 11.0)));
shape.Draw();
}
示例15: Use
void Use(void)
{
gl.ClearDepth(1.0f);
gl.ClearColor(0.8f, 0.8f, 0.8f, 0.0f);
gl.Enable(Capability::DepthTest);
gl.Enable(Capability::CullFace);
gl.CullFace(Face::Back);
dfb.Bind(Framebuffer::Target::Draw);
gl.Viewport(width, height);
prog.Use();
cube.Use();
SetProjection();
}