Browse Source

GL: compile forgotten code snippets.

Also wrap long lines to avoid ugly scrollbars.
pull/308/head
Vladimír Vondruš 7 years ago
parent
commit
e08b04c46b
  1. 7
      doc/snippets/MagnumGL-framebuffer.cpp
  2. 23
      doc/snippets/MagnumGL.cpp
  3. 5
      src/Magnum/GL/Framebuffer.h
  4. 4
      src/Magnum/GL/Renderer.h

7
doc/snippets/MagnumGL-framebuffer.cpp

@ -40,7 +40,8 @@ void viewportEvent(ViewportEvent& event) override {
/* [DefaultFramebuffer-usage-clear] */ /* [DefaultFramebuffer-usage-clear] */
void drawEvent() override { void drawEvent() override {
GL::defaultFramebuffer.clear(GL::FramebufferClear::Color|GL::FramebufferClear::Depth); GL::defaultFramebuffer.clear(GL::FramebufferClear::Color|
GL::FramebufferClear::Depth);
// ... // ...
} }
@ -54,7 +55,9 @@ GL::Framebuffer framebuffer;
/* [Framebuffer-usage-draw] */ /* [Framebuffer-usage-draw] */
void drawEvent() override { void drawEvent() override {
GL::defaultFramebuffer.clear(GL::FramebufferClear::Color); GL::defaultFramebuffer.clear(GL::FramebufferClear::Color);
framebuffer.clear(GL::FramebufferClear::Color|GL::FramebufferClear::Depth|GL::FramebufferClear::Stencil); framebuffer.clear(GL::FramebufferClear::Color|
GL::FramebufferClear::Depth|
GL::FramebufferClear::Stencil);
framebuffer.bind(); framebuffer.bind();
// ... // ...

23
doc/snippets/MagnumGL.cpp

@ -894,7 +894,8 @@ GL::Renderbuffer depthStencil;
framebuffer.attachTexture(GL::Framebuffer::ColorAttachment{0}, color, 0); framebuffer.attachTexture(GL::Framebuffer::ColorAttachment{0}, color, 0);
framebuffer.attachTexture(GL::Framebuffer::ColorAttachment{1}, normal, 0); framebuffer.attachTexture(GL::Framebuffer::ColorAttachment{1}, normal, 0);
framebuffer.attachRenderbuffer(GL::Framebuffer::BufferAttachment::DepthStencil, depthStencil); framebuffer.attachRenderbuffer(
GL::Framebuffer::BufferAttachment::DepthStencil, depthStencil);
/* [Framebuffer-usage-attach] */ /* [Framebuffer-usage-attach] */
} }
#endif #endif
@ -908,9 +909,16 @@ struct MyShader {
}; };
GL::Framebuffer framebuffer{{}}; GL::Framebuffer framebuffer{{}};
/* [Framebuffer-usage-map] */ /* [Framebuffer-usage-map] */
framebuffer.mapForDraw({{MyShader::ColorOutput, GL::Framebuffer::ColorAttachment(0)}, framebuffer.mapForDraw({
{MyShader::NormalOutput, GL::Framebuffer::ColorAttachment(1)}}); {MyShader::ColorOutput, GL::Framebuffer::ColorAttachment(0)},
{MyShader::NormalOutput, GL::Framebuffer::ColorAttachment(1)}});
/* [Framebuffer-usage-map] */ /* [Framebuffer-usage-map] */
/* [Framebuffer-mapForDraw] */
framebuffer.mapForDraw({
{MyShader::ColorOutput, GL::Framebuffer::ColorAttachment(0)},
{MyShader::NormalOutput, GL::Framebuffer::DrawAttachment::None}});
/* [Framebuffer-mapForDraw] */
} }
{ {
@ -1235,6 +1243,15 @@ GL::CompressedBufferImage2D image = texture.compressedSubImage(range, {},
} }
#endif #endif
{
GL::Renderer::Feature feature = GL::Renderer::Feature::Blending;
bool enabled{};
/* [Renderer-setFeature] */
enabled ? GL::Renderer::enable(feature) : GL::Renderer::disable(feature)
/* [Renderer-setFeature] */
;
}
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
{ {
/* [SampleQuery-usage] */ /* [SampleQuery-usage] */

5
src/Magnum/GL/Framebuffer.h

@ -490,10 +490,7 @@ class MAGNUM_GL_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractO
* used, you can achieve the same by passing @ref Framebuffer::DrawAttachment::None * used, you can achieve the same by passing @ref Framebuffer::DrawAttachment::None
* as color attachment ID. Example usage: * as color attachment ID. Example usage:
* *
* @code{.cpp} * @snippet MagnumGL.cpp Framebuffer-mapForDraw
* framebuffer.mapForDraw({{MyShader::ColorOutput, Framebuffer::ColorAttachment(0)},
* {MyShader::NormalOutput, Framebuffer::DrawAttachment::None}});
* @endcode
* *
* If neither @gl_extension{ARB,direct_state_access} (part of OpenGL 4.5) * If neither @gl_extension{ARB,direct_state_access} (part of OpenGL 4.5)
* nor @gl_extension{EXT,direct_state_access} desktop extension is * nor @gl_extension{EXT,direct_state_access} desktop extension is

4
src/Magnum/GL/Renderer.h

@ -331,9 +331,7 @@ class MAGNUM_GL_EXPORT Renderer {
* *
* Convenience equivalent to the following: * Convenience equivalent to the following:
* *
* @code{.cpp} * @snippet MagnumGL.cpp Renderer-setFeature
* enabled ? Renderer::enable(feature) : Renderer::disable(feature)
* @endcode
* *
* Prefer to use @ref enable() and @ref disable() directly to avoid * Prefer to use @ref enable() and @ref disable() directly to avoid
* unnecessary branching. * unnecessary branching.

Loading…
Cancel
Save