ShowMouse
This functions hides the mouse cursor.
Syntax
Example
#include "Leadwerks.h"
using namespace Leadwerks;
Model* model = NULL;
Vec3 camerarotation;
bool freelookmode=true;
int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
World* world = World::Create();
Camera* camera = Camera::Create();
camera->Move(0,0,-3);
Light* light = DirectionalLight::Create();
light->SetRotation(35,35,0);
//Create a model
model = Model::Box();
model->SetColor(0.0,0.0,1.0);
//Hide the mouse cursor
window->HideMouse();
//Move the mouse to the center of the screen
window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2);
while (true)
{
//Close the window to end the program
if (window->Closed()) return false;
//Press escape to end freelook mode
if (window->KeyHit(Key::Escape))
{
freelookmode=false;
window->ShowMouse();
}
model->Turn(0,Leadwerks::Time::GetSpeed(),0);
if (freelookmode)
{
//Get the mouse movement
float sx = context->GetWidth()/2;
float sy = context->GetHeight()/2;
Vec3 mouseposition = window->GetMousePosition();
float dx = mouseposition.x - sx;
float dy = mouseposition.y - sy;
//Adjust and set the camera rotation
camerarotation.x += dy / 10.0;
camerarotation.y += dx / 10.0;
camera->SetRotation(camerarotation);
//Move the mouse to the center of the screen
window->SetMousePosition(sx,sy);
}
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync(false);
}
return 0;
}