Browse Source

doc: avoid using deprecated functionality in image generators.

pull/255/head
Vladimír Vondruš 8 years ago
parent
commit
ff07b165c5
  1. 21
      doc/generated/primitives.cpp
  2. 75
      doc/generated/shaders.cpp

21
doc/generated/primitives.cpp

@ -235,11 +235,7 @@ int PrimitiveVisualizer::exec() {
Containers::Optional<Trade::MeshData2D> data;
std::tie(data, filename) = (this->*fun)();
std::unique_ptr<GL::Buffer> vertices, indices;
GL::Mesh mesh{NoCreate};
std::tie(mesh, vertices, indices) = MeshTools::compile(*data, GL::BufferUsage::StaticDraw);
mesh.draw(shader);
MeshTools::compile(*data).draw(shader);
GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color);
Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm});
@ -269,11 +265,7 @@ int PrimitiveVisualizer::exec() {
Containers::Optional<Trade::MeshData3D> data;
std::tie(data, filename) = (this->*fun)();
std::unique_ptr<GL::Buffer> vertices, indices;
GL::Mesh mesh{NoCreate};
std::tie(mesh, vertices, indices) = MeshTools::compile(*data, GL::BufferUsage::StaticDraw);
mesh.draw(shader);
MeshTools::compile(*data).draw(shader);
GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color);
Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm});
@ -350,12 +342,9 @@ int PrimitiveVisualizer::exec() {
Containers::Optional<Trade::MeshData3D> data;
std::tie(data, filename) = (this->*fun)();
std::unique_ptr<GL::Buffer> vertices, indices;
GL::Mesh mesh{NoCreate};
std::tie(mesh, vertices, indices) = MeshTools::compile(*data, GL::BufferUsage::StaticDraw);
mesh.draw(phong);
mesh.draw(wireframe);
MeshTools::compile(*data)
.draw(phong)
.draw(wireframe);
GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color);
Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm});

75
doc/generated/shaders.cpp

