I have a really silly problem were the answer is evading me at the moment.
I have an OpenGL window created using glut.
I have drawn 3 biggish squares with lines inside to create 3 grid boxes on the screen.
I register clicks on the screen and take them to be points.
I cannot however seem to plot these points in the boxes that that should have their own scales i.e Top Left Point 0,0…
If anyone can help me solve this silly problem, i would be most grateful.
P.S. This is more than likly a maths problems but the answer still evades me.
Don’t know if I fully understand the question. I gather you want to convert screen coordinates to the box coordinates, so lets say a click near the top right of the screen and points will be drawn near the top right of each box.
Ok X and Y are the coordiantes of the click. you convert theses to relative coordinates by dividing by the maxium value they could be, then multiply by the corresponding box side.
BoxX = BoxWidth * ( X / ScreenWidth )
BoxY = BoxHeight * ( Y / ScreenHeight )
Depending on how you render these you probably need to add the X and Y coordinates of the top left hand corner of each Box to the BoxX and BoxY values respectivly.