file type

Started by
3 comments, last by Syrillix 21 years, 7 months ago
hi im trying to write a file loader for textures where i can send any texture type(filename) into the function. the problem is i dont know how to parse the file name and find out whether its a .tga or .bmp or what not.. anyone know of any resources, articles or stuff for this??? and before anyone burns me for not searching, i have searched google with no decent results and the search function on the forums is disabled...
Get busy livin' or get busy dyin'... - Shawshank RedemptionIf a man is talking in the forest, and no woman is around to hear him, is he still wrong? - UnknownFulcrum
Advertisement
depends on what api you''re using as far as ''loading textures'' goes..
but if you want to know how to load every file known to man,
go to wotsit.org and check out the file specifications.


-eldee
;another space monkey;
[ Forced Evolution Studios ]

::evolve::

-eldee;another space monkey;[ Forced Evolution Studios ]
not quite, i mean checking the file name that comes in to see if has a .tga or a .bmp extension

Get busy livin'' or get busy dyin''... - Shawshank Redemption
Get busy livin' or get busy dyin'... - Shawshank RedemptionIf a man is talking in the forest, and no woman is around to hear him, is he still wrong? - UnknownFulcrum
Assuming you want what comes after the last dot in the file name


    std::string filename, extension;std::string::size_type backslash, dot;backslash = filename.find_last_of( '\\' );if ( backslash == std::string::npos )     backslash = 0;dot = filename.find_last_of( '.', backslash );if( dot != std::string::npos )    extension = filename.substr( dot );  


extension will be empty if there are no dots in the name.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]


[edited by - Fruny on September 7, 2002 11:40:50 PM]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
thanks, thats exactly what i wanted :D

Get busy livin'' or get busy dyin''... - Shawshank Redemption
Get busy livin' or get busy dyin'... - Shawshank RedemptionIf a man is talking in the forest, and no woman is around to hear him, is he still wrong? - UnknownFulcrum

This topic is closed to new replies.

Advertisement