Hey guys. I’ve been working with java for some time and just recently started using opengl/jogl. Drawing shapes and even lighting isn’t an issue, however I still fail to grasp the concept of the coordinate system.
For instance I’m currently working on a java app that draws some shapes in a GLCanvas and then checks to see if the mouse is hovered over it, if so it does some action (currently just prints to the console). I have the app running and the cavas set up drawing several shapes, I’m using a MouseMotionListener to check for a collision when the mouse moves.
However when I check coordinates, the coordinates it checks are that of the Frame below the canvas and range from 0 to the Frame size. The GLCanvas uses the openGL coordinates which at this point are from -1 to 1 on the x and y axis.
I guess I could write an algorithm to translate the plotted shapes points into the Frame coordinate system but that seems like an awful hassle. My next idea was to set the coordinates in the Canvas to match those of the Frame, yet I have no clue how to even go about it. It seems that my canvas, regardless of the used perspective or how I try to move the camera, always goes from -1 to 1. I was wondering if anyone could shed some insight on manipulating the coordinate system/camera. Every openGL tutorial I’ve looked at has touched upon the topic, but at the same time danced around it.
Then again, I could be over complicating things, any help/insight at allw ould be greatly appreciated.
-Me