Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// Clearing the render target fills it with the clear color from corner to corner.
TEST_F(RenderingTest, Clear)
{
const DWORD color = 0x102030;
const DWORD color = 0x603010;
clear(color);
capture("clear.png");
EXPECT_EQ(pixel(0, 0), color);
Expand Down
8 changes: 4 additions & 4 deletions Tests/Google/Core/Rendering/EXAMPLE_TEMPORARY_LaserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ TEST_F(RenderingTest, Laser)
return 0xFF000000 | brightness << 16 | brightness << 8 | brightness;
});

// A red beam from west to east and a blue one that crosses it on the way up.
// A green beam from west to east and a magenta one that crosses it on the way up.
Vector3 eastWest[] = {Vector3(-6.0f, 0.0f, 0.0f), Vector3(6.0f, 0.0f, 0.0f)};
Vector3 diagonal[] = {Vector3(-5.0f, -3.0f, 0.0f), Vector3(5.0f, 3.0f, 2.0f)};
SegmentedLineClass *red = NEW_REF(SegmentedLineClass, ());
red->Set_Points(2, eastWest);
red->Set_Color(Vector3(1.0f, 0.2f, 0.1f));
red->Set_Color(Vector3(0.2f, 1.0f, 0.2f));
SegmentedLineClass *blue = NEW_REF(SegmentedLineClass, ());
blue->Set_Points(2, diagonal);
blue->Set_Color(Vector3(0.2f, 0.4f, 1.0f));
blue->Set_Color(Vector3(1.0f, 0.2f, 1.0f));
for (SegmentedLineClass *laser : {red, blue})
{
laser->Set_Texture(glow);
laser->Set_Shader(ShaderClass::_PresetAdditiveShader);
laser->Set_Width(0.8f);
laser->Set_Width(1.2f);
}

render({red, blue});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ TEST_F(RenderingTest, Particles)
return 0xFF000000 | brightness << 16 | brightness << 8 | brightness;
});

