API Question How to save mesh textures to file?

andargor

Flame
Joined
May 1, 2011
Messages
3
Reaction score
0
Points
0
Hi, first post, be gentle! :)

How would I be able to save mesh textures to file? I've read several threads here and tested a few things, but I can not get it to work. More specifically, the following are my stumbling blocks:

- The use of oapiGetDC or Sketchpad->GetDC return null values most of the time. I understand that this means the texture is in a back buffer, but the rest of the copying and saving code seems to fail because of this

- To CreateCompatibleBitmap, I need a width and a height. Where can I get this? The DC has no dimensions, can I assume 64x64? 32x32? In any case, I get an invalid bitmap as a result.

- Do these operations need to be at any particular point, such as during WM_PAINT?

- Is there a pointer somewhere to the mesh file so I can load textures from there?

I'm using RControl as my testing ground. Thanks for any insight! :)

PS: I intensely dislike the Windows API :lol:
 
Can't you just go to the textures folder and use dxtex to convert the .dds to something else?
 
Yes, of course, but I am trying to enumerate vessels from within the API. The path to the vessel config file might be sufficient, so that I could access it.

Otherwise, I need to save the textures somewhere.
 
The operations do not need to be in WM_PAINT or any other message in particular. Messages are only used to say "Hey ! something happened !" and they specify what happened. You could get the texture in your main function if you would like.

At the end of the mesh file, textures are listed after a flag called (with a lot of originality) TEXTURES. Just be aware that we can load dynamic textures within a DLL. Maybe some add-ons do not have every textures listed there.

For the conversion, try DevIL (called OpenIL a time ago).

You'll see, when you understand how Microsoft developers think (that may be pretty hard sometimes...), the WinAPI will be a great friend. Just do not ask why they called char arrays LPSTR. This is just weird :lol: (actually, there is a reason. Long Pointer String).
 
At the end of the mesh file, textures are listed after a flag called (with a lot of originality) TEXTURES. Just be aware that we can load dynamic textures within a DLL. Maybe some add-ons do not have every textures listed there.

Some textures can be loaded dynamically indeed, and that is why I'm attempting to grab them from within the API. Just looking at the DeltaGlider code:

strcpy (fname+n, scramjet ? "dgmk4_2.dds" : "dgmk4_2_ns.dds"); skin[1] = oapiLoadTexture (fname);

Currently, I enumerate the vessel meshes and get the SURFHANDLE of the texture. But like I said, I keep hitting a wall trying to save it.

If it would be possible to see "dgmk4_2_ns.dds" (for example) being associated to a mesh somewhere, it would make life easier. Perhaps there is a way to intercept oapiLoadTexture?

I don't want to resort to DLL injection :lol:
 
Back
Top