@ -148,54 +148,37 @@ namespace {
}
std::string ShaderVisualizer::phong() {
std::unique_ptr<GL::Buffer> vertices, indices;
GL::Mesh mesh{NoCreate};
std::tie(mesh, vertices, indices) = MeshTools::compile(Primitives::uvSphereSolid(16, 32), GL::BufferUsage::StaticDraw);
Shaders::Phong shader;
shader.setAmbientColor(0x22272e_rgbf)
MeshTools::compile(Primitives::uvSphereSolid(16, 32)).draw(Shaders::Phong{}
.setAmbientColor(0x22272e_rgbf)
.setDiffuseColor(BaseColor)
.setShininess(200.0f)
.setLightPosition({5.0f, 5.0f, 7.0f})
.setProjectionMatrix(Projection)
.setTransformationMatrix(Transformation)
.setNormalMatrix(Transformation.rotationScaling());
mesh.draw(shader);
.setNormalMatrix(Transformation.rotationScaling()));
return "phong.png";
}
std::string ShaderVisualizer::meshVisualizer() {
std::unique_ptr<GL::Buffer> vertices, indices;
GL::Mesh mesh{NoCreate};
std::tie(mesh, vertices, indices) = MeshTools::compile(Primitives::icosphereSolid(1), GL::BufferUsage::StaticDraw);
const Matrix4 projection = Projection*Transformation*
Matrix4::rotationZ(13.7_degf)*
Matrix4::rotationX(-12.6_degf);
Shaders::MeshVisualizer shader{Shaders::MeshVisualizer::Flag::Wireframe};
shader.setColor(BaseColor)
.setWireframeColor(OutlineColor)
.setViewportSize(Vector2{ImageSize})
.setTransformationProjectionMatrix(projection);
mesh.draw(shader);
MeshTools::compile(Primitives::icosphereSolid(1))
.draw(Shaders::MeshVisualizer{Shaders::MeshVisualizer::Flag::Wireframe}
.setColor(BaseColor)
.setWireframeColor(OutlineColor)
.setViewportSize(Vector2{ImageSize})
.setTransformationProjectionMatrix(projection));
return "meshvisualizer.png";
}
std::string ShaderVisualizer::flat() {
std::unique_ptr<GL::Buffer> vertices, indices;
GL::Mesh mesh{NoCreate};
std::tie(mesh, vertices, indices) = MeshTools::compile(Primitives::uvSphereSolid(16, 32), GL::BufferUsage::StaticDraw);
Shaders::Flat3D shader;
shader.setColor(BaseColor)
.setTransformationProjectionMatrix(Projection*Transformation);
mesh.draw(shader);
MeshTools::compile(Primitives::uvSphereSolid(16, 32)).draw(Shaders::Flat3D{}
.setColor(BaseColor)
.setTransformationProjectionMatrix(Projection*Transformation));
return "flat.png";
}
@ -244,20 +227,15 @@ std::string ShaderVisualizer::vector() {
.setStorage(1, GL::TextureFormat::RGBA8, image->size())
.setSubImage(0, {}, *image);
GL::Mesh mesh{NoCreate};
std::unique_ptr<GL::Buffer> vertices;
std::tie(mesh, vertices, std::ignore) = MeshTools::compile(Primitives::squareSolid(Primitives::SquareTextureCoords::Generate), GL::BufferUsage::StaticDraw);
Shaders::Vector2D shader;
shader.setColor(BaseColor)
.bindVectorTexture(texture)
.setTransformationProjectionMatrix({});
GL::Renderer::enable(GL::Renderer::Feature::Blending);
GL::Renderer::setBlendFunction(GL::Renderer::BlendFunction::One, GL::Renderer::BlendFunction::OneMinusSourceAlpha);
GL::Renderer::setBlendEquation(GL::Renderer::BlendEquation::Add, GL::Renderer::BlendEquation::Add);
mesh.draw(shader);
MeshTools::compile(Primitives::squareSolid(Primitives::SquareTextureCoords::Generate))
.draw(Shaders::Vector2D{}
.setColor(BaseColor)
.bindVectorTexture(texture)
.setTransformationProjectionMatrix({}));
GL::Renderer::disable(GL::Renderer::Feature::Blending);
@ -278,22 +256,17 @@ std::string ShaderVisualizer::distanceFieldVector() {
.setStorage(1, GL::TextureFormat::RGBA8, image->size())
.setSubImage(0, {}, *image);
GL::Mesh mesh{NoCreate};
std::unique_ptr<GL::Buffer> vertices;
std::tie(mesh, vertices, std::ignore) = MeshTools::compile(Primitives::squareSolid(Primitives::SquareTextureCoords::Generate), GL::BufferUsage::StaticDraw);
Shaders::DistanceFieldVector2D shader;
shader.setColor(BaseColor)
.setOutlineColor(OutlineColor)
.setOutlineRange(0.6f, 0.4f)
.bindVectorTexture(texture)
.setTransformationProjectionMatrix({});
GL::Renderer::enable(GL::Renderer::Feature::Blending);
GL::Renderer::setBlendFunction(GL::Renderer::BlendFunction::One, GL::Renderer::BlendFunction::OneMinusSourceAlpha);
GL::Renderer::setBlendEquation(GL::Renderer::BlendEquation::Add, GL::Renderer::BlendEquation::Add);
mesh.draw(shader);
MeshTools::compile(Primitives::squareSolid(Primitives::SquareTextureCoords::Generate))
.draw(Shaders::DistanceFieldVector2D{}
.setColor(BaseColor)
.setOutlineColor(OutlineColor)
.setOutlineRange(0.6f, 0.4f)
.bindVectorTexture(texture)
.setTransformationProjectionMatrix({}));
GL::Renderer::disable(GL::Renderer::Feature::Blending);

Loading…
Cancel
Save