So I basically have triangle vertices:
GLfloat Vertices[] = {
0.75f, 0.75f, 0.0f, 1.0f,
0.75f, -0.75f, 0.0f, 1.0f,
-0.75f, -0.75f, 0.0f, 1.0f };
Now I have mouse coordinates for example 512, 384 which is the center at 1024, 768 window.
When I translate this normalized 1.0f equals 1024 and -1.0f equals 0 for X and for Y 1.0f equals 768 and -1.0f 0.
Now I have these coordinates:
896, 672, 0 896, 288, 0 384, 288, 0I do not care about Z because I need to calculate only the GUI elements, which are on Z = 0;
Now I can calculate if the mouse coordinates are on top of the triangle, but for some reason glfw gives mouse coordinates with top-left coordinate as the 0.0 and OpenGL uses the bottom-left corner as 0.0, this means that I need to turn the mouse yPosition around, but at the center it still would be 384, but any other value would be different. MyPosition = 768 - oldMyPosition;
if((((896 >= MxPosition) == true && (672 >= MyPosition) == true) &&
((896 >= MxPosition) == true && (288 <= MyPosition) == true) &&
((384 <= MxPosition) == true && (288 <= MyPosition) == true)) == true) {
return true;
} else {
return false;
}
Of course this if statement is not the finished one, but should I calculate it this way or should I use some other method?






