Remove teststreaming

This commit is contained in:
Cameron Cawley
2025-10-07 14:53:37 +01:00
committed by Sam Lantinga
parent ce4af658ba
commit 0f62b7c3b4
4 changed files with 0 additions and 321 deletions

1
.gitignore vendored
View File

@@ -162,7 +162,6 @@ test/testshader
test/testshape
test/testsprite
test/testspriteminimal
test/teststreaming
test/testsurround
test/testthread
test/testtimer

View File

@@ -19,7 +19,6 @@
F35E56E72983133F00A43A5F /* PBXTargetDependency */,
DB0F490517CA5249008798C5 /* PBXTargetDependency */,
DB0F490717CA5249008798C5 /* PBXTargetDependency */,
DB166E9816A1D7CF00A1396C /* PBXTargetDependency */,
DB166E9616A1D7CD00A1396C /* PBXTargetDependency */,
DB166E6C16A1D72000A1396C /* PBXTargetDependency */,
DB166E5616A1D6B800A1396C /* PBXTargetDependency */,
@@ -131,7 +130,6 @@
DB166E5416A1D6A300A1396C /* testscale.c in Sources */ = {isa = PBXBuildFile; fileRef = DB166CC316A1C74100A1396C /* testscale.c */; };
DB166E6A16A1D70C00A1396C /* testshader.c in Sources */ = {isa = PBXBuildFile; fileRef = DB166CC416A1C74100A1396C /* testshader.c */; };
DB166E9316A1D7BC00A1396C /* testspriteminimal.c in Sources */ = {isa = PBXBuildFile; fileRef = DB166CC516A1C74100A1396C /* testspriteminimal.c */; };
DB166E9416A1D7C700A1396C /* teststreaming.c in Sources */ = {isa = PBXBuildFile; fileRef = DB166CC616A1C74100A1396C /* teststreaming.c */; };
DB166E9A16A1D7F700A1396C /* moose.dat in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00794E5E09D20839003FC8A1 /* moose.dat */; };
DB166E9C16A1D80900A1396C /* icon.bmp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00794E5D09D20839003FC8A1 /* icon.bmp */; };
DB445EFB18184BB600B306B0 /* testdropfile.c in Sources */ = {isa = PBXBuildFile; fileRef = DB445EFA18184BB600B306B0 /* testdropfile.c */; };
@@ -183,7 +181,6 @@
F3C17C8228E4112900E1A26D /* testutils.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C17C7328E40ADE00E1A26D /* testutils.c */; };
F3C17C8328E4124400E1A26D /* testutils.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C17C7328E40ADE00E1A26D /* testutils.c */; };
F3C17C8428E4126400E1A26D /* testutils.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C17C7328E40ADE00E1A26D /* testutils.c */; };
F3C17C8528E4127D00E1A26D /* testutils.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C17C7328E40ADE00E1A26D /* testutils.c */; };
F3C17CEB28E4177600E1A26D /* testgeometry.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C17CD628E416AC00E1A26D /* testgeometry.c */; };
F3C17CEC28E417EB00E1A26D /* testutils.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C17C7328E40ADE00E1A26D /* testutils.c */; };
F3C17D3928E424B800E1A26D /* sample.wav in Resources */ = {isa = PBXBuildFile; fileRef = 00794E6209D20839003FC8A1 /* sample.wav */; };
@@ -268,8 +265,6 @@
F3CB56FB2A78983200766177 /* SDL3.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
F3CB56FD2A78983C00766177 /* SDL3.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; };
F3CB56FE2A78983C00766177 /* SDL3.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
F3CB57002A78984300766177 /* SDL3.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; };
F3CB57012A78984300766177 /* SDL3.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
F3CB57032A78984A00766177 /* SDL3.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; };
F3CB57042A78984A00766177 /* SDL3.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
F3CB57062A78985400766177 /* SDL3.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; };
@@ -570,13 +565,6 @@
remoteGlobalIDString = DB166E6D16A1D78400A1396C;
remoteInfo = testspriteminimal;
};
DB166E9716A1D7CF00A1396C /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
proxyType = 1;
remoteGlobalIDString = DB166E8016A1D78C00A1396C;
remoteInfo = teststreaming;
};
F35E56E62983133F00A43A5F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
@@ -681,16 +669,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
DB166E9916A1D7EE00A1396C /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 7;
files = (
DB166E9A16A1D7F700A1396C /* moose.dat in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
DB166E9B16A1D7FC00A1396C /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
@@ -1161,17 +1139,6 @@
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
F3CB57022A78984300766177 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
F3CB57012A78984300766177 /* SDL3.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
F3CB57052A78984A00766177 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
@@ -1272,7 +1239,6 @@
003FA63A093FFD41000C53B3 /* SDL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL.xcodeproj; path = ../SDL/SDL.xcodeproj; sourceTree = SOURCE_ROOT; };
00794E5D09D20839003FC8A1 /* icon.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = icon.bmp; sourceTree = "<group>"; };
00794E5E09D20839003FC8A1 /* moose.dat */ = {isa = PBXFileReference; lastKnownFileType = file; path = moose.dat; sourceTree = "<group>"; };
00794E5F09D20839003FC8A1 /* picture.xbm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = picture.xbm; sourceTree = "<group>"; };
00794E6109D20839003FC8A1 /* sample.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = sample.bmp; sourceTree = "<group>"; };
00794E6209D20839003FC8A1 /* sample.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = sample.wav; sourceTree = "<group>"; };
00794E6309D20839003FC8A1 /* utf8.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = utf8.txt; sourceTree = "<group>"; };
@@ -1319,7 +1285,6 @@
DB166CC316A1C74100A1396C /* testscale.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testscale.c; sourceTree = "<group>"; };
DB166CC416A1C74100A1396C /* testshader.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testshader.c; sourceTree = "<group>"; };
DB166CC516A1C74100A1396C /* testspriteminimal.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testspriteminimal.c; sourceTree = "<group>"; };
DB166CC616A1C74100A1396C /* teststreaming.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = teststreaming.c; sourceTree = "<group>"; };
DB166D7F16A1D12400A1396C /* libSDL3_test.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSDL3_test.a; sourceTree = BUILT_PRODUCTS_DIR; };
DB166D8416A1D1A500A1396C /* SDL_test_assert.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_test_assert.c; sourceTree = "<group>"; };
DB166D8516A1D1A500A1396C /* SDL_test_common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_test_common.c; sourceTree = "<group>"; };
@@ -1338,7 +1303,6 @@
DB166E5216A1D69000A1396C /* testscale.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testscale.app; sourceTree = BUILT_PRODUCTS_DIR; };
DB166E6816A1D6F300A1396C /* testshader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testshader.app; sourceTree = BUILT_PRODUCTS_DIR; };
DB166E7E16A1D78400A1396C /* testspriteminimal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testspriteminimal.app; sourceTree = BUILT_PRODUCTS_DIR; };
DB166E9116A1D78C00A1396C /* teststreaming.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = teststreaming.app; sourceTree = BUILT_PRODUCTS_DIR; };
DB445EF818184B7000B306B0 /* testdropfile.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testdropfile.app; sourceTree = BUILT_PRODUCTS_DIR; };
DB445EFA18184BB600B306B0 /* testdropfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testdropfile.c; sourceTree = "<group>"; };
DB89957E18A19ABA0092407C /* testhotplug.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testhotplug.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1712,14 +1676,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
DB166E8316A1D78C00A1396C /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
F3CB57002A78984300766177 /* SDL3.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
DB445EE918184B7000B306B0 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -1887,7 +1843,6 @@
453774A4120915E3002F0F45 /* testshape.c */,
0017991910743F5300F5D044 /* testsprite.c */,
DB166CC516A1C74100A1396C /* testspriteminimal.c */,
DB166CC616A1C74100A1396C /* teststreaming.c */,
092D6D58FFB311A97F000001 /* testthread.c */,
083E4880006D86A17F000001 /* testtimer.c */,
F3C17C7328E40ADE00E1A26D /* testutils.c */,
@@ -1942,7 +1897,6 @@
DB166E5216A1D69000A1396C /* testscale.app */,
DB166E6816A1D6F300A1396C /* testshader.app */,
DB166E7E16A1D78400A1396C /* testspriteminimal.app */,
DB166E9116A1D78C00A1396C /* teststreaming.app */,
DB0F48EC17CA51E5008798C5 /* testdrawchessboard.app */,
DB0F490117CA5212008798C5 /* testfilesystem.app */,
DB89957E18A19ABA0092407C /* testhotplug.app */,
@@ -2703,24 +2657,6 @@
productReference = DB166E7E16A1D78400A1396C /* testspriteminimal.app */;
productType = "com.apple.product-type.application";
};
DB166E8016A1D78C00A1396C /* teststreaming */ = {
isa = PBXNativeTarget;
buildConfigurationList = DB166E8E16A1D78C00A1396C /* Build configuration list for PBXNativeTarget "teststreaming" */;
buildPhases = (
DB166E8116A1D78C00A1396C /* Sources */,
DB166E8316A1D78C00A1396C /* Frameworks */,
DB166E9916A1D7EE00A1396C /* CopyFiles */,
F3CB57022A78984300766177 /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = teststreaming;
productName = teststreaming;
productReference = DB166E9116A1D78C00A1396C /* teststreaming.app */;
productType = "com.apple.product-type.application";
};
DB445EE618184B7000B306B0 /* testdropfile */ = {
isa = PBXNativeTarget;
buildConfigurationList = DB445EF518184B7000B306B0 /* Build configuration list for PBXNativeTarget "testdropfile" */;
@@ -2952,9 +2888,6 @@
DB166E6D16A1D78400A1396C = {
ProvisioningStyle = Automatic;
};
DB166E8016A1D78C00A1396C = {
ProvisioningStyle = Automatic;
};
DB445EE618184B7000B306B0 = {
ProvisioningStyle = Automatic;
};
@@ -3035,7 +2968,6 @@
4537749112091504002F0F45 /* testshape */,
001798FE10743F1000F5D044 /* testsprite */,
DB166E6D16A1D78400A1396C /* testspriteminimal */,
DB166E8016A1D78C00A1396C /* teststreaming */,
BEC567230761D90400A33029 /* testthread */,
BEC5678D0761D90500A33029 /* testtimer */,
BEC567A70761D90500A33029 /* testversion */,
@@ -3439,15 +3371,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
DB166E8116A1D78C00A1396C /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DB166E9416A1D7C700A1396C /* teststreaming.c in Sources */,
F3C17C8528E4127D00E1A26D /* testutils.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
DB445EE718184B7000B306B0 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -3733,11 +3656,6 @@
target = DB166E6D16A1D78400A1396C /* testspriteminimal */;
targetProxy = DB166E9516A1D7CD00A1396C /* PBXContainerItemProxy */;
};
DB166E9816A1D7CF00A1396C /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = DB166E8016A1D78C00A1396C /* teststreaming */;
targetProxy = DB166E9716A1D7CF00A1396C /* PBXContainerItemProxy */;
};
F35E56E72983133F00A43A5F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = F35E56A2298312CB00A43A5F /* testautomation */;
@@ -4658,26 +4576,6 @@
};
name = Release;
};
DB166E8F16A1D78C00A1396C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = teststreaming;
PROVISIONING_PROFILE_SPECIFIER = "";
};
name = Debug;
};
DB166E9016A1D78C00A1396C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = teststreaming;
PROVISIONING_PROFILE_SPECIFIER = "";
};
name = Release;
};
DB445EF618184B7000B306B0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -5192,15 +5090,6 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
};
DB166E8E16A1D78C00A1396C /* Build configuration list for PBXNativeTarget "teststreaming" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DB166E8F16A1D78C00A1396C /* Debug */,
DB166E9016A1D78C00A1396C /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
};
DB445EF518184B7000B306B0 /* Build configuration list for PBXNativeTarget "testdropfile" */ = {
isa = XCConfigurationList;
buildConfigurations = (

View File

@@ -405,7 +405,6 @@ add_sdl_test_executable(testsprite MAIN_CALLBACKS NEEDS_RESOURCES TESTUTILS SOUR
add_sdl_test_executable(testspriteminimal SOURCES testspriteminimal.c ${icon_png_header} DEPENDS generate-icon_png_header)
add_sdl_test_executable(testspritesurface SOURCES testspritesurface.c ${icon_png_header} DEPENDS generate-icon_png_header)
add_sdl_test_executable(testpalette SOURCES testpalette.c)
add_sdl_test_executable(teststreaming NEEDS_RESOURCES TESTUTILS SOURCES teststreaming.c)
add_sdl_test_executable(testtimer NONINTERACTIVE NONINTERACTIVE_ARGS --no-interactive NONINTERACTIVE_TIMEOUT 60 SOURCES testtimer.c)
add_sdl_test_executable(testurl SOURCES testurl.c)
add_sdl_test_executable(testver NONINTERACTIVE NOTRACKMEM SOURCES testver.c)

View File

@@ -1,208 +0,0 @@
/*
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely.
*/
/********************************************************************************
* *
* Running moose :) Coded by Mike Gorchak. *
* *
********************************************************************************/
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <SDL3/SDL_test.h>
#include "testutils.h"
#ifdef SDL_PLATFORM_EMSCRIPTEN
#include <emscripten/emscripten.h>
#endif
#include <stdlib.h>
#define MOOSEPIC_W 64
#define MOOSEPIC_H 88
#define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H)
#define MOOSEFRAMES_COUNT 10
/* *INDENT-OFF* */ /* clang-format off */
static SDL_Color MooseColors[84] = {
{49, 49, 49, 255}, {66, 24, 0, 255}, {66, 33, 0, 255}, {66, 66, 66, 255},
{66, 115, 49, 255}, {74, 33, 0, 255}, {74, 41, 16, 255}, {82, 33, 8, 255},
{82, 41, 8, 255}, {82, 49, 16, 255}, {82, 82, 82, 255}, {90, 41, 8, 255},
{90, 41, 16, 255}, {90, 57, 24, 255}, {99, 49, 16, 255}, {99, 66, 24, 255},
{99, 66, 33, 255}, {99, 74, 33, 255}, {107, 57, 24, 255}, {107, 82, 41, 255},
{115, 57, 33, 255}, {115, 66, 33, 255}, {115, 66, 41, 255}, {115, 74, 0, 255},
{115, 90, 49, 255}, {115, 115, 115, 255}, {123, 82, 0, 255}, {123, 99, 57, 255},
{132, 66, 41, 255}, {132, 74, 41, 255}, {132, 90, 8, 255}, {132, 99, 33, 255},
{132, 99, 66, 255}, {132, 107, 66, 255}, {140, 74, 49, 255}, {140, 99, 16, 255},
{140, 107, 74, 255}, {140, 115, 74, 255}, {148, 107, 24, 255}, {148, 115, 82, 255},
{148, 123, 74, 255}, {148, 123, 90, 255}, {156, 115, 33, 255}, {156, 115, 90, 255},
{156, 123, 82, 255}, {156, 132, 82, 255}, {156, 132, 99, 255}, {156, 156, 156, 255},
{165, 123, 49, 255}, {165, 123, 90, 255}, {165, 132, 82, 255}, {165, 132, 90, 255},
{165, 132, 99, 255}, {165, 140, 90, 255}, {173, 132, 57, 255}, {173, 132, 99, 255},
{173, 140, 107, 255}, {173, 140, 115, 255}, {173, 148, 99, 255}, {173, 173, 173, 255},
{181, 140, 74, 255}, {181, 148, 115, 255}, {181, 148, 123, 255}, {181, 156, 107, 255},
{189, 148, 123, 255}, {189, 156, 82, 255}, {189, 156, 123, 255}, {189, 156, 132, 255},
{189, 189, 189, 255}, {198, 156, 123, 255}, {198, 165, 132, 255}, {206, 165, 99, 255},
{206, 165, 132, 255}, {206, 173, 140, 255}, {206, 206, 206, 255}, {214, 173, 115, 255},
{214, 173, 140, 255}, {222, 181, 148, 255}, {222, 189, 132, 255}, {222, 189, 156, 255},
{222, 222, 222, 255}, {231, 198, 165, 255}, {231, 231, 231, 255}, {239, 206, 173, 255}
};
/* *INDENT-ON* */ /* clang-format on */
static Uint8 MooseFrames[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE];
static SDL_Renderer *renderer;
static int frame;
static SDL_Texture *MooseTexture;
static bool done = false;
static SDLTest_CommonState *state;
static void quit(int rc)
{
SDL_Quit();
SDLTest_CommonDestroyState(state);
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
}
}
static void UpdateTexture(SDL_Texture *texture)
{
SDL_Color *color;
Uint8 *src;
Uint32 *dst;
int row, col;
void *pixels;
int pitch;
if (!SDL_LockTexture(texture, NULL, &pixels, &pitch)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock texture: %s", SDL_GetError());
quit(5);
}
src = MooseFrames[frame];
for (row = 0; row < MOOSEPIC_H; ++row) {
dst = (Uint32 *)((Uint8 *)pixels + row * pitch);
for (col = 0; col < MOOSEPIC_W; ++col) {
color = &MooseColors[*src++];
*dst++ = (0xFF000000 | (color->r << 16) | (color->g << 8) | color->b);
}
}
SDL_UnlockTexture(texture);
}
static void loop(void)
{
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_EVENT_KEY_DOWN:
if (event.key.key == SDLK_ESCAPE) {
done = true;
}
break;
case SDL_EVENT_QUIT:
done = true;
break;
default:
break;
}
}
frame = (frame + 1) % MOOSEFRAMES_COUNT;
UpdateTexture(MooseTexture);
SDL_RenderClear(renderer);
SDL_RenderTexture(renderer, MooseTexture, NULL, NULL);
SDL_RenderPresent(renderer);
#ifdef SDL_PLATFORM_EMSCRIPTEN
if (done) {
emscripten_cancel_main_loop();
}
#endif
}
int main(int argc, char **argv)
{
SDL_Window *window;
SDL_IOStream *handle;
char *filename = NULL;
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, 0);
if (!state) {
return 1;
}
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
SDL_Quit();
SDLTest_CommonDestroyState(state);
return 1;
}
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
return 1;
}
/* load the moose images */
filename = GetResourceFilename(NULL, "moose.dat");
if (!filename) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory");
return -1;
}
handle = SDL_IOFromFile(filename, "rb");
SDL_free(filename);
if (!handle) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !");
quit(2);
}
SDL_ReadIO(handle, MooseFrames, MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
SDL_CloseIO(handle);
/* Create the window and renderer */
window = SDL_CreateWindow("Happy Moose", MOOSEPIC_W * 4, MOOSEPIC_H * 4, SDL_WINDOW_RESIZABLE);
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s", SDL_GetError());
quit(3);
}
renderer = SDL_CreateRenderer(window, NULL);
if (!renderer) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s", SDL_GetError());
quit(4);
}
MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
if (!MooseTexture) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s", SDL_GetError());
quit(5);
}
/* Loop, waiting for QUIT or the escape key */
frame = 0;
#ifdef SDL_PLATFORM_EMSCRIPTEN
emscripten_set_main_loop(loop, 0, 1);
#else
while (!done) {
loop();
}
#endif
SDL_DestroyRenderer(renderer);
quit(0);
return 0;
}