View Full Version : glutMouseFunc :error message under Borland C++ Builder 6.0

07-16-2002, 01:03 AM
Hello there everyone,

I have sent this to the Beginner's section but got no answer and here I am resending the message again.

I am trying to use glutMouseFunc from GLUT and have called it using glutMouseFunc(mouse_callback_func) where mouse_callback_func is the callback function. I don't know where I've gone wrong as I have appropriately defined and declared mouse_callback_func in the header and source files. Below are the messages that I received from Borland C++ Builder 6.0. I'd truly appreciate if anyone could assist me with this matter. Thank you.

Kind regards,

[C++ Error] MainForm1.cpp(53): E2034 Cannot convert 'void (_fastcall * (_closure )(int,int,int,int))(int,int,int,int)' to 'void (*)(int,int,int,int)'
[C++ Error] MainForm1.cpp(53): E2342 Type mismatch in parameter 'func' (wanted 'void (*)(int,int,int,int)', got 'void')

07-16-2002, 02:45 AM
Typecast the function to the expected type maybe?

reinterpret_cast<void (*)(int, int, int, int)>(yourFunctionGoesHere)

07-16-2002, 04:55 AM

I am really lost. I have reinterpreted the function as suggested but to no avail. Here is the mouse callback function that I have:

void __fastcall TForm1::mouse_callback_func(int button, int state, int x, int y)

if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN)

and I call it using glutMouseFunc(mouse_callback_func)

[This message has been edited by Suf (edited 07-16-2002).]

[This message has been edited by Suf (edited 07-16-2002).]

07-16-2002, 05:22 AM
A callback function needs to be like a regular C style function.
i.e. static if it's part of a class.


07-16-2002, 05:45 AM
Thanks Mezz, I have done as suggested and got different error messages now.

[Linker Error] Unresolved external 'TForm1::mouse(int, int, int, int)' referenced from C:\JULY4\MAINFORM1.OBJ
[Linker Error] Unresolved external 'glutMouseFunc' referenced from C:\JULY4\MAINFORM1.OBJ

Does it have any connection with GLUT that I have installed?

07-16-2002, 06:36 AM
Are you linking with the glut libraries?

glut32.lib or something it's called. I dont remember because I havent worked with it in a while. There may also be more than one library you need to link with.
Hopefully you know how to do this with Builder because I don't! (I use VC++)