JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestGluUnprojectFloatNOUI.java
Go to the documentation of this file.
1/**
2 * Copyright 2010 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.opengl.test.junit.math;
30
31import com.jogamp.junit.util.JunitTracer;
32import com.jogamp.opengl.glu.GLU;
33
34import org.junit.Assert;
35import org.junit.Test;
36import org.junit.FixMethodOrder;
37import org.junit.runners.MethodSorters;
38
39@FixMethodOrder(MethodSorters.NAME_ASCENDING)
40public class TestGluUnprojectFloatNOUI extends JunitTracer {
41
42 @Test
43 public void testNaN(){
44 final GLU glu = new GLU();
45 final int[] pickedPoint = new int[]{400,300};
46 final float pickedPointDepth = 0;
47 final float[] sceneModelViewValues = new float[]{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
48 final float[] projectionValues = new float[]{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
49 final int[] viewport = new int[]{0,0,800,600};
50 final float[] objCoords = new float[]{Float.NaN,Float.NaN,Float.NaN};
51 glu.gluUnProject(pickedPoint[0], pickedPoint[1], pickedPointDepth, sceneModelViewValues, 0, projectionValues, 0, viewport, 0, objCoords, 0);
52 Assert.assertTrue(!Double.isNaN(objCoords[0])&&!Double.isNaN(objCoords[1])&&!Double.isNaN(objCoords[2]));
53 }
54
55 @Test
56 public void test01(){
57 final float[] mv = new float[] { 1, 0, 0, 0,
58 0, 1, 0, 0,
59 0, 0, 1, 0,
60 0, 0, 0, 1 };
61
62 final float[] p = new float[] { 2.3464675f, 0, 0, 0,
63 0, 2.4142134f, 0, 0,
64 0, 0, -1.0002f, -1,
65 0, 0, -20.002f, 0 };
66
67 final int[] v = new int[] { 0, 0, 1000, 1000 };
68
69 final float[] s = new float[] { 250, 250, 0.5f };
70
71 final float[] expected = new float[] { -4.2612f, -4.1417f, -19.9980f };
72 final float[] result = new float[] { 0, 0, 0 };
73
74 final GLU glu = new GLU();
75 glu.gluUnProject(s[0], s[1], s[2], mv, 0, p, 0, v, 0, result, 0);
76
77 Assert.assertArrayEquals(expected, result, 0.0001f);
78 }
79
80 @Test
81 public void test02(){
82 final float[] mv = new float[] { 1, 0, 0, 0,
83 0, 1, 0, 0,
84 0, 0, 1, 0,
85 0, 0, -200, 1 } ;
86
87 final float[] p = new float[] { 2.3464675f, 0, 0, 0,
88 0, 2.4142134f, 0, 0,
89 0, 0, -1.0002f, -1,
90 0, 0, -20.002f, 0 };
91
92 final int[] v = new int[] { 0, 0, 1000, 1000 };
93
94 final float[] s = new float[] { 250, 250, 0.5f };
95 final float[] expected = new float[] { -4.2612f, -4.1417f, 180.002f };
96 final float[] result = new float[] { 0, 0, 0 };
97
98 final GLU glu = new GLU();
99 glu.gluUnProject(s[0], s[1], s[2], mv, 0, p, 0, v, 0, result, 0);
100
101 Assert.assertArrayEquals(expected, result, 0.0001f);
102 }
103
104 public static void main(final String args[]) {
105 org.junit.runner.JUnitCore.main(TestGluUnprojectFloatNOUI.class.getName());
106 }
107}
Provides access to the OpenGL Utility Library (GLU).
Definition: GLU.java:43
boolean gluUnProject(float winX, float winY, float winZ, float[] model, int model_offset, float[] proj, int proj_offset, int[] view, int view_offset, float[] objPos, int objPos_offset)
Interface to C language function: GLint gluUnProject(GLdouble winX, GLdouble winY,...
Definition: GLU.java:1387