wzmviewer: More refactoring to ease code sharing between programs.
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6226 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
3345cb2180
commit
bc4a850c94
|
@ -31,6 +31,11 @@
|
|||
|
||||
void prepareModel(MODEL *psModel)
|
||||
{
|
||||
if (!psModel || !psModel->pixmap)
|
||||
{
|
||||
printf("Bad model passed to prepareModel!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
glGenTextures(1, &psModel->texture);
|
||||
glBindTexture(GL_TEXTURE_2D, psModel->texture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, psModel->pixmap->w, psModel->pixmap->h, 0, GL_RGBA,
|
||||
|
@ -238,7 +243,7 @@ PIXMAP *readPixmap(const char *filename)
|
|||
return gfx;
|
||||
}
|
||||
|
||||
MODEL *readModel(const char *filename, const char *path, int now)
|
||||
MODEL *readModel(const char *filename, int now)
|
||||
{
|
||||
FILE *fp = fopen(filename, "r");
|
||||
int num, x, meshes, mesh;
|
||||
|
@ -272,8 +277,7 @@ MODEL *readModel(const char *filename, const char *path, int now)
|
|||
exit(1);
|
||||
}
|
||||
psModel = createModel(meshes, now);
|
||||
strcpy(psModel->texPath, path);
|
||||
strcat(psModel->texPath, s);
|
||||
strcpy(psModel->texPath, s);
|
||||
|
||||
// WZM does not support multiple meshes, nor importing them from PIE
|
||||
for (mesh = 0; mesh < meshes; mesh++)
|
||||
|
|
|
@ -85,7 +85,7 @@ typedef struct
|
|||
|
||||
MODEL *createModel(int meshes, int now);
|
||||
PIXMAP *readPixmap(const char *filename);
|
||||
MODEL *readModel(const char *filename, const char *path, int now);
|
||||
MODEL *readModel(const char *filename, int now);
|
||||
void freeModel(MODEL *psModel);
|
||||
void drawModel(MODEL *psModel, int now);
|
||||
void prepareModel(MODEL *psModel);
|
||||
|
|
|
@ -70,6 +70,7 @@ int main(int argc, char **argv)
|
|||
bool quit = false;
|
||||
float dimension = 0.0f;
|
||||
int i;
|
||||
char path[PATH_MAX];
|
||||
|
||||
parse_args(argc, argv);
|
||||
|
||||
|
@ -81,8 +82,10 @@ int main(int argc, char **argv)
|
|||
}
|
||||
atexit(SDL_Quit);
|
||||
|
||||
psModel = readModel(input, texPath, SDL_GetTicks());
|
||||
psModel->pixmap = readPixmap(psModel->texPath);
|
||||
psModel = readModel(input, SDL_GetTicks());
|
||||
strcpy(path, texPath);
|
||||
strcat(path, psModel->texPath);
|
||||
psModel->pixmap = readPixmap(path);
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
|
||||
|
|
Loading…
Reference in New Issue