本文整理汇总了C++中Context::ClearColor方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::ClearColor方法的具体用法?C++ Context::ClearColor怎么用?C++ Context::ClearColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context::ClearColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: gl
FlowExample(void)
: gl()
, flow(images::LoadTexture("flow_map"), 1)
, screen(
List("Position")("TexCoord").Get(),
shapes::Screen(),
screen_prog
)
{
Texture::Active(0);
{
auto bound_tex = Bind(background, Texture::Target::_2D);
bound_tex.Image2D(images::LoadTexture("flower_glass"));
bound_tex.MinFilter(TextureMinFilter::Linear);
bound_tex.MagFilter(TextureMagFilter::Linear);
bound_tex.WrapS(TextureWrap::MirroredRepeat);
bound_tex.WrapT(TextureWrap::MirroredRepeat);
}
screen_prog.background.Set(0);
screen_prog.normal_map.Set(flow.TexUnit());
gl.ClearColor(0.4f, 0.4f, 0.4f, 0.0f);
gl.ClearDepth(1.0f);
gl.Enable(Capability::DepthTest);
}
示例3: grid
LiquidExample(const ExampleParams& params)
: liquid_prog()
, grid(liquid_prog, params.quality)
, grid_repeat(int(1 + params.quality*2))
{
Texture::Active(1);
{
auto image = images::Squares(512, 512, 0.9f, 8, 8);
auto bound_tex = gl.Bound(Texture::Target::CubeMap, env_map);
for(int i=0; i!=6; ++i)
Texture::ImageCM(i, image);
bound_tex.GenerateMipmap();
bound_tex.MinFilter(TextureMinFilter::LinearMipmapLinear);
bound_tex.MagFilter(TextureMagFilter::Linear);
bound_tex.WrapS(TextureWrap::ClampToEdge);
bound_tex.WrapT(TextureWrap::ClampToEdge);
bound_tex.WrapR(TextureWrap::ClampToEdge);
bound_tex.SwizzleG(TextureSwizzle::Red);
bound_tex.SwizzleB(TextureSwizzle::Red);
}
ProgramUniformSampler(liquid_prog, "EnvMap").Set(1);
const Vec3f light_position(12.0, 1.0, 8.0);
liquid_prog.light_position.Set(light_position);
gl.ClearColor(0.7f, 0.65f, 0.55f, 0.0f);
gl.ClearDepth(1.0f);
gl.Enable(Capability::DepthTest);
gl.Enable(Capability::CullFace);
gl.FrontFace(FaceOrientation::CW);
gl.CullFace(Face::Back);
}
示例4: gl
CubeExample(void)
: gl()
, prog()
, field(
images::FlipImageAxes<GLubyte, 1>(
images::LoadTexture("suzanne_vol"),
0, 2,-1
),
prog
), shadowmaps(
images::LoadTexture("oglcraft_ao"),
prog
)
{
gl.ClearColor(0.1f, 0.1f, 0.1f, 0.0f);
gl.ClearDepth(1.0f);
gl.Enable(Capability::DepthTest);
gl.Enable(Capability::CullFace);
gl.FrontFace(FaceOrientation::CCW);
gl.CullFace(Face::Back);
prog.Use();
field.Use();
}
示例5: BlobExample
BlobExample(const ExampleParams& params)
: blob_prog()
, metal_prog()
, grid(blob_prog, params.quality)
, plane(metal_prog) {
std::srand(234);
for(GLuint i = 0; i != 24; ++i) {
GLuint j = 0, n = 3 + std::rand() % 3;
std::vector<Vec4f> points(n);
GLfloat ball_size = 0.15f * std::rand() / GLfloat(RAND_MAX) + 0.25f;
while(j != n) {
points[j] = Vec4f(
1.2f * std::rand() / GLfloat(RAND_MAX) - 0.6f,
1.2f * std::rand() / GLfloat(RAND_MAX) - 0.6f,
1.2f * std::rand() / GLfloat(RAND_MAX) - 0.6f,
ball_size);
++j;
}
ball_paths.push_back(CubicBezierLoop<Vec4f, double>(points));
}
//
Texture::Active(1);
blob_prog.metaballs.Set(1);
gl.Bound(Texture::Target::_1D, metaballs_tex)
.Filter(TextureFilter::Nearest)
.Wrap(TextureWrap::ClampToEdge)
.Image1D(
0,
PixelDataInternalFormat::RGBA32F,
ball_paths.size(),
0,
PixelDataFormat::RGBA,
PixelDataType::Float,
nullptr);
Texture::Active(2);
metal_prog.metal_tex.Set(2);
gl.Bound(Texture::Target::_2D, metal_tex)
.MinFilter(TextureMinFilter::LinearMipmapLinear)
.MagFilter(TextureMagFilter::Linear)
.Wrap(TextureWrap::Repeat)
.Image2D(images::BrushedMetalUByte(512, 512, 5120, -3, +3, 32, 128))
.GenerateMipmap();
const Vec3f light_position(12.0, 1.0, 8.0);
blob_prog.light_position.Set(light_position);
metal_prog.light_position.Set(light_position);
gl.ClearColor(0.8f, 0.7f, 0.6f, 0.0f);
gl.ClearDepth(1.0f);
gl.Enable(Capability::DepthTest);
gl.Enable(Capability::CullFace);
gl.FrontFace(FaceOrientation::CW);
gl.CullFace(Face::Back);
}
示例6: vs
SphereExample(void)
: vs(make_vs())
, proton(vs,make_fs(fs_proton()))
, neutron(vs,make_fs(fs_neutron()))
, electron(vs,make_fs(fs_electron()))
{
gl.ClearColor(0.3f, 0.3f, 0.3f, 0.0f);
gl.ClearDepth(1.0f);
gl.Enable(Capability::DepthTest);
}
示例7: 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;
}
示例8: gl
SortingExample(void)
: gl()
, particles(4096)
, dist_proc(particles)
, sort_proc(particles)
, draw_proc(particles)
{
gl.ClearColor(0.3f, 0.3f, 0.3f, 0.0f);
gl.Enable(Capability::DepthTest);
gl.BlendFunc(BlendFn::SrcAlpha, BlendFn::OneMinusSrcAlpha);
}
示例9: gl
SubsurfExample(void)
: gl()
, shape("stanford_dragon", data_prog)
, screen(List("Position").Get(), shapes::Screen(), draw_prog)
, data_buffer(draw_prog, 0, 800, 600)
{
gl.Enable(Capability::CullFace);
gl.CullFace(Face::Back);
gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.ClearDepth(1.0f);
}
示例10: MorphingExample
MorphingExample()
: shape(point_prog)
, status(0.0) {
point_prog.color_1 = Vec3f(1.0f, 0.5f, 0.4f);
point_prog.color_2 = Vec3f(1.0f, 0.8f, 0.7f);
gl.ClearColor(0.2f, 0.2f, 0.2f, 0.0f);
gl.ClearDepth(1.0f);
gl.Enable(Capability::DepthTest);
gl.Enable(Capability::ProgramPointSize);
gl.Enable(Capability::Blend);
}
示例11: vs
ShapeExample(void)
: vs(make_vs())
, sphere(vs,make_fs(fs_yb_strips(), "Y/B strips"))
, cubeX(vs, make_fs(fs_bw_checker(), "B/W checker"))
, cubeY(vs, make_fs(fs_br_circles(), "B/R circles"))
, cubeZ(vs, make_fs(fs_wg_spirals(), "W/G spirals"))
, torus(vs, make_fs(fs_wo_vstrips(), "W/O vstrips"))
{
gl.ClearColor(0.5f, 0.5f, 0.5f, 0.0f);
gl.ClearDepth(1.0f);
gl.Enable(Capability::DepthTest);
}
示例12: main
int main() {
sf::ContextSettings set;
set.antialiasingLevel = 8;
sf::Window w(sf::VideoMode(700, 700), "ogl", sf::Style::Default, set);
glewExperimental = true;
glewInit();
Context gl;
gl.ClearColor(0.0, 0.0, 0.0, 1.0);
gl.Enable(Capability::DepthTest);
gl.Enable(Capability::CullFace);
gl.Enable(Capability::Blend);
w.setMouseCursorVisible(false);
Pyramid pyramid { w };
bool running = true;
while(running) {
sf::Event e;
while(w.pollEvent(e)){
if(e.type == sf::Event::Closed){ running = false; }
if(e.type == sf::Event::KeyPressed) {
switch(e.key.code) {
case sf::Keyboard::Escape:
running = false;
break;
case sf::Keyboard::W: case sf::Keyboard::Up:
camera.forward();
break;
case sf::Keyboard::A: case sf::Keyboard::Left:
camera.left();
break;
case sf::Keyboard::S: case sf::Keyboard::Down:
camera.back();
break;
case sf::Keyboard::D: case sf::Keyboard::Right:
camera.right();
break;
default:
break;
}
}
if(e.type == sf::Event::MouseMoved) {
//idk
}
}
pyramid.update();
pyramid.draw(gl);
gl.Clear().ColorBuffer().DepthBuffer();
w.display();
}
return 0;
}
示例13:
CubeExample(void)
{
scene.AddShape(shapes::Cage());
scene.AddShape(shapes::WickerTorus(1.0, 0.5, 0.02, 12, 12));
scene.AddShape(shapes::SpiralSphere());
scene.AddShape(shapes::TwistedTorus(0.9, 0.5, 0.02, 8, 48, 7));
scene.AddShape(shapes::Icosahedron());
gl.ClearColor(0.1f, 0.1f, 0.1f, 0.0f);
gl.ClearDepth(1.0f);
gl.Enable(Capability::DepthTest);
}
示例14: 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);
}
示例15: 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);
}