Horde3D

Next-Generation Graphics Engine
It is currently 29.09.2024, 00:22

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: 27.01.2009, 17:06 
Offline

Joined: 01.01.2009, 21:09
Posts: 54
Hey all, Trying to organizer the basic ( re usable ) code in to a few classes and reached a snag here..

glfwSetKeyCallback( keyPressListener );

As most of you know. You are not necessarily permitted the passing of a member from with in a class. You will get..

error C3867: function call missing argument list; use '&CLASS::MEMBER' to create a pointer to member

So I tried to pass the address of the member or using a pointer to the function, I even tried the sloppy global approach. No matter what I try I get errors. Has anyone used this call in a function?


Top
 Profile  
Reply with quote  
PostPosted: 27.01.2009, 17:10 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
ulao wrote:
glfwSetKeyCallback( keyPressListener );

As most of you know. You are not necessarily permitted the passing of a member from with in a class. You will get..

error C3867: function call missing argument list; use '&CLASS::MEMBER' to create a pointer to member
You cannot pass an instance function where a free function is required. You can either use free (global) functions for your callbacks, as the samples do, or you can use static class methods.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 27.01.2009, 17:44 
Offline

Joined: 01.01.2009, 21:09
Posts: 54
I used static but get "error LNK2001: unresolved external symbol " during linking?


Top
 Profile  
Reply with quote  
PostPosted: 27.01.2009, 17:54 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
You have to implement that function


Top
 Profile  
Reply with quote  
PostPosted: 27.01.2009, 17:57 
Offline

Joined: 01.01.2009, 21:09
Posts: 54
durr, thx ;)


Top
 Profile  
Reply with quote  
PostPosted: 28.01.2009, 02:51 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
I used a global pointer (singleton kind-of design) when I made my GLFW wrapper class:

Header:
Code:
class CApp
{
public:
   CApp();
   virtual void KeyStateChange( int key, bool down );///< Callback to respond to keyboard state changes
};
extern CApp* g_pApp;


Source file:
Code:
CApp* g_pApp = 0;
CApp::CApp()
{
   g_pApp = this;
}

void GLFWCALL MyKeyCallback( int k, int action )
{
   if( !g_pApp )
      return;
   g_pApp->KeyStateChange( k, (action==GLFW_PRESS) );
}


And then inside the initialisation function:
Code:
      glfwSetKeyCallback( &MyKeyCallback );


Top
 Profile  
Reply with quote  
PostPosted: 28.01.2009, 07:03 
Offline

Joined: 06.12.2008, 08:32
Posts: 10
Using something like SFML is also a nice option that let's you sidestep this problem altogether :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 27 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group