当前位置: 首页>>代码示例>>C++>>正文


C++ Context::Bound方法代码示例

本文整理汇总了C++中Context::Bound方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::Bound方法的具体用法?C++ Context::Bound怎么用?C++ Context::Bound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Context的用法示例。


在下文中一共展示了Context::Bound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Reshape

    void Reshape(GLuint vp_width, GLuint vp_height) {
        width = vp_width;
        height = vp_height;

        float aspect = float(width) / height;

        auto projection = CamMatrixf::PerspectiveX(Degrees(60), aspect, 1, 20);

        plane_projection_matrix.Set(projection);
        shape_projection_matrix.Set(projection);

        gl.Bound(Texture::Target::Rectangle, depth_tex)
          .Image2D(
            0,
            PixelDataInternalFormat::DepthComponent,
            width / tex_size_div,
            height / tex_size_div,
            0,
            PixelDataFormat::DepthComponent,
            PixelDataType::Float,
            nullptr);
        gl.Bound(Texture::Target::Rectangle, reflect_tex)
          .Image2D(
            0,
            PixelDataInternalFormat::RGB,
            width / tex_size_div,
            height / tex_size_div,
            0,
            PixelDataFormat::RGB,
            PixelDataType::UnsignedByte,
            nullptr);
    }
开发者ID:matus-chochlik,项目名称:oglplus,代码行数:32,代码来源:027_reflected_shape.cpp

示例2: count

	Particles(GLuint n)
	 : count(n)
	 , sort_nw(n)
	{
		Context gl;
		const GLfloat irm = 1.0f/RAND_MAX;
		std::vector<GLfloat> pos_data(count*3);

		for(GLuint p=0; p!=count; ++p)
		{
			for(GLuint c=0; c!=3; ++c)
			{
				pos_data[p*3+c] = 2.0f*(0.5f-std::rand()*irm);
			}
		}

		gl.Bound(BufferTarget::Array, positions).Data(pos_data);
		gl.Bound(BufferTarget::Uniform, distances).Data<GLfloat>(
			count,
			nullptr,
			BufferUsage::DynamicDraw
		);
		gl.Bound(BufferTarget::CopyRead, indices_f).Data<GLuint>(
			count,
			nullptr,
			BufferUsage::DynamicRead
		);
		gl.Bound(BufferTarget::CopyWrite,indices_d).Data<GLuint>(
			count,
			nullptr,
			BufferUsage::DynamicDraw
		);

	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:34,代码来源:029_gpu_sort_tfb.cpp

示例3: 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);
    }
开发者ID:matus-chochlik,项目名称:oglplus,代码行数:57,代码来源:031_blob.cpp

示例4: 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;
    }
开发者ID:matus-chochlik,项目名称:oglplus,代码行数:55,代码来源:029_muddy_stones.cpp

示例5: SetupFramebuffers

void ShadowMapRenderer::SetupFramebuffers(const unsigned &w,
        const unsigned &h)
{
    using namespace oglplus;
    static Context gl;
    // save size
    shadowMapSize = glm::uvec2(w, h);
    // setup shadow framebuffer
    shadowFramebuffer.Bind(FramebufferTarget::Draw);
    // create render buffer for depth testing
    depthRender.Bind(RenderbufferTarget::Renderbuffer);
    depthRender.Storage(RenderbufferTarget::Renderbuffer,
                        PixelDataInternalFormat::DepthComponent24, w, h);
    // create variance shadow mapping texture, z and z * z
    gl.Bound(TextureTarget::_2D, shadowMap)
    .Image2D(0, PixelDataInternalFormat::RGBA32F, w, h, 0,
             PixelDataFormat::RGBA, PixelDataType::Float, nullptr);
    Filtering(filtering);
    Anisotropy(8);
    shadowFramebuffer.AttachColorTexture(FramebufferTarget::Draw, 0, shadowMap, 0);
    shadowFramebuffer.AttachRenderbuffer(FramebufferTarget::Draw,
                                         FramebufferAttachment::Depth,
                                         depthRender);
    gl.DrawBuffer(FramebufferColorAttachment::_0);

    // check if success building frame buffer
    if (!Framebuffer::IsComplete(FramebufferTarget::Draw))
    {
        auto status = Framebuffer::Status(FramebufferTarget::Draw);
        Framebuffer::HandleIncompleteError(FramebufferTarget::Draw, status);
    }

    Framebuffer::Bind(Framebuffer::Target::Draw, FramebufferName(0));
    // setup shadow blur framebuffer
    blurFramebuffer.Bind(FramebufferTarget::Draw);
    // create variance shadow mapping texture, z and z * z
    gl.Bound(TextureTarget::_2D, blurShadow)
    .Image2D(0, PixelDataInternalFormat::RGBA32F, w, h, 0,
             PixelDataFormat::RGBA, PixelDataType::Float, nullptr)
    .MinFilter(TextureMinFilter::Linear).MagFilter(TextureMagFilter::Linear)
    .WrapS(TextureWrap::ClampToEdge).WrapT(TextureWrap::ClampToEdge).Anisotropy(8);
    blurFramebuffer.AttachColorTexture(FramebufferTarget::Draw, 0, blurShadow, 0);
    gl.DrawBuffer(FramebufferColorAttachment::_0);

    // check if success building frame buffer
    if (!Framebuffer::IsComplete(FramebufferTarget::Draw))
    {
        auto status = Framebuffer::Status(FramebufferTarget::Draw);
        Framebuffer::HandleIncompleteError(FramebufferTarget::Draw, status);
    }

    Framebuffer::Bind(Framebuffer::Target::Draw, FramebufferName(0));
}
开发者ID:Alan-Baylis,项目名称:VCTRenderer,代码行数:53,代码来源:shadow_map_renderer.cpp

