event_x() To Get FL_Gl_Window Coordinates

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.opengl  ]
Previous Message ]New Message | Reply ]Next Message ]

event_x() To Get FL_Gl_Window Coordinates Mike Werner Apr 03, 2013 top right image
I want to be able to left click in an OpenGL window and have the mouse coordinates in that window returned (i.e. relative to the upper left corner of the window). Seems like I should be able to do this using Fl::event_x.  However it's turning out to be difficult. First of all the only way I can get event_x to return anything is to put it in the draw function of my Fl_Gl_Window with the syntax Fl::event_x(). But this doesn't return anything when I click in the OpenGL window. It ONLY returns coordinates when I click on a button outside the OGL window. And the X value returned is relative to main FLTK window. Not what I need.

Was hoping to be able to put event_x() in the draw function or in the callback to Fl_Gl_Window and get OGL window relative coordinates.

The only idea I have now is to put a large button underneath the OGL window. When I click inside the OGL window, this button will be activated and I'll get an x cord. relative to the main FLTK window and have to subtract off the upper left corner coordinates of the OGL window.

Anyone have a more elegant solution?
Direct Link to Message ]
bottom left image   bottom right image
Previous Message ]New Message | Reply ]Next Message ]

Comments are owned by the poster. All other content is copyright 1998-2023 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.