public static Point3d intersectPointWithXYPlane(GLAutoDrawable drawable, int rawMouseX, int rawMouseY) { int[] raw = {rawMouseX, rawMouseY}; int[] coords = drawable.getNativeSurface().convertToPixelUnits(raw); int mouseX = coords[0]; int mouseY = coords[1]; Vector3[] mouseRay = getRayFromMouse(drawable, mouseX, mouseY); Vector3 R1 = mouseRay[0]; Vector3 R2 = mouseRay[1]; Vector3 S1 = new Vector3(-1., 1., 0); Vector3 S2 = new Vector3(1., 1., 0); Vector3 S3 = new Vector3(-1., -1., 0); return intersectPointWithPlane(R1, R2, S1, S2, S3); }
public static boolean isRetina(final GL pGL) { final int[] trialSizes = new int[2]; trialSizes[0] = 512; trialSizes[1] = 512; pGL.getContext() .getGLDrawable() .getNativeSurface() .convertToPixelUnits(trialSizes); if (trialSizes[0] == 512 && trialSizes[1] == 512) { return false; } else { return true; } }
private Point3f getOGLPos(int x, int y) { int[] xy = new int[2]; xy[0] = x; xy[1] = y; ((GLAutoDrawable) canvas).getNativeSurface().convertToPixelUnits(xy); x = xy[0]; y = xy[1]; double[] obj_pos = new double[3]; float winX, winY;//, winZ = cameraStart.getZ(); float posX, posY;//, posZ; double[] w_pos = new double[3]; winX = x; winY = viewport[3] - y; GLU glu = new GLU(); obj_pos[2]=0; // Check view relative z-koord of layer zero == visnet layer glu.gluProject( obj_pos[0], obj_pos[1],obj_pos[2], modelview,0, projection,0, viewport,0, w_pos,0); glu.gluUnProject( winX, winY, w_pos[2], modelview,0, projection,0, viewport,0, obj_pos,0); posX = (float)obj_pos[0]; posY = (float)obj_pos[1]; return new Point3f(posX, posY, 0); }
if (button == 1) { int startxy[] = new int[]{OTFOGLDrawer.this.start.x, OTFOGLDrawer.this.start.y}; ((GLAutoDrawable) OTFOGLDrawer.this.canvas).getNativeSurface().convertToPixelUnits(startxy); int endxy[] = new int[]{e.getX(), e.getY()}; ((GLAutoDrawable) OTFOGLDrawer.this.canvas).getNativeSurface().convertToPixelUnits(endxy); int deltax = Math.abs(startxy[0] - endxy[0]); int deltay = Math.abs(startxy[1] - endxy[1]);