The Internet has already solved the mouse exclusive problemArticleFor example, ogre + cegui + OIS perfectly solves the non-exclusive use of the mouse, and there is also an article on this basis to solve the no pointer problem of the mouse in the window border, for example, the ogre + cegui + OIS mouse is not exclusively used
(Including code). These articles provide a complete solution to solve the mouse exclusive problem. However, they are applicable to the ogre 1.6.x version and are not applicable to the new ogre version 1.7.x. Ogre 1.7 uses a system called "Tray ".CodeIn the sdktray. h file. Sdktray uses ogre overlay to implement the GUI, And ogre 1.7 seems to have more Gui-related components (details) than earlier versions ). In short, we need to modify the corresponding code to achieve mouse monopoly.
There are two steps to solve this problem:
(1) solve the mouse exclusive problem
(2) solve the mouse display problem
(1) modify the setupinput function in samplecontext. h to achieve mouse exclusive. The Code is as follows:
Virtual void setupinput () <br/>{< br/> showcursor (0); // ** <br/> ois: paramlist pl; <br/> size_t winhandle = 0; <br/> STD: ostringstream winhandlestr; <br/> mwindow-> getcustomattribute ("window", & winhandle ); <br/> winhandlestr <winhandle; <br/> Pl. insert (STD: make_pair ("window", winhandlestr. STR (); <br/> Pl. insert (STD: make_pair (STD: string ("w32_mouse"), STD: string ("discl_foreground"); // ** <br/> Pl. insert (STD: make_pair (STD: string ("w32_mouse"), STD: string ("discl_nonexclusive "))); // ** <br/> minputmgr = ois: inputmanager: createinputsystem (PL); <br/> createinputdevices (); // create the specific input devices <br/> windowresized (mwindow); // do an initial adjustment of mouse area <br/>}
(2) modify the mousemoved function in sdksample. h to display the mouse. The Code is as follows:
Virtual bool mousemoved (const ois: mouseevent & EVT) <br/>{< br/> If (EVT. state. x. ABS <mwindow-> getviewport (0)-> getactualleft () + 1 <br/> | (EVT. state. y. ABS <mwindow-> getviewport (0)-> getactualtop () + 1) <br/> | (EVT. state. x. ABS> mwindow-> getviewport (0)-> getactualleft () + mwindow-> getviewport (0)-> getactualwidth () <br/> | (EVT. state. y. ABS> mwindow-> getviewport (0)-> getactualtop () + mwindow-> getviewport (0)-> G Etactualheight () <br/>{< br/> If (! Msysmouseshowflag) <br/>{< br/> showcursor (1); <br/> mtraymgr-> hidecursor (); <br/> msysmouseshowflag = true; <br/>}< br/> else <br/> {<br/> If (msysmouseshowflag) <br/>{< br/> showcursor (0); <br/> mtraymgr-> showcursor (); <br/> msysmouseshowflag = false; <br/>}< br/> If (mtraymgr-> injectmousemove (EVT) return true; <br/> mcameraman-> injectmousemove (EVT ); <br/> return true; <br/>}
Do not forget to define bool msysmouseshowflag and initialize it to false.
In this way, the mouse exclusive problem is solved and the mouse can be properly displayed.
By cgnerds@gmail.com
Time:, 2011/06/21