Emulator: migrate SDL2 -> SDL3
Port the shared emulator harness (all apps) to SDL 3.4 + SDL3_ttf 3.2:
- window creation without position args; renderer logical size via
SDL_SetRenderLogicalPresentation(LETTERBOX); SDL_RenderTexture;
SDL_SaveBMP_IO frame dumps
- SDL_EVENT_* event scheme, flattened SDL_KeyboardEvent, float mouse
coords; clicks mapped with SDL_ConvertEventToRenderCoordinates, keeping
the Xwayland global-state cross-check from 260a2b3
- audio shim on the stream API (SDL_OpenAudioDeviceStream +
SDL_PutAudioStreamData) since SDL_QueueAudio is gone
- TTF_RenderText_Blended (explicit length); SDL3_ttf header layout
handled via __has_include (Ubuntu installs under SDL3_ttf/)
- e2e freeze-tint pixel assertions updated to the committed
diagonal-stripe pattern (stale since the freeze rework; pre-existing
failures at HEAD under SDL2), sampled away from the freeze text
Full suite green: 14 unit + 7 integration + 3 E2E journeys, 0 failures.
MissileCommand, MiataDrive, NetDeck build; CrtTerminal (missing sndBlip
declaration) and Lotus3 (sketch not in repo) fail identically at HEAD -
pre-existing, out of scope.
This commit is contained in:
@@ -11,10 +11,10 @@
|
||||
* Slower by nature (~1-2 min: the scenario runs at 20 Hz real time), which
|
||||
* is why it gets its own build and its own make target.
|
||||
*/
|
||||
#include "harness.h"
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3_ttf/SDL_ttf.h> // Debian/Ubuntu layout (upstream: SDL3/SDL_ttf.h)
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_ttf.h>
|
||||
#include "harness.h"
|
||||
|
||||
// pull in the whole sketch as a single translation unit (-DAPP_INO)
|
||||
#include APP_INO
|
||||
@@ -115,13 +115,20 @@ TEST(e2e/boot_and_controls)
|
||||
|
||||
// HUD separator rendered across the top of the HUD bar
|
||||
EXPECT(test::pixelIs565(160, nd::HUD_Y, nd::C_BORDER));
|
||||
// paused -> dithered freeze tint with color-key transparency:
|
||||
// black dots where ((x>>1)+(y>>1)) is even, map shows through elsewhere
|
||||
EXPECT(test::pixelIs565(50, 2, 0x0000)); // dither dot drawn
|
||||
EXPECT(test::pixelIs565(52, 0, 0x0000)); // dither dot drawn
|
||||
EXPECT(test::pixelIs565(50, 0, nd::C_WALL)); // transparent: wall pixel
|
||||
EXPECT(test::pixelIs565(50, 4, nd::C_WALL)); // survives untouched
|
||||
EXPECT(!test::pixelIs565(50, 0, 0x1F1F)); // key color never rendered
|
||||
// paused -> diagonal-stripe freeze tint with color-key transparency:
|
||||
// within each 8x8 cell the anti-diagonal stripe ((x%8)+(y%8))%8 == 2
|
||||
// stamps black, every other pixel keeps the frozen view, and the key
|
||||
// color 0x1F1F is never rendered (transparency held). Sampled on the
|
||||
// left side of the top wall row, away from the top-right anchored
|
||||
// "* TACTICAL FREEZE *" text, so font metric drift can't leak in.
|
||||
EXPECT(test::pixelIs565(10, 0, 0x0000)); // stripe dot (2,0)
|
||||
EXPECT(test::pixelIs565(9, 1, 0x0000)); // stripe dot (1,1)
|
||||
EXPECT(test::pixelIs565(8, 2, 0x0000)); // stripe dot (0,2)
|
||||
EXPECT(!test::pixelIs565(12, 0, 0x0000)); // off-stripe: frozen view
|
||||
EXPECT(!test::pixelIs565(12, 0, 0x1F1F)); // key color never rendered
|
||||
for (int yy = 0; yy < 8; yy++)
|
||||
for (int xx = 8; xx < 16; xx++)
|
||||
EXPECT(!test::pixelIs565(xx, yy, 0x1F1F));
|
||||
}
|
||||
|
||||
TEST(e2e/network_journey)
|
||||
@@ -154,8 +161,8 @@ TEST(e2e/corridor_assault)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// headless: no window needed — rendering goes into the shim framebuffer
|
||||
SDL_setenv("SDL_VIDEODRIVER", "dummy", 1);
|
||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||
::setenv("SDL_VIDEODRIVER", "dummy", 1);
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
std::printf("SDL_Init failed: %s\n", SDL_GetError());
|
||||
return 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user