// A ring of particles on the ground that turn from red to yellow and grow, around one in the middle.
// A ring of particles on the ground that turn from blue to cyan and grow, around one in the middle.
constexpr int Count = 13;
ShareBufferClass<Vector3> *locations = NEW_REF(ShareBufferClass<Vector3>, (Count, "ParticlesTest"));
ShareBufferClass<Vector4> *colors = NEW_REF(ShareBufferClass<Vector4>, (Count, "ParticlesTest"));
ShareBufferClass<float> *sizes = NEW_REF(ShareBufferClass<float>, (Count, "ParticlesTest"));
for (int i = 0; i < Count; ++i)
{
const float angle = i * WWMATH_PI * 2.0f / (Count - 1);
const float radius = i == 0 ? 0.0f : 4.0f;
const float radius = i == 0 ? 0.0f : 3.0f;
locations->Get_Array()[i] = Vector3(radius * cosf(angle), radius * sinf(angle), 0.0f);
colors->Get_Array()[i] = Vector4(1.0f, static_cast<float>(i) / Count, 0.1f, 1.0f);
colors->Get_Array()[i] = Vector4(0.1f, static_cast<float>(i) / Count, 1.0f, 1.0f);
sizes->Get_Array()[i] = 1.0f + i * 0.1f;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ TEST_F(RenderingTest, Render2DBlending)
renderer.Set_Coordinate_Range(RectClass(0.0f, 0.0f, Width, Height));
renderer.Enable_Texturing(false);

// Half transparent red.
// Half transparent blue.
renderer.Enable_Alpha(true);
renderer.Add_Quad(RectClass(16.0f, 16.0f, 112.0f, 240.0f), 0x80FF0000);
renderer.Add_Quad(RectClass(16.0f, 16.0f, 112.0f, 240.0f), 0x800000FF);
renderer.Render();

// Green added on top, partly over the red.
// Red added on top, partly over the blue.
renderer.Reset();
renderer.Enable_Additive(true);
renderer.Add_Quad(RectClass(80.0f, 16.0f, 176.0f, 240.0f), 0xFF006000);
renderer.Add_Quad(RectClass(80.0f, 16.0f, 176.0f, 240.0f), 0xFF600000);
renderer.Render();

// Blue multiplied with what is below, partly over the green.
// Yellow multiplied with what is below, partly over the red.
renderer.Reset();
*renderer.Get_Shader() = ShaderClass::_PresetMultiplicative2DShader;
renderer.Enable_Texturing(false);
renderer.Add_Quad(RectClass(144.0f, 16.0f, 240.0f, 240.0f), 0xFF4080FF);
renderer.Add_Quad(RectClass(144.0f, 16.0f, 240.0f, 240.0f), 0xFFFFFF40);
renderer.Render();

capture("render2d_blending.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ TEST_F(RenderingTest, Render2DShapes)
renderer.Set_Coordinate_Range(RectClass(0.0f, 0.0f, Width, Height));
renderer.Enable_Texturing(false);

// A blue rectangle with a white border, an orange outline, a green line and a red to blue gradient.
renderer.Add_Rect(RectClass(16.0f, 16.0f, 112.0f, 112.0f), 4.0f, 0xFFFFFFFF, 0xFF2040C0);
renderer.Add_Outline(RectClass(144.0f, 16.0f, 240.0f, 112.0f), 2.0f, 0xFFFFC000);
renderer.Add_Line(Vector2(16.0f, 136.0f), Vector2(240.0f, 184.0f), 3.0f, 0xFF40FF40);
renderer.Add_Quad_HGradient(RectClass(16.0f, 208.0f, 240.0f, 240.0f), 0xFFFF0000, 0xFF0000FF);
// An orange rectangle with a green border, a cyan outline, a yellow line and a green to magenta gradient.
renderer.Add_Rect(RectClass(16.0f, 16.0f, 112.0f, 112.0f), 4.0f, 0xFF40FF40, 0xFFC04020);
renderer.Add_Outline(RectClass(144.0f, 16.0f, 240.0f, 112.0f), 2.0f, 0xFF00C0FF);
renderer.Add_Line(Vector2(16.0f, 136.0f), Vector2(240.0f, 184.0f), 3.0f, 0xFFFFFF40);
renderer.Add_Quad_HGradient(RectClass(16.0f, 208.0f, 240.0f, 240.0f), 0xFF00FF00, 0xFFFF00FF);
renderer.Render();

capture("render2d_shapes.png");
// The fill and the border of the rectangle, and the inside and the edge of the outline.
EXPECT_EQ(pixel(64, 64), 0x2040C0);
EXPECT_EQ(pixel(17, 64), 0xFFFFFF);
EXPECT_EQ(pixel(64, 64), 0xC04020);
EXPECT_EQ(pixel(17, 64), 0x40FF40);
EXPECT_EQ(pixel(192, 64), 0x000000);
EXPECT_EQ(pixel(145, 64), 0xFFC000);
EXPECT_EQ(pixel(145, 64), 0x00C0FF);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
// linear filtering blends them, and transparent texels let the background show through.
TEST_F(RenderingTest, Render2DTexture)
{
const DWORD background = 0x204060;
const DWORD background = 0x402060;
clear(background);

// A red and white checkerboard with a transparent top left quarter.
// A blue and white checkerboard with a transparent top left quarter.
const auto checkerboard = [](UINT x, UINT y) -> DWORD
{
const DWORD alpha = (x < 4 && y < 4) ? 0x00000000 : 0xFF000000;
return alpha | (((x ^ y) & 1) ? 0xFFFFFF : 0xC02020);
return alpha | (((x ^ y) & 1) ? 0xFFFFFF : 0x2080C0);
};
TextureClass *sharp = createTexture(8, 8, checkerboard);
sharp->Get_Filter().Set_Min_Filter(TextureFilterClass::FILTER_TYPE_NONE);
Expand All @@ -53,8 +53,8 @@ TEST_F(RenderingTest, Render2DTexture)
REF_PTR_RELEASE(smooth);

capture("render2d_texture.png");
// Each texel covers 12 by 12 pixels. These are the centers of texel (5, 5), which is red, and texel (1, 1),
// Each texel covers 12 by 12 pixels. These are the centers of texel (5, 5), which is blue, and texel (1, 1),
// which is transparent.
EXPECT_EQ(pixel(16 + 5 * 12 + 6, 64 + 5 * 12 + 6), 0xC02020);
EXPECT_EQ(pixel(16 + 5 * 12 + 6, 64 + 5 * 12 + 6), 0x2080C0);
EXPECT_EQ(pixel(16 + 1 * 12 + 6, 64 + 1 * 12 + 6), background);
}
8 changes: 4 additions & 4 deletions Tests/Google/Core/Rendering/EXAMPLE_TEMPORARY_TextTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// including the drop shadow below the text.
TEST_F(RenderingTest, Text)
{
const DWORD background = 0x204060;
const DWORD background = 0x302020;
clear(background);

FontCharsClass *font = NEW_REF(FontCharsClass, ());
Expand All @@ -33,12 +33,12 @@ TEST_F(RenderingTest, Text)
REF_PTR_RELEASE(font);

// The black shadow first, then the text over it.
const WCHAR *text = L"Command & Conquer";
const WCHAR *text = L"Generals Zero Hour";
sentence.Build_Sentence(text, nullptr, nullptr);
sentence.Set_Location(Vector2(18.0f, 18.0f));
sentence.Draw_Sentence(0xFF000000);
sentence.Set_Location(Vector2(16.0f, 16.0f));
sentence.Draw_Sentence(0xFFFFC000);
sentence.Draw_Sentence(0xFF40C0FF);
sentence.Render();
const Vector2 extents = sentence.Get_Text_Extents(text);

Expand All @@ -48,7 +48,7 @@ TEST_F(RenderingTest, Text)
bool found = false;
for (UINT x = 16; x < 16 + extents.X; ++x)
{
found |= pixel(x, 16 + static_cast<UINT>(extents.Y) / 2) == 0xFFC000;
found |= pixel(x, 16 + static_cast<UINT>(extents.Y) / 2) == 0x40C0FF;
}
EXPECT_TRUE(found);
}
6 changes: 3 additions & 3 deletions Tests/Google/Core/Rendering/EXAMPLE_TEMPORARY_TracerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
// Tracers are 3D lines, which W3DTracerDraw fades out by lowering their opacity.
TEST_F(RenderingTest, Tracer)
{
// A solid yellow tracer, crossed by a red one at half opacity.
Line3DClass *solid = NEW_REF(Line3DClass, (Vector3(-6.0f, -2.0f, 0.0f), Vector3(6.0f, 2.0f, 0.0f), 0.2f, 1.0f, 0.9f, 0.2f));
Line3DClass *faded = NEW_REF(Line3DClass, (Vector3(-6.0f, 2.0f, 0.0f), Vector3(6.0f, -2.0f, 0.0f), 0.2f, 1.0f, 0.3f, 0.2f, 0.5f));
// A solid cyan tracer, crossed by a magenta one at half opacity.
Line3DClass *solid = NEW_REF(Line3DClass, (Vector3(-6.0f, -2.0f, 0.0f), Vector3(6.0f, 2.0f, 0.0f), 0.3f, 0.2f, 0.9f, 1.0f));
Line3DClass *faded = NEW_REF(Line3DClass, (Vector3(-6.0f, 2.0f, 0.0f), Vector3(6.0f, -2.0f, 0.0f), 0.3f, 1.0f, 0.2f, 1.0f, 0.5f));

render({solid, faded});
REF_PTR_RELEASE(solid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
// A triangle with a red, a green and a blue corner blends the corner colors across its area.
TEST_F(RenderingTest, Triangle)
{
const DWORD background = 0x102030;
const DWORD background = 0x301020;
clear(background);
drawTriangles({
{128.0f, 32.0f, 0xff0000},
{224.0f, 224.0f, 0x00ff00},
{32.0f, 224.0f, 0x0000ff},
{128.0f, 32.0f, 0x0000ff},
{224.0f, 224.0f, 0xff0000},
{32.0f, 224.0f, 0x00ff00},
});
capture("triangle.png");
// GPUs round the blended colors differently, so the exact colors are left to the image comparison of CI.
Expand Down
Loading