本文整理汇总了C++中oglplus::Context类的典型用法代码示例。如果您正苦于以下问题:C++ Context类的具体用法?C++ Context怎么用?C++ Context使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawScene
void drawScene() {
gl.ClearColor(0.2, 0.2, 0.2, 1.0);
gl.Clear().ColorBuffer().DepthBuffer();
gl.Viewport(0, 0, 640, 480);
// draw GUI
System::getSingleton().renderAllGUIContexts();
}
示例2: DrawElements
void FullscreenQuad::DrawElements() const
{
static oglplus::Context gl;
fsQuadVertexArray.Bind();
gl.DrawElements(
oglplus::PrimitiveType::Triangles, 6,
oglplus::DataType::UnsignedInt
);
}
示例3:
Example(GLuint width, GLuint height)
: log_sink(
[](const oglplus::ARB_debug_output::CallbackData& data) -> void
{
std::cout << "[" << data.id << "] '" <<
data.message << "'" << std::endl;
std::cout << " [source] '" <<
oglplus::EnumValueName(data.source) << "'" <<
std::endl;
std::cout << " [type] '" <<
oglplus::EnumValueName(data.type) << "'" <<
std::endl;
std::cout << " [severity] '" <<
oglplus::EnumValueName(data.severity) << "'" <<
std::endl;
}
)
{
using namespace oglplus;
dbg.Control(
DebugOutputARBSource::DontCare,
DebugOutputARBType::DontCare,
DebugOutputARBSeverity::Low,
true
);
gl.ClearColor(1.0f, 1.0f, 1.0f, 0.0f);
gl.Viewport(width, height);
glc.MatrixMode(CompatibilityMatrixMode::Projection);
glc.LoadIdentity();
glc.MatrixMode(CompatibilityMatrixMode::Modelview);
glc.LoadIdentity();
}
示例4: gl
DSATextureExample(int /*argc*/, const char** /*argv*/)
: gl()
, prog(make_prog())
, projection_matrix(prog, "ProjectionMatrix")
, camera_matrix(prog, "CameraMatrix")
, model_matrix(prog, "ModelMatrix")
, textured_cube(
oglplus::List("Position")("Normal")("TexCoord").Get(),
oglplus::shapes::Cube(),
prog
)
{
using namespace oglplus;
checker.target = Texture::Target::_2D;
checker.Image2D(images::CheckerRedBlack(256, 256, 8, 8));
checker.GenerateMipmap();
checker.MinFilter(TextureMinFilter::LinearMipmapLinear);
checker.MagFilter(TextureMagFilter::Linear);
checker.Anisotropy(2.0);
checker.WrapS(TextureWrap::Repeat);
checker.WrapT(TextureWrap::Repeat);
checker.Bind();
(prog/"Checker") = 0;
(prog/"LightPos") = Vec3f(10.0f, 20.0f, 30.0f);
gl.ClearColor(0.3f, 0.3f, 0.3f, 0.0f);
gl.ClearDepth(1.0f);
gl.Enable(Capability::DepthTest);
gl.Enable(Capability::CullFace);
}
示例5: RenderFrame
//------------------------------------------------------------------------------
void Example::RenderFrame(double /*time*/)
{
bool dragging = mouse_left_down || mouse_middle_down;
if(dragging && (frame_no % 2))
{
gl.Scissor(
mouse_x-screen_width/(view_divs*2),
mouse_y-screen_height/(view_divs*2),
screen_width/view_divs,
screen_height/view_divs
);
}
else
{
unsigned this_tile = view_tile_index[view_tile];
gl.Scissor(
(this_tile % view_divs)*screen_width/view_divs,
(this_tile / view_divs)*screen_height/view_divs,
screen_width/view_divs+1,
screen_height/view_divs+1
);
if(++view_tile >= (dragging?view_divs:view_divs*view_divs))
{
view_tile = 0;
}
}
screen.Draw();
++frame_no;
}
示例6: Render
void Render(void)
{
using namespace oglplus;
double t = FrameTime();
gl.Clear().ColorBuffer().DepthBuffer();
//
auto camera = CamMatrixf::Orbiting(
camera_target,
camera_distance,
-FullCircles(t / 17.0),
Degrees(SineWave(t / 41.0) * 85)
);
camera_matrix.Set(camera);
camera_position.Set(camera.Position());
light_position.Set(
CamMatrixf::Orbiting(
camera_target,
camera_distance*2.0,
FullCircles(t / 37.0),
Degrees(SineWave(t / 31.0) * 85)
).Position()
);
face_normals.Set(int(t*0.25) % 2);
gl.DrawElements(
PrimitiveType::TriangleFan,
element_count,
DataType::UnsignedInt
);
}
示例7: Render
void Render(void)
{
gl.Clear().ColorBuffer();
gl.DrawArrays(
oglplus::PrimitiveType::Triangles,
0, 3
);
}
示例8: Render
void Render() {
using namespace oglplus;
gl.Clear().ColorBuffer().StencilBuffer();
glc.Color(0.2, 0.2, 1.0);
text_path.StencilFillInstanced(
glyph_indices,
PathNVFillMode::CountUp,
0xFF,
PathNVTransformType::TranslateX,
glyph_spacings);
text_path.CoverFillInstanced(
glyph_indices,
PathNVFillCoverMode::BoundingBoxOfBoundingBoxes,
PathNVTransformType::TranslateX,
glyph_spacings);
glc.Color(0.0, 0.0, 0.0);
text_path.StencilStrokeInstanced(
glyph_indices,
1,
~0,
PathNVTransformType::TranslateX,
glyph_spacings);
text_path.CoverStrokeInstanced(
glyph_indices,
PathNVStrokeCoverMode::ConvexHull,
PathNVTransformType::TranslateX,
glyph_spacings);
}
示例9: Render
void Render() {
using namespace oglplus;
gl.Clear().ColorBuffer().DoIt();
GLfloat t = GLfloat(FrameTime());
rndr.Use();
text_stream.str(std::string());
text_stream << "Time: " << std::fixed << std::setw(5)
<< std::setprecision(3) << t << " [s]";
if(time_str != text_stream.str()) {
time_str = text_stream.str();
time_layout.Set(time_str);
}
rndr.SetCamera(CamMatrixf::Orbiting(
Vec3f(),
GLfloat(9.0 + SineWave(t / 7.0) * 3.0),
-FullCircles(t / 17.0),
Degrees(SineWave(t / 21.0) * 35)));
rndr.SetLayoutTransform(ModelMatrixf::Translation(-3.0f, 0.7f, 1.1f));
rndr.Render(oglp_layout);
rndr.SetLayoutTransform(ModelMatrixf::Translation(-6.0f, -0.7f, 0.0f));
rndr.Render(desc_layout);
rndr.SetLayoutTransform(
ModelMatrixf::Translation(-4.0f, -2.0f, -0.5f) *
ModelMatrixf::Scale(0.7f, 0.7f, 0.5f));
rndr.Render(time_layout);
}
示例10: Reshape
void Reshape() {
using namespace oglplus;
gl.Viewport(Width(), Height());
rndr.SetProjection(
CamMatrixf::PerspectiveX(Degrees(60), Width() / Height(), 1, 60));
}
示例11: gl
STBTruetypeExample(int argc, const char** argv)
: gl()
, tr(oglplus::text::STBTrueTypeRendering(0, 1, 2))
, font(tr.LoadFont((argc>1)?argv[1]:"FreeSans"))
, oglp_layout(tr.MakeLayout(font, "OGLplus"))
, desc_layout(tr.MakeLayout(font, u8"a C++ wrapper for OpenGL©"))
, time_layout(tr.MakeLayout(font, 25))
, rndr(tr.GetRenderer(
oglplus::FragmentShader(
oglplus::ObjectDesc("Pixel color"),
oglplus::StrCRef(
"#version 330\n"
"vec4 PixelColor("
" vec4 TexelColor,"
" vec3 GlyphPosition,"
" float GlyphXOffset,"
" vec2 GlyphExtent,"
" vec2 GlyphCoord,"
" float LayoutWidth"
")"
"{"
" float g = GlyphXOffset / LayoutWidth;"
" float b = GlyphCoord.y;"
" vec3 Color = mix("
" vec3(1.0, 0.2, 0.2+0.8*b), "
" vec3(0.2, 1.0, 0.2+0.8*b), "
" g"
" );"
" return vec4(Color, TexelColor.r);"
"}")
)
)
)
{
using namespace oglplus;
rndr.Use();
gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.Enable(Capability::Blend);
gl.BlendFunc(
BlendFunction::SrcAlpha,
BlendFunction::DstAlpha
);
}
示例12: Render
void Render(void)
{
gl.Clear().ColorBuffer().DepthBuffer();
//
oglplus::Uniform<GLfloat>(prog, "Time") = FrameTime();
// draw 36 instances of the cube
// the vertex shader will take care of their placement
cube_instr.Draw(cube_indices, 36);
}
示例13: Resize
//------------------------------------------------------------------------------
void Example::Resize(int width, int height)
{
if((width > 0) && (height > 0))
{
screen_width = width;
screen_height = height;
view_aspect = float(width)/float(height);
}
gl.Viewport(0, 0, width, height);
}
示例14: gl
PangoCairoTextExample(int argc, const char** argv)
: gl()
, tr(0)
, font(tr.LoadFont((argc>2)?argv[2]:"Sans 38"))
, layout(tr.MakeLayout(font, 48))
, rndr(tr.GetRenderer(
oglplus::FragmentShader(
oglplus::ObjectDesc("Pixel color"),
"#version 330\n"
"uniform vec3 Color;"
"uniform float Opacity;"
"vec4 PixelColor("
" vec4 TexelColor,"
" vec3 GlyphPosition,"
" float GlyphXOffset,"
" vec2 GlyphExtent,"
" vec2 GlyphCoord,"
" float LayoutWidth"
")"
"{"
" return vec4(Color, TexelColor.r*Opacity);"
"}"
)
)
), rndr_color(rndr.GetUniform<oglplus::Vec3f>("Color"))
, rndr_opacity(rndr.GetUniform<GLfloat>("Opacity"))
, prev_interval(-1)
, current_line(0)
{
using namespace oglplus;
rndr.Use();
gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.Enable(Capability::Blend);
gl.BlendFunc(
BlendFunction::SrcAlpha,
BlendFunction::DstAlpha
);
rndr.SetAlignment(text::Alignment::Center);
}
示例15: Display
void Display(void)
{
using namespace oglplus;
gl.BlitFramebuffer(
0, 0, width, height,
0, height, width, 0,
BufferSelectBit::ColorBuffer,
BlitFilter::Nearest
);
}