示例6: 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);
    }
开发者ID:matus-chochlik,项目名称:oglplus,代码行数:50,代码来源:031_brick_torus.cpp

示例7: 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);
	}
开发者ID:xubingyue,项目名称:oglplus,代码行数:33,代码来源:029_waves.cpp

示例8: DoName

llvm_value CompileExpression::DoName(Name *what)
// ----------------------------------------------------------------------------
//   Compile a name
// ----------------------------------------------------------------------------
{
    Prefix_p   where;
    Infix_p    rewrite;
    Context   *context  = unit->context;
    Tree      *existing = context->Bound(what, true, &rewrite, &where);

    assert(existing || !"Type checking didn't realize a name is missing");
    Tree *from = RewriteDefined(rewrite->left);
    if (where == context->CurrentScope())
        if (llvm_value result = unit->Known(from))
            return result;

    // Check true and false values
    if (existing == eliot_true)
        return ConstantInt::get(unit->compiler->booleanTy, 1);
    if (existing == eliot_false)
        return ConstantInt::get(unit->compiler->booleanTy, 0);

    // Check if it is a global
    if (llvm_value global = unit->Global(existing))
        return global;
    if (llvm_value global = unit->Global(from))
        return global;

    // If we are in a context building a closure, record dependency
    if (unit->closureTy)
        return unit->NeedClosure(from);

    return DoCall(what);
}
开发者ID:ronaldnsabiyera,项目名称:eliot,代码行数:34,代码来源:expred.cpp

示例9: DoName

llvm_value CompileExpression::DoName(Name *what)
// ----------------------------------------------------------------------------
//   Compile a name
// ----------------------------------------------------------------------------
{
    Context_p  where;
    Rewrite_p  rewrite;
    Context   *context  = unit->context;
    Tree      *existing = context->Bound(what, Context::SCOPE_LOOKUP,
                                         &where, &rewrite);
    assert(existing || !"Type checking didn't realize a name is missing");
    if (where == context)
        if (llvm_value result = unit->Known(rewrite->from))
            return result;

    // Check true and false values
    if (existing == xl_true)
        return ConstantInt::get(unit->compiler->booleanTy, 1);
    if (existing == xl_false)
        return ConstantInt::get(unit->compiler->booleanTy, 0);

    // Check if it is a global
    if (llvm_value global = unit->Global(existing))
        return global;

    // If we are in a context building a closure, record dependency
    if (unit->closureTy)
        return unit->NeedClosure(rewrite->from);

    return DoCall(what);
}
开发者ID:trustifier,项目名称:xlr,代码行数:31,代码来源:expred.cpp

示例10: Anisotropy

void ShadowMapRenderer::Anisotropy(const int &val) const
{
    using namespace oglplus;
    static Context gl;
    gl.Bound(TextureTarget::_2D, shadowMap)
    .Anisotropy(static_cast<float>(val));
}
开发者ID:Alan-Baylis,项目名称:VCTRenderer,代码行数:7,代码来源:shadow_map_renderer.cpp

示例11: gl

	FBTexThread(FBTexExample& example)
	 : gl()
	 , prog(make_prog(example))
	 , projection_matrix(prog, "ProjectionMatrix")
	 , camera_matrix(prog, "CameraMatrix")
	 , model_matrix(prog, "ModelMatrix")
	 , shape(List("Position")("Normal")("TexCoord").Get(), shapes::TwistedTorus(), prog)
	 , tex_side(512)
	 , parent_ready(example.parent_ready)
	{
		example.thread_ready = &thread_ready;

		Uniform<Vec3f>(prog, "LightPos").Set(20.0f, 30.0f, 40.0f);

		Texture::Active(0);
		gl.Bound(Texture::Target::_2D, example.tex)
			.MinFilter(TextureMinFilter::Linear)
			.MagFilter(TextureMagFilter::Linear)
			.WrapS(TextureWrap::Repeat)
			.WrapT(TextureWrap::Repeat)
			.Image2D(
				0,
				PixelDataInternalFormat::RGBA,
				tex_side, tex_side,
				0,
				PixelDataFormat::RGBA,
				PixelDataType::UnsignedByte,
				nullptr
			);

		gl.Bound(Renderbuffer::Target::Renderbuffer, rbo)
 			.Storage(
				PixelDataInternalFormat::DepthComponent,
				tex_side,
				tex_side
			);

		gl.Bound(Framebuffer::Target::Draw, fbo)
			.AttachTexture(FramebufferAttachment::Color, example.tex, 0)
			.AttachRenderbuffer(FramebufferAttachment::Depth, rbo);

		Use();
	}
