pointer / deltaTime in OpenGL Game Programming book

M

Michael Sgier

Hello
I've a function like:

extern CModelMD3 *pModel;
gameCamera->MoveTo(* pModel);

which returns:
no matching function for call to `CCamera::MoveTo(CModelMD3&)

but in camera.h i've:
void MoveTo(CObject *object);

and in camera.cpp:
void CCamera::MoveTo(CObject *object)
{
....
}

The modelclass is like:
class CModelMD3 : public CObject

I might have missunderstood something here as I'm new to pointers?
Secondly in the book
OpenGL Game Programming there's in the engine example often deltaTime. I
can't find
any definition/declaration. It has random values like 286 but as far as
I've seen always
around 250-350. it's used like position = velocity + deltaTime
What is it? Where is deltaTime defined? How could i use / exchange
deltaTime in Linux/Mac.
THANKS and regards
Michael
 
I

int2str

Michael said:
extern CModelMD3 *pModel;
gameCamera->MoveTo(* pModel);

The second line shoult be:
gameCamera->MoveTo(pModel);

The function takes a pointer as it's argument. Passing "*pModel" means
you're dereferencing the pointer first before passing it - meaning
you'll try to pass the actual object and not the pointer to it.

Cheers,
Andre
 
K

Karl Heinz Buchegger

Michael said:
Hello
I've a function like:

extern CModelMD3 *pModel;
gameCamera->MoveTo(* pModel);

which returns:
no matching function for call to `CCamera::MoveTo(CModelMD3&)

but in camera.h i've:
void MoveTo(CObject *object);

and in camera.cpp:
void CCamera::MoveTo(CObject *object)
{
...
}

As the compiler tells you: There is no function taking an object or a reference
to an object. There is only a function taking a pointer.

If you have a pointer
extern CModelMD3 *pModel;

the applying the dereference operator on it, as in *pModel
lets you request the object where the pointer points to.

MoveTo wants a pointer, you have a pointer, thus:

gameCamera->MoveTo( pModel);
 
M

Michael Sgier

Hello
thanks for you answers. Well if i do so:

extern CCamera* gameCamera;
extern CModelMD3 *pModel;
gameCamera->MoveTo(pModel);

i get:
undefined reference to `gameCamera'

which is defined/declared exactly like CModelMD3.
THANKS and regards
Michael
 
H

Howard

Michael Sgier said:
Hello
thanks for you answers. Well if i do so:

extern CCamera* gameCamera;
extern CModelMD3 *pModel;
gameCamera->MoveTo(pModel);

i get:
undefined reference to `gameCamera'

which is defined/declared exactly like CModelMD3.

Changing the parameter to the function MoveTo wouldn't affect whether
gameCamera is defined or not, and that change was the correct thing to do.

Is the error a compile error, or a link error? Is gameCamera actually
defined somewhere else? (That's what the "extern" specifier says.) Do you
include camera.h in this file? (Also, is gameCamera initialized somewhere?)

I'm also wondering where this code you've shown resides. You've got an
extern declaration, and apparently follow it immediately with a function
call. That's pretty strange. Usually extern declarations are made in the
global scope, either before any functions in a cpp file, or in an included
header file. What's the _real_ code look like?

Perhaps you don't need pointers or extern declarations at all, but just
local object declarations, or member declarations? It's impossible to tell
with the little code you've shown, though.

-Howard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top