OGLplus (0.52.0) a C++ wrapper for OpenGL

standalone/002_simple_path.cpp

Shows simple usage of the NV_path_rendering extensionCopyright 2008-2014 Matus Chochlik. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include "glut_glew_example.hpp"
#include <oglplus/all.hpp>
class PathExample
: public oglplus::StandaloneExample
{
private:
public:
PathExample(int, const char**)
{
using namespace oglplus;
path.Spec(PathNVSpec<GLfloat>(6, 10)
.MoveTo( 0.00f, 0.85f)
.LineTo( 0.65f,-0.80f)
.LineTo(-0.85f, 0.30f)
.LineTo( 0.85f, 0.30f)
.LineTo(-0.65f,-0.80f)
.Close()
);
path.StrokeWidth(0.01);
path.JoinStyle(PathNVJoinStyle::Round);
path.Dashes(0.05f, 0.02f);
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);
}
void Render(void)
{
using namespace oglplus;
gl.Clear().ColorBuffer().StencilBuffer();
glc.Color(0.2, 0.2, 1.0);
path.StencilFill(PathNVFillMode::CountUp, 0x1F);
path.CoverFill(PathNVFillCoverMode::BoundingBox);
glc.Color(0.1, 0.1, 0.1);
path.StencilStroke(1, ~0);
path.CoverStroke(PathNVStrokeCoverMode::ConvexHull);
}
void Reshape(void)
{
using namespace oglplus;
gl.Viewport(Width(), Height());
}
};
int main(int argc, char* argv[])
{
return oglplus::GlutGlewMain<PathExample>(
"Simple example of NV_path_rendering",
argc, argv
);
}

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).