开发者ID:xubingyue,项目名称:oglplus,代码行数:43,代码来源:025_rendered_texture_mt.cpp

示例12: self

	SortNWTex(GLuint n)
	{
		images::Image sort_nw_map = images::SortNWMap(n);
		pass_count = sort_nw_map.Height();

		Context gl;
		Texture::Active(0);
		gl.Bound(TextureTarget::Rectangle, self())
			.Filter(TextureFilter::Nearest)
			.WrapS(TextureWrap::ClampToEdge)
			.WrapT(TextureWrap::ClampToEdge)
			.Image2D(sort_nw_map);
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:13,代码来源:029_gpu_sort_tfb.cpp

示例13: Filtering

void ShadowMapRenderer::Filtering(const int &val)
{
    using namespace oglplus;
    static Context gl;
    filtering = glm::clamp(val, 0, 2);

    if(filtering == 0)
        gl.Bound(TextureTarget::_2D, shadowMap)
        .MagFilter(TextureMagFilter::Nearest)
        .MinFilter(TextureMinFilter::Nearest);

    if(filtering == 1)
        gl.Bound(TextureTarget::_2D, shadowMap)
        .MagFilter(TextureMagFilter::Linear)
        .MinFilter(TextureMinFilter::Linear);

    if(filtering == 2)
        gl.Bound(TextureTarget::_2D, shadowMap)
        .MagFilter(TextureMagFilter::Linear)
        .MinFilter(TextureMinFilter::LinearMipmapLinear)
        .GenerateMipmap();
}
开发者ID:Alan-Baylis,项目名称:VCTRenderer,代码行数:22,代码来源:shadow_map_renderer.cpp

示例14: UpdateMetaballs

    void UpdateMetaballs(double time) {
        std::size_t metaball_count = ball_paths.size(), k = 0;
        std::vector<GLfloat> metaballs(metaball_count * 4);
        for(std::size_t ball = 0; ball != metaball_count; ++ball) {
            Vec4f pos = ball_paths[ball].Position(time / 21.0);

            for(GLuint coord = 0; coord != 4; ++coord)
                metaballs[k++] = pos.At(coord);
        }

        gl.Bound(Texture::Target::_1D, metaballs_tex)
          .Image1D(
            0,
            PixelDataInternalFormat::RGBA32F,
            metaball_count,
            0,
            PixelDataFormat::RGBA,
            PixelDataType::Float,
            metaballs.data());
    }
开发者ID:matus-chochlik,项目名称:oglplus,代码行数:20,代码来源:031_blob.cpp

示例15: cube

	CubeExample(void)
	 : cube(
		List("Position")("Normal")("TexCoord").Get(),
		shapes::Cube(),
		cube_prog
	)
	{
		// setup the texture
		{
			GLuint tex_side = 512;
			auto image = images::NewtonFractal(
				tex_side, tex_side,
				Vec3f(0.2f, 0.1f, 0.4f),
				Vec3f(0.8f, 0.8f, 1.0f),
				Vec2f(-1.0f, -1.0f),
				Vec2f( 1.0f,  1.0f),
				images::NewtonFractal::X4Minus1(),
				images::NewtonFractal::DefaultMixer()
			);

			gl.Bound(Texture::Target::_2D, cube_tex)
				.Image2D(image)
				.GenerateMipmap()
				.BorderColor(Vec4f(0.8f, 0.8f, 1.0f, 1.0f))
				.MinFilter(TextureMinFilter::LinearMipmapLinear)
				.MagFilter(TextureMagFilter::Linear)
				.WrapS(TextureWrap::Repeat)
				.WrapT(TextureWrap::Repeat);
		}

		cube_prog.cube_tex = 0;
		cube_prog.light_position.Set(4.0f, 4.0f, -8.0f);

		gl.ClearColor(0.8f, 0.8f, 0.7f, 0.0f);
		gl.ClearDepth(1.0f);
		gl.Enable(Capability::DepthTest);
		gl.Enable(Capability::CullFace);
		gl.CullFace(Face::Back);
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:39,代码来源:025_subroutines.cpp


注:本文中的Context::Bound方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。