JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
MouseInfo Class Reference

Classes

struct  Down
 
struct  Over
 

Public Member Functions

void transform (const jngl::Mat3 &transformationMatrix)
 Applies the transformationMatrix on the mouse position.
 
std::span< Overcursors ()
 Only returns mouse cursors that are currently not over something.
 

Friends

class jngl::Window
 

Detailed Description

Definition at line 18 of file MouseInfo.hpp.

Member Function Documentation

◆ transform()

void transform ( const jngl::Mat3 & transformationMatrix)

Applies the transformationMatrix on the mouse position.

Let's say you want to move the move position in MouseInfo 50 pixel to the right, you'd do:

jngl::Mat3 matrix;
matrix.translate(jngl::Vec2(50, 0));
jngl::mouseInfo().transform(matrix);
3x3 matrix
Definition Mat3.hpp:18
Mat3 & translate(const Vec2 &v)
Multiplies the matrix with a translation matrix generated from v.
Two-dimensional vector.
Definition Vec2.hpp:36

If (mousePos.x, mousePos.y, 1) is $p$ and transformationMatrix is $M$ this does:

\[
p' = M^{-1} \cdot p
\]

It uses the inverse of the passed matrix, because normally transformations are for rendering where world coordinates are transformed into screen coordinates. The mouse position is in screen coordinates and you want to transform it to world coordinates. This is useful if you have a camera matrix and use it for rendering (applying it on jngl::modelview()) and here.

Friends And Related Symbol Documentation

◆ jngl::Window

friend class jngl::Window
friend

Definition at line 82 of file MouseInfo.hpp.


The documentation for this class was generated from the following file: