Jump to content
  • Advertisement
Sign in to follow this  
AKClaus

Class Function Pointer(solved)

This topic is 3795 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

Hi, Im learning Cplusplus and D3D, and wanted to pass a D3DXHANDLE* to my class so i can set the lights from there, but when i compile it says this: 1>Hd3d.obj : error LNK2019: unresolved external symbol "public: void __thiscall Light_class::SetDiffuseLights(char const * *,char const * *)" (?SetDiffuseLights@Light_class@@QAEXPAPBD00@Z) referenced in function "void __cdecl DrawScene(struct HWND__ *)" (?DrawScene@@YAXPAUHWND__@@@Z) and dont know what it is, can you help me ?. Here is my class and call to the function: (removed non important(working) stuff)
//CLASS:

class Light_class
{
public:
    Light_class( int max_ambiental, int max_diffuse );
    void SetDiffuseLights( D3DXHANDLE* position, D3DXHANDLE* power );
};

//the SetDiffuseLights function has nothing inside so the problem cant be there.

//CALL TO FUNCTION:

//declarations:

Light_class *lightobject;
D3DXHANDLE *hfx_DiffuseLight_position,
*hfx_DiffuseLight_power;

lightobject = new Light_class( 50, 50 );

//then i set the handles:

hfx_DiffuseLight_position = new D3DXHANDLE[ 2 ];
hfx_DiffuseLight_position[0] = effect->GetParameterByName( 0, "diffuse_lights[0].position" );
hfx_DiffuseLight_position[1] = effect->GetParameterByName( 0, "diffuse_lights[1].position" );
//{ ..same with but with power instead of position.. }

//then i call the function in the draw step:

lightobject->SetDiffuseLights( hfx_DiffuseLight_position, hfx_DiffuseLight_power );


Thanks for reading.

Share this post


Link to post
Share on other sites
Advertisement
This appears to be a good lesson on why should omit details sparingly when you don't fully understand the problem. In this case, the linker is complaing that a function called SetDiffuseLights that is a member of Light_class, returns nothing, and takes two 'char const**' objects (what the D3DXHANDLE* type resolves to) could not be found.

That means you either have failed to define it, or defined it in such a way that it is not accessible, not viewed as the same function the linker expects, or was not actually compiled.

Where do you define this function and what does it look like?

[EDIT: Too slow, it seems]

Share this post


Link to post
Share on other sites
The thing was that i havent defined it in the Lights.cpp after i added:

void Light_class::SetDiffuseLights(D3DXHANDLE *position, D3DXHANDLE *power)
{
}



The problem was gone.
Thx for the explanation i understood better what was happening.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!