Google Groepen ondersteunt geen nieuwe Usenet-berichten of -abonnementen meer. Historische content blijft zichtbaar.

OpenGL and cursors

136 weergaven
Naar het eerste ongelezen bericht

Patrick Steele

ongelezen,
17 nov 2007, 10:20:5317-11-2007
aan
wxWidgets: 2.8.6
OS: XP SP 2
IDE: VS 2005

Hi,
I have created an OpenGL wxWidgets application using wxGLCanvas and wxGLContext. Part of what I am doing is designing a 3D environment, so I have written a camera class to control moving around. The camera is controlled by mouse and keyboard. The application currently runs windowed with other windows likely to come eg for editing tools. What I would like to do is:

- by default, the mouse moves as it usually would around the screen
- on right clicking the mouse inside the opengl window, enter camera mode and use the keyboard and mouse inputs from then on to control the camera, and if right-clicked again, to exit camera mode so that you could access any other windows again

Most of that I have already done, but the bit that I am getting stuck on is that when I enter camera mode, I want to hide the cursor and constrain it from leaving the window. And I can't see how to do this under wxWidgets. I could use ShowCursor( FALSE ); from winuser.h but that ties me to the Windows OS and I want to be free to be multi-platform. This will hide the mouse cursor but still it is not constrained to be within the window. So currently it looks like I am controlling a camera, until the mouse moves out of the window, reappears and naturally because it is outside of the window is no longer sending mouse motion events to it to move the camera. I'm sure there must be a nice answer for this but I haven't found it yet. Can anyone suggest anything please?
Thanks in advance,
Patrick

Vadim Zeitlin

ongelezen,
17 nov 2007, 10:25:5917-11-2007
aan
On Sat, 17 Nov 2007 15:20:53 +0000 Patrick Steele <steele....@gmail.com> wrote:

PS> Most of that I have already done, but the bit that I am getting stuck on is
PS> that when I enter camera mode, I want to hide the cursor and constrain it
PS> from leaving the window.

To hide the cursor, you need to use wxCursor(wxCURSOR_BLANK) I believe.
And while it isn't really possible to constrain the mouse with a single
call, you should capture it using wxWindow::CaptureMouse() as this will
allow you to receive mouse events even when the mouse is outside your
window and you will also be able to call WarpPointer() to move it back
inside (although this is not recommended). Notice that you should also be
ready to handle wxEVT_MOUSE_CAPTURE_CHANGED events if you capture the mouse
to react adequately (e.g. exit your camera mode) if another window breaks
the capture.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
For additional commands, e-mail: wx-use...@lists.wxwidgets.org

Patrick Steele

ongelezen,
17 nov 2007, 10:55:5917-11-2007
aan
Thanks Vadim,
ok I just tried this:

m_pGLCanvas->SetCursor( wxCursor( wxCURSOR_BLANK ) );

but I am still seeing the arrow cursor. I have tried various of the cursor enums and it appears that some are supported on some platforms. Debugging into it, in src/msw/cursor.cpp, line #354

HCURSOR hcursor = ::LoadCursor(stdCursor.isStd ? NULL : wxGetInstance(), stdCursor.name);

where isStd = false, and name = WXCURSOR_BLANK, ends up giving hcursor = NULL

Cut to a few lines later and we get

wxLogLastError(_T("LoadCursor"));

Does this mean then that WXCURSOR_BLANK isn't supported on Windows, or is there a bug somewhere? Obviously I'm hoping for the latter ;)

Thanks,
Patrick








On Nov 17, 2007 3:25 PM, Vadim Zeitlin <va...@wxwidgets.org> wrote:
On Sat, 17 Nov 2007 15:20:53 +0000 Patrick Steele <steele....@gmail.com> wrote:

PS> Most of that I have already done, but the bit that I am getting stuck on is

Vadim Zeitlin

ongelezen,
17 nov 2007, 11:28:4517-11-2007
aan
On Sat, 17 Nov 2007 15:55:59 +0000 Patrick Steele <steele....@gmail.com> wrote:

PS> HCURSOR hcursor = ::LoadCursor(stdCursor.isStd ? NULL : wxGetInstance(),
PS> stdCursor.name);
PS>
PS> where isStd = false, and name = WXCURSOR_BLANK, ends up giving hcursor =
PS> NULL

This means you didn't include "wx/msw/wx.rc" in your project as this is
where this cursor is defined.

Patrick Steele

ongelezen,
17 nov 2007, 11:42:1917-11-2007
aan
Ahhhh, I see! Excellent, thanks for your help Vadim :)



On Nov 17, 2007 4:28 PM, Vadim Zeitlin <va...@wxwidgets.org> wrote:
On Sat, 17 Nov 2007 15:55:59 +0000 Patrick Steele <steele....@gmail.com> wrote:

PS> HCURSOR hcursor = ::LoadCursor(stdCursor.isStd ? NULL : wxGetInstance(),
PS> stdCursor.name);
PS>
PS> where isStd = false, and name = WXCURSOR_BLANK, ends up giving hcursor =
PS> NULL

 This means you didn't include "wx/msw/wx.rc" in your project as this is
where this cursor is defined.
0 nieuwe berichten