Source/ThunderBeast/QuakeToonProto1/ref_gl/gl_image.c
image_t	*GL_FindImage (char *name, imagetype_t type)
{
	image_t	*image;
	int		i, len;
	byte	*pic, *palette;
	int		width, height;

	if (!name)
		return NULL;	//	ri.Sys_Error (ERR_DROP, "GL_FindImage: NULL name");
	len = strlen(name);
	if (len<5)
		return NULL;	//	ri.Sys_Error (ERR_DROP, "GL_FindImage: bad name: %s", name);

	// look for it
	for (i=0, image=gltextures ; i<numgltextures ; i++,image++)
	{
		if (!strcmp(name, image->name))
		{
			image->registration_sequence = registration_sequence;
			return image;
		}
	}

	//
	// load the pic from disk
	//
	pic = NULL;
	palette = NULL;
	if (!strcmp(name+len-4, ".pcx"))
	{
		LoadPCX (name, &pic, &palette, &width, &height);
		if (!pic)
			return NULL; // ri.Sys_Error (ERR_DROP, "GL_FindImage: can't load %s", name);
		image = GL_LoadPic (name, pic, width, height, type, 8);
	}
	else if (!strcmp(name+len-4, ".wal"))
	{
		image = GL_LoadWal (name);
	}
	else if (!strcmp(name+len-4, ".tga"))
	{
		LoadTGA (name, &pic, &width, &height);
		if (!pic)
			return NULL; // ri.Sys_Error (ERR_DROP, "GL_FindImage: can't load %s", name);
		image = GL_LoadPic (name, pic, width, height, type, 32);
	}
	else
		return NULL;	//	ri.Sys_Error (ERR_DROP, "GL_FindImage: bad extension on: %s", name);


	if (pic)
		free(pic);
	if (palette)
		free(palette);

	return image;
}
/*
===============
GL_FindImage

Finds or loads the given image
===============
*/
GL_FindImage
Finds or loads the given image
GL_FindImage Finds or loads the given image
image_t	*GL_FindImage (char *name, imagetype_t type)
{
	image_t	*image;
	int		i, len;
	byte	*pic, *palette;
	int		width, height;
	if (!name)
		return NULL;	
	len = strlen(name);
	if (len<5)
		return NULL;	
	for (i=0, image=gltextures ; i<numgltextures ; i++,image++)
	{
		if (!strcmp(name, image->name))
		{
			image->registration_sequence = registration_sequence;
			return image;
		}
	}
	 load the pic from disk
	pic = NULL;
	palette = NULL;
	if (!strcmp(name+len-4, ".pcx"))
	{
		LoadPCX (name, &pic, &palette, &width, &height);
		if (!pic)
			return NULL;  ri.Sys_Error (ERR_DROP, "GL_FindImage: can't load %s", name);
		image = GL_LoadPic (name, pic, width, height, type, 8);
	}
	else if (!strcmp(name+len-4, ".wal"))
	{
		image = GL_LoadWal (name);
	}
	else if (!strcmp(name+len-4, ".tga"))
	{
		LoadTGA (name, &pic, &width, &height);
		if (!pic)
			return NULL;  ri.Sys_Error (ERR_DROP, "GL_FindImage: can't load %s", name);
		image = GL_LoadPic (name, pic, width, height, type, 32);
	}
	else
		return NULL;		ri.Sys_Error (ERR_DROP, "GL_FindImage: bad extension on: %s", name);
	if (pic)
		free(pic);
	if (palette)
		free(palette);
	return image;
}
image_t * GL_FindImage ( char * name , imagetype_t type ) { image_t * image ; int i , len ; byte * pic , * palette ; int width , height ; if ( ! name ) return NULL ; len = strlen ( name ) ; if ( len < 5 ) return NULL ; for ( i = 0 , image = gltextures ; i < numgltextures ; i ++ , image ++ ) { if ( ! strcmp ( name , image -> name ) ) { image -> registration_sequence = registration_sequence ; return image ; } } pic = NULL ; palette = NULL ; if ( ! strcmp ( name + len - 4 , " " ) ) { LoadPCX ( name , & pic , & palette , & width , & height ) ; if ( ! pic ) return NULL ; image = GL_LoadPic ( name , pic , width , height , type , 8 ) ; } else if ( ! strcmp ( name + len - 4 , " " ) ) { image = GL_LoadWal ( name ) ; } else if ( ! strcmp ( name + len - 4 , " " ) ) { LoadTGA ( name , & pic , & width , & height ) ; if ( ! pic ) return NULL ; image = GL_LoadPic ( name , pic , width , height , type , 32 ) ; } else return NULL ; if ( pic ) free ( pic ) ; if ( palette ) free ( palette ) ; return image ; }
GL_FindImage
Finds or loads the given image
GL_FindImage Finds or loads the given image
//	ri.Sys_Error (ERR_DROP, "GL_FindImage: NULL name"); //	ri.Sys_Error (ERR_DROP, "GL_FindImage: bad name: %s", name); // look for it // // load the pic from disk // // ri.Sys_Error (ERR_DROP, "GL_FindImage: can't load %s", name); // ri.Sys_Error (ERR_DROP, "GL_FindImage: can't load %s", name); //	ri.Sys_Error (ERR_DROP, "GL_FindImage: bad extension on: %s", name);