Re: Mouse position in a GtkGlArea



On Fri, 2002-08-23 at 09:26, Fabrice Depaulis wrote:
> Hello,
> 
> I would like to get the position of the mouse when I click on a GtkGlArea.
> The problem is that when I use the common way (creating a callback function on the "button press event"), I can only get the position of the mouse relatively to the WINDOW. But these coordonnates don't correspond to the position of the mouse in the reference of the GlArea creation object (that ones depend of the view of the scene) ... I'm not sure to be very comprehensible ... it's not easy to explain without an image.
> 
> If you understand and if you have an answer to this question ...
> Thanks,
> 
> Fabrice.

Sorry for the delay.

1) You want to get the position of the mouse relating to the OpenGL
view.
That's pretty easy as the events gives you the position relating to the
top left border of the widget (when the docs says relating to the
window, it's the the window with the decoration of the window manager
but the widget's own window (invisible to the user but not to X)

for example, take the viewlw.c in the example directory,
add the line:
  g_message("Position is (%f,%f)",event->x,event->y);
in the glarea_motion_notify function just after the line:
mesh_info *info = (mesh_info*)gtk_object_get_data(GTK_OBJECT(widget),
"mesh_info");

Compile and play with it.


2) You want to get the position in the OpenGL world and therefore it'll
depend on OpenGL for that (I've never looked at feedback in OpenGL so
far).

Tell me more about it.

-- 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]