Jump to content
  • Advertisement
Sign in to follow this  
noodleBowl

Image resources and textures

This topic is 676 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering how do you guys handle loading in your image resources for your textures?

 

I was hoping since DirectX seems to be more of a complete package (APIs for rendering, sound, and etc) there would be some kind of function to load in various image types so I could use them as texture resources. Eg I could use something like loadResource(fileName) and I would get back something that I could use as a texture resource, where fileName could be a image resource that is a png, jpg, bmp, or dds file. But I don't think there is one directly within the DirectX APIs.

Is this correct? or is there something I can use that can accomplish this? Do you guys just roll your own image loaders?

 

Share this post


Link to post
Share on other sites
Advertisement

In the old days there used to be a component named D3DX that contained helpers for loading various different image formats from resources, memory, files, etc.  What's important to understand is that this was just a software library; i.e. it was the kind of thing that you might come up with yourself if you decided to roll your own.

 

D3DX has been deprecated for some time, and for this particular task you have a number of options.  Basically anything that gives you RGBA data from an image can be used; this includes standard open source libraries such as libjpeg or libpng, accessing an object via GDI or GDI+, something like stb_image.h, or even writing your own loader.

 

The DirectX Tool Kit also exists: https://directxtk.codeplex.com/ - which includes a number of texture loaders, among other helpers.

Share this post


Link to post
Share on other sites

While you can write code to load any image format you want to, I'd strongly recommend using .dds files. They support many features that many standard image file formats like jpeg don't always handle:

 

- Mip maps. You want to generate high quality ones offline, and not try to generate them at load time. Especially if your textures are compressed.

- Texture compression (BC1-BC7 formats in DX11, DXT1/DXT5 in D3D9). These can make your textures up to 8 times smaller in video memory as well as reducing the file size.

- Floating point textures.

- Cubemaps.

- Alpha channels.

 

If you want to convert images to DDS format programatically, then you can use https://github.com/Microsoft/DirectXTex

 

If you prefer a Photoshop plugin, then Nvidia have made one: https://developer.nvidia.com/nvidia-texture-tools-adobe-photoshop

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!