Esempio n. 1
0
 public StringBuilder toString(StringBuilder sb) {
   if (null == sb) {
     sb = new StringBuilder();
   }
   sb.append("ShaderProgram[id=").append(id);
   sb.append(
       ", linked="
           + programLinked
           + ", inUse="
           + programInUse
           + ", program: "
           + shaderProgram
           + ",");
   for (Iterator<ShaderCode> iter = allShaderCode.iterator(); iter.hasNext(); ) {
     sb.append(Platform.getNewline()).append("   ").append(iter.next());
   }
   sb.append("]");
   return sb;
 }
Esempio n. 2
0
 public static FragmentShader makemain(List<FragmentShader> shaders) {
   StringBuilder buf = new StringBuilder();
   Collections.sort(shaders, cmp);
   for (FragmentShader sh : shaders) buf.append(sh.header + "\n");
   buf.append("\n");
   buf.append("void main()\n{\n");
   buf.append("    vec4 res = gl_Color;\n");
   for (FragmentShader sh : shaders) {
     buf.append("    " + sh.entry + "(res);\n");
   }
   buf.append("    gl_FragColor = res;\n");
   buf.append("}\n");
   return (new FragmentShader(buf.toString()));
 }
Esempio n. 3
0
 public void parse() throws IOException {
   String ln;
   while ((ln = in.readLine()) != null) {
     if (ln.startsWith("#pp ")) {
       String d = ln.substring(4).trim();
       String a = "";
       int p = d.indexOf(' ');
       if (p >= 0) {
         a = d.substring(p + 1);
         d = d.substring(0, p).trim();
       }
       d = d.intern();
       directive(d, a);
     } else {
       buf.append(ln + "\n");
     }
   }
 }
Esempio n. 4
0
 public static VertexShader makemain(List<VertexShader> shaders) {
   StringBuilder buf = new StringBuilder();
   Collections.sort(shaders, cmp);
   for (VertexShader sh : shaders) buf.append(sh.header + "\n");
   buf.append("\n");
   buf.append("void main()\n{\n");
   buf.append("    vec4 fcol = gl_Color;\n");
   buf.append("    vec4 bcol = gl_Color;\n");
   buf.append("    vec4 objv = gl_Vertex;\n");
   buf.append("    vec3 objn = gl_Normal;\n");
   int i = 0;
   for (; i < shaders.size(); i++) {
     VertexShader sh = shaders.get(i);
     if (sh.uses("eyev") || sh.uses("eyen")) break;
     buf.append("    " + sh.call() + ";\n");
   }
   buf.append("    vec4 eyev = gl_ModelViewMatrix * objv;\n");
   buf.append("    vec3 eyen = gl_NormalMatrix * objn;\n");
   for (; i < shaders.size(); i++) {
     VertexShader sh = shaders.get(i);
     buf.append("    " + sh.call() + ";\n");
   }
   buf.append("    gl_FrontColor = fcol;\n");
   buf.append("    gl_Position = gl_ProjectionMatrix * eyev;\n");
   buf.append("}\n");
   return (new VertexShader(buf.toString()));
 }
    public void init(GLAutoDrawable glAutoDrawable) {
      StringBuilder sb = new StringBuilder();

      sb.append(gov.nasa.worldwind.Version.getVersion() + "\n");

      sb.append("\nSystem Properties\n");
      sb.append("Processors: " + Runtime.getRuntime().availableProcessors() + "\n");
      sb.append("Free memory: " + Runtime.getRuntime().freeMemory() + " bytes\n");
      sb.append("Max memory: " + Runtime.getRuntime().maxMemory() + " bytes\n");
      sb.append("Total memory: " + Runtime.getRuntime().totalMemory() + " bytes\n");

      for (Map.Entry prop : System.getProperties().entrySet()) {
        sb.append(prop.getKey() + " = " + prop.getValue() + "\n");
      }

      GL gl = glAutoDrawable.getGL();

      sb.append("\nOpenGL Values\n");

      String oglVersion = gl.glGetString(GL.GL_VERSION);
      sb.append("OpenGL version: " + oglVersion + "\n");

      String oglVendor = gl.glGetString(GL.GL_VENDOR);
      sb.append("OpenGL vendor: " + oglVendor + "\n");

      String oglRenderer = gl.glGetString(GL.GL_RENDERER);
      sb.append("OpenGL renderer: " + oglRenderer + "\n");

      int[] intVals = new int[2];
      for (Attr attr : attrs) {
        sb.append(attr.name).append(": ");

        if (attr.attr instanceof Integer) {
          gl.glGetIntegerv((Integer) attr.attr, intVals, 0);
          sb.append(intVals[0]).append(intVals[1] > 0 ? ", " + intVals[1] : "");
        }

        sb.append("\n");
      }

      String extensionString = gl.glGetString(GL.GL_EXTENSIONS);
      String[] extensions = extensionString.split(" ");
      sb.append("Extensions\n");
      for (String ext : extensions) {
        sb.append("    " + ext + "\n");
      }

      sb.append("\nJOGL Values\n");
      String pkgName = "javax.media.opengl";
      try {
        getClass().getClassLoader().loadClass(pkgName + ".GL");

        Package p = Package.getPackage(pkgName);
        if (p == null) {
          sb.append("WARNING: Package.getPackage(" + pkgName + ") is null\n");
        } else {
          sb.append(p + "\n");
          sb.append("Specification Title = " + p.getSpecificationTitle() + "\n");
          sb.append("Specification Vendor = " + p.getSpecificationVendor() + "\n");
          sb.append("Specification Version = " + p.getSpecificationVersion() + "\n");
          sb.append("Implementation Vendor = " + p.getImplementationVendor() + "\n");
          sb.append("Implementation Version = " + p.getImplementationVersion() + "\n");
        }
      } catch (ClassNotFoundException e) {
        sb.append("Unable to load " + pkgName + "\n");
      }

      this.outputArea.setText(sb.toString());
    }