Author Topic: Help calling a function  (Read 575 times)

felipe

  • Member
  • ****
  • Posts: 824
  • Eagles are just great!
Help calling a function
« on: April 09, 2018, 02:39:56 PM »
Here is what i have of the include file for d3d9.lib.:
Code: [Select]
;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:
Code: [Select]
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... :(
Felipe.

Ascended

  • Member
  • ***
  • Posts: 331
Re: Help calling a function
« Reply #1 on: April 09, 2018, 02:48:00 PM »
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

  • Member
  • ****
  • Posts: 824
  • Eagles are just great!
Re: Help calling a function
« Reply #2 on: April 09, 2018, 03:13:44 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).

You are linking to D3D9.lib also?
Yes

**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.
Felipe.

Ascended

  • Member
  • ***
  • Posts: 331
Re: Help calling a function
« Reply #3 on: April 09, 2018, 03:18:08 PM »
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

Code: [Select]
coinvoke d3dDevice, IDirect3D9, param1, 2, 3, etc...


felipe

  • Member
  • ****
  • Posts: 824
  • Eagles are just great!
Re: Help calling a function
« Reply #4 on: April 09, 2018, 03:52:16 PM »
Ok, thanks for your help.
Felipe.

Ascended

  • Member
  • ***
  • Posts: 331
Re: Help calling a function
« Reply #5 on: April 09, 2018, 03:53:28 PM »
No probs :)

Did you get it going?

felipe

  • Member
  • ****
  • Posts: 824
  • Eagles are just great!
Re: Help calling a function
« Reply #6 on: April 10, 2018, 10:19:35 AM »
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:
Felipe.

Fabioxds

  • Regular Member
  • *
  • Posts: 12
Re: Help calling a function
« Reply #7 on: April 11, 2018, 11:47:08 PM »
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:

Ascended

  • Member
  • ***
  • Posts: 331
Re: Help calling a function
« Reply #8 on: April 12, 2018, 07:13:57 AM »
Giving up is always easier  :bgrin:

zedd151

  • Member
  • ****
  • Posts: 582
  • -------------
Re: Help calling a function
« Reply #9 on: April 12, 2018, 07:36:14 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

__________________________________________________________________
I'll be back to coding soon....

Ascended

  • Member
  • ***
  • Posts: 331
Re: Help calling a function
« Reply #10 on: April 12, 2018, 07:37:40 AM »
Very true though.  :t

felipe

  • Member
  • ****
  • Posts: 824
  • Eagles are just great!
Re: Help calling a function
« Reply #11 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:
Felipe.

Ascended

  • Member
  • ***
  • Posts: 331
Re: Help calling a function
« Reply #12 on: April 12, 2018, 09:42:32 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

  • Member
  • ****
  • Posts: 824
  • Eagles are just great!
Re: Help calling a function
« Reply #13 on: April 12, 2018, 09:46:43 AM »
Yes sure, is this a c forum btw?  :idea:
Felipe.

Ascended

  • Member
  • ***
  • Posts: 331
Re: Help calling a function
« Reply #14 on: April 12, 2018, 09:47:39 AM »
is this a c forum btw?  :idea:

Not sure what you mean by this.