UFO: Alien Invasion
Loading...
Searching...
No Matches
test_renderer.cpp
Go to the documentation of this file.
1
5
6/*
7Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24*/
25
26#include "test_shared.h"
27#include "../client/cl_video.h"
30
31class RendererTest: public ::testing::Test {
32protected:
33 static void SetUpTestCase() {
34 TEST_Init();
35 }
36
37 static void TearDownTestCase() {
39 }
40};
41
42TEST_F(RendererTest, LoadAllAnimationFiles)
43{
44 const char* pattern = "models/**.anm";
45 const char* filename;
46 mAliasModel_t mod;
47
48 OBJZERO(mod);
49 /* set a very high value to work around the error check in the loading function */
50 mod.num_frames = 100000;
51
52 while ((filename = FS_NextFileFromFileList(pattern)) != nullptr) {
53 vid_modelPool = Mem_CreatePool("Vid Model Pool");
54 Com_Printf("load anim file: %s\n", filename);
57 }
58
60}
61
62TEST_F(RendererTest, CharacterAnimationFiles)
63{
64 const char* pattern = "models/**.anm";
65 const char* filename;
66 mAliasModel_t mod;
67 const char* bloodspider[] = { "death1", "death2", "death3", "dead1",
68 "dead2", "dead3", "stand0", "stand1", "stand2", "stand3", "walk0",
69 "walk1", "walk2", "walk3", "cstand0", "cstand1", "cstand2",
70 "cstand3", "cwalk0", "cwalk1", "cwalk2", "cwalk3", "stand_menu",
71 "panic0", nullptr };
72 const char* hovernet[] = { "death1", "dead1", "death2","dead2", "death3",
73 "dead3", "stand0", "walk0", "cstand0", "cwalk0", "stand1", "walk1",
74 "cstand1", "cwalk1", "stand2", "walk2", "cstand2", "cwalk2",
75 "stand3", "walk3", "cstand3", "cwalk3", "move_rifle", "shoot_rifle",
76 "cmove_rifle", "cshoot_rifle", "stand_menu", "panic0", nullptr };
77 const char* soldiers[] = { "death1", "death2", "death3", "dead1", "dead2",
78 "dead3", "stand0", "stand1", "stand2", "stand3", "walk0", "walk1",
79 "walk2", "walk3", "cstand0", "cstand1", "cstand2", "cstand3",
80 "cwalk0", "cwalk1", "cwalk2", "cwalk3", "stand_menu", "panic0",
81 "move_rifle", "shoot_rifle", "cmove_rifle", "cshoot_rifle",
82 "move_biggun", "shoot_biggun", "cmove_biggun", "cshoot_biggun",
83 "move_melee", "shoot_melee", "cmove_melee", "cshoot_melee",
84 "stand_still", "move_pistol", "shoot_pistol", "cmove_pistol",
85 "cshoot_pistol", "move_pistol_d", "shoot_pistol_d",
86 "cmove_pistol_d", "cshoot_pistol_d", "move_grenade",
87 "shoot_grenade", "cmove_grenade", "cshoot_grenade", "move_item",
88 "shoot_item", "cmove_item", "cshoot_item", "move_rpg", "shoot_rpg",
89 "cmove_rpg", "cshoot_rpg", nullptr };
90 const char* civilians[] = { "death1", "dead1", "death2", "dead2", "death3",
91 "dead3", "stand0", "walk0", "panic0", "stand1", "stand2",
92 "stand_menu", "stand_still", nullptr };
93
94 FS_BuildFileList(pattern);
95
96 vid_modelPool = Mem_CreatePool("Vid Model Pool");
97
98 while ((filename = FS_NextFileFromFileList(pattern)) != nullptr) {
99 const char** animList;
100 if (Q_strstart(filename, "models/soldiers/"))
101 animList = soldiers;
102 else if (Q_strstart(filename, "models/civilians/"))
103 animList = civilians;
104 else if (Q_strstart(filename, "models/aliens/bloodspider"))
105 animList = bloodspider;
106 else if (Q_strstart(filename, "models/aliens/hovernet"))
107 animList = hovernet;
108 else if (Q_strstart(filename, "models/aliens/"))
109 animList = soldiers;
110 else
111 animList = nullptr;
112
114 if (Q_strstart(filename, "models/soldiers/ugv_"))
115 continue;
117 if (Q_strstart(filename, "models/aliens/alientank/"))
118 continue;
119
120 if (animList != nullptr) {
121 OBJZERO(mod);
122 /* set a very high value to work around the error check in the loading function */
123 mod.num_frames = 100000;
124
125 Com_Printf("load character anim file: %s\n", filename);
127
128 while (*animList != nullptr) {
129 int i;
130 for (i = 0; i < mod.num_anims; i++) {
131 const mAliasAnim_t* a = &mod.animdata[i];
132 if (Q_streq(a->name, *animList))
133 break;
134 }
135 ASSERT_FALSE(i == mod.num_anims) << "anm file " << filename << " does not contain the needed animation definition " << *animList;
136
137 animList++;
138 }
139 }
140 }
141
143
145}
memPool_t * vid_modelPool
Definition cl_main.cpp:90
Video driver defs.
static void SetUpTestCase()
static void TearDownTestCase()
void Com_Printf(const char *const fmt,...)
Definition common.cpp:428
const char * FS_NextFileFromFileList(const char *files)
Returns the next file that is found in the virtual filesystem identified by the given file pattern.
Definition files.cpp:1081
int FS_BuildFileList(const char *fileList)
Build a filelist.
Definition files.cpp:962
const char * filename
Definition ioapi.h:41
#define Mem_DeletePool(pool)
Definition mem.h:33
#define Mem_CreatePool(name)
Definition mem.h:32
QGL_EXTERN GLint i
Definition r_gl.h:113
Brush model header file.
void R_ModLoadAnims(mAliasModel_t *mod, const char *animname)
#define Q_streq(a, b)
Definition shared.h:136
#define OBJZERO(obj)
Definition shared.h:178
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
Definition shared.cpp:587
char name[MAX_ANIMNAME]
mAliasAnim_t * animdata
TEST_F(RendererTest, LoadAllAnimationFiles)
void TEST_Shutdown(void)
void TEST_Init(void)