PageRenderTime 44ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLPointsNEWT.java

https://github.com/s6rapala/jogl
Java | 159 lines | 106 code | 25 blank | 28 comment | 8 complexity | e6f7ef3868cb8f42936e02593e40dfed MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, Apache-2.0, GPL-3.0
  1. /**
  2. * Copyright 2011 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. package com.jogamp.opengl.test.junit.jogl.acore;
  29. import com.jogamp.newt.opengl.GLWindow;
  30. import com.jogamp.opengl.test.junit.util.UITestCase;
  31. import com.jogamp.opengl.test.junit.jogl.demos.PointsDemo;
  32. import com.jogamp.opengl.test.junit.jogl.demos.es1.PointsDemoES1;
  33. import com.jogamp.opengl.test.junit.jogl.demos.es2.PointsDemoES2;
  34. import javax.media.opengl.GLCapabilities;
  35. import javax.media.opengl.GLProfile;
  36. import org.junit.Assert;
  37. import org.junit.BeforeClass;
  38. import org.junit.AfterClass;
  39. import org.junit.Test;
  40. import org.junit.FixMethodOrder;
  41. import org.junit.runners.MethodSorters;
  42. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  43. public class TestGLPointsNEWT extends UITestCase {
  44. static int width, height;
  45. @BeforeClass
  46. public static void initClass() {
  47. width = 512;
  48. height = 512;
  49. }
  50. @AfterClass
  51. public static void releaseClass() {
  52. }
  53. protected void runTestGL0(GLCapabilities caps, PointsDemo demo) throws InterruptedException {
  54. GLWindow glWindow = GLWindow.create(caps);
  55. Assert.assertNotNull(glWindow);
  56. glWindow.setTitle(getSimpleTestName("."));
  57. glWindow.addGLEventListener(demo);
  58. final SnapshotGLEventListener snap = new SnapshotGLEventListener();
  59. snap.setPostSNDetail(demo.getClass().getSimpleName());
  60. glWindow.addGLEventListener(snap);
  61. glWindow.setSize(width, height);
  62. glWindow.setVisible(true);
  63. demo.setSmoothPoints(false);
  64. snap.setMakeSnapshot();
  65. snap.setPostSNDetail("flat");
  66. glWindow.display();
  67. demo.setSmoothPoints(true);
  68. snap.setMakeSnapshot();
  69. snap.setPostSNDetail("smooth");
  70. glWindow.display();
  71. demo.setPointParams(2f, 40f, 0.01f, 0.0f, 0.01f, 1f);
  72. snap.setMakeSnapshot();
  73. snap.setPostSNDetail("attn0");
  74. glWindow.display();
  75. glWindow.removeGLEventListener(demo);
  76. glWindow.destroy();
  77. }
  78. protected void runTestGL(GLCapabilities caps, PointsDemo demo, boolean forceFFPEmu) throws InterruptedException {
  79. // final PointsDemoES2 demo01 = new PointsDemoES2();
  80. runTestGL0(caps, demo);
  81. }
  82. @Test
  83. public void test01FFP__GL2() throws InterruptedException {
  84. if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; }
  85. GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
  86. runTestGL(caps, new PointsDemoES1(), false);
  87. }
  88. @Test
  89. public void test02FFP__ES1() throws InterruptedException {
  90. if(!GLProfile.isAvailable(GLProfile.GLES1)) { System.err.println("GLES1 n/a"); return; }
  91. GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1));
  92. runTestGL(caps, new PointsDemoES1(), false);
  93. }
  94. @Test
  95. public void test03FFP__ES2() throws InterruptedException {
  96. if(!GLProfile.isAvailable(GLProfile.GLES2)) { System.err.println("GLES2 n/a"); return; }
  97. GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
  98. PointsDemoES1 demo = new PointsDemoES1();
  99. demo.setForceFFPEmu(true, false, false, false);
  100. runTestGL(caps, demo, false);
  101. }
  102. @Test
  103. public void test04FFP__GL2ES2() throws InterruptedException {
  104. if(!GLProfile.isAvailable(GLProfile.GL2ES2)) { System.err.println("GL2ES2 n/a"); return; }
  105. GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2ES2));
  106. PointsDemoES1 demo = new PointsDemoES1();
  107. demo.setForceFFPEmu(true, false, false, false);
  108. runTestGL(caps, demo, false);
  109. }
  110. @Test
  111. public void test11GLSL_GL2() throws InterruptedException {
  112. if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; }
  113. GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
  114. runTestGL(caps, new PointsDemoES2(), false);
  115. }
  116. @Test
  117. public void test12GLSL_ES2() throws InterruptedException {
  118. if(!GLProfile.isAvailable(GLProfile.GLES2)) { System.err.println("GLES2 n/a"); return; }
  119. GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
  120. runTestGL(caps, new PointsDemoES2(), false); // should be FFPEmu implicit
  121. }
  122. static long duration = 1000; // ms
  123. public static void main(String args[]) {
  124. for(int i=0; i<args.length; i++) {
  125. if(args[i].equals("-time")) {
  126. i++;
  127. try {
  128. duration = Integer.parseInt(args[i]);
  129. } catch (Exception ex) { ex.printStackTrace(); }
  130. }
  131. }
  132. org.junit.runner.JUnitCore.main(TestGLPointsNEWT.class.getName());
  133. }
  134. }