Can you please use C++ style static casting here, rather than C style casting? For example this line would become:

```c++
float x1_rel = static_cast<float>(x1) / static_cast<float>(viewport->getActualWidth() - 1) - 0.5;
```

Also, if I am nit picking we should use consistent whitespace around the operators.