UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
test_renderer.cpp
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, 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"
28 #include "../client/renderer/r_image.h"
29 #include "../client/renderer/r_model.h"
30 
31 class RendererTest: public ::testing::Test {
32 protected:
33  static void SetUpTestCase() {
34  TEST_Init();
35  }
36 
37  static void TearDownTestCase() {
38  TEST_Shutdown();
39  }
40 };
41 
42 TEST_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);
55  R_ModLoadAnims(&mod, filename);
57  }
58 
59  FS_NextFileFromFileList(nullptr);
60 }
61 
62 TEST_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);
126  R_ModLoadAnims(&mod, 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 
144  FS_NextFileFromFileList(nullptr);
145 }
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:1079
memPool_t * vid_modelPool
Definition: cl_main.cpp:90
const char * filename
Definition: ioapi.h:41
void Com_Printf(const char *const fmt,...)
Definition: common.cpp:386
int FS_BuildFileList(const char *fileList)
Build a filelist.
Definition: files.cpp:960
#define OBJZERO(obj)
Definition: shared.h:178
void TEST_Shutdown(void)
Definition: test_shared.cpp:34
TEST_F(RendererTest, LoadAllAnimationFiles)
#define Mem_CreatePool(name)
Definition: mem.h:32
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
Definition: shared.cpp:587
#define Mem_DeletePool(pool)
Definition: mem.h:33
void R_ModLoadAnims(mAliasModel_t *mod, const char *animname)
QGL_EXTERN GLint i
Definition: r_gl.h:113
void TEST_Init(void)
Definition: test_shared.cpp:72
static void TearDownTestCase()
char name[MAX_ANIMNAME]
#define Q_streq(a, b)
Definition: shared.h:136
mAliasAnim_t * animdata
static void SetUpTestCase()