News:

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

Main Menu

Help calling a function

Started by felipe, April 09, 2018, 02:39:56 PM

Previous topic - Next topic

felipe

Here is what i have of the include file for d3d9.lib.:

;CONSTANTS:
D3D_SDK_VERSION     equ     32
D3DADAPTER_DEFAULT  equ     0
D3DDEVTYPE_HAL      equ     1
D3DCREATE_SOFTWARE_VERTEXPROCESSING    equ 00000020h


;FUNCTIONS:
Direct3DCreate9     proto    :dword
CreateDevice     proto    :dword,:dword,:dword,:dword,:dword,:dword


If in a program (where i include this file and the d3d9.lib and boths are in the masm32 inc and lib folders) i call the first function (Direct3DCreate9) every go ok. But when i use the second (CreateDevice) i have this link error:

Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

clicklaugh.obj : error LNK2001: unresolved external symbol _CreateDevice@24
clicklaugh.exe : fatal error LNK1120: 1 unresolved externals
_
Link error
...

How i should write the name of this function in the include file? How is the syntax of this convention? Any help will be great appreciated. Actually doing this (sh*t) job is frustrating if you don't know how to. I wish to be coding already... :(

Lonewolff

Can you also show the code you are using to create the device?

You are linking to D3D9.lib also?


**Edit**

Actually CreateDevice is not a function as such, it is a member of the IDirect3D9 interface (setup in the vTable).

So you don't need the function prototype at all.

You need to be using 'coinvoke' for the call.

felipe

Quote from: Lonewolff on April 09, 2018, 02:48:00 PM
Can you also show the code you are using to create the device?
Is just  simple code with the appropiate includes and includelib and the call instructions (nothing to worry about is just for testing the include file).

Quote from: Lonewolff on April 09, 2018, 02:48:00 PM
You are linking to D3D9.lib also?
Yes

Quote from: Lonewolff on April 09, 2018, 02:48:00 PM
**Edit**

Actually CreateDevice is not a function as such, it is a member of the IDirect3D9 interface (setup in the vTable).

So you don't need the function prototype at all.

You need to be using 'coinvoke' for the call.

And what is coinvoke or where is defined?

Thanks for the help.

Lonewolff

It is defined in the d3d9macro.inc file (assuming you are using Siekmanski's libraries).

Your CreateDevice command should look along the lines of this


coinvoke d3dDevice, IDirect3D9, param1, 2, 3, etc...



felipe


Lonewolff

No probs :)

Did you get it going?

felipe

No. I actually don't like macros too much. I will keep trying others ways. If anybody can say something relative with the decoration notation from the include file or from the source code where it call these functions, thank you very much.  :icon14:

Fabioxds

Did you try to use the macro then take a look at the generated code? I always do that to steal assembly code or to learn how things are being done under the hood  :bgrin:

Lonewolff


zedd151

Quote from: Lonewolff on April 12, 2018, 07:13:57 AM
Giving up is always easier  :bgrin:

winners never quit,   :eusa_naughty:

and quitters never win.   :eusa_snooty:

stole line from rrr314..... cant remember what comes next for pi.  :P

Lonewolff


felipe

 :biggrin: Sometimes the winners are not the pretty guys of the movies, i'm very happy with the assembly language even if microsh*t don't like to support it. :biggrin:

Lonewolff

Quote from: felipe on April 12, 2018, 09:21:52 AM
:biggrin: Sometimes the winners are not the pretty guys of the movies, i'm very happy with the assembly language even if microsh*t don't like to support it. :biggrin:

In what way do you mean? DirectX?

They do support it though. That is why DirectX is written in COM, to make it language independent.

felipe

Yes sure, is this a c forum btw?  :idea:

Lonewolff

Quote from: felipe on April 12, 2018, 09:46:43 AM
is this a c forum btw?  :idea:

Not sure what you mean by this.