Browse Source

Shaders: port tests away from MeshDataXD.

pull/371/head
Vladimír Vondruš 6 years ago
parent
commit
89d6d6de7c
  1. 3
      src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp
  2. 11
      src/Magnum/Shaders/Test/FlatGLTest.cpp
  3. 14
      src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp
  4. 12
      src/Magnum/Shaders/Test/PhongGLTest.cpp
  5. 3
      src/Magnum/Shaders/Test/VectorGLTest.cpp
  6. 19
      src/Magnum/Shaders/Test/VertexColorGLTest.cpp

3
src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp

@ -48,8 +48,7 @@
#include "Magnum/Shaders/DistanceFieldVector.h"
#include "Magnum/Trade/AbstractImporter.h"
#include "Magnum/Trade/ImageData.h"
#include "Magnum/Trade/MeshData2D.h"
#include "Magnum/Trade/MeshData3D.h"
#include "Magnum/Trade/MeshData.h"
#include "configure.h"

11
src/Magnum/Shaders/Test/FlatGLTest.cpp

@ -52,8 +52,7 @@
#include "Magnum/Shaders/Flat.h"
#include "Magnum/Trade/AbstractImporter.h"
#include "Magnum/Trade/ImageData.h"
#include "Magnum/Trade/MeshData2D.h"
#include "Magnum/Trade/MeshData3D.h"
#include "Magnum/Trade/MeshData.h"
#include "configure.h"
@ -640,11 +639,11 @@ template<class T> void FlatGLTest::renderVertexColor2D() {
!(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImageImporter plugins not found.");
Trade::MeshData2D circleData = Primitives::circle2DSolid(32,
Trade::MeshData circleData = Primitives::circle2DSolid(32,
Primitives::CircleTextureCoords::Generate);
/* Highlight a quarter */
Containers::Array<T> colorData{Containers::DirectInit, circleData.positions(0).size(), 0x999999_rgbf};
Containers::Array<T> colorData{Containers::DirectInit, circleData.vertexCount(), 0x999999_rgbf};
for(std::size_t i = 8; i != 16; ++i)
colorData[i + 1] = 0xffff99_rgbf*1.5f;
@ -694,11 +693,11 @@ template<class T> void FlatGLTest::renderVertexColor3D() {
!(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImageImporter plugins not found.");
Trade::MeshData3D sphereData = Primitives::uvSphereSolid(16, 32,
Trade::MeshData sphereData = Primitives::uvSphereSolid(16, 32,
Primitives::UVSphereTextureCoords::Generate);
/* Highlight the middle rings */
Containers::Array<T> colorData{Containers::DirectInit, sphereData.positions(0).size(), 0x999999_rgbf};
Containers::Array<T> colorData{Containers::DirectInit, sphereData.vertexCount(), 0x999999_rgbf};
for(std::size_t i = 6*33; i != 9*33; ++i)
colorData[i + 1] = 0xffff99_rgbf*1.5f;

14
src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp

@ -51,8 +51,7 @@
#include "Magnum/Primitives/UVSphere.h"
#include "Magnum/Shaders/MeshVisualizer.h"
#include "Magnum/Trade/AbstractImporter.h"
#include "Magnum/Trade/MeshData2D.h"
#include "Magnum/Trade/MeshData3D.h"
#include "Magnum/Trade/MeshData.h"
#include "configure.h"
@ -409,24 +408,19 @@ void MeshVisualizerGLTest::renderWireframe() {
#endif
#endif
const Trade::MeshData3D sphereData = Primitives::icosphereSolid(1);
const Trade::MeshData sphereData = Primitives::icosphereSolid(1);
GL::Mesh sphere{NoCreate};
if(data.flags & MeshVisualizer::Flag::NoGeometryShader) {
sphere = GL::Mesh{};
sphere.setCount(sphereData.indices().size());
/* Duplicate the vertices */
GL::Buffer positions;
positions.setData(MeshTools::duplicate(Containers::stridedArrayView(sphereData.indices()), Containers::stridedArrayView(sphereData.positions(0))));
sphere.addVertexBuffer(std::move(positions), 0, MeshVisualizer::Position{});
sphere = MeshTools::compile(MeshTools::duplicate(sphereData));
/* Supply also the vertex ID, if needed */
#ifndef MAGNUM_TARGET_GLES2
if(!GL::Context::current().isExtensionSupported<GL::Extensions::MAGNUM::shader_vertex_id>())
#endif
{
Containers::Array<Float> vertexIndex{sphereData.indices().size()};
Containers::Array<Float> vertexIndex{sphereData.indexCount()};
std::iota(vertexIndex.begin(), vertexIndex.end(), 0.0f);
GL::Buffer vertexId;

12
src/Magnum/Shaders/Test/PhongGLTest.cpp

@ -51,8 +51,8 @@
#include "Magnum/Primitives/UVSphere.h"
#include "Magnum/Shaders/Phong.h"
#include "Magnum/Trade/AbstractImporter.h"
#include "Magnum/Trade/MeshData3D.h"
#include "Magnum/Trade/ImageData.h"
#include "Magnum/Trade/MeshData.h"
#include "configure.h"
@ -506,12 +506,12 @@ void PhongGLTest::renderDefaults() {
/* The light is at the center by default, so we scale the sphere to half
and move the vertices back a bit to avoid a fully-black render but
still have the thing in the default [-1; 1] cube */
Trade::MeshData3D meshData = Primitives::uvSphereSolid(16, 32);
Trade::MeshData meshData = Primitives::uvSphereSolid(16, 32);
Matrix4 transformation =
Matrix4::translation(Vector3::zAxis(-1.0f))*Matrix4::scaling(Vector3(1.0f, 1.0f, 0.25f));
MeshTools::transformPointsInPlace(transformation, meshData.positions(0));
MeshTools::transformPointsInPlace(transformation, meshData.mutableAttribute<Vector3>(Trade::MeshAttribute::Position));
/** @todo use Matrix4::normalMatrix() */
MeshTools::transformVectorsInPlace(transformation.inverted().transposed(), meshData.normals(0));
MeshTools::transformVectorsInPlace(transformation.inverted().transposed(), meshData.mutableAttribute<Vector3>(Trade::MeshAttribute::Normal));
GL::Mesh sphere = MeshTools::compile(meshData);
Phong shader;
@ -854,11 +854,11 @@ template<class T> void PhongGLTest::renderVertexColor() {
!(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImageImporter plugins not found.");
Trade::MeshData3D sphereData = Primitives::uvSphereSolid(16, 32,
Trade::MeshData sphereData = Primitives::uvSphereSolid(16, 32,
Primitives::UVSphereTextureCoords::Generate);
/* Highlight the middle rings */
Containers::Array<T> colorData{Containers::DirectInit, sphereData.positions(0).size(), 0x999999_rgbf};
Containers::Array<T> colorData{Containers::DirectInit, sphereData.vertexCount(), 0x999999_rgbf};
for(std::size_t i = 6*33; i != 9*33; ++i)
colorData[i + 1] = 0xffff99_rgbf*1.5f;

3
src/Magnum/Shaders/Test/VectorGLTest.cpp

@ -48,8 +48,7 @@
#include "Magnum/Shaders/Vector.h"
#include "Magnum/Trade/AbstractImporter.h"
#include "Magnum/Trade/ImageData.h"
#include "Magnum/Trade/MeshData2D.h"
#include "Magnum/Trade/MeshData3D.h"
#include "Magnum/Trade/MeshData.h"
#include "configure.h"

19
src/Magnum/Shaders/Test/VertexColorGLTest.cpp

@ -44,8 +44,7 @@
#include "Magnum/Primitives/UVSphere.h"
#include "Magnum/Shaders/VertexColor.h"
#include "Magnum/Trade/AbstractImporter.h"
#include "Magnum/Trade/MeshData2D.h"
#include "Magnum/Trade/MeshData3D.h"
#include "Magnum/Trade/MeshData.h"
#include "configure.h"
@ -197,11 +196,11 @@ void VertexColorGLTest::renderTeardown() {
template<class T> void VertexColorGLTest::renderDefaults2D() {
setTestCaseTemplateName(T::Size == 3 ? "Color3" : "Color4");
Trade::MeshData2D circleData = Primitives::circle2DSolid(32,
Trade::MeshData circleData = Primitives::circle2DSolid(32,
Primitives::CircleTextureCoords::Generate);
/* All a single color */
Containers::Array<T> colorData{Containers::DirectInit, circleData.positions(0).size(), 0xffffff_rgbf};
Containers::Array<T> colorData{Containers::DirectInit, circleData.vertexCount(), 0xffffff_rgbf};
GL::Buffer colors;
colors.setData(colorData);
@ -238,11 +237,11 @@ template<class T> void VertexColorGLTest::renderDefaults3D() {
!(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImageImporter plugins not found.");
Trade::MeshData3D sphereData = Primitives::uvSphereSolid(16, 32,
Trade::MeshData sphereData = Primitives::uvSphereSolid(16, 32,
Primitives::UVSphereTextureCoords::Generate);
/* All a single color */
Containers::Array<T> colorData{Containers::DirectInit, sphereData.positions(0).size(), 0xffffff_rgbf};
Containers::Array<T> colorData{Containers::DirectInit, sphereData.vertexCount(), 0xffffff_rgbf};
GL::Buffer colors;
colors.setData(colorData);
@ -271,11 +270,11 @@ template<class T> void VertexColorGLTest::renderDefaults3D() {
template<class T> void VertexColorGLTest::render2D() {
setTestCaseTemplateName(T::Size == 3 ? "Color3" : "Color4");
Trade::MeshData2D circleData = Primitives::circle2DSolid(32,
Trade::MeshData circleData = Primitives::circle2DSolid(32,
Primitives::CircleTextureCoords::Generate);
/* Highlight a quarter */
Containers::Array<T> colorData{Containers::DirectInit, circleData.positions(0).size(), 0x9999ff_rgbf};
Containers::Array<T> colorData{Containers::DirectInit, circleData.vertexCount(), 0x9999ff_rgbf};
for(std::size_t i = 8; i != 16; ++i)
colorData[i + 1] = 0xffff99_rgbf;
@ -316,11 +315,11 @@ template<class T> void VertexColorGLTest::render3D() {
!(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImageImporter plugins not found.");
Trade::MeshData3D sphereData = Primitives::uvSphereSolid(16, 32,
Trade::MeshData sphereData = Primitives::uvSphereSolid(16, 32,
Primitives::UVSphereTextureCoords::Generate);
/* Highlight the middle rings */
Containers::Array<T> colorData{Containers::DirectInit, sphereData.positions(0).size(), 0x9999ff_rgbf};
Containers::Array<T> colorData{Containers::DirectInit, sphereData.vertexCount(), 0x9999ff_rgbf};
for(std::size_t i = 6*33; i != 9*33; ++i)
colorData[i + 1] = 0xffff99_rgbf;

Loading…
Cancel
Save