Hello everyone. I just have started learning OpenGL, and i have a problem. I am reading OpenGL SuperBible, i have all sample code, models, textures and other stuff from that book. I just have reached topic about textures, models and everything is okay, but models in samples are in "SBM" format, and textures are in "KTX". All i want to load models in other format(obj,3ds), and load textures in png or other popular format. How i can do it? Please, give me some code or something. I have downloaded all samples from here: openglsuperbible.com and I am programming with C++. Thanks for help!
Members - Reputation: 738
Posted 16 April 2014 - 01:24 AM
Unluckly, opengl is not a full framework like DX, it only cover the rendering side of the whole thing. You have to do yourself everything else.
Crossbones+ - Reputation: 3966
Posted 16 April 2014 - 03:12 AM
… and load textures in png or other popular format. ...
Don't confuse "popular for the web" with "popular for 3D". Notice that PNG and similar popular image formats are for other, typically general purposes. Not all of them support an alpha channel (PNG does, e.g. JPG does not), only a few allows to store HDR images, nearly none of them allows to store multi resolution images, nearly none of them allows to store MIP map levels, nearly none of them allows to store array layers, nearly none of them support storing of multiple faces natively, probably none of them allows to store image data pre-encoded with a GPU friendly compression, and none (to my knowledge) of them allows to do all at once. The reason to use especially KTX is that it is one of the very very few public formats that allows for all of that. For example, to represent a 1024^3 texel cube map with pre-computed MIP mapping, you would need to use 6 faces by ld(1024) = 60 (!) PNG files where a single KTX file would be sufficient (this is, of course, a strong example, but nevertheless not unrealistic).
A usual way of handling texture resources is to let the artist store the asset in an appropriate format. This may be PNG or the like as long as the format would preserve all necessary features. Professionally formats like OpenEXR are more likely to be used when the demands grow. The resource processing then will read in images in the chosen format and convert / integrate them internally to a texture. Insofar your request for loading other formats is not untypical. However, don't be trapped in thinking that textures are like "ordinary" images; they are not! They are special!
Edited by haegarr, 16 April 2014 - 03:13 AM.