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


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

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


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

示例1:

	PathExample(int, const char**)
	{
		using namespace oglplus;

		PathNVCommand commands[] = {
			PathNVCommand::MoveTo,
			PathNVCommand::LineTo,
			PathNVCommand::LineTo,
			PathNVCommand::LineTo,
			PathNVCommand::LineTo,
			PathNVCommand::Close
		};

		GLfloat coords[] = {
			 0.00, 0.85,
			 0.65,-0.80,
			-0.85, 0.30,
			 0.85, 0.30,
			-0.65,-0.80
		};

		path.Commands(
			sizeof(commands)/sizeof(commands[0]),
			commands,
			sizeof(coords)/sizeof(coords[0]),
			coords
		);

		path.StrokeWidth(0.01);
		path.JoinStyle(PathNVJoinStyle::Round);

		GLfloat dash_array[] = {0.05, 0.02};

		path.DashArray(
			sizeof(dash_array)/sizeof(dash_array[0]),
			dash_array
		);

		glc.MatrixMode(CompatibilityMatrixMode::Projection);
		glc.LoadIdentity();
		glc.MatrixMode(CompatibilityMatrixMode::Modelview);
		glc.LoadIdentity();

		gl.ClearColor(1.0f, 1.0f, 1.0f, 0.0f);
		gl.ClearStencil(0);
		gl.StencilMask(~0);
		gl.StencilFunc(CompareFunction::NotEqual, 0, 0x1F);
		gl.StencilOp(
			StencilOperation::Keep,
			StencilOperation::Keep,
			StencilOperation::Zero
		);

		gl.Enable(Capability::StencilTest);
	}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:55,代码来源:002_simple_path.cpp

示例2:

	TextExample(int /*argc*/, const char** /*argv*/)
	 : text_glyphs(128)
	{
		using namespace oglplus;

		GLfloat font_scale = 48;

		text_glyphs.GlyphRange(
			PathNVFontTarget::Standard,
			"Sans",
			PathNVFontStyle::Bold,
			0, 128,
			PathNVMissingGlyph::Use,
			~0,
			font_scale
		);

		GLfloat color_gen_coeffs[9] = {
			-0.6f, 0.0f, 0.8f,
			 0.0f, 0.0f, 0.0f,
			 0.5f, 0.0f, 0.5f
		};
		npr.ColorGen(
			PathNVColor::Primary,
			PathNVGenMode::ObjectBoundingBox,
			PathNVColorFormat::RGB,
			color_gen_coeffs
		);

		gl.ClearColor(1.0f, 1.0f, 1.0f, 0.0f);
		gl.ClearStencil(0);
		gl.StencilMask(~0);
		gl.StencilFunc(CompareFunction::NotEqual, 0, 0xFF);
		gl.StencilOp(
			StencilOperation::Keep,
			StencilOperation::Keep,
			StencilOperation::Zero
		);

		gl.Enable(Capability::StencilTest);
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:41,代码来源:004_text_rendering.cpp

示例3: TextExample

    TextExample(int /*argc*/, const char** /*argv*/)
      : text("OpenGL")
      , text_path(text.size())
      , glyph_indices(make_glyph_indices())
      , glyph_spacings(glyph_indices.size()) {
        using namespace oglplus;

        GLfloat font_scale = 64;

        text_path.Glyphs(
          PathNVFontTarget::Standard,
          "Sans",
          PathNVFontStyle::Bold,
          text,
          PathNVMissingGlyph::Use,
          ~0,
          font_scale);

        text_path.GetSpacing(
          PathNVListMode::AccumAdjacentPairs,
          glyph_indices,
          1.0f,
          1.0f,
          PathNVTransformType::TranslateX,
          glyph_spacings);

        glyph_spacings.insert(glyph_spacings.begin(), 0);
        glyph_spacings.pop_back();
        glyph_indices.pop_back();

        GLfloat text_left = glyph_spacings.front();
        GLfloat text_right = glyph_spacings.back();

        GLfloat font_min_max[2];

        text_path.GetMetricRange(
          PathNVMetricQuery::FontYMinBounds | PathNVMetricQuery::FontYMaxBounds,
          1,
          0,
          font_min_max);

        projection.Ortho(
          text_left - 10,
          text_right + 10,
          font_min_max[0],
          font_min_max[1],
          -1.0,
          +1.0);
        modelview.LoadIdentity();

        gl.ClearColor(1.0f, 1.0f, 1.0f, 0.0f);
        gl.ClearStencil(0);
        gl.StencilMask(~0);
        gl.StencilFunc(CompareFunction::NotEqual, 0, 0xFF);
        gl.StencilOp(
          StencilOperation::Keep,
          StencilOperation::Keep,
          StencilOperation::Zero);

        gl.Enable(Capability::StencilTest);
    }
开发者ID:matus-chochlik,项目名称:oglplus,代码行数:61,代码来源:003_simple_text.cpp


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