Jump to content
  • Advertisement
Sign in to follow this  
godsenddeath

How to manually load a texture (C++ and DirectX)

This topic is 3627 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'm working on loading MD2 models, but they usually come with textures in PCX format, and since LoadTextureFromFile doesn't load this format, how would I go about manualy loading and setting a texture?

Share this post


Link to post
Share on other sites
Advertisement
Creating your own PCX loader would be a real pain as PCX is a RLE (run-length-encoded) format and you'd have to set a texture pixel by pixel but that's one solution.

Another solution is to use a supported-format texture.

A third alternative is a bit of a hack if you have to use the extension pcx but you don't care what's its real format is. Depending on your needs, it may help:

Load the PCX into a graphics editor and save it in a supported format (PNG, etc.) and save it where your DirectX app can find it.

Rename the <texture>.png to <texture>.pcx. It should still load. The DirectX texture loader doesn't care about the extension, just the content.

EDIT: A quick google search showed hits for third party code for loading various formats. You could grab some PCX loader code and modify it to suit.

Share this post


Link to post
Share on other sites
well its just a matter of the included model textures being in PCX, i guess i could convert them to a png and change the file path in the MD2 file

thanks

out of curiousity, how would you create a texture manually from anotehr file format, if you had the image already loaded? use D3DXCreateTexture(), then lock the newly created texture, and fill it manually?

Share this post


Link to post
Share on other sites
Yeah, that would be the approach if (shudder) I were to try it.

Be sure to check the device caps to see if your card supports a dynamic texture if you're going to do that before you go to the trouble of writing a conversion routine.

EDIT: Read through the SDK info first if you're going to try it. There are several restrictions (dynamic textures can't be managed, etc.).

EDIT2: I don't think you'd have to modify the MD2 file. I'll bet your "fake" <texture>.png.pcx will load in most other apps.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!