Skip to content
Permalink
Browse files

Blend States CI Test (#1730)

Expand the continuous integration testing to cover blend modes supported by the Travis Mesa driver. A few columns and rows are excluded from the blend mode matrix for now because the Travis Mesa driver does not support them.

This includes the following columns and rows which are excluded:
* GL_SRC_COLOR and GL_ONE_MINUS_SRC_COLOR for source
* GL_DST_COLOR and GL_ONE_MINUS_DST_COLOR for destination
* GL_SRC_ALPHA_SATURATE for destination
  • Loading branch information...
RobertBColton committed May 19, 2019
1 parent 0536c82 commit 148023a668ad72927fc165bc0bc1c24952e5077e
@@ -0,0 +1,25 @@
#include "TestHarness.hpp"

#include <gtest/gtest.h>

TEST(Regression, draw_blend_test) {
if (!TestHarness::windowing_supported()) return;
TestConfig tc;
tc.extensions = "Paths,libpng";
auto test_harness = LAUNCH_HARNESS_FOR_SOG(tc);
if (!test_harness) FAIL() << "Game could not be run.";

test_harness->wait(); // Let the game render a frame first.
ASSERT_TRUE(test_harness->game_is_running())
<< "Game stopped running unexpectedly";

test_harness->screen_save("./test-harness-out/enigma_draw_blend_test.png");

test_harness->close_window();
bool game_running = test_harness->game_is_running();
for (int i = 0; game_running && i < 10; ++i) {
test_harness->wait();
game_running = test_harness->game_is_running();
}
ASSERT_FALSE(game_running) << "Game did not exit after window was closed!";
}
@@ -0,0 +1 @@
spr_hugar = sprite_add("CommandLine/testing/data/hugar.png", 1, false, false, 0, 0);
@@ -0,0 +1,25 @@
draw_rectangle_color(0, 0, 352, 352, c_red, c_green, c_blue, c_yellow, 0);

var blend_mode_count = bm_src_alpha_sat - bm_zero;
for (var i = 0; i <= blend_mode_count; i += 1) {
var src = i + bm_zero;

// GL 1.4 or greater required else invalid enum
// Travis Mesa driver is too old for now
if (src == bm_src_color || src == bm_inv_src_color) continue;

// OpenGL/OpenGL ES does not accept bm_src_alpha_sat (aka GL_SRC_ALPHA_SATURATE) for destination
// so this inner loop needs to be exclusive of that constant (< instead of <=)
// https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glBlendFunc.xml
for (var j = 0; j < blend_mode_count; j += 1) {
var dst = j + bm_zero;

// GL 1.4 or greater required else invalid enum
// Travis Mesa driver is too old for now
if (dst == bm_dest_color || dst == bm_inv_dest_color) continue;

draw_set_blend_mode_ext(src, dst);
draw_sprite(spr_hugar, 0, i*32, j*32);
draw_set_blend_mode(bm_normal);
}
}
@@ -70,7 +70,7 @@ using namespace enigma_user;
namespace enigma
{

void draw_sprite_pos_raw(const enigma::sprite* spr2d, int subimg, gs_scalar x1, gs_scalar y1, gs_scalar x2, gs_scalar y2, gs_scalar x3, gs_scalar y3, gs_scalar x4, gs_scalar y4, gs_scalar color, gs_scalar alpha)
void draw_sprite_pos_raw(const enigma::sprite *const spr2d, int subimg, gs_scalar x1, gs_scalar y1, gs_scalar x2, gs_scalar y2, gs_scalar x3, gs_scalar y3, gs_scalar x4, gs_scalar y4, gs_scalar color, gs_scalar alpha)
{
alpha = CLAMP_ALPHAF(alpha);
get_subimg(usi, spr2d, subimg);
@@ -86,7 +86,8 @@ void draw_sprite_pos_raw(const enigma::sprite* spr2d, int subimg, gs_scalar x1,
draw_vertex_texture_color(x3,y3, tx+tw, ty+th, color,alpha);
draw_primitive_end();
}
void draw_sprite_pos_part_raw(const enigma::sprite* spr2d, int subimg,

void draw_sprite_pos_part_raw(const enigma::sprite *const spr2d, int subimg,
gs_scalar px, gs_scalar py, gs_scalar pw, gs_scalar ph,
gs_scalar x1, gs_scalar y1, gs_scalar x2, gs_scalar y2, gs_scalar x3, gs_scalar y3, gs_scalar x4, gs_scalar y4,
gs_scalar color, gs_scalar alpha

0 comments on commit 148023a

Please sign in to comment.
You can’t perform that action at this time.