News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Any help with this please?

Started by felipe, April 21, 2018, 01:52:47 PM

Previous topic - Next topic

felipe

I'm making an include file from a .h file from directx9 sdk. Until now everything is ok i have actually finish one already. With this other also is almost all fine. I even can skip (maybe for some period) this particular line i will show you, but i want to ask here first if any have a clue of the meaning of it.

Quote
typedef VOID (WINAPI *LPD3DXFILL2D)(D3DXVECTOR4 *pOut,
    CONST D3DXVECTOR2 *pTexCoord, CONST D3DXVECTOR2 *pTexelSize, LPVOID pData);

So i can typedef all the parameters to dwords because they are pointers, no big issue, as such: D3DXVECTOR4 typedef dword, etc.
But what should i do with this? typedef VOID (WINAPI *LPD3DXFILL2D). It's suppose to be a funtion type used by another function as say the .h file as a comment:
QuoteFunction types used by the texture fill functions.
Looks like a definition of a void type (i suppose that dosen't matter for us) but then is like pointer to WINAPI(STDCALL). Sounds confusing to me. Any help will be very welcome. Thanks.  :icon14:

Lonewolff

[edit]
Ah sorry, I think I misread the question.

Siekmanski

It's a prototype that points to a user provided evaluator function. ( callback function )

Just translate it to,

LPD3DXFILL2D   typedef PTR DWORD

see the D3DXFillTexture function
https://msdn.microsoft.com/en-us/library/windows/desktop/bb172833(v=vs.85).aspx
Creative coders use backward thinking techniques as a strategy.

aw27

It is a typedef of a function pointer.
I have not directx9 around here, so I will post a generic example:

typedef void (WINAPI *TFUNC)(int, float);

void WINAPI func2(int a, float b)
{
   // do something
   return;
}

void func1(TFUNC somefunc)
{
   somefunc(1, 2.0f);
        return;
}

int main()
{
    func1(&func2);
    return 0;
}

felipe


felipe

Siekmanski: i have the includes needed for now working really fine. But now i need to use the d3dx9.inc file(which form part of the includes that were probed and works fine.) The problem now is that i don't know which .dll i have to load now (with LoadLibrary), because there isn't in system32 a dll with that name. They have names like d3dx9_xx.dll (there are like 20 i think). So do you know how to know which one of this i have to load. While i'm typing i have thinked in using a tool like dumpbin which works ok i think  :idea:. Well if you have another idea for this please tell me. Thanks again, you are amazing!  :icon14:  :icon14:

felipe

Siekmanski: i have found the function D3DXLoadSurfaceFromFile in one of this d3dx9d_xx.dll with dumpbin. So i loaded the library, found the proc address, but i still had unresolveable externals problems. Funny enough this unresolveable externals are 22: the exact number of the d3dx_xx.dlls in the system32 directory (22). So i have used the .lib file d3dx9.lib from the sdk in the source and now everything works ok. This whole thing sounds familiar to me from a post you did (maybe this is directly related with your pixel shader compiler?  :idea:). If so, probably this is a good time for me to understand that topic a little better. Anyway, anything you can say about this issue to better clarify it, would be very appreciated. Thanks again!  :icon14:  :icon14:

Siekmanski

Hi Felipe, in the pixelshader source code is a routine that searches for all d3dx_xx.dll versions starting with the latest back to the oldest version.
The much older versions need additional libs included in your sourc code, see the link to zip file I posted for you earlier with all the translated DirectX9 wrapper include files.
I think from d3dx_32.dll to d3dx_43.dll you don't need the additional libs anymore. Just try it out.

Look in the DirectX9 SDK help file or in those translated include files which functions you need from a d3dx_xx.dll and import them with "LoadLibrary and GetProcAddress"
Creative coders use backward thinking techniques as a strategy.

felipe

Siekmanski: This function i was using (D3DXLoadSurfaceFromFile) i had find it in the dll d3dx9d_43.dll and it give me the externals problem. I was using just that function, from the functions which need, in the sdk, the d3dx9.lib  lib file. The strange thing is that all this d3dx9_xx.dlls, seems they are very related between them, even (probably) needing each one the other in some kind of dependency hell. I will be checking the sdk help file (i have done that already before). I will be trying to load the library (needed) too. But if gives me the unresolveable externals problem with some function from the d3d9x.lib of the sdk i will use that .lib file and leave it to do the work of linking. Anyway, whatever other suggestion i will be all ears, thanks again!  :icon14:  :icon14:

Siekmanski

One solution is, include the static d3d9x.lib in your sources.
Don't count on it, it will run on other users machines if they don't have the right d3dx_XX.dll  version installed.
The other solution is, skip the whole d3d9x wrapper lib and code your own texture loader and write your own math code.
Then it will run on all machines.
Creative coders use backward thinking techniques as a strategy.

felipe

Now i see, Siekmanski. I have actually tested the airforce in another computer and it can't run there because i don't have those libraries in that pc (d3d9.dll is installed by default). So i can use the library in the source and advice the users of the need of this libraries, or maybe even supply them to use the programs. Or the second option you have said, of course. If i want to do something like that (second option), i will have to do more research on that topic.
Thanks one more time.  :icon14:  :icon14:

Siekmanski

Or scan the computer for other d3dx_xx.dll versions, like I have done in the Pixel Shader source code.
Creative coders use backward thinking techniques as a strategy.

Siekmanski

Is that other machine a XP machine?
Now I'm being a little bit selfish, to test my vertical blank test routine.  :icon_mrgreen:
Creative coders use backward thinking techniques as a strategy.

felipe

Ok, thanks that is a good idea too. In fact, because the airforce dosen't have this type of checking the program crash in a computer without this .dlls. Luckly windows manage this situation well. Meanwhile, do you have the link for the correct runtime dlls for the final users?  :idea: I will like to provide this link (or you if it's possible) in the DAYDREAMER's air force topic.  :redface:

Quote from: Siekmanski on April 23, 2018, 08:16:11 AM
Is that other machine a XP machine?
Now I'm being a little bit selfish, to test my vertical blank test routine.  :icon_mrgreen:

No, is another windows 8.1 but has a different screen resolution (is a netbook). After posting this i will try your program in both pcs.  :t

Siekmanski

DirectX End-User Runtimes (June 2010)
https://www.microsoft.com/en-us/download/details.aspx?id=8109
Creative coders use backward thinking techniques as a strategy.