From 1b665cc38eaf06939b658bdf0c2043197919caf9 Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Mon, 17 Oct 2011 01:00:15 +0000 Subject: [PATCH] - add GLSL editor to SDK by default git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8421 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- sdk/jme3-glsl-support/build.xml | 10 + sdk/jme3-glsl-support/license.txt | 27 + sdk/jme3-glsl-support/manifest.mf | 15 + .../nbproject/build-impl.xml | 45 + .../nbproject/genfiles.properties | 8 + .../nbproject/project.properties | 6 + sdk/jme3-glsl-support/nbproject/project.xml | 103 + .../nbproject/suite.properties | 1 + .../nboglpack/glsleditor/Bundle.properties | 28 + .../glsleditor/GlslCompletionProvider.java | 327 ++ .../glsleditor/GlslShaderFileObserver.java | 65 + .../glsleditor/GlslVocabularyManager.java | 172 + .../glsleditor/dataobject/Bundle.properties | 11 + .../GlslFragmentShaderDataLoader.java | 40 + .../GlslFragmentShaderDataLoaderBeanInfo.java | 32 + .../GlslFragmentShaderDataNode.java | 24 + .../GlslFragmentShaderDataObject.java | 57 + .../GlslGeometryShaderDataLoader.java | 44 + .../GlslGeometryShaderDataLoaderBeanInfo.java | 37 + .../GlslGeometryShaderDataNode.java | 34 + .../GlslGeometryShaderDataObject.java | 60 + .../GlslVertexShaderDataLoader.java | 40 + .../GlslVertexShaderDataLoaderBeanInfo.java | 32 + .../dataobject/GlslVertexShaderDataNode.java | 24 + .../GlslVertexShaderDataObject.java | 54 + .../glsleditor/glsl/Bundle.properties | 4 + .../nboglpack/glsleditor/glsl/GLSL_120.nbs | 316 ++ .../nboglpack/glsleditor/glsl/GLSL_130.nbs | 389 ++ .../java/nboglpack/glsleditor/glsl/Glsl.java | 361 ++ .../net/java/nboglpack/glsleditor/layer.xml | 289 + .../java/nboglpack/glsleditor/lexer/Glsl.java | 61 + .../nboglpack/glsleditor/lexer/GlslLexer.java | 343 ++ .../glsleditor/lexer/GlslTokenId.java | 90 + .../java/nboglpack/glsleditor/opengl-icon.gif | Bin 0 -> 1712 bytes .../resources/FragmentShaderIcon.gif | Bin 0 -> 607 bytes .../resources/FragmentShaderTemplate.frag | 8 + .../resources/GeometryShaderIcon.gif | Bin 0 -> 614 bytes .../resources/GeometryShaderTemplate.geom | 26 + .../resources/GlslFragmentShaderExample.frag | 28 + .../resources/GlslFragmentShaderResolver.xml | 18 + .../resources/GlslGeometryShaderExample.geom | 26 + .../resources/GlslGeometryShaderResolver.xml | 18 + .../resources/GlslVertexShaderExample.vert | 29 + .../resources/GlslVertexShaderResolver.xml | 18 + .../glsleditor/resources/GlslVocabulary.xml | 4724 +++++++++++++++++ .../glsleditor/resources/JmeVocabulary.xml | 4724 +++++++++++++++++ .../resources/NetBeans-glsl-fontsColors.xml | 26 + .../glsleditor/resources/OptionsIcon.gif | Bin 0 -> 163 bytes .../glsleditor/resources/VertexShaderIcon.gif | Bin 0 -> 613 bytes .../resources/VertexShaderTemplate.vert | 7 + .../nboglpack/glsleditor/resources/field.gif | Bin 0 -> 310 bytes .../glsleditor/resources/function.gif | Bin 0 -> 346 bytes .../glsleditor/resources/preprocessor.png | Bin 0 -> 432 bytes .../vocabulary/GLSLElementDescriptor.java | 56 + .../glsleditor/vocabulary/GLSLVocabulary.java | 33 + .../glsleditor/vocabulary/jaxb.index | 2 + .../services/org.openide.loaders.DataLoader | 1 + sdk/nbproject/platform.properties | 1 - sdk/nbproject/project.properties | 2 + 59 files changed, 12895 insertions(+), 1 deletion(-) create mode 100644 sdk/jme3-glsl-support/build.xml create mode 100644 sdk/jme3-glsl-support/license.txt create mode 100644 sdk/jme3-glsl-support/manifest.mf create mode 100644 sdk/jme3-glsl-support/nbproject/build-impl.xml create mode 100644 sdk/jme3-glsl-support/nbproject/genfiles.properties create mode 100644 sdk/jme3-glsl-support/nbproject/project.properties create mode 100644 sdk/jme3-glsl-support/nbproject/project.xml create mode 100644 sdk/jme3-glsl-support/nbproject/suite.properties create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/Bundle.properties create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslCompletionProvider.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslShaderFileObserver.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslVocabularyManager.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/Bundle.properties create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataLoader.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataLoaderBeanInfo.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataNode.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataObject.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataLoader.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataLoaderBeanInfo.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataNode.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataObject.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataLoader.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataLoaderBeanInfo.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataNode.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataObject.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/Bundle.properties create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/GLSL_120.nbs create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/GLSL_130.nbs create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/Glsl.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/layer.xml create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/Glsl.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/GlslLexer.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/GlslTokenId.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/opengl-icon.gif create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/FragmentShaderIcon.gif create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/FragmentShaderTemplate.frag create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GeometryShaderIcon.gif create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GeometryShaderTemplate.geom create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslFragmentShaderExample.frag create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslFragmentShaderResolver.xml create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslGeometryShaderExample.geom create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslGeometryShaderResolver.xml create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslVertexShaderExample.vert create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslVertexShaderResolver.xml create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslVocabulary.xml create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/JmeVocabulary.xml create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/NetBeans-glsl-fontsColors.xml create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/OptionsIcon.gif create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/VertexShaderIcon.gif create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/VertexShaderTemplate.vert create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/field.gif create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/function.gif create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/preprocessor.png create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/vocabulary/GLSLElementDescriptor.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/vocabulary/GLSLVocabulary.java create mode 100644 sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/vocabulary/jaxb.index create mode 100644 sdk/jme3-glsl-support/test/unit/src/META-INF/services/org.openide.loaders.DataLoader diff --git a/sdk/jme3-glsl-support/build.xml b/sdk/jme3-glsl-support/build.xml new file mode 100644 index 000000000..6f9e53ce8 --- /dev/null +++ b/sdk/jme3-glsl-support/build.xml @@ -0,0 +1,10 @@ + + + + + + Builds, tests, and runs the project net.java.nboglpack.glsleditor. + + + diff --git a/sdk/jme3-glsl-support/license.txt b/sdk/jme3-glsl-support/license.txt new file mode 100644 index 000000000..5f7c82192 --- /dev/null +++ b/sdk/jme3-glsl-support/license.txt @@ -0,0 +1,27 @@ +Copyright (c) 2007, Michael Bien, Mathias Henze + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the organization nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sdk/jme3-glsl-support/manifest.mf b/sdk/jme3-glsl-support/manifest.mf new file mode 100644 index 000000000..314fb97c7 --- /dev/null +++ b/sdk/jme3-glsl-support/manifest.mf @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +OpenIDE-Module: net.java.nboglpack.glsleditor +OpenIDE-Module-Implementation-Version: 0 +OpenIDE-Module-Layer: net/java/nboglpack/glsleditor/layer.xml +OpenIDE-Module-Localizing-Bundle: net/java/nboglpack/glsleditor/Bundle.properties + +Name: net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataLoader.class +OpenIDE-Module-Class: Loader + +Name: net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataLoader.class +OpenIDE-Module-Class: Loader + +Name: net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataLoader.class +OpenIDE-Module-Class: Loader + diff --git a/sdk/jme3-glsl-support/nbproject/build-impl.xml b/sdk/jme3-glsl-support/nbproject/build-impl.xml new file mode 100644 index 000000000..4950dbe5c --- /dev/null +++ b/sdk/jme3-glsl-support/nbproject/build-impl.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + You must set 'suite.dir' to point to your containing module suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sdk/jme3-glsl-support/nbproject/genfiles.properties b/sdk/jme3-glsl-support/nbproject/genfiles.properties new file mode 100644 index 000000000..72ab1096d --- /dev/null +++ b/sdk/jme3-glsl-support/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=a85cd232 +build.xml.script.CRC32=bcb3cbef +build.xml.stylesheet.CRC32=79c3b980 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=7f5f482a +nbproject/build-impl.xml.script.CRC32=d103b190 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.46.2 diff --git a/sdk/jme3-glsl-support/nbproject/project.properties b/sdk/jme3-glsl-support/nbproject/project.properties new file mode 100644 index 000000000..528234a42 --- /dev/null +++ b/sdk/jme3-glsl-support/nbproject/project.properties @@ -0,0 +1,6 @@ +javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.5 +license.file=license.txt +nbm.homepage=http://kenai.com/projects/netbeans-opengl-pack +nbm.module.author=Mathias Henze, Michael Bien +spec.version.base=3.0.0 diff --git a/sdk/jme3-glsl-support/nbproject/project.xml b/sdk/jme3-glsl-support/nbproject/project.xml new file mode 100644 index 000000000..33014128c --- /dev/null +++ b/sdk/jme3-glsl-support/nbproject/project.xml @@ -0,0 +1,103 @@ + + + org.netbeans.modules.apisupport.project + + + net.java.nboglpack.glsleditor + + + + org.netbeans.modules.editor.completion + + + + 1 + 1.13.2 + + + + org.netbeans.modules.editor.lib + + + + 3 + 2.0 + + + + org.netbeans.modules.languages + + + + 0-1 + 1.84.0.1 + + + + org.netbeans.modules.lexer + + + + 2 + 1.20.0.1 + + + + org.openide.filesystems + + + + 6.4.1 + + + + org.openide.loaders + + + + 5.9.1 + + + + org.openide.nodes + + + + 6.7.1 + + + + org.openide.text + + + + 6.21.2 + + + + org.openide.util + + + + 6.8.1 + + + + org.openide.windows + + + + 6.16 + + + + + net.java.nboglpack.glsleditor + net.java.nboglpack.glsleditor.dataobject + net.java.nboglpack.glsleditor.glsl + net.java.nboglpack.glsleditor.lexer + net.java.nboglpack.glsleditor.vocabulary + + + + diff --git a/sdk/jme3-glsl-support/nbproject/suite.properties b/sdk/jme3-glsl-support/nbproject/suite.properties new file mode 100644 index 000000000..29d7cc9bd --- /dev/null +++ b/sdk/jme3-glsl-support/nbproject/suite.properties @@ -0,0 +1 @@ +suite.dir=${basedir}/.. diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/Bundle.properties b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/Bundle.properties new file mode 100644 index 000000000..c442c39c6 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/Bundle.properties @@ -0,0 +1,28 @@ +OpenIDE-Module-Display-Category=jMonkeyEngine +OpenIDE-Module-Long-Description=\ + Provides syntax highlighting and code completion with documentation for jME3 GLSL shader files. +OpenIDE-Module-Name=GLSL Editor +OpenIDE-Module-Short-Description=Editor for jME3 shader files + +text/x-glsl-fragment-shader=GLSL Fragment Shader +text/x-glsl-vertex-shader=GLSL Vertex Shader +text/x-glsl-geometry-shader=GLSL Geometry Shader + +#Layer.xml entries for fonts & colors in Options window: +NetBeans=NetBeans +glsl-keyword=Keyword +glsl-name=Name +glsl-brace=Brace +glsl-value=Value +glsl-curly-brace=Curly brace +glsl-string-value=String value +glsl-comment=Comment +glsl-ml-comment=Multiline comment +glsl-separator=Separator +glsl-function=Function +glsl-whitespace=Whitespace +glsl-end-of-line=EOL +glsl-build-in-var=Build in variable +glsl-build-in-func=Build in function +glsl-preprocessor=Preprocessor directive + diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslCompletionProvider.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslCompletionProvider.java new file mode 100644 index 000000000..38dabbbc0 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslCompletionProvider.java @@ -0,0 +1,327 @@ +package net.java.nboglpack.glsleditor; + +import java.util.Map.Entry; +import java.util.Set; +import org.netbeans.api.editor.completion.Completion; +import org.openide.ErrorManager; +import org.netbeans.editor.BaseDocument; +import org.netbeans.spi.editor.completion.CompletionDocumentation; +import org.netbeans.spi.editor.completion.CompletionItem; +import org.netbeans.spi.editor.completion.CompletionProvider; +import org.netbeans.spi.editor.completion.CompletionResultSet; +import org.netbeans.spi.editor.completion.CompletionTask; +import org.netbeans.spi.editor.completion.support.AsyncCompletionQuery; +import org.netbeans.spi.editor.completion.support.AsyncCompletionTask; +import javax.swing.Action; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; +import javax.swing.text.JTextComponent; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.event.KeyEvent; +import java.net.URL; +import java.util.Iterator; +import java.util.Map; +import net.java.nboglpack.glsleditor.dataobject.GlslFragmentShaderDataLoader; +import net.java.nboglpack.glsleditor.dataobject.GlslGeometryShaderDataLoader; +import net.java.nboglpack.glsleditor.dataobject.GlslVertexShaderDataLoader; +import net.java.nboglpack.glsleditor.glsl.Glsl; +import net.java.nboglpack.glsleditor.vocabulary.GLSLElementDescriptor; +import org.netbeans.spi.editor.completion.support.CompletionUtilities; + + +/** + * Completion provider for the OpenGL Shading Language editor. + * + * @author Mathias Henze + * @author Michael Bien + */ +public class GlslCompletionProvider implements CompletionProvider { + + private static final ErrorManager LOGGER = ErrorManager.getDefault().getInstance(GlslCompletionProvider.class.getName()); + + private final String mimeType; + + private GlslCompletionProvider(String mimeType) { + this.mimeType = mimeType; + } + + public CompletionTask createTask(int queryType, JTextComponent component) { + return new AsyncCompletionTask(new GlslCompletionQuery(mimeType), component); + } + + public int getAutoQueryTypes(JTextComponent component, String typedText) { + return 0; + } + + public static GlslCompletionProvider createVSCompletionProvider(){ + return new GlslCompletionProvider(GlslVertexShaderDataLoader.REQUIRED_MIME); + } + + public static GlslCompletionProvider createGSCompletionProvider(){ + return new GlslCompletionProvider(GlslGeometryShaderDataLoader.REQUIRED_MIME); + } + + public static GlslCompletionProvider createFSCompletionProvider(){ + return new GlslCompletionProvider(GlslFragmentShaderDataLoader.REQUIRED_MIME); + } + + + private static class GlslCompletionQuery extends AsyncCompletionQuery { + + private GlslVocabularyManager vocabulary; + + public GlslCompletionQuery(String mimetype) { + vocabulary = GlslVocabularyManager.getInstance(mimetype); + } + + protected void query(CompletionResultSet completionResultSet, Document document, int pos) { + + fillResultset(completionResultSet, document, pos); + completionResultSet.finish(); + } + + private void fillResultset(CompletionResultSet completionResultSet, Document doc, int pos) { + + Element paragraph = ((BaseDocument) doc).getParagraphElement(pos); + String prefix; + try { + prefix = doc.getText(paragraph.getStartOffset(), pos - paragraph.getStartOffset()); + // daf�r sorgen, dass wir in den meisten f�llen einen korrekten prefix haben + // TODO: besser machen, ist ne hau-ruck-methode + // problem: bei leerzeichen in strings werden auch dort funktoren als autocomplete angeboten... + prefix = prefix.replaceAll(".*?([\\w-\"]*)$", "$1"); + } catch (BadLocationException e) { + LOGGER.notify(e); + prefix = ""; + } + + // add user declared functions first + synchronized(Glsl.declaredFunctions) { + Set> entrySet = Glsl.declaredFunctions.entrySet(); + + for (Entry entry : entrySet) { + + String name = entry.getKey(); + GLSLElementDescriptor desc = entry.getValue(); + + if (name.regionMatches(true, 0, prefix, 0, prefix.length())) { + completionResultSet.addItem(new GlslCompletionItem(name.substring(0, name.indexOf('(')), desc, prefix, pos)); + } + } + } + + + // add core GLSL completion items + Iterator it = vocabulary.getKeys().iterator(); + + while (it.hasNext()) { + + String name = (String) it.next(); + + if (name.regionMatches(true, 0, prefix, 0, prefix.length())) { + + GLSLElementDescriptor[] elements = vocabulary.getDesc(name); + + if (elements != null) { + for (GLSLElementDescriptor element : elements) + completionResultSet.addItem(new GlslCompletionItem(name, element, prefix, pos)); + } + } + + } + } + } + + private static class GlslCompletionItem implements CompletionItem { + + private String key; + private GLSLElementDescriptor content; + private int carretPosition = 0; + private String prefix; + + private String leftText; + private String rightText; + + private String ARGUMENTS_COLOR = ""; + private String BUILD_IN_VAR_COLOR = ""; + private String KEYWORD_COLOR = ""; + + private int priority; + + public GlslCompletionItem(String key, GLSLElementDescriptor content, String prefix, int carretPosition) { + + this.key = key; + this.content = content; + this.prefix = prefix; + this.carretPosition = carretPosition; + + leftText = createLeftText(); + rightText = content.type; + + // low prority is first in completion list + switch (content.category) { + case TYPE: + priority = 10; + break; + case JUMP: + priority = 9; + break; + case SELECTION: + priority = 8; + break; + case ITERATION: + priority = 7; + break; + case KEYWORD: + priority = 6; + break; + case QUALIFIER: + priority = 5; + break; + case BUILD_IN_FUNC: + priority = 4; + break; + case BUILD_IN_VAR: + priority = 3; + break; + } + } + + private String createLeftText() { + + StringBuilder text = new StringBuilder(); + + switch (content.category) { + case TYPE: + case JUMP: + case SELECTION: + case ITERATION: + case KEYWORD: + case QUALIFIER: + text.append(KEYWORD_COLOR); + break; + case BUILD_IN_VAR: + text.append(BUILD_IN_VAR_COLOR); + break; + } + + text.append(""); + text.append(key); + text.append(""); + + if (content.arguments != null) { + text.append(ARGUMENTS_COLOR); + text.append(content.arguments); + text.append(""); + } + return text.toString(); + } + + public void defaultAction(JTextComponent component) { + Completion.get().hideAll(); + // replace prefix with key + try { + component.getDocument().remove(carretPosition-prefix.length(), prefix.length()); + component.getDocument().insertString(carretPosition-prefix.length(), key, null); + } catch (BadLocationException e) { + LOGGER.notify(e); + } + } + + public void processKeyEvent(KeyEvent evt) { + // TODO: if "." then Completion.get().showCompletion() + } + + public int getPreferredWidth(Graphics g, Font defaultFont) { + return CompletionUtilities.getPreferredWidth(leftText, rightText, g, defaultFont); + } + + public void render(Graphics g, Font defaultFont, Color defaultColor, Color backgroundColor, int width, int height, boolean selected) { + + CompletionUtilities.renderHtml(null, leftText, rightText, g, defaultFont, defaultColor, width, height, selected); + + } + + public CompletionTask createDocumentationTask() { + + if (content.doc == null) { + return null; + } + + return new AsyncCompletionTask(new AsyncCompletionQuery() { + private GlslDocItem item = new GlslDocItem(key, content); + + protected void query(CompletionResultSet completionResultSet, Document document, int i) { + completionResultSet.setDocumentation(item); + completionResultSet.finish(); + } + }); + } + + public CompletionTask createToolTipTask() { + return null; + } + + public boolean instantSubstitution(JTextComponent component) { + defaultAction(component); + return true; + } + + public int getSortPriority() { + return priority; + } + + public CharSequence getSortText() { + return key; + } + + public CharSequence getInsertPrefix() { + return prefix; + } + } + + private static class GlslDocItem implements CompletionDocumentation { + + private String text; + + public GlslDocItem(String item, GLSLElementDescriptor content) { + + StringBuilder sb = new StringBuilder(); + sb.append(""); + if(content.type != null) { + sb.append(content.type); + sb.append(" "); + } + sb.append(""); + sb.append(item); + sb.append(""); + if(content.arguments != null) { + sb.append(content.arguments); + } + sb.append("

"); + sb.append(content.doc); + sb.append("

"); + + text = sb.toString(); + } + + public String getText() { + return text; + } + + public URL getURL() { + return null; + } + + public CompletionDocumentation resolveLink(String link) { + return null; + } + + public Action getGotoSourceAction() { + return null; + } + } +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslShaderFileObserver.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslShaderFileObserver.java new file mode 100644 index 000000000..2bd30a671 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslShaderFileObserver.java @@ -0,0 +1,65 @@ +package net.java.nboglpack.glsleditor; + +/** + * Created on 26. March 2007, 00:49 + * + */ + +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +//import net.java.nboglpack.glslcompiler.GLSLCompilerService; +import org.openide.loaders.DataObject; +import org.openide.util.Lookup; +import org.openide.util.RequestProcessor; + +/** + * Observes an DataObject for document updates and starts compilation automatically. + * @author Michael Bien + */ +public class GlslShaderFileObserver implements DocumentListener { + + private final DataObject observedDao; + private final static RequestProcessor RP = new RequestProcessor("compiler"); + private final RequestProcessor.Task compilerTask; + private boolean runOnDocUpdate = true; + private int compileDelay = 500; + + public GlslShaderFileObserver(DataObject dao) { + observedDao = dao; + + compilerTask = RP.create(new Runnable() { + public void run() { +// GLSLCompilerService compiler = Lookup.getDefault().lookup(GLSLCompilerService.class); +// compiler.compileShader(new DataObject[] {observedDao}, false); + } + }); + compilerTask.setPriority(Thread.MIN_PRIORITY); + } + + + // DocumentListener + public void insertUpdate(DocumentEvent arg0) { + if(runOnDocUpdate) + runCompileTask(); + } + public void removeUpdate(DocumentEvent arg0) { + if(runOnDocUpdate) + runCompileTask(); + } + public void changedUpdate(DocumentEvent arg0) { + } + + + public final void runCompileTask() { + compilerTask.schedule(compileDelay); + } + + public void setCompileDelay(int compileDelay) { + this.compileDelay = compileDelay; + } + + public void setRunOnDocUpdate(boolean runOnDocUpdate) { + this.runOnDocUpdate = runOnDocUpdate; + } + +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslVocabularyManager.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslVocabularyManager.java new file mode 100644 index 000000000..98078f36e --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslVocabularyManager.java @@ -0,0 +1,172 @@ +/* + * GlslVocabularyManager.java + * + * Created on 12. Februar 2006, 03:37 + * + */ + +package net.java.nboglpack.glsleditor; + +import java.io.InputStream; +import java.util.AbstractSet; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Unmarshaller; +import net.java.nboglpack.glsleditor.dataobject.GlslFragmentShaderDataLoader; +import net.java.nboglpack.glsleditor.dataobject.GlslGeometryShaderDataLoader; +import net.java.nboglpack.glsleditor.dataobject.GlslVertexShaderDataLoader; +import net.java.nboglpack.glsleditor.vocabulary.GLSLElementDescriptor; +import net.java.nboglpack.glsleditor.vocabulary.GLSLVocabulary; +import org.openide.ErrorManager; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; + +/** + * + * @author mhenze + * @author Michael Bien + */ +public class GlslVocabularyManager { + + private static final ErrorManager LOGGER = ErrorManager.getDefault().getInstance(GlslVocabularyManager.class.getName()); + private static final HashMap instances = new HashMap(); + private static GLSLVocabulary vocabulary = null; + + private final String mimetype; + private final Set keySet; + private final Map vocabularyExtention; + + /** Creates a new instance of GlslVocabularyManager */ + private GlslVocabularyManager(String mimetype) { + + if( !mimetype.equals(GlslFragmentShaderDataLoader.REQUIRED_MIME) + && !mimetype.equals(GlslVertexShaderDataLoader.REQUIRED_MIME) + && !mimetype.equals(GlslGeometryShaderDataLoader.REQUIRED_MIME)) { + throw new IllegalArgumentException(mimetype+" is no GLSL mime type"); + } + + + this.mimetype = mimetype; + + if(vocabulary == null) + loadVocabulary(); + + if(mimetype.equals(GlslFragmentShaderDataLoader.REQUIRED_MIME)) { + vocabularyExtention = vocabulary.fragmentShaderVocabulary; + }else if(mimetype.equals(GlslVertexShaderDataLoader.REQUIRED_MIME)) { + vocabularyExtention = vocabulary.vertexShaderVocabulary; + }else { + vocabularyExtention = vocabulary.geometryShaderVocabulary; + } + + // merges two views + keySet = new AbstractSet() { + + private final Set mainSet = vocabulary.mainVocabulary.keySet(); + private final Set extSet = vocabularyExtention.keySet(); + + + public Iterator iterator() { + return new Iterator(){ + + Iterator mainIt = mainSet.iterator(); + Iterator extIt = extSet.iterator(); + + public boolean hasNext() { + return mainIt.hasNext() || extIt.hasNext(); + } + + public String next() { + if(mainIt.hasNext()) + return mainIt.next(); + else + return extIt.next(); + } + + public void remove() { + throw new UnsupportedOperationException("Not supported yet."); + } + + }; + } + + public int size() { + return mainSet.size()+extSet.size(); + } + + }; + + } + + public static GlslVocabularyManager getInstance(String mimetype) { + + GlslVocabularyManager instance = instances.get(mimetype); + + if(instance == null) { + instance = new GlslVocabularyManager(mimetype); + instances.put(mimetype,instance); + } + + return instance; + } + + private void loadVocabulary() { + + FileObject vocabularyfile = FileUtil.getConfigFile("Editors/"+mimetype+"/vocabulary.xml"); + + if (vocabularyfile != null) { + + InputStream is = null; + + try { + + is = vocabularyfile.getInputStream(); + + // workaround; nb does not allow usage of jdk's jaxb implementation + // => we have to provide JAXB as library wrapper module and load it via module classloader + JAXBContext jc = JAXBContext.newInstance("net.java.nboglpack.glsleditor.vocabulary", this.getClass().getClassLoader()); + + Unmarshaller unmarshaller = jc.createUnmarshaller(); + vocabulary = (GLSLVocabulary)unmarshaller.unmarshal(is); + + } catch (Exception ex) { + + // create empty vocab + vocabulary = new GLSLVocabulary(); + LOGGER.notify(ex); + + } finally { + + if(is != null) { + try { + is.close(); + } catch (Exception e) { + LOGGER.notify(e); + } + } + + } + + } + + } + + public Set getKeys() { + return keySet; + } + + public GLSLElementDescriptor[] getDesc(String key) { + + GLSLElementDescriptor[] desc = vocabulary.mainVocabulary.get(key); + + if(desc == null) + desc = vocabularyExtention.get(key); + + return desc; + } + + +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/Bundle.properties b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/Bundle.properties new file mode 100644 index 000000000..c5e2ea05a --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/Bundle.properties @@ -0,0 +1,11 @@ +Services/MIMEResolver/GlslVertexShaderResolver.xml=GLSL Vertex Shader Files +Services/MIMEResolver/GlslFragmentShaderResolver.xml=GLSL Fragment Shader Files +Services/MIMEResolver/GlslGeometryShaderResolver.xml=GLSL Geometry Shader Files + +Templates/OpenGL/VertexShader.vert=GLSL Vertex Shader File +Templates/OpenGL/FragmentShader.frag=GLSL Fragment Shader File +Templates/OpenGL/GeometryShader.geom=GLSL Geometry Shader File + +LBL_glsl_vertex_shader_loader_name=GLSL Vertex Shader Files +LBL_glsl_fragment_shader_loader_name=GLSL Fragment Shader Files +LBL_glsl_geometry_shader_loader_name=GLSL Geometry Shader Files diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataLoader.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataLoader.java new file mode 100644 index 000000000..45bbae64a --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataLoader.java @@ -0,0 +1,40 @@ +package net.java.nboglpack.glsleditor.dataobject; + +import java.io.IOException; +import org.openide.filesystems.FileObject; +import org.openide.loaders.DataObjectExistsException; +import org.openide.loaders.MultiDataObject; +import org.openide.loaders.UniFileLoader; +import org.openide.util.NbBundle; + +public class GlslFragmentShaderDataLoader extends UniFileLoader { + + public static final String REQUIRED_MIME = "text/x-glsl-fragment-shader"; + + private static final long serialVersionUID = 1L; + + public GlslFragmentShaderDataLoader() { + super("net.java.nboglpack.glsleditor.dataobject.GlslFragmentShaderDataObject"); + } + + @Override + protected String defaultDisplayName() { + return NbBundle.getMessage(GlslFragmentShaderDataLoader.class, "LBL_glsl_fragment_shader_loader_name"); + } + + @Override + protected void initialize() { + super.initialize(); + getExtensions().addMimeType(REQUIRED_MIME); + } + + protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException { + return new GlslFragmentShaderDataObject(primaryFile, this); + } + + @Override + protected String actionsContext() { + return "Loaders/" + REQUIRED_MIME + "/Actions"; + } + +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataLoaderBeanInfo.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataLoaderBeanInfo.java new file mode 100644 index 000000000..1484e3065 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataLoaderBeanInfo.java @@ -0,0 +1,32 @@ +package net.java.nboglpack.glsleditor.dataobject; + +import java.awt.Image; +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.SimpleBeanInfo; +import org.openide.loaders.UniFileLoader; +import org.openide.util.ImageUtilities; + +public class GlslFragmentShaderDataLoaderBeanInfo extends SimpleBeanInfo { + + public static final String IMAGE_ICON_BASE = "net/java/nboglpack/glsleditor/resources/FragmentShaderIcon.gif"; + + @Override + public BeanInfo[] getAdditionalBeanInfo() { + try { + return new BeanInfo[]{Introspector.getBeanInfo(UniFileLoader.class)}; + } catch (IntrospectionException e) { + throw new AssertionError(e); + } + } + + @Override + public Image getIcon(int type) { + if (type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16) { + return ImageUtilities.loadImage(IMAGE_ICON_BASE); + } else { + return null; + } + } +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataNode.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataNode.java new file mode 100644 index 000000000..7b65c9f10 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataNode.java @@ -0,0 +1,24 @@ +package net.java.nboglpack.glsleditor.dataobject; + +import org.openide.loaders.DataNode; +import org.openide.nodes.Children; + +public class GlslFragmentShaderDataNode extends DataNode +{ + public GlslFragmentShaderDataNode(GlslFragmentShaderDataObject obj) + { + super(obj, Children.LEAF); + setIconBaseWithExtension(GlslFragmentShaderDataLoaderBeanInfo.IMAGE_ICON_BASE); + } +// /** Creates a property sheet. */ +// protected Sheet createSheet() { +// Sheet s = super.createSheet(); +// Sheet.Set ss = s.get(Sheet.PROPERTIES); +// if (ss == null) { +// ss = Sheet.createPropertiesSet(); +// s.put(ss); +// } +// // TODO add some relevant properties: ss.put(...) +// return s; +// } +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataObject.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataObject.java new file mode 100644 index 000000000..01bff6b0e --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataObject.java @@ -0,0 +1,57 @@ +package net.java.nboglpack.glsleditor.dataobject; + +import net.java.nboglpack.glsleditor.GlslShaderFileObserver; +import java.beans.PropertyChangeEvent; +import java.io.IOException; +import java.beans.PropertyChangeListener; +import javax.swing.text.Document; +import org.openide.filesystems.FileObject; +import org.openide.loaders.DataObjectExistsException; +import org.openide.loaders.MultiDataObject; +import org.openide.nodes.CookieSet; +import org.openide.nodes.Node; +import org.openide.text.CloneableEditorSupport; +import org.openide.text.DataEditorSupport; + + + +public class GlslFragmentShaderDataObject extends MultiDataObject { + + private final GlslShaderFileObserver observer; + + public GlslFragmentShaderDataObject(FileObject pf, GlslFragmentShaderDataLoader loader) throws DataObjectExistsException, IOException { + + super(pf, loader); + + CookieSet cookies = getCookieSet(); + observer= new GlslShaderFileObserver(this); + + final CloneableEditorSupport support= DataEditorSupport.create(this, getPrimaryEntry(), cookies); + support.addPropertyChangeListener( + new PropertyChangeListener(){ + public void propertyChange(PropertyChangeEvent event) { + if("document".equals(event.getPropertyName())){ + if(event.getNewValue()!=null) + { + support.getDocument().addDocumentListener(observer); + observer.runCompileTask(); + } + else if(event.getOldValue()!=null) + { + // cylab: I think this is never called. + // But I don't know if unregistering the observer makes any difference... + ((Document)event.getOldValue()).removeDocumentListener(observer); + } + } + } + } + ); + cookies.add((Node.Cookie) support); + } + + @Override + protected Node createNodeDelegate() { + return new GlslFragmentShaderDataNode(this); + } + +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataLoader.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataLoader.java new file mode 100644 index 000000000..6b98e854a --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataLoader.java @@ -0,0 +1,44 @@ +package net.java.nboglpack.glsleditor.dataobject; + +import java.io.IOException; +import org.openide.filesystems.FileObject; +import org.openide.loaders.DataObjectExistsException; +import org.openide.loaders.MultiDataObject; +import org.openide.loaders.UniFileLoader; +import org.openide.util.NbBundle; + + +/** + * @author Michael Bien + */ +public class GlslGeometryShaderDataLoader extends UniFileLoader { + + public static final String REQUIRED_MIME = "text/x-glsl-geometry-shader"; + + private static final long serialVersionUID = 1L; + + public GlslGeometryShaderDataLoader() { + super("net.java.nboglpack.glsleditor.dataobject.GlslGeometryShaderDataObject"); + } + + @Override + protected String defaultDisplayName() { + return NbBundle.getMessage(GlslGeometryShaderDataLoader.class, "LBL_glsl_geometry_shader_loader_name"); + } + + @Override + protected void initialize() { + super.initialize(); + getExtensions().addMimeType(REQUIRED_MIME); + } + + protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException { + return new GlslGeometryShaderDataObject(primaryFile, this); + } + + @Override + protected String actionsContext() { + return "Loaders/" + REQUIRED_MIME + "/Actions"; + } + +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataLoaderBeanInfo.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataLoaderBeanInfo.java new file mode 100644 index 000000000..708b47a63 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataLoaderBeanInfo.java @@ -0,0 +1,37 @@ +package net.java.nboglpack.glsleditor.dataobject; + +import java.awt.Image; +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.SimpleBeanInfo; +import org.openide.loaders.UniFileLoader; +import org.openide.util.ImageUtilities; + + +/** + * @author Michael Bien + */ +public class GlslGeometryShaderDataLoaderBeanInfo extends SimpleBeanInfo { + + public static final String IMAGE_ICON_BASE = "net/java/nboglpack/glsleditor/resources/GeometryShaderIcon.gif"; + + @Override + public BeanInfo[] getAdditionalBeanInfo() { + try { + return new BeanInfo[] {Introspector.getBeanInfo(UniFileLoader.class)}; + } catch (IntrospectionException e) { + throw new AssertionError(e); + } + } + + @Override + public Image getIcon(int type) { + if (type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16) { + return ImageUtilities.loadImage(IMAGE_ICON_BASE); + } else { + return null; + } + } + +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataNode.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataNode.java new file mode 100644 index 000000000..9706b7b31 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataNode.java @@ -0,0 +1,34 @@ +package net.java.nboglpack.glsleditor.dataobject; + +import org.openide.loaders.DataNode; +import org.openide.nodes.Children; +import org.openide.util.Lookup; + + +/** + * @author Michael Bien + */ +public class GlslGeometryShaderDataNode extends DataNode { + + public GlslGeometryShaderDataNode(GlslGeometryShaderDataObject obj) { + super(obj, Children.LEAF); + setIconBaseWithExtension(GlslGeometryShaderDataLoaderBeanInfo.IMAGE_ICON_BASE); + } + GlslGeometryShaderDataNode(GlslGeometryShaderDataObject obj, Lookup lookup) { + super(obj, Children.LEAF, lookup); + setIconBaseWithExtension(GlslGeometryShaderDataLoaderBeanInfo.IMAGE_ICON_BASE); + } + + // /** Creates a property sheet. */ + // protected Sheet createSheet() { + // Sheet s = super.createSheet(); + // Sheet.Set ss = s.get(Sheet.PROPERTIES); + // if (ss == null) { + // ss = Sheet.createPropertiesSet(); + // s.put(ss); + // } + // // TODO add some relevant properties: ss.put(...) + // return s; + // } + +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataObject.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataObject.java new file mode 100644 index 000000000..15acd890a --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataObject.java @@ -0,0 +1,60 @@ +package net.java.nboglpack.glsleditor.dataobject; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.IOException; +import javax.swing.text.Document; +import net.java.nboglpack.glsleditor.GlslShaderFileObserver; +import org.openide.filesystems.FileObject; +import org.openide.loaders.DataObjectExistsException; +import org.openide.loaders.MultiDataObject; +import org.openide.nodes.CookieSet; +import org.openide.nodes.Node; +import org.openide.text.CloneableEditorSupport; +import org.openide.util.Lookup; +import org.openide.text.DataEditorSupport; + + +/** + * @author Michael Bien + */ +public class GlslGeometryShaderDataObject extends MultiDataObject { + + private GlslShaderFileObserver observer; + + public GlslGeometryShaderDataObject(FileObject pf, GlslGeometryShaderDataLoader loader) throws DataObjectExistsException, IOException { + + super(pf, loader); + + CookieSet cookies = getCookieSet(); + observer = new GlslShaderFileObserver(this); + + final CloneableEditorSupport support = DataEditorSupport.create(this, getPrimaryEntry(), cookies); + support.addPropertyChangeListener(new PropertyChangeListener() { + + public void propertyChange(PropertyChangeEvent event) { + if ("document".equals(event.getPropertyName())) { + if (event.getNewValue() != null) { + support.getDocument().addDocumentListener(observer); + observer.runCompileTask(); + } else if (event.getOldValue() != null) { + // cylab: I think this is never called. + // But I don't know if unregistering the observer makes any difference... + ((Document) event.getOldValue()).removeDocumentListener(observer); + } + } + } + }); + cookies.add((Node.Cookie) support); + } + + @Override + protected Node createNodeDelegate() { + return new GlslGeometryShaderDataNode(this, getLookup()); + } + + @Override + public Lookup getLookup() { + return getCookieSet().getLookup(); + } +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataLoader.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataLoader.java new file mode 100644 index 000000000..252d55539 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataLoader.java @@ -0,0 +1,40 @@ +package net.java.nboglpack.glsleditor.dataobject; + +import java.io.IOException; +import org.openide.filesystems.FileObject; +import org.openide.loaders.DataObjectExistsException; +import org.openide.loaders.MultiDataObject; +import org.openide.loaders.UniFileLoader; +import org.openide.util.NbBundle; + +public class GlslVertexShaderDataLoader extends UniFileLoader { + + public static final String REQUIRED_MIME = "text/x-glsl-vertex-shader"; + + private static final long serialVersionUID = 1L; + + public GlslVertexShaderDataLoader() { + super("net.java.nboglpack.glsleditor.dataobject.GlslVertexShaderDataObject"); + } + + @Override + protected String defaultDisplayName() { + return NbBundle.getMessage(GlslFragmentShaderDataLoader.class, "LBL_glsl_vertex_shader_loader_name"); + } + + @Override + protected void initialize() { + super.initialize(); + getExtensions().addMimeType(REQUIRED_MIME); + } + + protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException { + return new GlslVertexShaderDataObject(primaryFile, this); + } + + @Override + protected String actionsContext() { + return "Loaders/" + REQUIRED_MIME + "/Actions"; + } + +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataLoaderBeanInfo.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataLoaderBeanInfo.java new file mode 100644 index 000000000..959d965bb --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataLoaderBeanInfo.java @@ -0,0 +1,32 @@ +package net.java.nboglpack.glsleditor.dataobject; + +import java.awt.Image; +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.SimpleBeanInfo; +import org.openide.loaders.UniFileLoader; +import org.openide.util.ImageUtilities; + +public class GlslVertexShaderDataLoaderBeanInfo extends SimpleBeanInfo { + + public static final String IMAGE_ICON_BASE = "net/java/nboglpack/glsleditor/resources/VertexShaderIcon.gif"; + + @Override + public BeanInfo[] getAdditionalBeanInfo() { + try { + return new BeanInfo[]{Introspector.getBeanInfo(UniFileLoader.class)}; + } catch (IntrospectionException e) { + throw new AssertionError(e); + } + } + + @Override + public Image getIcon(int type) { + if (type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16) { + return ImageUtilities.loadImage(IMAGE_ICON_BASE); + } else { + return null; + } + } +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataNode.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataNode.java new file mode 100644 index 000000000..25ca7e600 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataNode.java @@ -0,0 +1,24 @@ +package net.java.nboglpack.glsleditor.dataobject; + +import org.openide.loaders.DataNode; +import org.openide.nodes.Children; + +public class GlslVertexShaderDataNode extends DataNode +{ + public GlslVertexShaderDataNode(GlslVertexShaderDataObject obj) + { + super(obj, Children.LEAF); + setIconBaseWithExtension(GlslVertexShaderDataLoaderBeanInfo.IMAGE_ICON_BASE); + } +// /** Creates a property sheet. */ +// protected Sheet createSheet() { +// Sheet s = super.createSheet(); +// Sheet.Set ss = s.get(Sheet.PROPERTIES); +// if (ss == null) { +// ss = Sheet.createPropertiesSet(); +// s.put(ss); +// } +// // TODO add some relevant properties: ss.put(...) +// return s; +// } +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataObject.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataObject.java new file mode 100644 index 000000000..c753284f2 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataObject.java @@ -0,0 +1,54 @@ +package net.java.nboglpack.glsleditor.dataobject; + +import net.java.nboglpack.glsleditor.GlslShaderFileObserver; +import net.java.nboglpack.glsleditor.GlslShaderFileObserver; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.IOException; +import javax.swing.text.Document; +import org.openide.filesystems.FileObject; +import org.openide.loaders.DataObjectExistsException; +import org.openide.loaders.MultiDataObject; +import org.openide.nodes.CookieSet; +import org.openide.nodes.Node; +import org.openide.text.CloneableEditorSupport; +import org.openide.text.DataEditorSupport; + +public class GlslVertexShaderDataObject extends MultiDataObject { + + private GlslShaderFileObserver observer; + + public GlslVertexShaderDataObject(FileObject pf, GlslVertexShaderDataLoader loader) throws DataObjectExistsException, IOException { + + super(pf, loader); + CookieSet cookies = getCookieSet(); + observer= new GlslShaderFileObserver(this); + + final CloneableEditorSupport support= DataEditorSupport.create(this, getPrimaryEntry(), cookies); + support.addPropertyChangeListener( + new PropertyChangeListener(){ + public void propertyChange(PropertyChangeEvent event) { + if("document".equals(event.getPropertyName())){ + if(event.getNewValue()!=null) + { + support.getDocument().addDocumentListener(observer); + observer.runCompileTask(); + } + else if(event.getOldValue()!=null) + { + // cylab: I think this is never called. + // But I don't know if unregistering the observer makes any difference... + ((Document)event.getOldValue()).removeDocumentListener(observer); + } + } + } + } + ); + cookies.add((Node.Cookie) support); + } + + @Override + protected Node createNodeDelegate() { + return new GlslVertexShaderDataNode(this); + } +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/Bundle.properties b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/Bundle.properties new file mode 100644 index 000000000..abf92fabf --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/Bundle.properties @@ -0,0 +1,4 @@ +LBL_SYNTAX_ERROR=Syntax error. +LBL_UNEXPECTED_CHARACTER=Unexpected character. +LBL_RESERVED_KEYWORD=Reserved keyword. + diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/GLSL_120.nbs b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/GLSL_120.nbs new file mode 100644 index 000000000..cd5ca6d2b --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/GLSL_120.nbs @@ -0,0 +1,316 @@ +################################################################################ +# OpenGL Shading Language 1.20 GLF file ######################################## +################################################################################ +# @date 10.09.2007 # +# @author Michael Bien # +# @email mbien@fh-landshut.de # +################################################################################ + +BUNDLE "net.java.nboglpack.glsleditor.glsl.Bundle" + +SKIP:WHITESPACE +SKIP:END_OF_LINE +SKIP:COMMENT +SKIP:ML_COMMENT + +## error highlighting ########################################################## +MARK:ERROR: { + type:"Error"; + message:"LBL_SYNTAX_ERROR"; +} +MARK:error: { + type:"Error"; + message:"LBL_UNEXPECTED_CHARACTER"; +} +MARK:reserved: { + type:"Warning"; + message:"LBL_RESERVED_KEYWORD"; +} + +FOLD:function_body: { + fold_display_name:"{...}"; +} +FOLD:struct_body: { + fold_display_name:"{...}"; +} +FOLD:ML_COMMENT: { + fold_display_name:"/*...*/"; +} + +BRACE "(:)" +BRACE "{:}" +BRACE "[:]" + +COMPLETE "(:)" +COMPLETE "{:}" +COMPLETE "[:]" + +INDENT "(:)" +INDENT "{:}" +INDENT "[:]" +INDENT "\\s*(((if|while)\\s*\\(|else\\s*|else\\s+if\\s*\\(|for\\s*\\(.*\\))[^{;]*)" + +SELECTION ( ["a"-"z" "A"-"Z" "0"-"9" "_"] ) + +NAVIGATOR:global_preprocessor: { + display_name: net.java.nboglpack.glsleditor.glsl.Glsl.createPreprocessorString; + icon: "net/java/nboglpack/glsleditor/resources/preprocessor.png"; + isLeaf: "true"; +} +NAVIGATOR:global_declared_identifier, struct_declarator: { + display_name: net.java.nboglpack.glsleditor.glsl.Glsl.createFieldDeclarationString; + icon: "net/java/nboglpack/glsleditor/resources/field.gif"; + isLeaf: "true"; +} +NAVIGATOR:function: { + display_name: net.java.nboglpack.glsleditor.glsl.Glsl.createFunctionDeclarationString; + icon: "net/java/nboglpack/glsleditor/resources/function.gif"; + isLeaf: "true"; +} +#AST { +# process: net.java.nboglpack.glsleditor.glsl.Glsl.process; +#} +#PROPERTIES { +# traceSteps:"true"; +# printRules:"true"; +# printFirst:"true"; +#} + +##### GLSL 1.2 grammar ######################################################### + +S = declaration*; + + +## constants ################################################################### +type_specifier = "float" + | "int" + | "bool" + | "vec2" + | "vec3" + | "vec4" + | "bvec2" + | "bvec3" + | "bvec4" + | "ivec2" + | "ivec3" + | "ivec4" + | "mat2" + | "mat3" + | "mat4" + | "mat2x2" + | "mat2x3" + | "mat2x4" + | "mat3x2" + | "mat3x3" + | "mat3x4" + | "mat4x2" + | "mat4x3" + | "mat4x4" + | "sampler1D" + | "sampler2D" + | "sampler3D" + | "samplerCube" + | "sampler1DShadow" + | "sampler2DShadow"; + +type_specifier_or_identifier = type_specifier | ; + +type_qualifier = "const"; + +global_type_qualifier = type_qualifier + | "attribute" # Vertex only. + | "varying" + | ("centroid" "varying") + | ("invariant" ["centroid"] "varying") + | "uniform"; + +parameter_declaration_qualifier = "in" | "out" | "inout"; + +boolean_literal = "true" | "false"; # TODO move boolean literal to lexer? + + +assignment_operator = + | + | + | + | + | # reserved + | # reserved + | # reserved + | # reserved + | # reserved + | ; # reserved + +comperator = | | | | | ; + +operator = + | + | + | + | + | + | # reserved + | + | + | # reserved + | # reserved + | # reserved + | ; # reserved + +unary_operator = + | + | + | ; # reserved + +increment_or_decrement_operator = | ; + +reserved = "asm" + | "class" + | "union" + | "enum" + | "typedef" + | "template" + | "this" + | "packed" + | "goto" + | "switch" + | "default" + | "inline" + | "noinline" + | "volatile" + | "public" + | "static" + | "extern" + | "external" + | "interface" + | "long" + | "short" + | "double" + | "half" + | "fixed" + | "unsigned" + | "lowp" + | "mediump" + | "highp" + | "precision" + | "input" + | "output" + | "hvec2" + | "hvec3" + | "hvec4" + | "dvec2" + | "dvec3" + | "dvec4" + | "fvec2" + | "fvec3" + | "fvec4" + | "sampler2DRect" + | "sampler3DRect" + | "sampler2DRectShadow" + | "sizeof" + | "cast" + | "namespace" + | "using"; + + +## declarations ################################################################ +declaration = type_specifier_or_identifier [array_index] (function | (global_identifier_list )); +declaration = "void" function; +declaration = global_type_qualifier struct_declaration ; +declaration = global_type_qualifier global_type_declaration ; +declaration = struct_declaration ; +declaration = global_preprocessor; + +global_identifier_list = global_declared_identifier [array_index] ( global_declared_identifier [array_index])*; +global_declared_identifier = ; +global_preprocessor = ; + +struct_declaration = "struct" struct_body [global_identifier_list]; +struct_body = "{" (local_type_declaration )+ "}"; + +global_type_declaration = type_specifier_or_identifier [array_index] global_identifier_list [ expression]; +type_declaration = type_specifier_or_identifier [array_index] [array_index] ( [array_index])*; + +local_type_declaration = [type_qualifier] type_declaration; + +## function #################################################################### +function = "(" [parameter_declaration_list] ")" (function_body | ); +function_body = code_block; + +parameter_declaration = [type_qualifier] [parameter_declaration_qualifier] type_specifier_or_identifier ((array_index ) | ( [array_index])); +parameter_declaration_list = "void" | (parameter_declaration ( parameter_declaration)*); + +statement = ; +statement = expression_hack ; # statement = local_type_declaration [ expression] ; +statement = conditional_statement; +statement = "return" [expression] ; +statement = "break" ; # break just in loops allowed +statement = "continue" ;# continue just in loops allowed +statement = "discard" ; # Fragment shader only. + +code_block = "{" statement* "}"; + +## expresstions and operations ################################################# +# ternary operator +expression = expression1 ["?" expression1 ":" expression1]; + +expression1 = [unary_operator] expression2 operation_or_comparison*; +expression1 = [unary_operator] "(" expression ")" operation_or_comparison*; + +expression2 = ( [increment_or_decrement_operator] ( | ) (field_access)* [increment_or_decrement_operator] [assignment]) + | ((function_call | constructor_call) (field_access)*) + | + | + | boolean_literal; + + + +expression_hack = unary_operator expression1_hack operation_or_comparison*; +expression_hack = unary_operator "(" expression ")" operation_or_comparison*; +expression_hack = expression1_hack operation_or_comparison*; +expression_hack = "(" expression ")" operation_or_comparison*; + +expression_hack = (field_access)* [increment_or_decrement_operator] [assignment]; +expression_hack = (field_access)* [array_index] ( [array_index])*; +expression_hack = type_specifier (field_access)* [array_index] ( [array_index])*; + +expression1_hack = (increment_or_decrement_operator ( | ) (field_access)* [increment_or_decrement_operator] [assignment]) + | ( (field_access)* [increment_or_decrement_operator] [assignment]) + | ((function_call | constructor_call) (field_access)*) + | + | + | boolean_literal; + + + +assignment = assignment_operator expression; +operation_or_comparison = (comperator | operator) expression; + +field_access = array_index; +field_access = ; + +array_index = "[" [expression] "]"; + +function_call = ( | ) "(" [expression_list] ")"; +# Note constructor call is something like that: vec2(1.0, 2.0) or float[2] (1.0, 2.0) +constructor_call = type_specifier [array_index] "(" [expression_list] ")"; #TODO custom structs + +expression_list = "void" | (expression ( expression)*); + +## code flow ################################################################### +conditional_statement = if_statement + | for_statement + | while_statement + | do_while_statement; + +# TODO if rule not 100% correct, multiple else allowed even before else if +if_statement = "if" condition statement_or_code_block ("else" ["if" condition] statement_or_code_block)*; +while_statement = "while" condition statement_or_code_block; +do_while_statement = "do" statement_or_code_block "while" condition ; +# TODO for rule could be more restrictive +for_statement = "for" "(" [[type_specifier] assignment] [expression] [expression] ")" statement_or_code_block; + +condition = "(" expression ")"; +statement_or_code_block = (statement | code_block); + + diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/GLSL_130.nbs b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/GLSL_130.nbs new file mode 100644 index 000000000..120c4b19f --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/GLSL_130.nbs @@ -0,0 +1,389 @@ +################################################################################ +# OpenGL Shading Language 1.30 GLF file ######################################## +################################################################################ +# @date 10.09.2007 # +# @author Michael Bien # +# @email mbien@fh-landshut.de # +################################################################################ + +BUNDLE "net.java.nboglpack.glsleditor.glsl.Bundle" + +SKIP:WHITESPACE +SKIP:END_OF_LINE +SKIP:COMMENT +SKIP:ML_COMMENT + +## error highlighting ########################################################## +MARK:ERROR: { + type:"Error"; + message:"LBL_SYNTAX_ERROR"; +} +MARK:error: { + type:"Error"; + message:"LBL_UNEXPECTED_CHARACTER"; +} +MARK:reserved: { + type:"Warning"; + message:"LBL_RESERVED_KEYWORD"; +} + +FOLD:function_body: { + fold_display_name:"{...}"; +} +FOLD:struct_body: { + fold_display_name:"{...}"; +} +FOLD:ML_COMMENT: { + fold_display_name:"/*...*/"; +} + +BRACE "(:)" +BRACE "{:}" +BRACE "[:]" + +COMPLETE "(:)" +COMPLETE "{:}" +COMPLETE "[:]" + +INDENT "(:)" +INDENT "{:}" +INDENT "[:]" +INDENT "\\s*(((if|while)\\s*\\(|else\\s*|else\\s+if\\s*\\(|for\\s*\\(.*\\))[^{;]*)" + +SELECTION ( ["a"-"z" "A"-"Z" "0"-"9" "_"] ) + +AST { + process: net.java.nboglpack.glsleditor.glsl.Glsl.process; +} +NAVIGATOR:global_preprocessor: { + display_name: net.java.nboglpack.glsleditor.glsl.Glsl.createPreprocessorString; + icon: "net/java/nboglpack/glsleditor/resources/preprocessor.png"; + isLeaf: "true"; +} +NAVIGATOR:global_declared_identifier: { + display_name: net.java.nboglpack.glsleditor.glsl.Glsl.createFieldDeclarationString; + icon: "net/java/nboglpack/glsleditor/resources/field.gif"; + isLeaf: "true"; +} +NAVIGATOR:function: { + display_name: net.java.nboglpack.glsleditor.glsl.Glsl.createFunctionDeclarationString; + icon: "net/java/nboglpack/glsleditor/resources/function.gif"; + isLeaf: "true"; +} +#PROPERTIES { +# traceSteps:"true"; +# printRules:"true"; +# printFirst:"true"; +#} + +##### GLSL 1.3 grammar ######################################################### + +S = declaration*; + + +## constants ################################################################### +type_specifier = "float" + | "int" + | "uint" + | "bool" + | "vec2" + | "vec3" + | "vec4" + | "bvec2" + | "bvec3" + | "bvec4" + | "ivec2" + | "ivec3" + | "ivec4" + | "uvec2" + | "uvec3" + | "uvec4" + | "mat2" + | "mat3" + | "mat4" + | "mat2x2" + | "mat2x3" + | "mat2x4" + | "mat3x2" + | "mat3x3" + | "mat3x4" + | "mat4x2" + | "mat4x3" + | "mat4x4" + | "sampler1D" + | "sampler2D" + | "sampler3D" + | "samplerCube" + | "sampler1DShadow" + | "sampler2DShadow" + | "sampler1DArray" + | "sampler2DArray" + | "sampler1DArrayShadow" + | "sampler2DArrayShadow" + | "isampler1D" + | "isampler2D" + | "isampler3D" + | "isamplerCube" + | "isampler1DArray" + | "isampler2DArray" + | "usampler1D" + | "usampler2D" + | "usampler3D" + | "usamplerCube" + | "usampler1DArray" + | "usampler2DArray"; + +type_specifier_or_identifier = type_specifier | ; + +type_qualifier = "const"; + +interpolation_type_qualifier = "smooth" + | "flat" + | "noperspective"; + +inout_type_qualifier = "in" | "out"; + +global_type_qualifier = type_qualifier + | (inout_type_qualifier ["invariant"] ["centroid"]) + | (interpolation_type_qualifier ["invariant"] ["centroid"] [inout_type_qualifier]) + | ("centroid" [interpolation_type_qualifier] [inout_type_qualifier]) + | ("invariant" ["centroid"] [inout_type_qualifier]) + | "attribute" # Vertex only. + | "varying" + | ("centroid" "varying") + | ("invariant" ["centroid"] "varying") + | "uniform"; + +parameter_declaration_qualifier = "in" | "out" | "inout"; + +boolean_literal = "true" | "false"; # TODO move boolean literal to lexer? + +precision_qualifier = "highp" + | "mediump" + | "lowp"; + +assignment_operator = + | + | + | + | + | # reserved + | # reserved + | # reserved + | # reserved + | # reserved + | ; # reserved + +comperator = | | | | | ; + +operator = + | + | + | + | + | + | # reserved + | + | + | # reserved + | # reserved + | # reserved + | ; # reserved + +unary_operator = + | + | + | ; # reserved + +increment_or_decrement_operator = | ; + +reserved = "asm" + | "common" + | "partition" + | "active" + | "class" + | "union" + | "enum" + | "typedef" + | "template" + | "this" + | "packed" + | "goto" + | "inline" + | "noinline" + | "volatile" + | "public" + | "static" + | "extern" + | "external" + | "interface" + | "long" + | "short" + | "double" + | "half" + | "fixed" + | "unsigned" + | "superp" + | "input" + | "output" + | "hvec2" + | "hvec3" + | "hvec4" + | "dvec2" + | "dvec3" + | "dvec4" + | "fvec2" + | "fvec3" + | "fvec4" + | "sampler2DRect" + | "sampler3DRect" + | "sampler2DRectShadow" + | "samplerBuffer" + | "filter" + | "image1D" + | "image2D" + | "image3D" + | "imageCube" + | "iimage1D" + | "iimage2D" + | "iimage3D" + | "iimageCube" + | "uimage1D" + | "uimage2D" + | "uimage3D" + | "uimageCube" + | "image1DArray" + | "image2DArray" + | "iimage1DArray" + | "iimage2DArray" + | "uimage1DArray" + | "uimage2DArray" + | "image1DShadow" + | "image2DShadow" + | "image1DArrayShadow" + | "image2DArrayShadow" + | "imageBuffer" + | "iimageBuffer" + | "uimageBuffer" + | "sizeof" + | "cast" + | "namespace" + | "using" + | "row_major"; + + +## declarations ################################################################ +declaration = [precision_qualifier] type_specifier_or_identifier [array_index] (function | (global_identifier_list [assignment2] )); +declaration = "void" function; +declaration = field_declaration ; +declaration = struct_declaration ; +declaration = precision_declaration ; +declaration = global_preprocessor; + +global_identifier_list = global_declared_identifier [array_index] ( global_declared_identifier [array_index])*; +global_declared_identifier = ; +global_preprocessor = ; + +field_declaration = global_type_qualifier struct_declaration; +field_declaration = global_type_qualifier global_type_declaration [assignment2]; + +struct_declaration = "struct" struct_body [global_identifier_list]; +struct_body = "{" (local_type_declaration )+ "}"; + +global_type_declaration = [precision_qualifier] type_specifier_or_identifier [array_index] global_identifier_list [ expression]; +type_declaration = [precision_qualifier] type_specifier_or_identifier [array_index] [array_index] ( [array_index])*; + +local_type_declaration = [type_qualifier] type_declaration; + +precision_declaration = "precision" precision_qualifier type_specifier; + +## function #################################################################### +function = "(" [parameter_declaration_list] ")" (function_body | ); +function_body = code_block; + +parameter_declaration = [type_qualifier] [parameter_declaration_qualifier] [precision_qualifier] type_specifier_or_identifier ((array_index ) | ( [array_index])); +parameter_declaration_list = "void" | (parameter_declaration ( parameter_declaration)*); + +statement = ; +statement = expression_hack ; # statement = local_type_declaration [ expression] ; +statement = conditional_statement; +statement = "return" [expression] ; +statement = "break" ; # break just in loops allowed +statement = "continue" ;# continue just in loops allowed +statement = "discard" ; # Fragment shader only. + +code_block = "{" code_block* "}"; +code_block = "{" statement* "}"; + +## expresstions and operations ################################################# +# ternary operator +expression = expression1 ["?" expression1 ":" expression1]; + +expression1 = [unary_operator] expression2 operation_or_comparison*; +expression1 = [unary_operator] "(" expression ")" operation_or_comparison*; + +expression2 = ( [increment_or_decrement_operator] ( | ) (field_access)* [increment_or_decrement_operator] [assignment]) + | ((function_call | constructor_call) (field_access)*) + | + | + | boolean_literal; + + + +expression_hack = unary_operator expression1_hack operation_or_comparison*; +expression_hack = unary_operator "(" expression ")" operation_or_comparison*; +expression_hack = expression1_hack operation_or_comparison*; +expression_hack = "(" expression ")" operation_or_comparison*; + +expression_hack = (field_access)* [increment_or_decrement_operator] [assignment]; +expression_hack = (field_access)* [array_index] ( [array_index])*; +expression_hack = type_specifier (field_access)* [array_index] ( [array_index])*; + +expression1_hack = (increment_or_decrement_operator ( | ) (field_access)* [increment_or_decrement_operator] [assignment]) + | ( (field_access)* [increment_or_decrement_operator] [assignment]) + | ((function_call | constructor_call) (field_access)*) + | + | + | boolean_literal; + + + +assignment = assignment_operator expression; +assignment2 = expression; +operation_or_comparison = (comperator | operator) expression; + +field_access = array_index; +field_access = ; + +array_index = "[" [expression] "]"; + +function_call = ( | ) "(" [expression_list] ")"; +# Note constructor call is something like that: vec2(1.0, 2.0) or float[2] (1.0, 2.0) +constructor_call = type_specifier [array_index] "(" [expression_list] ")"; #TODO custom structs + +expression_list = "void" | (expression ( expression)*); + +## code flow ################################################################### +conditional_statement = if_statement + | for_statement + | while_statement + | do_while_statement + | switch_statement; + +# TODO if rule not 100% correct, multiple else allowed even before else if +if_statement = "if" condition statement_or_code_block ("else" ["if" condition] statement_or_code_block)*; + +while_statement = "while" condition statement_or_code_block; +do_while_statement = "do" statement_or_code_block "while" condition ; + +# TODO for rule could be more restrictive +for_statement = "for" "(" [[type_specifier] assignment] [expression] [expression] ")" statement_or_code_block; + +switch_statement = "switch" condition "{" case* "}"; +case = ("case" expression ":" statement*) + | ("default" ":" statement*); + +condition = "(" expression ")"; +statement_or_code_block = (statement | code_block); + + diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/Glsl.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/Glsl.java new file mode 100644 index 000000000..3d0b1344f --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/Glsl.java @@ -0,0 +1,361 @@ +/* + * Glsl.java + * + * Created on 24.09.2007, 00:46:53 + * + */ + +package net.java.nboglpack.glsleditor.glsl; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.swing.text.AbstractDocument; +import net.java.nboglpack.glsleditor.lexer.GlslTokenId; +import net.java.nboglpack.glsleditor.vocabulary.GLSLElementDescriptor; +import org.netbeans.api.languages.ASTItem; +import org.netbeans.api.languages.ASTNode; +import org.netbeans.api.languages.ASTToken; +import org.netbeans.api.languages.SyntaxContext; +import org.netbeans.api.lexer.Token; +import org.netbeans.api.lexer.TokenHierarchy; +import org.netbeans.api.lexer.TokenSequence; +import org.netbeans.api.lexer.TokenUtilities; + +/** + * Utility methods called from GLSL.nbs. + * @author Michael Bien + */ +public final class Glsl { + + private final static String KEYWORD_FONT_COLOR = ""; + + public final static Map declaredFunctions = new HashMap(); + + private Glsl() {} + + /** + * Assembles a human readable String containing the declaraton of a function. + * Asumes that the current token of the SyntaxContext represents the function name. + */ + public static final String createFunctionDeclarationString(SyntaxContext context) { + + AbstractDocument document = (AbstractDocument)context.getDocument(); + + StringBuilder sb = new StringBuilder(); + + try { + + document.readLock(); + + TokenSequence sequence = TokenHierarchy.get(context.getDocument()).tokenSequence(); + sequence.move(context.getOffset()); + sequence.moveNext(); + + sb.append(""); + + int moved = 0; + while(sequence.movePrevious() && isIgnoredToken(sequence.token())) + moved++; + + String type = sequence.token().toString(); + while(moved-- >= 0) + sequence.moveNext(); + + // append function name + sb.append(sequence.token().text()); + + while(!TokenUtilities.equals(sequence.token().text(), "(")) + sequence.moveNext(); + + sb.append("("); + + Token token; + boolean first = true; + while(sequence.moveNext() && !TokenUtilities.equals(sequence.token().text(), ")")) { + + token = sequence.token(); + + if(!isIgnoredToken(token)) { + + if(first) { + sb.append(KEYWORD_FONT_COLOR); + }else if(token.id() != GlslTokenId.COMMA && token.id() != GlslTokenId.BRACKET && token.id() != GlslTokenId.INTEGER_LITERAL) { + sb.append(" "); + } + + if(!TokenUtilities.equals(token.text(), "void")) { + + moved = 0; + while(sequence.moveNext() && isIgnoredToken(sequence.token())) + moved++; + + if(sequence.token().id() == GlslTokenId.COMMA || TokenUtilities.equals(sequence.token().text(), ")")) + sb.append(""); + + while(moved-- >= 0) + sequence.movePrevious(); + + sb.append(token.text()); + + if(token.id() == GlslTokenId.COMMA) + sb.append(KEYWORD_FONT_COLOR); + } + + first = false; + } + + } + + sb.append("
)"); + + if(!"void".equals(type)) { + sb.append(" : "); + sb.append(KEYWORD_FONT_COLOR); + sb.append(type); + sb.append(""); + } + sb.append(""); + + } finally { + document.readUnlock(); + } + + return sb.toString(); + } + + /** + * Assambles a human readable String containing the declaraton of a field and the field name itself. + * Asumes that the current token of the SyntaxContext represents the field name. + */ + public static final String createFieldDeclarationString(SyntaxContext context) { + + AbstractDocument document = (AbstractDocument)context.getDocument(); + + StringBuilder sb = new StringBuilder(); + + try { + + document.readLock(); + + TokenSequence sequence = TokenHierarchy.get(context.getDocument()).tokenSequence(); + sequence.move(context.getOffset()); + sequence.moveNext(); + + sb.append(""); + sb.append(sequence.token().text()); + sb.append(KEYWORD_FONT_COLOR); + sb.append(" :"); + + int insertIndex = sb.length(); + + // read forward + int moved = 0; + Token token; + while( sequence.moveNext() + && sequence.token().id() != GlslTokenId.SEMICOLON + && sequence.token().id() != GlslTokenId.COMMA + && sequence.token().id() != GlslTokenId.EQ ) { + token = sequence.token(); + if(!isIgnoredToken(token)) + sb.append(token); + moved++; + } + while(moved-- >= 0) + sequence.movePrevious(); + + // read backwards throw the declaration + boolean skipToken = false; + + while( sequence.movePrevious() + && sequence.token().id() != GlslTokenId.SEMICOLON + && sequence.token().id() != GlslTokenId.END_OF_LINE ) { + + token = sequence.token(); + + if(!isIgnoredToken(token)) { + + // we have a struct declaration; skip everything between { } + if(token.id() == GlslTokenId.BRACE && TokenUtilities.equals(token.text(), "}")) { + movePreviousUntil(sequence, GlslTokenId.BRACE, "}", "{"); + continue; + } + + // skip token in case of an comma seperated identifier list + if(skipToken) { + if( token.id() == GlslTokenId.BRACKET + && TokenUtilities.equals(token.text(), "]") ) { + movePreviousUntil(sequence, GlslTokenId.BRACKET, "]", "["); + skipToken = false; + }else { + skipToken = false; + } + continue; + } + + if(token.id() == GlslTokenId.COMMA) { + skipToken = true; + continue; + } + + if(!TokenUtilities.equals(token.text(), "struct")) { + sb.insert(insertIndex, token.text()); + sb.insert(insertIndex, " "); + } + } + + } + + sb.append(""); + } finally { + document.readUnlock(); + } + + + return sb.toString(); + } + + + public static final String createPreprocessorString(SyntaxContext context) { + + ASTNode node = (ASTNode)context.getASTPath().getLeaf(); + List children = node.getChildren(); + + String str = null; + + for (ASTItem item : children) + if (isTokenType(item, GlslTokenId.PREPROCESSOR.name())) + str = ((ASTToken)item).getIdentifier(); + + + for(int i = 0; i < str.length(); i++) { + + char c = str.charAt(i); + + if(c != '#' && !Character.isWhitespace(c)) + for(int j = str.length()-1; j > i; j--) + if(!Character.isWhitespace(str.charAt(j))) + return str.substring(i, j+1); + + } + + return str; + } + + /** + * called from withen GLSL_*.nbs each time the document has been modified. + */ + public static void process(SyntaxContext context) { + + AbstractDocument document = (AbstractDocument)context.getDocument(); + try{ + document.readLock(); + + // remember all declared funktions for auto completion + synchronized(declaredFunctions) { + declaredFunctions.clear(); + } + + List declarations = context.getASTPath().getLeaf().getChildren(); + + for (ASTItem declaration : declarations) { + + for (ASTItem declarationItem : declaration.getChildren()) { + + if(isNode(declarationItem, "function")) { + + + List functionItems = declarationItem.getChildren(); + + if(functionItems.size() < 3) + break; + + ASTItem nameToken = functionItems.get(0); + + if(isTokenType(nameToken, GlslTokenId.FUNCTION.name())) { + + // determine return type + StringBuilder returnType = new StringBuilder(); + for (ASTItem typeItem : declaration.getChildren()) { + + if(isNode(typeItem, "function")) + break; + + if(typeItem instanceof ASTNode) { + returnType.append(((ASTNode)typeItem).getAsText().trim()); + }else if(typeItem instanceof ASTToken) { + final ASTToken t = (ASTToken) typeItem; + returnType.append(t.getIdentifier().trim()); + } + + } + + // determine name and parameter list + StringBuilder name = new StringBuilder(); + + name.append("("); + ASTItem parameterList = functionItems.get(2); + if(isNode(parameterList, "parameter_declaration_list")) + name.append(((ASTNode)parameterList).getAsText()); + name.append(")"); + + GLSLElementDescriptor elementDesc = new GLSLElementDescriptor( + GLSLElementDescriptor.Category.USER_FUNC, + "", + "", + name.toString(), + returnType.toString()); + + name.insert(0, ((ASTToken) nameToken).getIdentifier()); + + synchronized(declaredFunctions) { + declaredFunctions.put(name.toString(), elementDesc); + } + +// System.out.println("|"+returnType.toString()+"|"+name.toString()+"|"); + } + + break; + } + } + } + }finally{ + document.readUnlock(); + } + + + } + + private static final void movePreviousUntil(TokenSequence sequence, GlslTokenId id, String countToken, String stopToken) { + int counter = 1; + while(sequence.movePrevious() && counter > 0) { + if(sequence.token().id() == id) { + if(TokenUtilities.equals(sequence.token().text(), stopToken)) { + counter--; + }else if(TokenUtilities.equals(sequence.token().text(), countToken)){ + counter++; + } + } + } + } + + private static final boolean isIgnoredToken(Token token) { + return token.id() == GlslTokenId.WHITESPACE + || token.id() == GlslTokenId.COMMENT + || token.id() == GlslTokenId.PREPROCESSOR; + } + + private static final boolean isNode(ASTItem item, String nodeToken) { + return item != null && item instanceof ASTNode && ((ASTNode)item).getNT().equals(nodeToken); + } + + private static final boolean isToken(ASTItem item, String id) { + return item != null && item instanceof ASTToken && ((ASTToken)item).getIdentifier().equals(id); + } + + private static final boolean isTokenType(ASTItem item, String type) { + return item != null && item instanceof ASTToken && ((ASTToken) item).getTypeName().equals(type); + } + + +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/layer.xml b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/layer.xml new file mode 100644 index 000000000..320827890 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/layer.xml @@ -0,0 +1,289 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/Glsl.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/Glsl.java new file mode 100644 index 000000000..26cb462a7 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/Glsl.java @@ -0,0 +1,61 @@ +/* + * VertexLanguage.java + * + * Created on 19.08.2007, 18:25:24 + * + */ + +package net.java.nboglpack.glsleditor.lexer; + +import java.util.Collection; +import java.util.EnumSet; +import net.java.nboglpack.glsleditor.GlslVocabularyManager; +import net.java.nboglpack.glsleditor.dataobject.GlslFragmentShaderDataLoader; +import net.java.nboglpack.glsleditor.dataobject.GlslGeometryShaderDataLoader; +import net.java.nboglpack.glsleditor.dataobject.GlslVertexShaderDataLoader; +import org.netbeans.api.lexer.Language; +import org.netbeans.spi.lexer.LanguageHierarchy; +import org.netbeans.spi.lexer.Lexer; +import org.netbeans.spi.lexer.LexerRestartInfo; + +/** + * OpenGL Shading Language. + * @author Michael Bien + */ +public class Glsl extends LanguageHierarchy { + + public static final Glsl VERTEX_LANGUAGE = new Glsl(GlslVertexShaderDataLoader.REQUIRED_MIME); + public static final Glsl GEOMETRY_LANGUAGE = new Glsl(GlslGeometryShaderDataLoader.REQUIRED_MIME); + public static final Glsl FRAGMENT_LANGUAGE = new Glsl(GlslFragmentShaderDataLoader.REQUIRED_MIME); + + private final String mimeType; + + private Glsl(String mimeType) { + this.mimeType = mimeType; + } + + @Override + protected String mimeType() { + return mimeType; + } + + @Override + protected Collection createTokenIds() { + return EnumSet.allOf(GlslTokenId.class); + } + + @Override + protected Lexer createLexer(LexerRestartInfo info) { + return new GlslLexer(info, GlslVocabularyManager.getInstance(mimeType())); + } + + public static Language vertexLanguage(){ + return VERTEX_LANGUAGE.language(); + } + public static Language fragmentLanguage(){ + return FRAGMENT_LANGUAGE.language(); + } + public static Language geometryLanguage(){ + return GEOMETRY_LANGUAGE.language(); + } +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/GlslLexer.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/GlslLexer.java new file mode 100644 index 000000000..9d3307e28 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/GlslLexer.java @@ -0,0 +1,343 @@ +/* + * GlslLexer.java + * + * Created on 19.08.2007, 18:31:16 + * + */ + +package net.java.nboglpack.glsleditor.lexer; + +import net.java.nboglpack.glsleditor.GlslVocabularyManager; +import net.java.nboglpack.glsleditor.vocabulary.GLSLElementDescriptor; +import org.netbeans.api.lexer.Token; +import org.netbeans.spi.lexer.Lexer; +import org.netbeans.spi.lexer.LexerInput; +import org.netbeans.spi.lexer.LexerRestartInfo; +import org.netbeans.spi.lexer.TokenFactory; + + +/** + * Lexer for the OpenGL Shading Language. + * @author Michael Bien + */ +public class GlslLexer implements Lexer { + + private final LexerInput input; + private final TokenFactory factory; + private final GlslVocabularyManager manager; + private final StringBuilder stringBuilder; + + + public GlslLexer(LexerRestartInfo info, GlslVocabularyManager manager) { + this.input = info.input(); + this.factory = info.tokenFactory(); + this.manager = manager; + this.stringBuilder = new StringBuilder(); + } + + @SuppressWarnings("fallthrough") + public Token nextToken() { + + int character = input.read(); + + switch(character) { + + case '(': + case ')': + return factory.createToken(GlslTokenId.PAREN); + case '{': + case '}': + return factory.createToken(GlslTokenId.BRACE); + case '[': + case ']': + return factory.createToken(GlslTokenId.BRACKET); + case '.': + return factory.createToken(GlslTokenId.DOT); + case ',': + return factory.createToken(GlslTokenId.COMMA); + case ':': + return factory.createToken(GlslTokenId.COLON); + case ';': + return factory.createToken(GlslTokenId.SEMICOLON); + case '?': + return factory.createToken(GlslTokenId.QUESTION); + case '~': + return factory.createToken(GlslTokenId.TILDE); + case '*': + if(input.read() == '=') { + return factory.createToken(GlslTokenId.MUL_ASSIGN); + }else{ + input.backup(1); + return factory.createToken(GlslTokenId.STAR); + } + case '%': + if(input.read() == '=') { + return factory.createToken(GlslTokenId.MOD_ASSIGN); + }else{ + input.backup(1); + return factory.createToken(GlslTokenId.PERCENT); + } + case '!': + if(input.read() == '=') { + return factory.createToken(GlslTokenId.NE); + }else{ + input.backup(1); + return factory.createToken(GlslTokenId.BANG); + } + case '=': + if(input.read() == '=') { + return factory.createToken(GlslTokenId.EQEQ); + }else{ + input.backup(1); + return factory.createToken(GlslTokenId.EQ); + } + case '^': + switch(input.read()) { + case('^'): + return factory.createToken(GlslTokenId.CARETCARET); + case('='): + return factory.createToken(GlslTokenId.XOR_ASSIGN); + default: + input.backup(1); + return factory.createToken(GlslTokenId.CARET); + } + case '+': + switch(input.read()) { + case('+'): + return factory.createToken(GlslTokenId.PLUSPLUS); + case('='): + return factory.createToken(GlslTokenId.ADD_ASSIGN); + default: + input.backup(1); + return factory.createToken(GlslTokenId.PLUS); + } + case '-': + switch(input.read()) { + case('-'): + return factory.createToken(GlslTokenId.MINUSMINUS); + case('='): + return factory.createToken(GlslTokenId.SUB_ASSIGN); + default: + input.backup(1); + return factory.createToken(GlslTokenId.MINUS); + } + case '&': + switch(input.read()) { + case('&'): + return factory.createToken(GlslTokenId.AMPAMP); + case('='): + return factory.createToken(GlslTokenId.AND_ASSIGN); + default: + input.backup(1); + return factory.createToken(GlslTokenId.AMP); + } + case '|': + switch(input.read()) { + case('|'): + return factory.createToken(GlslTokenId.BARBAR); + case ('='): + return factory.createToken(GlslTokenId.OR_ASSIGN); + default: + input.backup(1); + return factory.createToken(GlslTokenId.BAR); + } + case '<': + switch(input.read()) { + case('<'): + if(input.read() == '=') { + return factory.createToken(GlslTokenId.LEFT_BITSHIFT_ASSIGN); + }else{ + input.backup(1); + return factory.createToken(GlslTokenId.LEFT_BITSHIFT); + } + case('='): + return factory.createToken(GlslTokenId.LE); + default: + input.backup(1); + return factory.createToken(GlslTokenId.LEFT_ANGLE); + } + case '>': + switch(input.read()) { + case('>'): + if(input.read() == '=') { + return factory.createToken(GlslTokenId.RIGHT_BITSHIFT_ASSIGN); + }else{ + input.backup(1); + return factory.createToken(GlslTokenId.RIGHT_BITSHIFT); + } + case('='): + return factory.createToken(GlslTokenId.GE); + default: + input.backup(1); + return factory.createToken(GlslTokenId.RIGHT_ANGLE); + } + case '/': + int c = input.read(); + if(c == '/') { + readRemainingLine(); + return factory.createToken(GlslTokenId.COMMENT); + }else if(c == '*') { + return tokenizeMLComment(); + }else if(c == '=') { + return factory.createToken(GlslTokenId.DIV_ASSIGN); + }else{ + input.backup(1); + return factory.createToken(GlslTokenId.SLASH); + } + case '#': + readRemainingLine(); + return factory.createToken(GlslTokenId.PREPROCESSOR); + case ' ': + case '\t': + do{ + character = input.read(); + }while(character == ' ' || character == '\t'); + input.backup(1); + return factory.createToken(GlslTokenId.WHITESPACE); + case '\r': + input.consumeNewline(); + case LexerInput.EOF: + if(input.readLength() == 0) + return null; + case '\n': + return factory.createToken(GlslTokenId.END_OF_LINE); + default: + if(Character.isDigit(character)) { + return tokenizeNumber(); + }else if(Character.isUnicodeIdentifierStart(character)) { + return tokenizeName(); + }else{ + return factory.createToken(GlslTokenId.error); + } + } + + } + + @SuppressWarnings("fallthrough") + private final void readRemainingLine() { + + int character = input.read(); + + while(character != LexerInput.EOF) { + switch (character) { + case '\r': + input.consumeNewline(); + case '\n': + case LexerInput.EOF: + return; + } + character = input.read(); + } + + } + + private final Token tokenizeMLComment() { + + int character = input.read(); + + while(character != LexerInput.EOF) { + if(character == '*' && input.read() == '/') { + return factory.createToken(GlslTokenId.ML_COMMENT); + } + character = input.read(); + } + return factory.createToken(GlslTokenId.ML_COMMENT); + + } + + private final Token tokenizeNumber() { + + int character; + + do{ + character = input.read(); + }while(Character.isDigit(character)); + + if(character == '.') { + + do{ + character = input.read(); + }while(Character.isDigit(character)); + + if(character != 'f' && character != 'F') + input.backup(1); + + return factory.createToken(GlslTokenId.FLOAT_LITERAL); + + }else{ + + if(character != 'u' && character != 'U') + input.backup(1); + +// input.backup(1); + return factory.createToken(GlslTokenId.INTEGER_LITERAL); + + } + } + + private final Token tokenizeName() { + + if(stringBuilder.length() > 0) + stringBuilder.delete(0, stringBuilder.length()); + + // backup everything read + input.backup(input.readLength()); + + // assamble token + char c; + while(Character.isUnicodeIdentifierPart(c = ((char)input.read()))) + stringBuilder.append(c); + + if(stringBuilder.length() > 0) + input.backup(1); + + // categorise token + GLSLElementDescriptor[] desc = manager.getDesc(stringBuilder.toString()); + + if(desc != null) { + + if(desc[0].category != null) { + + if(desc[0].category == GLSLElementDescriptor.Category.BUILD_IN_FUNC) + return factory.createToken(GlslTokenId.BUILD_IN_FUNC); + + if(desc[0].category == GLSLElementDescriptor.Category.BUILD_IN_VAR) + return factory.createToken(GlslTokenId.BUILD_IN_VAR); + + return factory.createToken(GlslTokenId.KEYWORD); + + } + } + + // check if token = function name + int tokenEnd = input.readLength(); + int character = input.read(); + + while(true) { + switch (character) { + case ' ': + case '\t': + case '\r': + case '\n': + character = input.read(); + break; + case '(': + input.backup(input.readLength()-tokenEnd); + return factory.createToken(GlslTokenId.FUNCTION); + default: + input.backup(input.readLength()-tokenEnd); + return factory.createToken(GlslTokenId.IDENTIFIER); + } + } + + } + + public Object state() { + // we don't need states + return null; + } + + public void release() { + } + +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/GlslTokenId.java b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/GlslTokenId.java new file mode 100644 index 000000000..4909d00d6 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/GlslTokenId.java @@ -0,0 +1,90 @@ +/* + * GlslTokenId.java + * + * Created on 19.08.2007, 18:09:00 + * + */ + +package net.java.nboglpack.glsleditor.lexer; + +import org.netbeans.api.lexer.TokenId; + +/** + * Enumeration of GLSL token ids. + * @author Michael Bien + */ +public enum GlslTokenId implements TokenId { + + + IDENTIFIER("glsl-name"), + INTEGER_LITERAL("glsl-literal"), + FLOAT_LITERAL("glsl-literal"), + FUNCTION("glsl-function"), + KEYWORD("glsl-keyword"), + BUILD_IN_FUNC("glsl-build-in-func"), + BUILD_IN_VAR("glsl-build-in-var"), + COMMENT("glsl-comment"), + ML_COMMENT("glsl-comment"), + + PAREN("glsl-paren"), + BRACE("glsl-brace"), + BRACKET("glsl-bracket"), + LEFT_ANGLE("glsl-angle"), + RIGHT_ANGLE("glsl-angle"), + + SEMICOLON("glsl-separator"), + COMMA("glsl-separator"), + DOT("glsl-separator"), + COLON("glsl-separator"), + + PERCENT("glsl-operation"), + STAR("glsl-operation"), + TILDE("glsl-operation"), + QUESTION("glsl-operation"), + BANG("glsl-operation"), + SLASH("glsl-operation"), + LEFT_BITSHIFT("glsl-operation"), + RIGHT_BITSHIFT("glsl-operation"), + PLUS("glsl-operation"), + PLUSPLUS("glsl-operation"), + MINUS("glsl-operation"), + MINUSMINUS("glsl-operation"), + AMP("glsl-operation"), + AMPAMP("glsl-operation"), + EQ("glsl-operation"), + EQEQ("glsl-operation"), + NE("glsl-operation"), + LE("glsl-operation"), + GE("glsl-operation"), + BAR("glsl-operation"), + BARBAR("glsl-operation"), + CARET("glsl-operation"), + CARETCARET("glsl-operation"), + ADD_ASSIGN("glsl-operation"), + SUB_ASSIGN("glsl-operation"), + MUL_ASSIGN("glsl-operation"), + DIV_ASSIGN("glsl-operation"), + AND_ASSIGN("glsl-operation"), + OR_ASSIGN("glsl-operation"), + XOR_ASSIGN("glsl-operation"), + MOD_ASSIGN("glsl-operation"), + LEFT_BITSHIFT_ASSIGN("glsl-operation"), + RIGHT_BITSHIFT_ASSIGN("glsl-operation"), + + WHITESPACE("glsl-whitespace"), + END_OF_LINE("glsl-end-of-line"), + PREPROCESSOR("glsl-preprocessor"), + + error("glsl-error"); + + private final String primaryCategory; + + private GlslTokenId(String primaryCategory) { + this.primaryCategory = primaryCategory; + } + + public String primaryCategory() { + return primaryCategory; + } + +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/opengl-icon.gif b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/opengl-icon.gif new file mode 100644 index 0000000000000000000000000000000000000000..f5dce676a3aacf9e6813f06508cbca43f5c499fe GIT binary patch literal 1712 zcmZ?wbhEHbRA7)~_}<0<1kB9LY;0^C92{I+T-@B;!otELA|etJ5>ir9GBPrgqZ=ItB&?#>U1bCMK4amR43)wzjtR_Vx}A4xXN#-rn9pK|#U6!66|b z;o;$l@$rd?iD_wR>FMdYxw(0Hc_k$!rKP21Wo7mC^$c127_#><b?YkfY=fSLq?{l0!Vjhj>a4@s=ItD?7|zenhbR zuu$a@v6`deAaqQk_Lyw_aruT5@{K1H8c!%SoltH*snUE>z3rq%<8iI_Q#!3DbvjNP z^_(&3IcwH?)}sHMW&b&=3FmAkp0}HH-f_|em#G)sreAcQe$jKrCGQ!Rd}mz_ns+5+ z-qo;qSHkCA4PS6Ia?!Qu#n)pNU5if9gr(P$mfc8Qb|Y=&&GeNwGgbl7t&G*T za@XD|Sa+v<)7`2q_o}zttKD|Le*69A=H`y}_MV=ezP`Tx{{E>`r_Pu$W7e!$%a<=- zv0}xVHET9(*syo+-hKP_HSBoUxZ^?7jt9* zj0~XolZBCiVIzYM$h)9C!NBp4A^B*RsCL+zh>b}^F%~(upPQv-o~7X!+{rf=o30lw zMW0=}1mwf-Jn%fCAtY;sY4XH7DwiHD=Ef!kQ7k5FlJ|z8&`BM)!@AE+cj?LNSSXCg z@vD6oxmz7Mg4=`tj&`{o=UFNn@Zv}pEBBR!zKejN(CQ_k3GZ-qOrob-T2R%bwgpZQoso3(*8>MeosgI=!_eTk z#t#^o9s=GhXlhi`xO&8<0o}vc;IKSmjvGS(RLwy|aQqWp&e0=QoOJY+3qu35eVqbB z0#FeHgSbJ$i3Tlb*t;Hg?-lbgI@+bG0ZctWyCg)ofoed&K}+laB&53gCWz@qxd4rx zw$icgpG*-jO{qJza0n`eXu#ue+FYQTKMU~1n6}tlP2H$10r+BGJ50yQHEK&nVT&K$ zWLq+2OU6Yew%L}*32+gT?Gr#Qdr^~lagi&xY{H8RovxttR`TKkW};e@%<9$+bp4e8 uBi7SX)B}NvvE-U=zIl3XC07~(n>{71NzP`V>yS_M%&hq#D_4@wd?)(4$ z|K;)gjtZao>iECe?(+EkK5wHtZKCq{`~q#i)93Z4&FRwS_Ur2EZ?4@D==ETx+FYX6NSD)Kc7^o${qFbu=kfa&e8;KI>b&6kW2e~G;OteM z)mDbM#oqAJ;`5fn<{Ev*RG!r(gURgm{q^|$WsJ2iL{vUMKicZ{yV>qMZK6t;)2h$v zij0nex!~^g{duO;n8oMW>H7Ek{_^+y=JEPXn$m^3;N;@{QhE* z!a8iB00030|Nj6000000000000000000000000000000000000A^8LW004CWEC2ui z01yBW000NPfOU0pgoFWyKOjg73W9@hkZ=QWaRY2~J!+0}aAsFz5HB=QUSdsQn{Xmb zToo!FOJzYJ5u0NiSuzg~sPem3rbSp;y00#o(A3ASsNiy7Eu%?3va#m~r@iD{z5gr$W tkRX>&0G1dMP*7okBLO)9QjECxvS0xkHwn&=o5QlDOO}pe%9I%h06Tg+P!9kA literal 0 HcmV?d00001 diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/FragmentShaderTemplate.frag b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/FragmentShaderTemplate.frag new file mode 100644 index 000000000..d229255d3 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/FragmentShaderTemplate.frag @@ -0,0 +1,8 @@ +/* +* fragment shader template +*/ +void main() { + // Set the fragment color for example to gray, alpha 1.0 + gl_FragColor = vec4(0.5, 0.5, 0.5, 1.0); +} + diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GeometryShaderIcon.gif b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GeometryShaderIcon.gif new file mode 100644 index 0000000000000000000000000000000000000000..37f3defce9ee454737b0fa522ab391cdff4ad9e3 GIT binary patch literal 614 zcmV-s0-60sNk%w1VGsZi0OoxFTa3K={QmU#{qXkv_4@wy`u^qd{QLa=7Zw{hj?VJ; z{r~^}y}!ZC&d}lR`){t@7j?tz@%C1Rxbpb?W2e|tQ&=Y^D#hOL-QM7EaCA+Y(>!gW zK5wI3qSo&9{qgtwyV>r{;`Akh$>;I>)93X&ZK7bN+HrDrX{p)a@A)+~I&!bv1##$ji|D{r)yJ zIjYa<)#&x1&hUb{;50Ni)#mv8{{MEf;L_sr*y!|Qrq}HC{qFbu8hys}`Ta_m)7t9x znV6gM`2E)4?AYS#VIltNN%;NKTrqqwXv?fZg) zh57pW^7s7W@B8QR`}q6*WMpUk{{ILE3}TVOI&7i;|Nj6000000A^8LW004aeEC2ui z01yBW000NWfPH;?goFTx5*#oK3xb1rka-6I0S82UQge=bc|~++D>h_8GA|nun|Tu; zSsFTLPe?~4Gn*f9VkT2~2znMVX?&YIVNO&-J{Uc6UID^_ds_)XV0sM=3=DTy&x1)h zZEt!76$mN>0^NHZYerCdWd(XC=;}WrZZ{cvdS*Nd1Jp&K0ilZ(97|ZFaKT00m?jsr zFiC)g0*Wdm)CmCi1&EplHA2{Npl*N%B`ro6Fu 0.95) + color = vec4(1.0,0.5,0.5,1.0); + else if (intensity > 0.5) + color = vec4(0.6,0.3,0.3,1.0); + else if (intensity > 0.25) + color = vec4(0.4,0.2,0.2,1.0); + else + color = vec4(0.2,0.1,0.1,1.0); + + gl_FragColor = color; +} \ No newline at end of file diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslFragmentShaderResolver.xml b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslFragmentShaderResolver.xml new file mode 100644 index 000000000..824a55326 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslFragmentShaderResolver.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslGeometryShaderExample.geom b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslGeometryShaderExample.geom new file mode 100644 index 000000000..cf7776827 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslGeometryShaderExample.geom @@ -0,0 +1,26 @@ +// ------ Geometry shader ------ // + +#version 120 +#extension GL_EXT_geometry_shader4 : enable + +/* +* a passthrough geometry shader for color and position +*/ +void main() { + + for(int i = 0; i < gl_VerticesIn; ++i) { + + // copy color + gl_FrontColor = gl_FrontColorIn[i]; + + // copy position + gl_Position = gl_PositionIn[i]; + + // done with the vertex + EmitVertex(); + + } + + EndPrimitive(); + +} \ No newline at end of file diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslGeometryShaderResolver.xml b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslGeometryShaderResolver.xml new file mode 100644 index 000000000..3f3221ed9 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslGeometryShaderResolver.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslVertexShaderExample.vert b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslVertexShaderExample.vert new file mode 100644 index 000000000..a147153ab --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslVertexShaderExample.vert @@ -0,0 +1,29 @@ +// ------ Vertex shader ------ // + +#pragma debug(on) + +uniform vec3 LightPosition; +const float SpecularContribution = 0.3; +varying float LightIntensity; + +/* +* main function +*/ +void main() { + + vec3 ecPosition = vec3 (gl_ModelViewMatrix * gl_Vertex); + vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal); + vec3 lightVec = normalize(LightPosition - ecPosition); + vec3 reflectVec = reflect(-lightVec, tnorm); + vec3 viewVec = normalize(-ecPosition); + float diffuse = max(dot(lightVec, tnorm), 0.0); + float spec = 0.0; + + if (diffuse > 0.0) { + spec = max(dot(reflectVec, viewVec), 0.0); + spec = pow(spec, 16.0); + } + + LightIntensity = 0.7 * diffuse + SpecularContribution * spec; + gl_Position = ftransform(); +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslVertexShaderResolver.xml b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslVertexShaderResolver.xml new file mode 100644 index 000000000..39191a88f --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslVertexShaderResolver.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslVocabulary.xml b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslVocabulary.xml new file mode 100644 index 000000000..b956ddb9e --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/GlslVocabulary.xml @@ -0,0 +1,4724 @@ + + + + + pow + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (vec2, vec2) + vec2 + + + BUILD_IN_FUNC + (vec3, vec3) + vec3 + + + BUILD_IN_FUNC + (vec4, vec4) + vec4 + + + + + float + + + TYPE + single floating-point scalar + + + + + dot + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (vec2, vec2) + float + + + BUILD_IN_FUNC + (vec3, vec3) + float + + + BUILD_IN_FUNC + (vec4, vec4) + float + + + + + gl_MaxFragmentUniformComponents + + + BUILD_IN_VAR + value >= 64 ARB_fragment_shader required + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum allowed uniform + components inside the fragment shader.<br> This limit refers to the storage + for the combination of build-in uniform variables and user-defined uniform + variables that are actually used in a fragment shader. This constant can + be also queried by calling <b>glGetIntegerv</b> with the symbolic constant <i>GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB</i>. + The minimum value is 64 if <i>ARB_fragment_shader</i> is supported. + </body> +</html> + + const int + + + + + else + + + SELECTION + + + + + gl_BackLightProduct + + + BUILD_IN_VAR + INDEX < gl_MaxLights + [] + uniform gl_LightProducts + + + + + mod + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (vec2, float) + vec2 + + + BUILD_IN_FUNC + (vec3, float) + vec3 + + + BUILD_IN_FUNC + (vec4, float) + vec4 + + + + + gl_MaxVertexAttribs + + + BUILD_IN_VAR + value >= 16 ARB_vertex_shader required + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum useable vertex attributes + in a vertex shader.<br> This limit consists of the standard (build-in) attributes (these are color, secondary color, normal, vertex position, texture coordinates, and fog coordinates) and the generic attributes left for custom purposes. This constant can be also queried by calling <b>glGetIntegerv</b> + with the symbolic constant <i>GL_MAX_VERTEX_ATTRIBS_ARB</i>. Every OpenGL + implementation is required to support at least 16 vertex attributes in a + vertex shader. + </body> +</html> + + const int + + + + + log + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + texture2DLod + + + BUILD_IN_FUNC + (sampler2D, vec2, float lod) + vec4 + + + + + uvec2 + + + TYPE + a two-component unsigned integer vector + <html> + <head> + + </head> + <body> + a two-component unsigned integer vector + </body> +</html> + + + + + + floor + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + uvec3 + + + TYPE + a three-component unsigned integer vector + <html> + <head> + + </head> + <body> + a three-component unsigned integer vector + </body> +</html> + + + + + + uvec4 + + + TYPE + a four-component unsigned integer vector + <html> + <head> + + </head> + <body> + a four-component unsigned integer vector + </body> +</html> + + + + + + faceforward + + + BUILD_IN_FUNC + (float, float, float) + float + + + BUILD_IN_FUNC + (vec2, vec2, vec2) + vec2 + + + BUILD_IN_FUNC + (vec3, vec3, vec3) + vec3 + + + BUILD_IN_FUNC + (vec4 V, vec4 I, vec4 N) + vec4 + + + + + gl_TextureMatrixTranspose + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform mat4 + + + + + smooth + + + QUALIFIER + perspective correct interpolation + <html> + <head> + + </head> + <body> + <p> + perspective correct interpolation + </p> + </body> +</html> + + + + + + usampler2DArray + + + TYPE + a handle for accessing an unsigned integer 2D array texture + <html> + <head> + + </head> + <body> + a handle for accessing an unsigned integer 2D array texture + </body> +</html> + + + + + + ceil + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + smoothstep + + + BUILD_IN_FUNC + (float, float, float) + float + + + BUILD_IN_FUNC + (float, float, vec2) + vec2 + + + BUILD_IN_FUNC + (float, float, vec3) + vec3 + + + BUILD_IN_FUNC + (float, float, vec4) + vec4 + + + + + texture2DProjLod + + + BUILD_IN_FUNC + (sampler2D, vec3, float lod) + vec4 + + + BUILD_IN_FUNC + (sampler2D, vec4, float lod) + vec4 + + + + + isampler1D + + + TYPE + a handle for accessing an integer 1D texture + <html> + <head> + + </head> + <body> + a handle for accessing an integer 1D texture + </body> +</html> + + + + + + do + + + ITERATION + + + + + texture1DProjLod + + + BUILD_IN_FUNC + (sampler1D, vec2, float lod) + vec4 + + + BUILD_IN_FUNC + (sampler1D, vec4, float lod) + vec4 + + + + + max + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (vec2, float) + vec2 + + + BUILD_IN_FUNC + (vec3, float) + vec3 + + + BUILD_IN_FUNC + (vec4, float) + vec4 + + + + + sqrt + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + shadow1DProjLod + + + BUILD_IN_FUNC + (sampler1DShadow, vec4, float lod) + vec4 + + + + + highp + + + QUALIFIER + <html> + <head> + + </head> + <body> + qualifier for high precision + </body> +</html> + + + + + + gl_MaxVertexUniformComponents + + + BUILD_IN_VAR + value >= 512 ARB_vertex_shader required + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum allowed uniform + components inside the vertex shader.<br> This limit refers to the storage for + the combination of build-in uniform variables and user-defined uniform + variables that are actually used in a vertex shader. This constant can be + also queried by calling <b>glGetIntegerv</b> with the symbolic constant <i>GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB</i>. + The minimum value is 512 if <i>ARB_vertex_shader</i> is supported. + </body> +</html> + + const int + + + + + noise4 + + + BUILD_IN_FUNC + (float) + vec4 + + + BUILD_IN_FUNC + (vec2) + vec4 + + + BUILD_IN_FUNC + (vec3) + vec4 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + clamp + + + BUILD_IN_FUNC + (float, float, float) + float + + + BUILD_IN_FUNC + (vec2, float, float) + vec2 + + + BUILD_IN_FUNC + (vec3, float, float) + vec3 + + + BUILD_IN_FUNC + (vec4, float, float) + vec4 + + + + + sin + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric sine function. Angle in radians. + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric sine function. Angle in radians. + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric sine function. Angle in radians. + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric sine function. Angle in radians. + </body> + </html> + + (vec4) + vec4 + + + + + noise2 + + + BUILD_IN_FUNC + (float) + vec2 + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec2 + + + BUILD_IN_FUNC + (vec4) + vec2 + + + + + noise3 + + + BUILD_IN_FUNC + (float) + vec3 + + + BUILD_IN_FUNC + (vec2) + vec3 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec3 + + + + + noise1 + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + float + + + BUILD_IN_FUNC + (vec3) + float + + + BUILD_IN_FUNC + (vec4) + float + + + + + gl_ProjectionMatrixInverseTranspose + + + BUILD_IN_VAR + uniform mat4 + + + + + reflect + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (vec2, vec2) + vec2 + + + BUILD_IN_FUNC + (vec3, vec3) + vec3 + + + BUILD_IN_FUNC + (vec4 I, vec4 N) + vec4 + + + + + vec4 + + + TYPE + four component floating-point vector + + + + + cos + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric cosine function. Angle in radians. + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric cosine function. Angle in radians. + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric cosine function. Angle in radians. + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric cosine function. Angle in radians. + </body> + </html> + + (vec4) + vec4 + + + + + centroid + + + QUALIFIER + centroid interpolation on multi-sample varyings + <html> + <head> + + </head> + <body> + Examples: + + <blockquote> + <code><nobr>centroid varying vec4 color;</nobr><br><nobr>centroid varying float value;</nobr></code> + </blockquote> + By definition, varying variables are set per vertex and are interpolated + in a perspective-correct manner over the primitive being rendered. + + <ul> + <li> + If single-sampling, the value is interpolated to the pixel's center, + and the <b>centroid </b>qualifier, if present, is ignored. + </li> + <li> + If multi-sampling, and <b>varying</b> is not qualified with <b>centroid</b>, + then the value must be interpolated to the pixel's center, or anywhere + within the pixel, or to one of the pixel's samples. + </li> + <li> + If multi-sampling and <b>varying </b>is qualified with <b>centroid</b>, + then the value must be interpolated to a point that lies in both the + pixel and in the primitive being rendered, or to one of the pixel's + samples that falls within the primitive. Due to the less regular + location of centroids, their derivatives may be less accurate than + non-centroid varying variables. + </li> + </ul> + <p> + When using the <b>centroid </b>keyword, it must immediately precede the <b>varying + </b>keyword. A fragment shader may read from varying variables and the + value read will be the interpolated value, as a function of the + fragment's position within the primitive. A fragment shader can not + write to a varying variable. + </p> + <p> + The type and presence of the <b>centroid </b>and <b>invariant </b>qualifiers + of varying variables with the same name declared in linked vertex and + fragments shaders must match, otherwise the link command will fail. Only + those varying variables used (i.e. read) in the fragment shader + executable must be written to by the vertex shader executable; declaring + superfluous varying variables in a vertex shader is permissible. + </p> + </body> +</html> + + + + + + texture1D + + + BUILD_IN_FUNC + (sampler1D, float, float bias) + vec4 + + + + + ivec4 + + + TYPE + four component integer vector + + + + + ivec3 + + + TYPE + three component integer vector + + + + + shadow2D + + + BUILD_IN_FUNC + (sampler2DShadow, vec3, float bias) + vec4 + + + + + varying + + + QUALIFIER + output from Vertex shader (READ/WRITE), interpolated, then input to Fragment shader (READ-ONLY) + <html> + <head> + + </head> + <body> + <p> + <b>Deprecated since 1.3, use <i>smooth</i> instead</b> + </p> + <p> + </p> + Varying variables provide the interface between the vertex shader and + geometry shader and also between the geometry shader and fragment shader + and the fixed functionality between them. If no geometry shader is + present, <b>varying</b> variables also provide the interface between the + vertex shader and fragment shader. + + <p> + The vertex, or geometry shader will compute values per vertex (such as + color, texture coordinates, etc) and write them to output variables + declared with the &quot;varying&quot; qualifier (vertex) or &quot;varying out&quot; + qualifiers (geometry). A vertex or geometry shader may also read these + output varying variables, getting back the same values it has written. + Reading an output varying variable in a vertex or geometry shader + returns undefined results if it is read before being written. + </p> + <p> + A geometry shader may also read from an input <b>varying</b> variable + declared with the &quot;varying in&quot; qualifiers. The value read will be the + same value as written by the vertex shader for that <b>varying</b> + variable. Since a geometry shader operates on primitives, each input + varying variable needs to be declared as an array. Each element of such + an array corresponds to a vertex of the primitive being processed. If + the varying variable is declared as a scalar or matrix in the vertex + shader, it will be a one-dimensional array in the geometry shader. Each + array can optionally have a size declared. If a size is not specified, + it inferred by the linker and depends on the value of the input + primitive type. See table 4.3.xxx (GLSL specification) to determine the + exact size. The read-only built-in constant <b>gl_VerticesIn</b> will be + set to this value by the linker. If a size is specified, it has to be + the size as given by table 4.3.xxx, otherwise a link error will occur. + The built-in constant <b>gl_VerticesIn</b>, if so desired, can be used + to size the array correctly for each input primitive type. Varying + variables can also be declared as arrays in the vertex shader. This + means that those, on input to the geometry shader, must be declared as + two- dimensional arrays. The first index to the two-dimensional array + holds the vertex number. Declaring a size for the first range of the + array is optional, just as it is for one-dimensional arrays. The second + index holds the per-vertex array data. Declaring a size for the second + range of the array is not optional, and has to match the declaration in + the vertex shader. + </p> + <p> + By definition, varying variables are set per vertex and are interpolated + in a perspective-correct manner over the primitive being rendered. If + single-sampling, the value is interpolated to the pixel's center, and + the <b>centroid </b>qualifier, if present, is ignored. If + multi-sampling, and <b>varying</b> is not qualified with <b>centroid</b>, + then the value must be interpolated to the pixel's center, or anywhere + within the pixel, or to one of the pixel's samples. If multi-sampling + and <b>varying </b>is qualified with <b>centroid</b>, then the value + must be interpolated to a point that lies in both the pixel and in the + primitive being rendered, or to one of the pixel's samples that falls + within the primitive. Due to the less regular location of centroids, + their derivatives may be less accurate than non-centroid varying + variables. + </p> + <p> + When using the <b>centroid </b>keyword, it must immediately precede the <b>varying + </b>keyword. A fragment shader may read from varying variables and the + value read will be the interpolated value, as a function of the + fragment's position within the primitive. A fragment shader can not + write to a varying variable. + </p> + <p> + The type and presence of the <b>centroid </b>and <b>invariant </b>qualifiers + of varying variables with the same name declared in linked vertex and + fragments shaders must match, otherwise the link command will fail. Only + those varying variables used (i.e. read) in the fragment shader + executable must be written to by the vertex shader executable; declaring + superfluous varying variables in a vertex shader is permissible. + </p> + <p> + Varying variables are declared as in the following examples: + </p> + <blockquote> + <nobr><code>varying vec3 normal;</code></nobr><code><br><nobr>centroid + varying vec2 TexCoord;</nobr><br><nobr>invariant centroid varying vec4 + Color;</nobr><br></code> + </blockquote> + <p> + The <b>varying </b>qualifier can be used only with <b>float</b>, + floating-point vectors, matrices, or arrays of these. Structures cannot + be <b>varying</b>. If no vertex shader executable is active, the fixed + functionality pipeline of OpenGL will compute values for the built-in + varying variables that will be consumed by the fragment shader + executable. Similarly, if no fragment shader executable is active, the + vertex shader executable is responsible for computing and writing to the + varying variables that are needed for OpenGL's fixed functionality + fragment pipeline. Varying variables are required to have global scope, + and must be declared outside of function bodies, before their first use. + </p> + </body> +</html> + + + + + + any + + + BUILD_IN_FUNC + (bvec2) + bool + + + BUILD_IN_FUNC + (bvec3) + bool + + + BUILD_IN_FUNC + (bvec4) + bool + + + + + notEqual + + + BUILD_IN_FUNC + (bvec2, bvec2) + bvec2 + + + BUILD_IN_FUNC + (bvec3, bvec3) + bvec3 + + + BUILD_IN_FUNC + (bvec4, bvec4) + bvec4 + + + + + ivec2 + + + TYPE + two component integer vector + + + + + sampler1DArray + + + TYPE + a handle for accessing a 1D array texture + <html> + <head> + + </head> + <body> + a handle for accessing a 1D array texture + </body> +</html> + + + + + + + sampler2DArrayShadow + + + TYPE + <html> + <head> + + </head> + <body> + a handle for accessing a 2D array depth texture with comparison + </body> +</html> + + + + + + + radians + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts degrees to radians, i.e. pi / 180 * degrees + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts degrees to radians, i.e. pi / 180 * degrees + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts degrees to radians, i.e. pi / 180 * degrees + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts degrees to radians, i.e. pi / 180 * degrees + </body> + </html> + + (vec4) + vec4 + + + + + usamplerCube + + + TYPE + a handle for accessing an unsigned integer cube mapped texture + <html> + <head> + + </head> + <body> + a handle for accessing an unsigned integer cube mapped texture + </body> +</html> + + + + + + gl_TextureMatrixInverse + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform mat4 + + + + + texture2D + + + BUILD_IN_FUNC + (sampler2D, vec2, float bias) + vec4 + + + + + sampler1DArrayShadow + + + TYPE + a handle for accessing a 1D array depth texture with comparison + <html> + <head> + + </head> + <body> + a handle for accessing a 1D array depth texture with comparison + </body> +</html> + + + + + + + sign + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + texture2DProj + + + BUILD_IN_FUNC + (sampler2D, vec3, float bias) + vec4 + + + BUILD_IN_FUNC + (sampler2D, vec4, float bias) + vec4 + + + + + shadow1D + + + BUILD_IN_FUNC + (sampler1DShadow, vec3, float bias) + vec4 + + + + + gl_MaxTextureCoords + + + BUILD_IN_VAR + value >= 2 ARB_fragment_program required + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum allowed number of + texture coordinate sets.<br>The number of texture coordinate sets defines + the maximum number of texture coordinates that can be attached to a + vertex. A texture coordinate set encompasses vertex texture coordinate attributes, as well as the texture matrix stack and texture generation state. This limit applies regardless of using a vertex shader or + fixed-function pipeline to perform vertex processing. This constant can be + also queried by calling <b>glGetIntegerv</b> with the symbolic constant <i>GL_MAX_TEXTURE_COORDS_ARB</i>. + Minimum value is 2. + </body> +</html> + + const int + + + + + gl_MaxVertexTextureImageUnits + + + BUILD_IN_VAR + value >= 0 ARB_vertex_shader required + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum available texture image + units in a vertex shader.<br> The texture image unit constant specifyes the + number of hardware units that can be used simultaneously for accessing + texture maps. This constant can be also queried by calling <b>glGetIntegerv</b> + with the symbolic constant <i>GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB</i>. + The minimum value is 0. + </body> +</html> + + const int + + + + + vec3 + + + TYPE + three component floating-point vector + + + + + vec2 + + + TYPE + two component floating-point vector + + + + + case + + + KEYWORD + + + + + texture1DLod + + + BUILD_IN_FUNC + (sampler1D, float, float lod) + vec4 + + + + + asin + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc sine. Returns an angle whose sine is x. The range of values returned + by this function is [- Pi / 2 , Pi / 2 ] Results are undefined if |x| &gt; 1. + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc sine. Returns an angle whose sine is x. The range of values returned + by this function is [- Pi / 2 , Pi / 2 ] Results are undefined if |x| &gt; 1. + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc sine. Returns an angle whose sine is x. The range of values returned + by this function is [- Pi / 2 , Pi / 2 ] Results are undefined if |x| &gt; 1. + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc sine. Returns an angle whose sine is x. The range of values returned + by this function is [- Pi / 2 , Pi / 2 ] Results are undefined if |x| &gt; 1. + </body> + </html> + + (vec4) + vec4 + + + + + texture3D + + + BUILD_IN_FUNC + (sampler3D, vec3, float bias) + vec4 + + + + + gl_LightModel + + + BUILD_IN_VAR + uniform gl_LightModelParameters + + + + + bvec2 + + + TYPE + two component boolean vector + + + + + bvec3 + + + TYPE + three component boolean vector + + + + + bvec4 + + + TYPE + four component boolean vector + + + + + normalize + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + gl_MaxCombinedTextureImageUnits + + + BUILD_IN_VAR + value >= 2 + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum available combined + texture image units in all shader processing parts of OpenGL.<br>The + texture image unit constant specifys the number of hardware units that can + be used simultaneously for accessing texture maps. This constant can be + also queried by calling <b>glGetIntegerv</b> with the symbolic constant <i>GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB</i>. + The minimum value is 2. + + <p> + <b>Note:</b> If a vertex shader and a fragment shader both use the same + texture image unit, that counts as two units against this limit. + </p> + </body> +</html> + + const int + + + + + struct + + + KEYWORD + <html> + <head> + + </head> + <body> + Once a structure is defined, and its type is given a name, a constructor + is available with the same name to construct instances of that structure. + For example: + + <pre><code>struct light { + float intensity; + vec3 position; +}; +<nobr>light lightVar = light(3.0, vec3(1.0, 2.0, 3.0));</nobr></code> + </pre> + <p> + The arguments to the constructor will be used to set the structure's + fields, in order, using one argument per field. Each argument must be + the same type as the field it sets. + </p> + <p> + Structure constructors can be used as initializers or in expressions. + </p> + </body> +</html> + + + + + + all + + + BUILD_IN_FUNC + (bvec2) + bool + + + BUILD_IN_FUNC + (bvec3) + bool + + + BUILD_IN_FUNC + (bvec4) + bool + + + + + shadow2DLod + + + BUILD_IN_FUNC + (sampler2DShadow, vec3, float lod) + vec4 + + + + + precision + + + KEYWORD + <html> + <head> + + </head> + <body> + The precision statement +<pre> +precision precision-qualifier type; +</pre> +can be used to establish a default precision qualifier. The type field can be either int or <b>float</b>, and the +precision-qualifier can be <b>lowp, mediump, or highp</b>. Any other types or qualifiers will result in an error. +If type is float, the directive applies to non-precision-qualified floating point type (scalar, vector, and +matrix) declarations. If type is <b>int</b>, the directive applies to all non-precision-qualified integer type (scalar, +vector, signed, and unsigned) declarations. This includes global variable declarations, function return declarations, +function parameter declarations, and local variable declarations. Non-precision qualified declarations will use the precision qualifier +specified in the most recent precision statement that is still in scope. The <b>precision</b> statement has the same scoping rules as variable +declarations. If it is declared inside a compound statement, its effect stops at the end of the innermost +statement it was declared in. Precision statements in nested scopes override <b>precision</b> statements in outer +scopes. Multiple precision statements for the same basic type can appear inside the same scope, with later +statements overriding earlier statements within that scope. +<p> +The vertex language has the following predeclared globally scoped default + precision statements: +<pre> +precision highp float; +precision highp int; +</pre> +</p> +<p> +The fragment language has the following predeclared globally scoped default + precision statement: +<pre> +precision mediump int; +</pre> +</p> +The fragment language has no default precision qualifier for floating point types. Hence for float, floating +point vector and matrix variable declarations, either the declaration must include a precision qualifier or +the default float precision must have been previously declared. + </body> +</html> + + + + + + gl_BackMaterial + + + BUILD_IN_VAR + uniform gl_MaterialParameters + + + + + uniform + + + QUALIFIER + input to Vertex and Fragment shader from OpenGL or application (READ-ONLY) + <html> + <head> + + </head> + <body> + <nobr>The <b>uniform </b>qualifier is used to declare global variables + whose values are the same across the entire</nobr> <nobr>primitive being + processed. All <b>uniform </b>variables are read-only and are initialized + externally either at link</nobr> <nobr>time or through the API. The link + time initial value is either the value of the variable's initializer, if</nobr> + <nobr>present, or 0 if no initializer is present. Sampler types cannot + have initializers.</nobr><br>Example declarations are: + + <pre> <nobr>uniform vec4 lightPosition;</nobr> + <nobr>uniform vec3 color = vec3(0.7, 0.7, 0.2); // value assigned at link time </nobr></pre> +<p> + <nobr>The <b>uniform </b>qualifier can be used with any of the basic data + types, or when declaring a variable whose</nobr> <nobr>type is a + structure, or an array of any of these.</nobr> <nobr>There is an + implementation dependent limit on the amount of storage for uniforms that + can be used for</nobr> <nobr>each type of shader and if this is exceeded + it will cause a compile-time or link-time error. Uniform</nobr> <nobr>variables + that are declared but not used do not count against this limit. The number + of user-defined</nobr> <nobr>uniform variables and the number of built-in + uniform variables that are used within a shader are added</nobr> <nobr>together + to determine whether available uniform storage has been exceeded.</nobr> + + <p> + <nobr>If multiple shaders are linked together, then they will share a + single global uniform name space. Hence,</nobr> <nobr>the types and + initializers of uniform variables with the same name must match across + all shaders that are</nobr> <nobr>linked into a single executable. It is + legal for some shaders to provide an initializer for a particular</nobr> <nobr>uniform + variable, while another shader does not, but all provided initializers + must be equal.</nobr> + </p> + </body> +</html> + + + + + + matrixCompMult + + + BUILD_IN_FUNC + (mat2, mat2) + mat2 + + + BUILD_IN_FUNC + (mat3, mat3) + mat3 + + + BUILD_IN_FUNC + (mat4, mat4) + mat4 + + + + + gl_BackLightModelProduct + + + BUILD_IN_VAR + uniform gl_LightModelProducts + + + + + equal + + + BUILD_IN_FUNC + (bvec2, bvec2) + bvec2 + + + BUILD_IN_FUNC + (bvec3, bvec3) + bvec3 + + + BUILD_IN_FUNC + (bvec4, bvec4) + bvec4 + + + + + gl_NormalScale + + + BUILD_IN_VAR + uniform float + + + + + gl_ModelViewProjectionMatrixInverse + + + BUILD_IN_VAR + uniform mat4 + + + + + gl_DepthRange + + + BUILD_IN_VAR + uniform gl_DepthRangeParameters + + + + + isampler2DArray + + + TYPE + a handle for accessing an integer 2D array texture + <html> + <head> + + </head> + <body> + a handle for accessing an integer 2D array texture + </body> +</html> + + + + + + out + + + QUALIFIER + copied out on return, but not initialized + + + + + noperspective + + + QUALIFIER + linear interpolation + <html> + <head> + + </head> + <body> + <p> + linear interpolation + </p> + </body> +</html> + + + + + + samplerCube + + + TYPE + handle for accessing a cube mapped texture + <html> + <head> + + </head> + <body> + </body> + </html> + + + + + + sampler2DShadow + + + TYPE + handle for accessing a 2D depth texture with comparison + <html> + <head> + + </head> + <body> + </body> + </html> + + + + + + for + + + ITERATION + <html> + <head> + + </head> + <body> + + </body> +</html> + + + + + + break + + + JUMP + + + + + invariant + + + QUALIFIER + ensures all calculations of this variable give identical values across programs + <html> + <head> + + </head> + <body> + To ensure that a particular output variable is invariant, it is necessary + to use the <b>invariant </b>qualifier. It can either be used to qualify a + previously declared variable as being invariant + + <blockquote> + <code><nobr>invariant gl_Position; // make existing gl_Position be invariant</nobr><br><nobr>varying + vec3 Color;</nobr><br><nobr>invariant Color; // make existing Color be invariant</nobr><br></code> + </blockquote> + <p> + or as part of a declaration when a variable is declared + </p> + <blockquote> + <code><nobr>invariant varying vec3 Color;</nobr></code> + </blockquote> + <p> + The invariant qualifier must appear before any storage qualifiers (<b>varying</b>) + when combined with a declaration. Only variables output from a vertex + shader can be candidates for invariance. This includes user-defined + varying variables, the built-in vertex-side varying variables, and the + special vertex variables <i>gl_Position </i>and <i>gl_PointSize</i>. For + varying variables leaving a vertex shader and coming into a fragment + shader with the same name, the <b>invariant </b>keyword has to be used + in both the vertex and fragment shaders. The <b>invariant </b>keyword + can be followed by a comma separated list of previously declared + identifiers. All uses of <b>invariant </b>must be at the global scope, + and before any use of the variables being declared as invariant. + </p> + <p> + To guarantee invariance of a particular output variable across two + programs, the following must also be true: + </p> + <ul> + <li> + The output variable is declared as invariant in both programs. + </li> + <li> + The same values must be input to all shader input variables consumed + by expressions and flow control contributing to the value assigned to + the output variable. + </li> + <li> + The texture formats, texel values, and texture filtering are set the + same way for any texture function calls contributing to the value of + the output variable. + </li> + <li> + All input values are all operated on in the same way. All operations + in the consuming expressions and any intermediate expressions must be + the same, with the same order of operands and same associativity, to + give the same order of evaluation. Intermediate variables and + functions must be declared as the same type with the same explicit or + implicit precision qualifiers. Any control flow affecting the output + value must be the same, and any expressions consumed to determine this + control flow must also follow these invariance rules. + </li> + <li> + All the data flow and control flow leading to setting the invariant + output variable reside in a single compilation unit. + </li> + </ul> + <p> + Essentially, all the data flow and control flow leading to an invariant + output must match. Initially, by default, all output variables are + allowed to be variant. To force all output variables to be invariant, + use the pragma + </p> + <blockquote> + <code>#pragma STDGL invariant(all)</code> + </blockquote> + <p> + before all declarations in a shader. If this pragma is used after the + declaration of any variables or functions, then the set of outputs that + behave as invariant is undefined. It is an error to use this pragma in a + fragment shader. + </p> + <p> + Generally, invariance is ensured at the cost of flexibility in + optimization, so performance can be degraded by use of invariance. + Hence, use of this pragma is intended as a debug aid, to avoid + individually declaring all output variables as invariant. + </p> + </body> +</html> + + + + + + abs + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Returns x if x &gt;= 0, otherwise it returns -x + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Returns x if x &gt;= 0, otherwise it returns -x + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Returns x if x &gt;= 0, otherwise it returns -x + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Returns x if x &gt;= 0, otherwise it returns -x + </body> + </html> + + (vec4) + vec4 + + + + + greaterThanEqual + + + BUILD_IN_FUNC + (ivec2, ivec2) + bvec2 + + + BUILD_IN_FUNC + (ivec3, ivec3) + bvec3 + + + BUILD_IN_FUNC + (ivec4, ivec4) + bvec4 + + + + + gl_NormalMatrix + + + BUILD_IN_VAR + uniform mat3 + + + + + false + + + KEYWORD + boolean value + + + + + gl_ModelViewMatrixInverse + + + BUILD_IN_VAR + uniform mat4 + + + + + gl_ModelViewProjectionMatrix + + + BUILD_IN_VAR + uniform mat4 + + + + + refract + + + BUILD_IN_FUNC + (float, float, float eta) + float + + + BUILD_IN_FUNC + (vec2, vec2, float eta) + vec2 + + + BUILD_IN_FUNC + (vec3, vec3, float eta) + vec3 + + + BUILD_IN_FUNC + (vec4 I, vec4 M, float eta) + vec4 + + + + + dFdx + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + dFdy + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + gl_ModelViewProjectionMatrixInverseTranspose + + + BUILD_IN_VAR + uniform mat4 + + + + + lessThanEqual + + + BUILD_IN_FUNC + (ivec2, ivec2) + bvec2 + + + BUILD_IN_FUNC + (ivec3, ivec3) + bvec3 + + + BUILD_IN_FUNC + (ivec4, ivec4) + bvec4 + + + + + usampler1D + + + TYPE + a handle for accessing an unsigned integer 1D texture + <html> + <head> + + </head> + <body> + a handle for accessing an unsigned integer 1D texture + </body> +</html> + + + + + + not + + + BUILD_IN_FUNC + (bvec2) + bvec2 + + + BUILD_IN_FUNC + (bvec3) + bvec3 + + + BUILD_IN_FUNC + (bvec4) + bvec4 + + + + + gl_ModelViewMatrixInverseTranspose + + + BUILD_IN_VAR + uniform mat4 + + + + + greaterThan + + + BUILD_IN_FUNC + (ivec2, ivec2) + bvec2 + + + BUILD_IN_FUNC + (ivec3, ivec3) + bvec3 + + + BUILD_IN_FUNC + (ivec4, ivec4) + bvec4 + + + + + gl_Fog + + + BUILD_IN_VAR + uniform gl_FogParameters + + + + + tan + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric tangent function. Angle in radians. + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric tangent function. Angle in radians. + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric tangent function. Angle in radians. + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric tangent function. Angle in radians. + </body> + </html> + + (vec4) + vec4 + + + + + cross + + + BUILD_IN_FUNC + (vec3, vec3) + vec3 + + + + + gl_ClipPlane + + + BUILD_IN_VAR + INDEX < gl_MaxClipPlanes + [] + uniform vec4 + + + + + textureCube + + + BUILD_IN_FUNC + (samplerCube, vec3, float bias) + vec4 + + + + + const + + + QUALIFIER + constant function input + + + + + gl_MaxTextureUnits + + + BUILD_IN_VAR + value >= 2 since OpenGL 1.3 + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum available multitexture + statges.<br>This constant can + be also queried by calling <b>glGetIntegerv</b> with the symbolic constant <i>GL_MAX_TEXTURE_UNITS</i>. + The minimum value is 2. + </body> +</html> + + const int + + + + + mediump + + + QUALIFIER + <html> + <head> + + </head> + <body> + qualifier for medium precision + </body> +</html> + + + + + + inout + + + QUALIFIER + value initialized on entry, and copied out on return + + + + + switch + + + KEYWORD + + + + + gl_FrontLightModelProduct + + + BUILD_IN_VAR + uniform gl_LightModelProducts + + + + + shadow1DProj + + + BUILD_IN_FUNC + (sampler1DShadow, vec4, float bias) + vec4 + + + + + usampler1DArray + + + TYPE + a handle for accessing an unsigned integer 1D array texture + <html> + <head> + + </head> + <body> + a handle for accessing an unsigned integer 1D array texture + </body> +</html> + + + + + + gl_EyePlaneT + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + gl_EyePlaneS + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + gl_EyePlaneR + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + distance + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (vec2, vec2) + float + + + BUILD_IN_FUNC + (vec3, vec3) + float + + + BUILD_IN_FUNC + (vec4, vec4) + float + + + + + gl_EyePlaneQ + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + sampler1DShadow + + + TYPE + handle for accessing a 1D depth texture with comparison + <html> + <head> + + </head> + <body> + a handle for accessing a 1D depth texture with comparison + </body> +</html> + + + + + + gl_ProjectionMatrix + + + BUILD_IN_VAR + uniform mat4 + + + + + gl_TextureEnvColor + + + BUILD_IN_VAR + INDEX < gl_MaxTextureUnits + [] + uniform vec4 + + + + + length + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + float + + + BUILD_IN_FUNC + (vec3) + float + + + BUILD_IN_FUNC + (vec4) + float + + + + + gl_ModelViewMatrixTranspose + + + BUILD_IN_VAR + uniform mat4 + + + + + gl_FrontMaterial + + + BUILD_IN_VAR + uniform gl_MaterialParameters + + + + + sampler2DArray + + + TYPE + a handle for accessing a 2D array texture + <html> + <head> + + </head> + <body> + a handle for accessing a 2D array texture + </body> +</html> + + + + + + + min + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (vec2, float) + vec2 + + + BUILD_IN_FUNC + (vec3, float) + vec3 + + + BUILD_IN_FUNC + (vec4, float) + vec4 + + + + + gl_LightSource + + + BUILD_IN_VAR + INDEX < gl_MaxLights + [] + uniform gl_LightSourceParameters + + + + + return + + + JUMP + + + + + void + + + TYPE + for functions that do not return a value + + + + + true + + + KEYWORD + boolean value + + + + + mix + + + BUILD_IN_FUNC + (float, float, float) + float + + + BUILD_IN_FUNC + (vec2, vec2, float) + vec2 + + + BUILD_IN_FUNC + (vec3, vec3, float) + vec3 + + + BUILD_IN_FUNC + (vec4, vec4, float) + vec4 + + + + + texture3DProj + + + BUILD_IN_FUNC + (sampler3D, vec4, float bias) + vec4 + + + + + gl_MaxDrawBuffers + + + BUILD_IN_VAR + value >= 1 ARB_draw_buffers required + min = 1; // proposed ARB_draw_buffers + const int + + + + + gl_ProjectionMatrixTranspose + + + BUILD_IN_VAR + uniform mat4 + + + + + lowp + + + QUALIFIER + <html> + <head> + + </head> + <body> + qualifier for low precision + </body> +</html> + + + + + + isamplerCube + + + TYPE + a handle for accessing an integer cube mapped texture + <html> + <head> + + </head> + <body> + a handle for accessing an integer cube mapped texture + </body> +</html> + + + + + + gl_ModelViewMatrix + + + BUILD_IN_VAR + uniform mat4 + + + + + fwidth + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + atan + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y + are used to determine what quadrant the angle is in. The range of values + returned by this function is [-Pi, Pi]. Results are undefined if x and y + are both 0. + </body> + </html> + + (float, float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y + are used to determine what quadrant the angle is in. The range of values + returned by this function is [-Pi, Pi]. Results are undefined if x and y + are both 0. + </body> + </html> + + (vec2, vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y + are used to determine what quadrant the angle is in. The range of values + returned by this function is [-Pi, Pi]. Results are undefined if x and y + are both 0. + </body> + </html> + + (vec3, vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y + are used to determine what quadrant the angle is in. The range of values + returned by this function is [-Pi, Pi]. Results are undefined if x and y + are both 0. + </body> + </html> + + (vec4, vec4) + vec4 + + + + + gl_MaxVaryingFloats + + + BUILD_IN_VAR + value >= 32 + min = 32; // ARB_vertex_shader + const int + + + + + fract + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + gl_Point + + + BUILD_IN_VAR + uniform gl_PointParameters + + + + + texture3DProjLod + + + BUILD_IN_FUNC + (sampler3D, vec4, float lod) + vec4 + + + + + gl_ObjectPlaneS + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + gl_ObjectPlaneT + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + isampler2D + + + TYPE + a handle for accessing an integer 2D texture + <html> + <head> + + </head> + <body> + a handle for accessing an integer 2D texture + </body> +</html> + + + + + + exp2 + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + gl_ObjectPlaneR + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + gl_ObjectPlaneQ + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + lessThan + + + BUILD_IN_FUNC + (ivec2, ivec2) + bvec2 + + + BUILD_IN_FUNC + (ivec3, ivec3) + bvec3 + + + BUILD_IN_FUNC + (ivec4, ivec4) + bvec4 + + + + + shadow2DProjLod + + + BUILD_IN_FUNC + (sampler2DShadow, vec4, float lod) + vec4 + + + + + gl_MaxTextureImageUnits + + + BUILD_IN_VAR + value >= 2 + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum available texture image + units in a fragment shader.<br> The texture image unit constant specifyes the + number of hardware units that can be used simultaneously for accessing + texture maps. This constant can be also queried by calling <b>glGetIntegerv</b> + with the symbolic constant <i>GL_MAX_TEXTURE_IMAGE_UNITS_ARB</i>. The + minimum value is 2. + </body> +</html> + + const int + + + + + gl_FrontLightProduct + + + BUILD_IN_VAR + INDEX < gl_MaxLights + [] + uniform gl_LightProducts + + + + + gl_MaxClipPlanes + + + BUILD_IN_VAR + value >= 6 since OpenGL 1.0 + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum supported clip planes. + + <p> + This constant can be also queried by calling <b>glGetIntegerv</b> with + the symbolic constant <i>GL_MAX_CLIP_PLANES_ARB</i>. The minimum value + is 6. + </p> + </body> +</html> + + const int + + + + + inversesqrt + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + gl_TextureMatrixInverseTranspose + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform mat4 + + + + + int + + + TYPE + signed integer + + + + + gl_MaxLights + + + BUILD_IN_VAR + value >= 8 since OpenGL 1.0 + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum allowed dynamic light + sources.<br> The minimum value is 8. + </body> +</html> + + const int + + + + + flat + + + QUALIFIER + no interpolation + <html> + <head> + + </head> + <body> + <p> + no interpolation. + </p> + </body> +</html> + + + + + + log2 + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + isampler3D + + + TYPE + a handle for accessing an integer 3D texture + <html> + <head> + + </head> + <body> + a handle for accessing an integer 3D texture + </body> +</html> + + + + + + exp + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + ftransform + + + BUILD_IN_FUNC + () + vec4 + + + + + mat4 + + + TYPE + 4×4 floating-point matrix + + + + + default + + + KEYWORD + + + + + sampler1D + + + TYPE + handle for accessing a 1D texture + + + + + mat2 + + + TYPE + 2×2 floating-point matrix + + + + + mat3 + + + TYPE + 3×3 floating-point matrix + + + + + gl_ModelViewProjectionMatrixTranspose + + + BUILD_IN_VAR + uniform mat4 + + + + + textureCubeLod + + + BUILD_IN_FUNC + (samplerCube, vec3, float lod) + vec4 + + + + + usampler2D + + + TYPE + a handle for accessing an unsigned integer 2D texture + <html> + <head> + + </head> + <body> + a handle for accessing an unsigned integer 2D texture + </body> +</html> + + + + + + gl_TextureMatrix + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform mat4 + + + + + gl_ProjectionMatrixInverse + + + BUILD_IN_VAR + uniform mat4 + + + + + shadow1DLod + + + BUILD_IN_FUNC + (sampler1DShadow, vec3, float lod) + vec4 + + + + + while + + + ITERATION + + + + + sampler2D + + + TYPE + handle for accessing a 2D texture + + + + + texture1DProj + + + BUILD_IN_FUNC + (sampler1D, vec2, float bias) + vec4 + + + BUILD_IN_FUNC + (sampler1D, vec4, float bias) + vec4 + + + + + if + + + SELECTION + + + + + shadow2DProj + + + BUILD_IN_FUNC + (sampler2DShadow, vec4, float bias) + vec4 + + + + + isampler1DArray + + + TYPE + a handle for accessing an integer 1D array texture + <html> + <head> + + </head> + <body> + a handle for accessing an integer 1D array texture + </body> +</html> + + + + + + acos + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc cosine. Returns an angle whose cosine is x. The range of values + returned by this function is [0, pi]. Results are undefined if |x|&gt;1. + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc cosine. Returns an angle whose cosine is x. The range of values + returned by this function is [0, pi]. Results are undefined if |x|&gt;1. + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc cosine. Returns an angle whose cosine is x. The range of values + returned by this function is [0, pi]. Results are undefined if |x|&gt;1. + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc cosine. Returns an angle whose cosine is x. The range of values + returned by this function is [0, pi]. Results are undefined if |x|&gt;1. + </body> + </html> + + (vec4) + vec4 + + + + + usampler3D + + + TYPE + a handle for accessing an unsigned integer 3D texture + <html> + <head> + + </head> + <body> + a handle for accessing an unsigned integer 3D texture + </body> +</html> + + + + + + degrees + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts radians to degrees, i.e. 180/Pi * radians + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts radians to degrees, i.e. 180/Pi * radians + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts radians to degrees, i.e. 180/Pi * radians + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts radians to degrees, i.e. 180/Pi * radians + </body> + </html> + + (vec4) + vec4 + + + + + in + + + QUALIFIER + value initialized on entry, not copied on return (default) + + + + + sampler3D + + + TYPE + handle for accessing a 3D texture + + + + + continue + + + JUMP + + + + + bool + + + TYPE + conditional type, taking on values of true or false (also known as boolean) + + + + + step + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (float, vec2) + vec2 + + + BUILD_IN_FUNC + (float, vec3) + vec3 + + + BUILD_IN_FUNC + (float, vec4) + vec4 + + + + + uint + + + TYPE + an unsigned integer + <html> + <head> + + </head> + <body> + an unsigned integer + </body> +</html> + + + + + + + + gl_FragDepth + + + BUILD_IN_VAR + pixel depth + <html> + <head> + + </head> + <body> + Writing to <i>gl_FragDepth </i>will establish the depth value for the + fragment being processed. If depth buffering is enabled, and no shader + writes <i>gl_FragDepth</i>, then the fixed function value for depth will + be used as the fragment&#8217;s depth value. If a shader statically assigns a + value to <i>gl_FragDepth</i>, and there is an execution path through the + shader that does not set <i>gl_FragDepth</i>, then the value of the + fragment&#8217;s depth may be undefined for executions of the shader that take + that path. That is, if the set of linked fragment shaders statically + contain a write to <i>gl_FragDepth</i>, then it is responsible for always + writing it. + + <p> + (A shader contains a <i>static assignment </i>to a variable <i>x </i>if, + after pre-processing, the shader contains a statement that would write + to <i>x</i>, whether or not run-time flow of control will cause that + statement to be executed.) + </p> + </body> + </html> + + float + + + + + gl_FragCoord + + + BUILD_IN_VAR + pixel coordinate (READ ONLY) + <html> + <head> + + </head> + <body> + The variable <i>gl_FragCoord </i>is available as a read-only variable from + within fragment shaders and it holds the window relative coordinates x, y, + z, and 1/w values for the fragment. If multi-sampling, this value can be + for any location within the pixel, or one of the fragment samples. The use + of <b>centroid </b>varyings does not further restrict this value to be + inside the current primitive. This value is the result of the fixed + functionality that interpolates primitives after vertex processing to + generate fragments. The <i>z </i>component is the depth value that would + be used for the fragment&#8217;s depth if no shader contained no writes to <i>gl_FragDepth. + </i>This is useful for invariance if a shader conditionally computes <i>gl_FragDepth + </i>but otherwise wants the fixed functionality fragment depth. + </body> + </html> + + vec4 + + + + + gl_PointCoord + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + The values in <i>gl_PointCoord </i>are two-dimensional coordinates + indicating where within a point primitive the current fragment is located, + when point sprites are enabled. They range from 0.0 to 1.0 across the + point. If the current primitive is not a point, or if point sprites are + not enabled, then the values read from gl_PointCoord are undefined. + </body> + </html> + + vec2 + + + + + gl_FrontFacing + + + BUILD_IN_VAR + (READ ONLY) + <html> + <head> + + </head> + <body> + Fragment shaders have access to the read-only built-in variable <i>gl_FrontFacing, + </i>whose value is <b>true </b>if the fragment belongs to a front-facing + primitive.<p> One use of this is to emulate two-sided lighting + by selecting one of two colors calculated by the vertex shader or geometry + shader. + </body> +</html> + + bool + + + + + gl_Color + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + The values in <i>gl_Color </i>and <i>gl_SecondaryColor </i>will be derived + automatically by the system from <i>gl_FrontColor, gl_BackColor, + gl_FrontSecondaryColor, </i>and <i>gl_BackSecondaryColor </i>based on + which face is visible. If fixed functionality is used for vertex + processing, then <i>gl_FogFragCoord </i>will either be the z-coordinate of + the fragment in eye space, or the interpolation of the fog coordinate, as + described in section 3.10 of the OpenGL 1.4 Specification. The <i>gl_TexCoord[] + </i>values are the interpolated <i>gl_TexCoord[] </i>values from a vertex + shader or the texture coordinates of any fixed pipeline based vertex + functionality. + </body> + </html> + + varying vec4 + + + + + discard + + + JUMP + <html> + <head> + + </head> + <body> + The <b>discard </b>keyword is only allowed within fragment shaders. It can + be used within a fragment shader to abandon the operation on the current + fragment. This keyword causes the fragment to be discarded and no updates + to any buffers will occur. It would typically be used within a conditional + statement, for example: + + <pre> if (intensity &lt; 0.0) + discard; + </pre> + A fragment shader may test a fragment&#8217;s alpha value and discard the + fragment based on that test. However, it should be noted that coverage + testing occurs after the fragment shader runs, and the coverage test can + change the alpha value. + </body> + </html> + + + + + + gl_SecondaryColor + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + The values in <i>gl_Color </i>and <i>gl_SecondaryColor </i>will be derived + automatically by the system from <i>gl_FrontColor, gl_BackColor, + gl_FrontSecondaryColor, </i>and <i>gl_BackSecondaryColor </i>based on + which face is visible. If fixed functionality is used for vertex + processing, then <i>gl_FogFragCoord </i>will either be the z-coordinate of + the fragment in eye space, or the interpolation of the fog coordinate, as + described in section 3.10 of the OpenGL 1.4 Specification. The <i>gl_TexCoord[] + </i>values are the interpolated <i>gl_TexCoord[] </i>values from a vertex + shader or the texture coordinates of any fixed pipeline based vertex + functionality. + </body> + </html> + + varying vec4 + + + + + gl_FragData + + + BUILD_IN_VAR + INDEX<gl_MaxDrawBuffers + <html> + <head> + + </head> + <body> + The variable <i>gl_FragData </i>is an array. Writing to <i>gl_FragData[n] </i>specifies + the fragment data that will be used by the subsequent fixed functionality + pipeline for data <i>n</i>. If subsequent fixed functionality consumes + fragment data and an execution of a fragment shader executable does not + write a value to it, then the fragment data consumed is undefined. + </body> + </html> + + [] + vec4 + + + + + gl_FragColor + + + BUILD_IN_VAR + pixel color + <html> + <head> + + </head> + <body> + If a shader statically assigns a value to <i>gl_FragColor</i>, it may not + assign a value to any element of <i>gl_FragData</i>. If a shader + statically writes a value to any element of <i>gl_FragData</i>, it may not + assign a value to <i>gl_FragColor</i>. That is, a shader may assign values + to either <i>gl_FragColor </i>or <i>gl_FragData</i>, but not both. + Multiple shaders linked together must also consistently write just one of + these variables. + </body> + </html> + + vec4 + + + + + + + gl_BackColor + + + BUILD_IN_VAR + enable GL_VERTEX_PROGRAM_TWO_SIDE + varying vec4 + + + + + gl_FogFragCoord + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + For <i>gl_FogFragCoord</i>, the value written will be used as the &quot;c&quot; + value on page 160 of the OpenGL 1.4 Specification by the fixed + functionality pipeline. For example, if the z-coordinate of the fragment + in eye space is desired as &quot;c&quot;, then that's what the vertex or geometry shader + executable should write into <i>gl_FogFragCoord</i>. + </body> + </html> + + varying float + + + + + gl_Position + + + BUILD_IN_VAR + must be written from vertex shader + <html> + <head> + + </head> + <body> + The variable <i>gl_Position</i> is available only in the vertex and + geometry language and is intended for writing the homogeneous vertex + position. + + <p> + It can be written at any time during shader execution. It may also be + read back by the shader after being written. This value will be used by + primitive assembly, clipping, culling, and other fixed functionality + operations that operate on primitives after vertex or geometry + processing has occurred. Compilers may generate a diagnostic message if + they detect <i>gl_Position</i> is read before being written, but not all + such cases are detectable. Writing to <i>gl_Position</i> is optional. If <i>gl_Position</i> + is not written but subsequent stages of the OpenGL pipeline consume <i>gl_Position</i>, + then results are undefined. + </p> + </body> +</html> + + vec4 + + + + + gl_TexCoord + + + BUILD_IN_VAR + INDEX<gl_MaxTextureCoords + <html> + <head> + + </head> + <body> + As with all arrays, indices used to subscript <i>gl_TexCoord </i>must + either be an integral constant expressions, or this array must be + re-declared by the shader with a size. The size can be at most <i>gl_MaxTextureCoords</i>. + Using indexes close to 0 may aid the implementation in preserving varying + resources. + </body> + </html> + + [] + varying vec4 + + + + + gl_FrontSecondaryColor + + + BUILD_IN_VAR + varying vec4 + + + + + attribute + + + QUALIFIER + linkage between a vertex shader and OpenGL for per-vertex data (READ-ONLY) + <html> + <head> + + </head> + <body> + The <b>attribute </b>qualifier is used to declare variables that are + passed to a vertex shader from OpenGL on a per-vertex basis. It is an + error to declare an attribute variable in any type of shader other than a + vertex shader. Attribute variables are read-only as far as the vertex + shader is concerned. Values for attribute variables are passed to a vertex + shader through the OpenGL vertex API or as part of a vertex array. They + convey vertex attributes to the vertex shader and are expected to change + on every vertex shader run. The attribute qualifier can be used only with <b>float, + </b>floating-point vectors, and matrices. Attribute variables cannot be + declared as arrays or structures.<p>Example declarations: + + <pre>attribute vec4 position; +attribute vec3 normal; +attribute vec2 texCoord;</pre> + <p> + All the standard OpenGL vertex attributes have built-in variable names + to allow easy integration between user programs and OpenGL vertex + functions. See Section 7 &quot;Built-in Variables&quot; of the OpenGL Shading + Language specification; for a list of the built-in attribute names. + </p> + <p> + It is expected that graphics hardware will have a small number of fixed + locations for passing vertex attributes. Therefore, the OpenGL Shading + language defines each non-matrix attribute variable as having space for + up to four floating-point values (i.e., a vec4). There is an + implementation dependent limit on the number of attribute variables that + can be used and if this is exceeded it will cause a link error. + (Declared attribute variables that are not used do not count against + this limit.) A float attribute counts the same amount against this limit + as a vec4, so applications may want to consider packing groups of four + unrelated float attributes together into a vec4 to better utilize the + capabilities of the underlying hardware. A matrix attribute will use up + multiple attribute locations. The number of locations used will equal + the number of columns in the matrix. + </p> + <p> + Attribute variables are required to have global scope, and must be + declared outside of function bodies, before their first use. + </p> + </body> +</html> + + + + + + gl_BackSecondaryColor + + + BUILD_IN_VAR + enable GL_VERTEX_PROGRAM_TWO_SIDE + varying vec4 + + + + + gl_FrontColor + + + BUILD_IN_VAR + varying vec4 + + + + + gl_FogCoord + + + BUILD_IN_VAR + attribute float + + + + + gl_MultiTexCoord7 + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_MultiTexCoord6 + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_MultiTexCoord5 + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_PointSize + + + BUILD_IN_VAR + may be written from vertex shader + <html> + <head> + + </head> + <body> + The variable <i>gl_PointSize </i>is available only in the vertex and geometry language + and is intended to write the size of the point to be + rasterized. It is measured in pixels. + + <p> + If <i>gl_PointSize </i>or <i>gl_ClipVertex </i>are not written to, their + values are undefined. Any of these variables can be read back by the + shader after writing to them, to retrieve what was written. Reading them + before writing them results in undefined behavior. If they are written + more than once, it is the last value written that is consumed by the + subsequent operations. These built-in variables have global scope. + </p> + </body> + </html> + + float + + + + + gl_Color + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_MultiTexCoord0 + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_Normal + + + BUILD_IN_VAR + attribute vec3 + + + + + gl_Vertex + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_SecondaryColor + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_MultiTexCoord4 + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_MultiTexCoord3 + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_ClipVertex + + + BUILD_IN_VAR + may be written from vertex shader + <html> + <head> + + </head> + <body> + The variable <i>gl_ClipVertex </i>is available only in the vertex and geometry language + and provides a place for vertex and geometry shaders to write the coordinate to be used + with the user clipping planes. The user must ensure the clip vertex and + user clipping planes are defined in the same coordinate space. User clip + planes work properly only under linear transform. It is undefined what + happens under non-linear transform. + + <p> + If <i>gl_PointSize </i>or <i>gl_ClipVertex </i>are not written to, their + values are undefined. Any of these variables can be read back by the + shader after writing to them, to retrieve what was written. Reading them + before writing them results in undefined behavior. If they are written + more than once, it is the last value written that is consumed by the + subsequent operations. These built-in variables have global scope. + </p> + </body> + </html> + + vec4 + + + + + gl_MultiTexCoord2 + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_MultiTexCoord1 + + + BUILD_IN_VAR + attribute vec4 + + + + + + + gl_FogFragCoord + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + For <i>gl_FogFragCoord</i>, the value written will be used as the &quot;c&quot; + value on page 160 of the OpenGL 1.4 Specification by the fixed + functionality pipeline. For example, if the z-coordinate of the fragment + in eye space is desired as &quot;c&quot;, then that's what the vertex or geometry shader + executable should write into <i>gl_FogFragCoord</i>. + </body> + </html> + + varying out float + + + + + gl_BackColor + + + BUILD_IN_VAR + enable GL_VERTEX_PROGRAM_TWO_SIDE + varying out vec4 + + + + + gl_Layer + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + The built-in output variable <i>gl_Layer</i> is available only in the + geometry language, and provides the number of the layer of textures + attached to a FBO to direct rendering to.<p> If a shader statically assigns a + value to <i>gl_Layer</i>, layered rendering mode is enabled. See section + 2.16.4 for a detailed explanation. If a shader statically assigns a value + to <i>gl_Layer</i>, and there is an execution path through the shader that + does not set <i>gl_Layer</i>, then the value of <i>gl_Layer</i> may be + undefined for executions of the shader that take that path. + </body> +</html> + + int + + + + + gl_Position + + + BUILD_IN_VAR + must be written from vertex shader + <html> + <head> + + </head> + <body> + The variable <i>gl_Position</i> is available only in the vertex and + geometry language and is intended for writing the homogeneous vertex + position. + + <p> + It can be written at any time during shader execution. It may also be + read back by the shader after being written. This value will be used by + primitive assembly, clipping, culling, and other fixed functionality + operations that operate on primitives after vertex or geometry + processing has occurred. Compilers may generate a diagnostic message if + they detect <i>gl_Position</i> is read before being written, but not all + such cases are detectable. Writing to <i>gl_Position</i> is optional. If <i>gl_Position</i> + is not written but subsequent stages of the OpenGL pipeline consume <i>gl_Position</i>, + then results are undefined. + </p> + </body> +</html> + + vec4 + + + + + gl_TexCoord + + + BUILD_IN_VAR + INDEX<gl_MaxTextureCoords + <html> + <head> + + </head> + <body> + As with all arrays, indices used to subscript <i>gl_TexCoord </i>must + either be an integral constant expressions, or this array must be + re-declared by the shader with a size. The size can be at most <i>gl_MaxTextureCoords</i>. + Using indexes close to 0 may aid the implementation in preserving varying + resources. + </body> + </html> + + [] + varying out vec4 + + + + + gl_FogFragCoordIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in float + + + + + EmitVertex + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The function <b>EmitVertex()</b> specifies that a vertex is completed. A + vertex is added to the current output primitive using the current values + of the varying output variables and the current values of the special + built-in output variables <b>gl_PointSize</b>, <b>gl_ClipVertex</b>, <b>gl_Layer</b>, + gl_Position</b> and <b>gl_PrimitiveID</b>. + + <p> + The values of any unwritten output variables are undefined. The values + of all varying output variables and the special built-in output + variables are undefined after a call to <b>EmitVertex()</b>. If a + geometry shader, in one invocation, emits more vertices than the value <i>GEOMETRY_VERTICES_OUT_EXT</i>, + these emits may have no effect. + </p> + </body> +</html> + + () + void + + + + + gl_BackColorIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in vec4 + + + + + gl_PointSizeIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in float + + + + + gl_FrontSecondaryColor + + + BUILD_IN_VAR + varying out vec4 + + + + + gl_BackSecondaryColorIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in vec4 + + + + + gl_ClipVertexIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in vec4 + + + + + gl_BackSecondaryColor + + + BUILD_IN_VAR + enable GL_VERTEX_PROGRAM_TWO_SIDE + varying out vec4 + + + + + gl_TexCoordIn + + + BUILD_IN_VAR + value <= gl_MaxTextureCoords + +value <= gl_MaxTextureCoords + [gl_VerticesIn][] + varying in vec4 + + + + + gl_FrontColorIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in vec4 + + + + + gl_FrontColor + + + BUILD_IN_VAR + varying out vec4 + + + + + gl_FrontSecondaryColorIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in vec4 + + + + + gl_VerticesIn + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + <p> + Value set at link time. + </p> + </body> +</html> + + const int + + + + + gl_PointSize + + + BUILD_IN_VAR + may be written from vertex shader + <html> + <head> + + </head> + <body> + The variable <i>gl_PointSize </i>is available only in the vertex and geometry language + and is intended to write the size of the point to be + rasterized. It is measured in pixels. + + <p> + If <i>gl_PointSize </i>or <i>gl_ClipVertex </i>are not written to, their + values are undefined. Any of these variables can be read back by the + shader after writing to them, to retrieve what was written. Reading them + before writing them results in undefined behavior. If they are written + more than once, it is the last value written that is consumed by the + subsequent operations. These built-in variables have global scope. + </p> + </body> + </html> + + float + + + + + EndPrimitive + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The function <b>EndPrimitive()</b> specifies that the current output + primitive is completed and a new output primitive (of the same type) + should be started. This function does not emit a vertex.<br> The effect of <b>EndPrimitive()</b> + is roughly equivalent to calling End followed by a new Begin, where the + primitive mode is taken from the program object parameter <i>GEOMETRY_OUTPUT_TYPE_EXT</i>. + If the output primitive type is <i>POINTS</i>, calling <b>EndPrimitive()</b> + is optional. + + <p> + A geometry shader starts with an output primitive containing no + vertices. When a geometry shader terminates, the current output + primitive is automatically completed. It is not necessary to call <b>EndPrimitive()</b> + if the geometry shader writes only a single primitive. + </p> + </body> +</html> + + () + void + + + + + gl_PositionIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in vec4 + + + + + gl_PrimitiveID + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + The built-in output variable <i>gl_PrimitiveID</i> is available only in the + geometry language and provides a single integer that serves as a primitive + identifier.<p> This written primitive ID is available to fragment shaders. + If a fragment shader using primitive IDs is active and a geometry shader + is also active, the geometry shader must write to <i>gl_PrimitiveID</i> or the + primitive ID in the fragment shader number is undefined. + </body> +</html> + + int + + + + + gl_ClipVertex + + + BUILD_IN_VAR + may be written from vertex shader + <html> + <head> + + </head> + <body> + The variable <i>gl_ClipVertex </i>is available only in the vertex and geometry language + and provides a place for vertex and geometry shaders to write the coordinate to be used + with the user clipping planes. The user must ensure the clip vertex and + user clipping planes are defined in the same coordinate space. User clip + planes work properly only under linear transform. It is undefined what + happens under non-linear transform. + + <p> + If <i>gl_PointSize </i>or <i>gl_ClipVertex </i>are not written to, their + values are undefined. Any of these variables can be read back by the + shader after writing to them, to retrieve what was written. Reading them + before writing them results in undefined behavior. If they are written + more than once, it is the last value written that is consumed by the + subsequent operations. These built-in variables have global scope. + </p> + </body> + </html> + + vec4 + + + + + diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/JmeVocabulary.xml b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/JmeVocabulary.xml new file mode 100644 index 000000000..287c9111d --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/JmeVocabulary.xml @@ -0,0 +1,4724 @@ + + + + + pow + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (vec2, vec2) + vec2 + + + BUILD_IN_FUNC + (vec3, vec3) + vec3 + + + BUILD_IN_FUNC + (vec4, vec4) + vec4 + + + + + float + + + TYPE + single floating-point scalar + + + + + dot + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (vec2, vec2) + float + + + BUILD_IN_FUNC + (vec3, vec3) + float + + + BUILD_IN_FUNC + (vec4, vec4) + float + + + + + gl_MaxFragmentUniformComponents + + + BUILD_IN_VAR + value >= 64 ARB_fragment_shader required + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum allowed uniform + components inside the fragment shader.<br> This limit refers to the storage + for the combination of build-in uniform variables and user-defined uniform + variables that are actually used in a fragment shader. This constant can + be also queried by calling <b>glGetIntegerv</b> with the symbolic constant <i>GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB</i>. + The minimum value is 64 if <i>ARB_fragment_shader</i> is supported. + </body> +</html> + + const int + + + + + else + + + SELECTION + + + + + gl_BackLightProduct + + + BUILD_IN_VAR + INDEX < gl_MaxLights + [] + uniform gl_LightProducts + + + + + mod + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (vec2, float) + vec2 + + + BUILD_IN_FUNC + (vec3, float) + vec3 + + + BUILD_IN_FUNC + (vec4, float) + vec4 + + + + + gl_MaxVertexAttribs + + + BUILD_IN_VAR + value >= 16 ARB_vertex_shader required + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum useable vertex attributes + in a vertex shader.<br> This limit consists of the standard (build-in) attributes (these are color, secondary color, normal, vertex position, texture coordinates, and fog coordinates) and the generic attributes left for custom purposes. This constant can be also queried by calling <b>glGetIntegerv</b> + with the symbolic constant <i>GL_MAX_VERTEX_ATTRIBS_ARB</i>. Every OpenGL + implementation is required to support at least 16 vertex attributes in a + vertex shader. + </body> +</html> + + const int + + + + + log + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + texture2DLod + + + BUILD_IN_FUNC + (sampler2D, vec2, float lod) + vec4 + + + + + uvec2 + + + TYPE + a two-component unsigned integer vector + <html> + <head> + + </head> + <body> + a two-component unsigned integer vector + </body> +</html> + + + + + + floor + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + uvec3 + + + TYPE + a three-component unsigned integer vector + <html> + <head> + + </head> + <body> + a three-component unsigned integer vector + </body> +</html> + + + + + + uvec4 + + + TYPE + a four-component unsigned integer vector + <html> + <head> + + </head> + <body> + a four-component unsigned integer vector + </body> +</html> + + + + + + faceforward + + + BUILD_IN_FUNC + (float, float, float) + float + + + BUILD_IN_FUNC + (vec2, vec2, vec2) + vec2 + + + BUILD_IN_FUNC + (vec3, vec3, vec3) + vec3 + + + BUILD_IN_FUNC + (vec4 V, vec4 I, vec4 N) + vec4 + + + + + gl_TextureMatrixTranspose + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform mat4 + + + + + smooth + + + QUALIFIER + perspective correct interpolation + <html> + <head> + + </head> + <body> + <p> + perspective correct interpolation + </p> + </body> +</html> + + + + + + usampler2DArray + + + TYPE + a handle for accessing an unsigned integer 2D array texture + <html> + <head> + + </head> + <body> + a handle for accessing an unsigned integer 2D array texture + </body> +</html> + + + + + + ceil + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + smoothstep + + + BUILD_IN_FUNC + (float, float, float) + float + + + BUILD_IN_FUNC + (float, float, vec2) + vec2 + + + BUILD_IN_FUNC + (float, float, vec3) + vec3 + + + BUILD_IN_FUNC + (float, float, vec4) + vec4 + + + + + texture2DProjLod + + + BUILD_IN_FUNC + (sampler2D, vec3, float lod) + vec4 + + + BUILD_IN_FUNC + (sampler2D, vec4, float lod) + vec4 + + + + + isampler1D + + + TYPE + a handle for accessing an integer 1D texture + <html> + <head> + + </head> + <body> + a handle for accessing an integer 1D texture + </body> +</html> + + + + + + do + + + ITERATION + + + + + texture1DProjLod + + + BUILD_IN_FUNC + (sampler1D, vec2, float lod) + vec4 + + + BUILD_IN_FUNC + (sampler1D, vec4, float lod) + vec4 + + + + + max + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (vec2, float) + vec2 + + + BUILD_IN_FUNC + (vec3, float) + vec3 + + + BUILD_IN_FUNC + (vec4, float) + vec4 + + + + + sqrt + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + shadow1DProjLod + + + BUILD_IN_FUNC + (sampler1DShadow, vec4, float lod) + vec4 + + + + + highp + + + QUALIFIER + <html> + <head> + + </head> + <body> + qualifier for high precision + </body> +</html> + + + + + + gl_MaxVertexUniformComponents + + + BUILD_IN_VAR + value >= 512 ARB_vertex_shader required + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum allowed uniform + components inside the vertex shader.<br> This limit refers to the storage for + the combination of build-in uniform variables and user-defined uniform + variables that are actually used in a vertex shader. This constant can be + also queried by calling <b>glGetIntegerv</b> with the symbolic constant <i>GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB</i>. + The minimum value is 512 if <i>ARB_vertex_shader</i> is supported. + </body> +</html> + + const int + + + + + noise4 + + + BUILD_IN_FUNC + (float) + vec4 + + + BUILD_IN_FUNC + (vec2) + vec4 + + + BUILD_IN_FUNC + (vec3) + vec4 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + clamp + + + BUILD_IN_FUNC + (float, float, float) + float + + + BUILD_IN_FUNC + (vec2, float, float) + vec2 + + + BUILD_IN_FUNC + (vec3, float, float) + vec3 + + + BUILD_IN_FUNC + (vec4, float, float) + vec4 + + + + + sin + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric sine function. Angle in radians. + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric sine function. Angle in radians. + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric sine function. Angle in radians. + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric sine function. Angle in radians. + </body> + </html> + + (vec4) + vec4 + + + + + noise2 + + + BUILD_IN_FUNC + (float) + vec2 + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec2 + + + BUILD_IN_FUNC + (vec4) + vec2 + + + + + noise3 + + + BUILD_IN_FUNC + (float) + vec3 + + + BUILD_IN_FUNC + (vec2) + vec3 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec3 + + + + + noise1 + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + float + + + BUILD_IN_FUNC + (vec3) + float + + + BUILD_IN_FUNC + (vec4) + float + + + + + gl_ProjectionMatrixInverseTranspose + + + BUILD_IN_VAR + uniform mat4 + + + + + reflect + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (vec2, vec2) + vec2 + + + BUILD_IN_FUNC + (vec3, vec3) + vec3 + + + BUILD_IN_FUNC + (vec4 I, vec4 N) + vec4 + + + + + vec4 + + + TYPE + four component floating-point vector + + + + + cos + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric cosine function. Angle in radians. + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric cosine function. Angle in radians. + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric cosine function. Angle in radians. + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric cosine function. Angle in radians. + </body> + </html> + + (vec4) + vec4 + + + + + centroid + + + QUALIFIER + centroid interpolation on multi-sample varyings + <html> + <head> + + </head> + <body> + Examples: + + <blockquote> + <code><nobr>centroid varying vec4 color;</nobr><br><nobr>centroid varying float value;</nobr></code> + </blockquote> + By definition, varying variables are set per vertex and are interpolated + in a perspective-correct manner over the primitive being rendered. + + <ul> + <li> + If single-sampling, the value is interpolated to the pixel's center, + and the <b>centroid </b>qualifier, if present, is ignored. + </li> + <li> + If multi-sampling, and <b>varying</b> is not qualified with <b>centroid</b>, + then the value must be interpolated to the pixel's center, or anywhere + within the pixel, or to one of the pixel's samples. + </li> + <li> + If multi-sampling and <b>varying </b>is qualified with <b>centroid</b>, + then the value must be interpolated to a point that lies in both the + pixel and in the primitive being rendered, or to one of the pixel's + samples that falls within the primitive. Due to the less regular + location of centroids, their derivatives may be less accurate than + non-centroid varying variables. + </li> + </ul> + <p> + When using the <b>centroid </b>keyword, it must immediately precede the <b>varying + </b>keyword. A fragment shader may read from varying variables and the + value read will be the interpolated value, as a function of the + fragment's position within the primitive. A fragment shader can not + write to a varying variable. + </p> + <p> + The type and presence of the <b>centroid </b>and <b>invariant </b>qualifiers + of varying variables with the same name declared in linked vertex and + fragments shaders must match, otherwise the link command will fail. Only + those varying variables used (i.e. read) in the fragment shader + executable must be written to by the vertex shader executable; declaring + superfluous varying variables in a vertex shader is permissible. + </p> + </body> +</html> + + + + + + texture1D + + + BUILD_IN_FUNC + (sampler1D, float, float bias) + vec4 + + + + + ivec4 + + + TYPE + four component integer vector + + + + + ivec3 + + + TYPE + three component integer vector + + + + + shadow2D + + + BUILD_IN_FUNC + (sampler2DShadow, vec3, float bias) + vec4 + + + + + varying + + + QUALIFIER + output from Vertex shader (READ/WRITE), interpolated, then input to Fragment shader (READ-ONLY) + <html> + <head> + + </head> + <body> + <p> + <b>Deprecated since 1.3, use <i>smooth</i> instead</b> + </p> + <p> + </p> + Varying variables provide the interface between the vertex shader and + geometry shader and also between the geometry shader and fragment shader + and the fixed functionality between them. If no geometry shader is + present, <b>varying</b> variables also provide the interface between the + vertex shader and fragment shader. + + <p> + The vertex, or geometry shader will compute values per vertex (such as + color, texture coordinates, etc) and write them to output variables + declared with the &quot;varying&quot; qualifier (vertex) or &quot;varying out&quot; + qualifiers (geometry). A vertex or geometry shader may also read these + output varying variables, getting back the same values it has written. + Reading an output varying variable in a vertex or geometry shader + returns undefined results if it is read before being written. + </p> + <p> + A geometry shader may also read from an input <b>varying</b> variable + declared with the &quot;varying in&quot; qualifiers. The value read will be the + same value as written by the vertex shader for that <b>varying</b> + variable. Since a geometry shader operates on primitives, each input + varying variable needs to be declared as an array. Each element of such + an array corresponds to a vertex of the primitive being processed. If + the varying variable is declared as a scalar or matrix in the vertex + shader, it will be a one-dimensional array in the geometry shader. Each + array can optionally have a size declared. If a size is not specified, + it inferred by the linker and depends on the value of the input + primitive type. See table 4.3.xxx (GLSL specification) to determine the + exact size. The read-only built-in constant <b>gl_VerticesIn</b> will be + set to this value by the linker. If a size is specified, it has to be + the size as given by table 4.3.xxx, otherwise a link error will occur. + The built-in constant <b>gl_VerticesIn</b>, if so desired, can be used + to size the array correctly for each input primitive type. Varying + variables can also be declared as arrays in the vertex shader. This + means that those, on input to the geometry shader, must be declared as + two- dimensional arrays. The first index to the two-dimensional array + holds the vertex number. Declaring a size for the first range of the + array is optional, just as it is for one-dimensional arrays. The second + index holds the per-vertex array data. Declaring a size for the second + range of the array is not optional, and has to match the declaration in + the vertex shader. + </p> + <p> + By definition, varying variables are set per vertex and are interpolated + in a perspective-correct manner over the primitive being rendered. If + single-sampling, the value is interpolated to the pixel's center, and + the <b>centroid </b>qualifier, if present, is ignored. If + multi-sampling, and <b>varying</b> is not qualified with <b>centroid</b>, + then the value must be interpolated to the pixel's center, or anywhere + within the pixel, or to one of the pixel's samples. If multi-sampling + and <b>varying </b>is qualified with <b>centroid</b>, then the value + must be interpolated to a point that lies in both the pixel and in the + primitive being rendered, or to one of the pixel's samples that falls + within the primitive. Due to the less regular location of centroids, + their derivatives may be less accurate than non-centroid varying + variables. + </p> + <p> + When using the <b>centroid </b>keyword, it must immediately precede the <b>varying + </b>keyword. A fragment shader may read from varying variables and the + value read will be the interpolated value, as a function of the + fragment's position within the primitive. A fragment shader can not + write to a varying variable. + </p> + <p> + The type and presence of the <b>centroid </b>and <b>invariant </b>qualifiers + of varying variables with the same name declared in linked vertex and + fragments shaders must match, otherwise the link command will fail. Only + those varying variables used (i.e. read) in the fragment shader + executable must be written to by the vertex shader executable; declaring + superfluous varying variables in a vertex shader is permissible. + </p> + <p> + Varying variables are declared as in the following examples: + </p> + <blockquote> + <nobr><code>varying vec3 normal;</code></nobr><code><br><nobr>centroid + varying vec2 TexCoord;</nobr><br><nobr>invariant centroid varying vec4 + Color;</nobr><br></code> + </blockquote> + <p> + The <b>varying </b>qualifier can be used only with <b>float</b>, + floating-point vectors, matrices, or arrays of these. Structures cannot + be <b>varying</b>. If no vertex shader executable is active, the fixed + functionality pipeline of OpenGL will compute values for the built-in + varying variables that will be consumed by the fragment shader + executable. Similarly, if no fragment shader executable is active, the + vertex shader executable is responsible for computing and writing to the + varying variables that are needed for OpenGL's fixed functionality + fragment pipeline. Varying variables are required to have global scope, + and must be declared outside of function bodies, before their first use. + </p> + </body> +</html> + + + + + + any + + + BUILD_IN_FUNC + (bvec2) + bool + + + BUILD_IN_FUNC + (bvec3) + bool + + + BUILD_IN_FUNC + (bvec4) + bool + + + + + notEqual + + + BUILD_IN_FUNC + (bvec2, bvec2) + bvec2 + + + BUILD_IN_FUNC + (bvec3, bvec3) + bvec3 + + + BUILD_IN_FUNC + (bvec4, bvec4) + bvec4 + + + + + ivec2 + + + TYPE + two component integer vector + + + + + sampler1DArray + + + TYPE + a handle for accessing a 1D array texture + <html> + <head> + + </head> + <body> + a handle for accessing a 1D array texture + </body> +</html> + + + + + + + sampler2DArrayShadow + + + TYPE + <html> + <head> + + </head> + <body> + a handle for accessing a 2D array depth texture with comparison + </body> +</html> + + + + + + + radians + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts degrees to radians, i.e. pi / 180 * degrees + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts degrees to radians, i.e. pi / 180 * degrees + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts degrees to radians, i.e. pi / 180 * degrees + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts degrees to radians, i.e. pi / 180 * degrees + </body> + </html> + + (vec4) + vec4 + + + + + usamplerCube + + + TYPE + a handle for accessing an unsigned integer cube mapped texture + <html> + <head> + + </head> + <body> + a handle for accessing an unsigned integer cube mapped texture + </body> +</html> + + + + + + gl_TextureMatrixInverse + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform mat4 + + + + + texture2D + + + BUILD_IN_FUNC + (sampler2D, vec2, float bias) + vec4 + + + + + sampler1DArrayShadow + + + TYPE + a handle for accessing a 1D array depth texture with comparison + <html> + <head> + + </head> + <body> + a handle for accessing a 1D array depth texture with comparison + </body> +</html> + + + + + + + sign + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + texture2DProj + + + BUILD_IN_FUNC + (sampler2D, vec3, float bias) + vec4 + + + BUILD_IN_FUNC + (sampler2D, vec4, float bias) + vec4 + + + + + shadow1D + + + BUILD_IN_FUNC + (sampler1DShadow, vec3, float bias) + vec4 + + + + + gl_MaxTextureCoords + + + BUILD_IN_VAR + value >= 2 ARB_fragment_program required + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum allowed number of + texture coordinate sets.<br>The number of texture coordinate sets defines + the maximum number of texture coordinates that can be attached to a + vertex. A texture coordinate set encompasses vertex texture coordinate attributes, as well as the texture matrix stack and texture generation state. This limit applies regardless of using a vertex shader or + fixed-function pipeline to perform vertex processing. This constant can be + also queried by calling <b>glGetIntegerv</b> with the symbolic constant <i>GL_MAX_TEXTURE_COORDS_ARB</i>. + Minimum value is 2. + </body> +</html> + + const int + + + + + gl_MaxVertexTextureImageUnits + + + BUILD_IN_VAR + value >= 0 ARB_vertex_shader required + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum available texture image + units in a vertex shader.<br> The texture image unit constant specifyes the + number of hardware units that can be used simultaneously for accessing + texture maps. This constant can be also queried by calling <b>glGetIntegerv</b> + with the symbolic constant <i>GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB</i>. + The minimum value is 0. + </body> +</html> + + const int + + + + + vec3 + + + TYPE + three component floating-point vector + + + + + vec2 + + + TYPE + two component floating-point vector + + + + + case + + + KEYWORD + + + + + texture1DLod + + + BUILD_IN_FUNC + (sampler1D, float, float lod) + vec4 + + + + + asin + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc sine. Returns an angle whose sine is x. The range of values returned + by this function is [- Pi / 2 , Pi / 2 ] Results are undefined if |x| &gt; 1. + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc sine. Returns an angle whose sine is x. The range of values returned + by this function is [- Pi / 2 , Pi / 2 ] Results are undefined if |x| &gt; 1. + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc sine. Returns an angle whose sine is x. The range of values returned + by this function is [- Pi / 2 , Pi / 2 ] Results are undefined if |x| &gt; 1. + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc sine. Returns an angle whose sine is x. The range of values returned + by this function is [- Pi / 2 , Pi / 2 ] Results are undefined if |x| &gt; 1. + </body> + </html> + + (vec4) + vec4 + + + + + texture3D + + + BUILD_IN_FUNC + (sampler3D, vec3, float bias) + vec4 + + + + + gl_LightModel + + + BUILD_IN_VAR + uniform gl_LightModelParameters + + + + + bvec2 + + + TYPE + two component boolean vector + + + + + bvec3 + + + TYPE + three component boolean vector + + + + + bvec4 + + + TYPE + four component boolean vector + + + + + normalize + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + gl_MaxCombinedTextureImageUnits + + + BUILD_IN_VAR + value >= 2 + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum available combined + texture image units in all shader processing parts of OpenGL.<br>The + texture image unit constant specifys the number of hardware units that can + be used simultaneously for accessing texture maps. This constant can be + also queried by calling <b>glGetIntegerv</b> with the symbolic constant <i>GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB</i>. + The minimum value is 2. + + <p> + <b>Note:</b> If a vertex shader and a fragment shader both use the same + texture image unit, that counts as two units against this limit. + </p> + </body> +</html> + + const int + + + + + struct + + + KEYWORD + <html> + <head> + + </head> + <body> + Once a structure is defined, and its type is given a name, a constructor + is available with the same name to construct instances of that structure. + For example: + + <pre><code>struct light { + float intensity; + vec3 position; +}; +<nobr>light lightVar = light(3.0, vec3(1.0, 2.0, 3.0));</nobr></code> + </pre> + <p> + The arguments to the constructor will be used to set the structure's + fields, in order, using one argument per field. Each argument must be + the same type as the field it sets. + </p> + <p> + Structure constructors can be used as initializers or in expressions. + </p> + </body> +</html> + + + + + + all + + + BUILD_IN_FUNC + (bvec2) + bool + + + BUILD_IN_FUNC + (bvec3) + bool + + + BUILD_IN_FUNC + (bvec4) + bool + + + + + shadow2DLod + + + BUILD_IN_FUNC + (sampler2DShadow, vec3, float lod) + vec4 + + + + + precision + + + KEYWORD + <html> + <head> + + </head> + <body> + The precision statement +<pre> +precision precision-qualifier type; +</pre> +can be used to establish a default precision qualifier. The type field can be either int or <b>float</b>, and the +precision-qualifier can be <b>lowp, mediump, or highp</b>. Any other types or qualifiers will result in an error. +If type is float, the directive applies to non-precision-qualified floating point type (scalar, vector, and +matrix) declarations. If type is <b>int</b>, the directive applies to all non-precision-qualified integer type (scalar, +vector, signed, and unsigned) declarations. This includes global variable declarations, function return declarations, +function parameter declarations, and local variable declarations. Non-precision qualified declarations will use the precision qualifier +specified in the most recent precision statement that is still in scope. The <b>precision</b> statement has the same scoping rules as variable +declarations. If it is declared inside a compound statement, its effect stops at the end of the innermost +statement it was declared in. Precision statements in nested scopes override <b>precision</b> statements in outer +scopes. Multiple precision statements for the same basic type can appear inside the same scope, with later +statements overriding earlier statements within that scope. +<p> +The vertex language has the following predeclared globally scoped default + precision statements: +<pre> +precision highp float; +precision highp int; +</pre> +</p> +<p> +The fragment language has the following predeclared globally scoped default + precision statement: +<pre> +precision mediump int; +</pre> +</p> +The fragment language has no default precision qualifier for floating point types. Hence for float, floating +point vector and matrix variable declarations, either the declaration must include a precision qualifier or +the default float precision must have been previously declared. + </body> +</html> + + + + + + gl_BackMaterial + + + BUILD_IN_VAR + uniform gl_MaterialParameters + + + + + uniform + + + QUALIFIER + input to Vertex and Fragment shader from OpenGL or application (READ-ONLY) + <html> + <head> + + </head> + <body> + <nobr>The <b>uniform </b>qualifier is used to declare global variables + whose values are the same across the entire</nobr> <nobr>primitive being + processed. All <b>uniform </b>variables are read-only and are initialized + externally either at link</nobr> <nobr>time or through the API. The link + time initial value is either the value of the variable's initializer, if</nobr> + <nobr>present, or 0 if no initializer is present. Sampler types cannot + have initializers.</nobr><br>Example declarations are: + + <pre> <nobr>uniform vec4 lightPosition;</nobr> + <nobr>uniform vec3 color = vec3(0.7, 0.7, 0.2); // value assigned at link time </nobr></pre> +<p> + <nobr>The <b>uniform </b>qualifier can be used with any of the basic data + types, or when declaring a variable whose</nobr> <nobr>type is a + structure, or an array of any of these.</nobr> <nobr>There is an + implementation dependent limit on the amount of storage for uniforms that + can be used for</nobr> <nobr>each type of shader and if this is exceeded + it will cause a compile-time or link-time error. Uniform</nobr> <nobr>variables + that are declared but not used do not count against this limit. The number + of user-defined</nobr> <nobr>uniform variables and the number of built-in + uniform variables that are used within a shader are added</nobr> <nobr>together + to determine whether available uniform storage has been exceeded.</nobr> + + <p> + <nobr>If multiple shaders are linked together, then they will share a + single global uniform name space. Hence,</nobr> <nobr>the types and + initializers of uniform variables with the same name must match across + all shaders that are</nobr> <nobr>linked into a single executable. It is + legal for some shaders to provide an initializer for a particular</nobr> <nobr>uniform + variable, while another shader does not, but all provided initializers + must be equal.</nobr> + </p> + </body> +</html> + + + + + + matrixCompMult + + + BUILD_IN_FUNC + (mat2, mat2) + mat2 + + + BUILD_IN_FUNC + (mat3, mat3) + mat3 + + + BUILD_IN_FUNC + (mat4, mat4) + mat4 + + + + + gl_BackLightModelProduct + + + BUILD_IN_VAR + uniform gl_LightModelProducts + + + + + equal + + + BUILD_IN_FUNC + (bvec2, bvec2) + bvec2 + + + BUILD_IN_FUNC + (bvec3, bvec3) + bvec3 + + + BUILD_IN_FUNC + (bvec4, bvec4) + bvec4 + + + + + gl_NormalScale + + + BUILD_IN_VAR + uniform float + + + + + gl_ModelViewProjectionMatrixInverse + + + BUILD_IN_VAR + uniform mat4 + + + + + gl_DepthRange + + + BUILD_IN_VAR + uniform gl_DepthRangeParameters + + + + + isampler2DArray + + + TYPE + a handle for accessing an integer 2D array texture + <html> + <head> + + </head> + <body> + a handle for accessing an integer 2D array texture + </body> +</html> + + + + + + out + + + QUALIFIER + copied out on return, but not initialized + + + + + noperspective + + + QUALIFIER + linear interpolation + <html> + <head> + + </head> + <body> + <p> + linear interpolation + </p> + </body> +</html> + + + + + + samplerCube + + + TYPE + handle for accessing a cube mapped texture + <html> + <head> + + </head> + <body> + </body> + </html> + + + + + + sampler2DShadow + + + TYPE + handle for accessing a 2D depth texture with comparison + <html> + <head> + + </head> + <body> + </body> + </html> + + + + + + for + + + ITERATION + <html> + <head> + + </head> + <body> + + </body> +</html> + + + + + + break + + + JUMP + + + + + invariant + + + QUALIFIER + ensures all calculations of this variable give identical values across programs + <html> + <head> + + </head> + <body> + To ensure that a particular output variable is invariant, it is necessary + to use the <b>invariant </b>qualifier. It can either be used to qualify a + previously declared variable as being invariant + + <blockquote> + <code><nobr>invariant gl_Position; // make existing gl_Position be invariant</nobr><br><nobr>varying + vec3 Color;</nobr><br><nobr>invariant Color; // make existing Color be invariant</nobr><br></code> + </blockquote> + <p> + or as part of a declaration when a variable is declared + </p> + <blockquote> + <code><nobr>invariant varying vec3 Color;</nobr></code> + </blockquote> + <p> + The invariant qualifier must appear before any storage qualifiers (<b>varying</b>) + when combined with a declaration. Only variables output from a vertex + shader can be candidates for invariance. This includes user-defined + varying variables, the built-in vertex-side varying variables, and the + special vertex variables <i>gl_Position </i>and <i>gl_PointSize</i>. For + varying variables leaving a vertex shader and coming into a fragment + shader with the same name, the <b>invariant </b>keyword has to be used + in both the vertex and fragment shaders. The <b>invariant </b>keyword + can be followed by a comma separated list of previously declared + identifiers. All uses of <b>invariant </b>must be at the global scope, + and before any use of the variables being declared as invariant. + </p> + <p> + To guarantee invariance of a particular output variable across two + programs, the following must also be true: + </p> + <ul> + <li> + The output variable is declared as invariant in both programs. + </li> + <li> + The same values must be input to all shader input variables consumed + by expressions and flow control contributing to the value assigned to + the output variable. + </li> + <li> + The texture formats, texel values, and texture filtering are set the + same way for any texture function calls contributing to the value of + the output variable. + </li> + <li> + All input values are all operated on in the same way. All operations + in the consuming expressions and any intermediate expressions must be + the same, with the same order of operands and same associativity, to + give the same order of evaluation. Intermediate variables and + functions must be declared as the same type with the same explicit or + implicit precision qualifiers. Any control flow affecting the output + value must be the same, and any expressions consumed to determine this + control flow must also follow these invariance rules. + </li> + <li> + All the data flow and control flow leading to setting the invariant + output variable reside in a single compilation unit. + </li> + </ul> + <p> + Essentially, all the data flow and control flow leading to an invariant + output must match. Initially, by default, all output variables are + allowed to be variant. To force all output variables to be invariant, + use the pragma + </p> + <blockquote> + <code>#pragma STDGL invariant(all)</code> + </blockquote> + <p> + before all declarations in a shader. If this pragma is used after the + declaration of any variables or functions, then the set of outputs that + behave as invariant is undefined. It is an error to use this pragma in a + fragment shader. + </p> + <p> + Generally, invariance is ensured at the cost of flexibility in + optimization, so performance can be degraded by use of invariance. + Hence, use of this pragma is intended as a debug aid, to avoid + individually declaring all output variables as invariant. + </p> + </body> +</html> + + + + + + abs + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Returns x if x &gt;= 0, otherwise it returns -x + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Returns x if x &gt;= 0, otherwise it returns -x + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Returns x if x &gt;= 0, otherwise it returns -x + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Returns x if x &gt;= 0, otherwise it returns -x + </body> + </html> + + (vec4) + vec4 + + + + + greaterThanEqual + + + BUILD_IN_FUNC + (ivec2, ivec2) + bvec2 + + + BUILD_IN_FUNC + (ivec3, ivec3) + bvec3 + + + BUILD_IN_FUNC + (ivec4, ivec4) + bvec4 + + + + + g_NormalMatrix + + + BUILD_IN_VAR + uniform mat3 + + + + + false + + + KEYWORD + boolean value + + + + + gl_ModelViewMatrixInverse + + + BUILD_IN_VAR + uniform mat4 + + + + + g_WorldViewProjectionMatrix + + + BUILD_IN_VAR + uniform mat4 + + + + + refract + + + BUILD_IN_FUNC + (float, float, float eta) + float + + + BUILD_IN_FUNC + (vec2, vec2, float eta) + vec2 + + + BUILD_IN_FUNC + (vec3, vec3, float eta) + vec3 + + + BUILD_IN_FUNC + (vec4 I, vec4 M, float eta) + vec4 + + + + + dFdx + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + dFdy + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + gl_ModelViewProjectionMatrixInverseTranspose + + + BUILD_IN_VAR + uniform mat4 + + + + + lessThanEqual + + + BUILD_IN_FUNC + (ivec2, ivec2) + bvec2 + + + BUILD_IN_FUNC + (ivec3, ivec3) + bvec3 + + + BUILD_IN_FUNC + (ivec4, ivec4) + bvec4 + + + + + usampler1D + + + TYPE + a handle for accessing an unsigned integer 1D texture + <html> + <head> + + </head> + <body> + a handle for accessing an unsigned integer 1D texture + </body> +</html> + + + + + + not + + + BUILD_IN_FUNC + (bvec2) + bvec2 + + + BUILD_IN_FUNC + (bvec3) + bvec3 + + + BUILD_IN_FUNC + (bvec4) + bvec4 + + + + + gl_ModelViewMatrixInverseTranspose + + + BUILD_IN_VAR + uniform mat4 + + + + + greaterThan + + + BUILD_IN_FUNC + (ivec2, ivec2) + bvec2 + + + BUILD_IN_FUNC + (ivec3, ivec3) + bvec3 + + + BUILD_IN_FUNC + (ivec4, ivec4) + bvec4 + + + + + gl_Fog + + + BUILD_IN_VAR + uniform gl_FogParameters + + + + + tan + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric tangent function. Angle in radians. + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric tangent function. Angle in radians. + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric tangent function. Angle in radians. + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The standard trigonometric tangent function. Angle in radians. + </body> + </html> + + (vec4) + vec4 + + + + + cross + + + BUILD_IN_FUNC + (vec3, vec3) + vec3 + + + + + gl_ClipPlane + + + BUILD_IN_VAR + INDEX < gl_MaxClipPlanes + [] + uniform vec4 + + + + + textureCube + + + BUILD_IN_FUNC + (samplerCube, vec3, float bias) + vec4 + + + + + const + + + QUALIFIER + constant function input + + + + + gl_MaxTextureUnits + + + BUILD_IN_VAR + value >= 2 since OpenGL 1.3 + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum available multitexture + statges.<br>This constant can + be also queried by calling <b>glGetIntegerv</b> with the symbolic constant <i>GL_MAX_TEXTURE_UNITS</i>. + The minimum value is 2. + </body> +</html> + + const int + + + + + mediump + + + QUALIFIER + <html> + <head> + + </head> + <body> + qualifier for medium precision + </body> +</html> + + + + + + inout + + + QUALIFIER + value initialized on entry, and copied out on return + + + + + switch + + + KEYWORD + + + + + gl_FrontLightModelProduct + + + BUILD_IN_VAR + uniform gl_LightModelProducts + + + + + shadow1DProj + + + BUILD_IN_FUNC + (sampler1DShadow, vec4, float bias) + vec4 + + + + + usampler1DArray + + + TYPE + a handle for accessing an unsigned integer 1D array texture + <html> + <head> + + </head> + <body> + a handle for accessing an unsigned integer 1D array texture + </body> +</html> + + + + + + gl_EyePlaneT + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + gl_EyePlaneS + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + gl_EyePlaneR + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + distance + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (vec2, vec2) + float + + + BUILD_IN_FUNC + (vec3, vec3) + float + + + BUILD_IN_FUNC + (vec4, vec4) + float + + + + + gl_EyePlaneQ + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + sampler1DShadow + + + TYPE + handle for accessing a 1D depth texture with comparison + <html> + <head> + + </head> + <body> + a handle for accessing a 1D depth texture with comparison + </body> +</html> + + + + + + g_ProjectionMatrix + + + BUILD_IN_VAR + uniform mat4 + + + + + gl_TextureEnvColor + + + BUILD_IN_VAR + INDEX < gl_MaxTextureUnits + [] + uniform vec4 + + + + + length + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + float + + + BUILD_IN_FUNC + (vec3) + float + + + BUILD_IN_FUNC + (vec4) + float + + + + + gl_ModelViewMatrixTranspose + + + BUILD_IN_VAR + uniform mat4 + + + + + gl_FrontMaterial + + + BUILD_IN_VAR + uniform gl_MaterialParameters + + + + + sampler2DArray + + + TYPE + a handle for accessing a 2D array texture + <html> + <head> + + </head> + <body> + a handle for accessing a 2D array texture + </body> +</html> + + + + + + + min + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (vec2, float) + vec2 + + + BUILD_IN_FUNC + (vec3, float) + vec3 + + + BUILD_IN_FUNC + (vec4, float) + vec4 + + + + + gl_LightSource + + + BUILD_IN_VAR + INDEX < gl_MaxLights + [] + uniform gl_LightSourceParameters + + + + + return + + + JUMP + + + + + void + + + TYPE + for functions that do not return a value + + + + + true + + + KEYWORD + boolean value + + + + + mix + + + BUILD_IN_FUNC + (float, float, float) + float + + + BUILD_IN_FUNC + (vec2, vec2, float) + vec2 + + + BUILD_IN_FUNC + (vec3, vec3, float) + vec3 + + + BUILD_IN_FUNC + (vec4, vec4, float) + vec4 + + + + + texture3DProj + + + BUILD_IN_FUNC + (sampler3D, vec4, float bias) + vec4 + + + + + gl_MaxDrawBuffers + + + BUILD_IN_VAR + value >= 1 ARB_draw_buffers required + min = 1; // proposed ARB_draw_buffers + const int + + + + + gl_ProjectionMatrixTranspose + + + BUILD_IN_VAR + uniform mat4 + + + + + lowp + + + QUALIFIER + <html> + <head> + + </head> + <body> + qualifier for low precision + </body> +</html> + + + + + + isamplerCube + + + TYPE + a handle for accessing an integer cube mapped texture + <html> + <head> + + </head> + <body> + a handle for accessing an integer cube mapped texture + </body> +</html> + + + + + + g_WorldViewMatrix + + + BUILD_IN_VAR + uniform mat4 + + + + + fwidth + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + atan + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y + are used to determine what quadrant the angle is in. The range of values + returned by this function is [-Pi, Pi]. Results are undefined if x and y + are both 0. + </body> + </html> + + (float, float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y + are used to determine what quadrant the angle is in. The range of values + returned by this function is [-Pi, Pi]. Results are undefined if x and y + are both 0. + </body> + </html> + + (vec2, vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y + are used to determine what quadrant the angle is in. The range of values + returned by this function is [-Pi, Pi]. Results are undefined if x and y + are both 0. + </body> + </html> + + (vec3, vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y + are used to determine what quadrant the angle is in. The range of values + returned by this function is [-Pi, Pi]. Results are undefined if x and y + are both 0. + </body> + </html> + + (vec4, vec4) + vec4 + + + + + gl_MaxVaryingFloats + + + BUILD_IN_VAR + value >= 32 + min = 32; // ARB_vertex_shader + const int + + + + + fract + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + gl_Point + + + BUILD_IN_VAR + uniform gl_PointParameters + + + + + texture3DProjLod + + + BUILD_IN_FUNC + (sampler3D, vec4, float lod) + vec4 + + + + + gl_ObjectPlaneS + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + gl_ObjectPlaneT + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + isampler2D + + + TYPE + a handle for accessing an integer 2D texture + <html> + <head> + + </head> + <body> + a handle for accessing an integer 2D texture + </body> +</html> + + + + + + exp2 + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + gl_ObjectPlaneR + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + gl_ObjectPlaneQ + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform vec4 + + + + + lessThan + + + BUILD_IN_FUNC + (ivec2, ivec2) + bvec2 + + + BUILD_IN_FUNC + (ivec3, ivec3) + bvec3 + + + BUILD_IN_FUNC + (ivec4, ivec4) + bvec4 + + + + + shadow2DProjLod + + + BUILD_IN_FUNC + (sampler2DShadow, vec4, float lod) + vec4 + + + + + gl_MaxTextureImageUnits + + + BUILD_IN_VAR + value >= 2 + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum available texture image + units in a fragment shader.<br> The texture image unit constant specifyes the + number of hardware units that can be used simultaneously for accessing + texture maps. This constant can be also queried by calling <b>glGetIntegerv</b> + with the symbolic constant <i>GL_MAX_TEXTURE_IMAGE_UNITS_ARB</i>. The + minimum value is 2. + </body> +</html> + + const int + + + + + gl_FrontLightProduct + + + BUILD_IN_VAR + INDEX < gl_MaxLights + [] + uniform gl_LightProducts + + + + + gl_MaxClipPlanes + + + BUILD_IN_VAR + value >= 6 since OpenGL 1.0 + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum supported clip planes. + + <p> + This constant can be also queried by calling <b>glGetIntegerv</b> with + the symbolic constant <i>GL_MAX_CLIP_PLANES_ARB</i>. The minimum value + is 6. + </p> + </body> +</html> + + const int + + + + + inversesqrt + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + gl_TextureMatrixInverseTranspose + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform mat4 + + + + + int + + + TYPE + signed integer + + + + + gl_MaxLights + + + BUILD_IN_VAR + value >= 8 since OpenGL 1.0 + <html> + <head> + + </head> + <body> + Implementation dependent constant for the maximum allowed dynamic light + sources.<br> The minimum value is 8. + </body> +</html> + + const int + + + + + flat + + + QUALIFIER + no interpolation + <html> + <head> + + </head> + <body> + <p> + no interpolation. + </p> + </body> +</html> + + + + + + log2 + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + isampler3D + + + TYPE + a handle for accessing an integer 3D texture + <html> + <head> + + </head> + <body> + a handle for accessing an integer 3D texture + </body> +</html> + + + + + + exp + + + BUILD_IN_FUNC + (float) + float + + + BUILD_IN_FUNC + (vec2) + vec2 + + + BUILD_IN_FUNC + (vec3) + vec3 + + + BUILD_IN_FUNC + (vec4) + vec4 + + + + + ftransform + + + BUILD_IN_FUNC + () + vec4 + + + + + mat4 + + + TYPE + 4×4 floating-point matrix + + + + + default + + + KEYWORD + + + + + sampler1D + + + TYPE + handle for accessing a 1D texture + + + + + mat2 + + + TYPE + 2×2 floating-point matrix + + + + + mat3 + + + TYPE + 3×3 floating-point matrix + + + + + gl_ModelViewProjectionMatrixTranspose + + + BUILD_IN_VAR + uniform mat4 + + + + + textureCubeLod + + + BUILD_IN_FUNC + (samplerCube, vec3, float lod) + vec4 + + + + + usampler2D + + + TYPE + a handle for accessing an unsigned integer 2D texture + <html> + <head> + + </head> + <body> + a handle for accessing an unsigned integer 2D texture + </body> +</html> + + + + + + gl_TextureMatrix + + + BUILD_IN_VAR + INDEX < gl_MaxTextureCoords + [] + uniform mat4 + + + + + gl_ProjectionMatrixInverse + + + BUILD_IN_VAR + uniform mat4 + + + + + shadow1DLod + + + BUILD_IN_FUNC + (sampler1DShadow, vec3, float lod) + vec4 + + + + + while + + + ITERATION + + + + + sampler2D + + + TYPE + handle for accessing a 2D texture + + + + + texture1DProj + + + BUILD_IN_FUNC + (sampler1D, vec2, float bias) + vec4 + + + BUILD_IN_FUNC + (sampler1D, vec4, float bias) + vec4 + + + + + if + + + SELECTION + + + + + shadow2DProj + + + BUILD_IN_FUNC + (sampler2DShadow, vec4, float bias) + vec4 + + + + + isampler1DArray + + + TYPE + a handle for accessing an integer 1D array texture + <html> + <head> + + </head> + <body> + a handle for accessing an integer 1D array texture + </body> +</html> + + + + + + acos + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc cosine. Returns an angle whose cosine is x. The range of values + returned by this function is [0, pi]. Results are undefined if |x|&gt;1. + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc cosine. Returns an angle whose cosine is x. The range of values + returned by this function is [0, pi]. Results are undefined if |x|&gt;1. + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc cosine. Returns an angle whose cosine is x. The range of values + returned by this function is [0, pi]. Results are undefined if |x|&gt;1. + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Arc cosine. Returns an angle whose cosine is x. The range of values + returned by this function is [0, pi]. Results are undefined if |x|&gt;1. + </body> + </html> + + (vec4) + vec4 + + + + + usampler3D + + + TYPE + a handle for accessing an unsigned integer 3D texture + <html> + <head> + + </head> + <body> + a handle for accessing an unsigned integer 3D texture + </body> +</html> + + + + + + degrees + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts radians to degrees, i.e. 180/Pi * radians + </body> + </html> + + (float) + float + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts radians to degrees, i.e. 180/Pi * radians + </body> + </html> + + (vec2) + vec2 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts radians to degrees, i.e. 180/Pi * radians + </body> + </html> + + (vec3) + vec3 + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + Converts radians to degrees, i.e. 180/Pi * radians + </body> + </html> + + (vec4) + vec4 + + + + + in + + + QUALIFIER + value initialized on entry, not copied on return (default) + + + + + sampler3D + + + TYPE + handle for accessing a 3D texture + + + + + continue + + + JUMP + + + + + bool + + + TYPE + conditional type, taking on values of true or false (also known as boolean) + + + + + step + + + BUILD_IN_FUNC + (float, float) + float + + + BUILD_IN_FUNC + (float, vec2) + vec2 + + + BUILD_IN_FUNC + (float, vec3) + vec3 + + + BUILD_IN_FUNC + (float, vec4) + vec4 + + + + + uint + + + TYPE + an unsigned integer + <html> + <head> + + </head> + <body> + an unsigned integer + </body> +</html> + + + + + + + + gl_FragDepth + + + BUILD_IN_VAR + pixel depth + <html> + <head> + + </head> + <body> + Writing to <i>gl_FragDepth </i>will establish the depth value for the + fragment being processed. If depth buffering is enabled, and no shader + writes <i>gl_FragDepth</i>, then the fixed function value for depth will + be used as the fragment&#8217;s depth value. If a shader statically assigns a + value to <i>gl_FragDepth</i>, and there is an execution path through the + shader that does not set <i>gl_FragDepth</i>, then the value of the + fragment&#8217;s depth may be undefined for executions of the shader that take + that path. That is, if the set of linked fragment shaders statically + contain a write to <i>gl_FragDepth</i>, then it is responsible for always + writing it. + + <p> + (A shader contains a <i>static assignment </i>to a variable <i>x </i>if, + after pre-processing, the shader contains a statement that would write + to <i>x</i>, whether or not run-time flow of control will cause that + statement to be executed.) + </p> + </body> + </html> + + float + + + + + gl_FragCoord + + + BUILD_IN_VAR + pixel coordinate (READ ONLY) + <html> + <head> + + </head> + <body> + The variable <i>gl_FragCoord </i>is available as a read-only variable from + within fragment shaders and it holds the window relative coordinates x, y, + z, and 1/w values for the fragment. If multi-sampling, this value can be + for any location within the pixel, or one of the fragment samples. The use + of <b>centroid </b>varyings does not further restrict this value to be + inside the current primitive. This value is the result of the fixed + functionality that interpolates primitives after vertex processing to + generate fragments. The <i>z </i>component is the depth value that would + be used for the fragment&#8217;s depth if no shader contained no writes to <i>gl_FragDepth. + </i>This is useful for invariance if a shader conditionally computes <i>gl_FragDepth + </i>but otherwise wants the fixed functionality fragment depth. + </body> + </html> + + vec4 + + + + + gl_PointCoord + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + The values in <i>gl_PointCoord </i>are two-dimensional coordinates + indicating where within a point primitive the current fragment is located, + when point sprites are enabled. They range from 0.0 to 1.0 across the + point. If the current primitive is not a point, or if point sprites are + not enabled, then the values read from gl_PointCoord are undefined. + </body> + </html> + + vec2 + + + + + gl_FrontFacing + + + BUILD_IN_VAR + (READ ONLY) + <html> + <head> + + </head> + <body> + Fragment shaders have access to the read-only built-in variable <i>gl_FrontFacing, + </i>whose value is <b>true </b>if the fragment belongs to a front-facing + primitive.<p> One use of this is to emulate two-sided lighting + by selecting one of two colors calculated by the vertex shader or geometry + shader. + </body> +</html> + + bool + + + + + gl_Color + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + The values in <i>gl_Color </i>and <i>gl_SecondaryColor </i>will be derived + automatically by the system from <i>gl_FrontColor, gl_BackColor, + gl_FrontSecondaryColor, </i>and <i>gl_BackSecondaryColor </i>based on + which face is visible. If fixed functionality is used for vertex + processing, then <i>gl_FogFragCoord </i>will either be the z-coordinate of + the fragment in eye space, or the interpolation of the fog coordinate, as + described in section 3.10 of the OpenGL 1.4 Specification. The <i>gl_TexCoord[] + </i>values are the interpolated <i>gl_TexCoord[] </i>values from a vertex + shader or the texture coordinates of any fixed pipeline based vertex + functionality. + </body> + </html> + + varying vec4 + + + + + discard + + + JUMP + <html> + <head> + + </head> + <body> + The <b>discard </b>keyword is only allowed within fragment shaders. It can + be used within a fragment shader to abandon the operation on the current + fragment. This keyword causes the fragment to be discarded and no updates + to any buffers will occur. It would typically be used within a conditional + statement, for example: + + <pre> if (intensity &lt; 0.0) + discard; + </pre> + A fragment shader may test a fragment&#8217;s alpha value and discard the + fragment based on that test. However, it should be noted that coverage + testing occurs after the fragment shader runs, and the coverage test can + change the alpha value. + </body> + </html> + + + + + + gl_SecondaryColor + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + The values in <i>gl_Color </i>and <i>gl_SecondaryColor </i>will be derived + automatically by the system from <i>gl_FrontColor, gl_BackColor, + gl_FrontSecondaryColor, </i>and <i>gl_BackSecondaryColor </i>based on + which face is visible. If fixed functionality is used for vertex + processing, then <i>gl_FogFragCoord </i>will either be the z-coordinate of + the fragment in eye space, or the interpolation of the fog coordinate, as + described in section 3.10 of the OpenGL 1.4 Specification. The <i>gl_TexCoord[] + </i>values are the interpolated <i>gl_TexCoord[] </i>values from a vertex + shader or the texture coordinates of any fixed pipeline based vertex + functionality. + </body> + </html> + + varying vec4 + + + + + gl_FragData + + + BUILD_IN_VAR + INDEX<gl_MaxDrawBuffers + <html> + <head> + + </head> + <body> + The variable <i>gl_FragData </i>is an array. Writing to <i>gl_FragData[n] </i>specifies + the fragment data that will be used by the subsequent fixed functionality + pipeline for data <i>n</i>. If subsequent fixed functionality consumes + fragment data and an execution of a fragment shader executable does not + write a value to it, then the fragment data consumed is undefined. + </body> + </html> + + [] + vec4 + + + + + gl_FragColor + + + BUILD_IN_VAR + pixel color + <html> + <head> + + </head> + <body> + If a shader statically assigns a value to <i>gl_FragColor</i>, it may not + assign a value to any element of <i>gl_FragData</i>. If a shader + statically writes a value to any element of <i>gl_FragData</i>, it may not + assign a value to <i>gl_FragColor</i>. That is, a shader may assign values + to either <i>gl_FragColor </i>or <i>gl_FragData</i>, but not both. + Multiple shaders linked together must also consistently write just one of + these variables. + </body> + </html> + + vec4 + + + + + + + gl_BackColor + + + BUILD_IN_VAR + enable GL_VERTEX_PROGRAM_TWO_SIDE + varying vec4 + + + + + gl_FogFragCoord + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + For <i>gl_FogFragCoord</i>, the value written will be used as the &quot;c&quot; + value on page 160 of the OpenGL 1.4 Specification by the fixed + functionality pipeline. For example, if the z-coordinate of the fragment + in eye space is desired as &quot;c&quot;, then that's what the vertex or geometry shader + executable should write into <i>gl_FogFragCoord</i>. + </body> + </html> + + varying float + + + + + gl_Position + + + BUILD_IN_VAR + must be written from vertex shader + <html> + <head> + + </head> + <body> + The variable <i>gl_Position</i> is available only in the vertex and + geometry language and is intended for writing the homogeneous vertex + position. + + <p> + It can be written at any time during shader execution. It may also be + read back by the shader after being written. This value will be used by + primitive assembly, clipping, culling, and other fixed functionality + operations that operate on primitives after vertex or geometry + processing has occurred. Compilers may generate a diagnostic message if + they detect <i>gl_Position</i> is read before being written, but not all + such cases are detectable. Writing to <i>gl_Position</i> is optional. If <i>gl_Position</i> + is not written but subsequent stages of the OpenGL pipeline consume <i>gl_Position</i>, + then results are undefined. + </p> + </body> +</html> + + vec4 + + + + + gl_TexCoord + + + BUILD_IN_VAR + INDEX<gl_MaxTextureCoords + <html> + <head> + + </head> + <body> + As with all arrays, indices used to subscript <i>gl_TexCoord </i>must + either be an integral constant expressions, or this array must be + re-declared by the shader with a size. The size can be at most <i>gl_MaxTextureCoords</i>. + Using indexes close to 0 may aid the implementation in preserving varying + resources. + </body> + </html> + + [] + varying vec4 + + + + + gl_FrontSecondaryColor + + + BUILD_IN_VAR + varying vec4 + + + + + attribute + + + QUALIFIER + linkage between a vertex shader and OpenGL for per-vertex data (READ-ONLY) + <html> + <head> + + </head> + <body> + The <b>attribute </b>qualifier is used to declare variables that are + passed to a vertex shader from OpenGL on a per-vertex basis. It is an + error to declare an attribute variable in any type of shader other than a + vertex shader. Attribute variables are read-only as far as the vertex + shader is concerned. Values for attribute variables are passed to a vertex + shader through the OpenGL vertex API or as part of a vertex array. They + convey vertex attributes to the vertex shader and are expected to change + on every vertex shader run. The attribute qualifier can be used only with <b>float, + </b>floating-point vectors, and matrices. Attribute variables cannot be + declared as arrays or structures.<p>Example declarations: + + <pre>attribute vec4 position; +attribute vec3 normal; +attribute vec2 texCoord;</pre> + <p> + All the standard OpenGL vertex attributes have built-in variable names + to allow easy integration between user programs and OpenGL vertex + functions. See Section 7 &quot;Built-in Variables&quot; of the OpenGL Shading + Language specification; for a list of the built-in attribute names. + </p> + <p> + It is expected that graphics hardware will have a small number of fixed + locations for passing vertex attributes. Therefore, the OpenGL Shading + language defines each non-matrix attribute variable as having space for + up to four floating-point values (i.e., a vec4). There is an + implementation dependent limit on the number of attribute variables that + can be used and if this is exceeded it will cause a link error. + (Declared attribute variables that are not used do not count against + this limit.) A float attribute counts the same amount against this limit + as a vec4, so applications may want to consider packing groups of four + unrelated float attributes together into a vec4 to better utilize the + capabilities of the underlying hardware. A matrix attribute will use up + multiple attribute locations. The number of locations used will equal + the number of columns in the matrix. + </p> + <p> + Attribute variables are required to have global scope, and must be + declared outside of function bodies, before their first use. + </p> + </body> +</html> + + + + + + gl_BackSecondaryColor + + + BUILD_IN_VAR + enable GL_VERTEX_PROGRAM_TWO_SIDE + varying vec4 + + + + + gl_FrontColor + + + BUILD_IN_VAR + varying vec4 + + + + + gl_FogCoord + + + BUILD_IN_VAR + attribute float + + + + + gl_MultiTexCoord7 + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_MultiTexCoord6 + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_MultiTexCoord5 + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_PointSize + + + BUILD_IN_VAR + may be written from vertex shader + <html> + <head> + + </head> + <body> + The variable <i>gl_PointSize </i>is available only in the vertex and geometry language + and is intended to write the size of the point to be + rasterized. It is measured in pixels. + + <p> + If <i>gl_PointSize </i>or <i>gl_ClipVertex </i>are not written to, their + values are undefined. Any of these variables can be read back by the + shader after writing to them, to retrieve what was written. Reading them + before writing them results in undefined behavior. If they are written + more than once, it is the last value written that is consumed by the + subsequent operations. These built-in variables have global scope. + </p> + </body> + </html> + + float + + + + + inColor + + + BUILD_IN_VAR + attribute vec4 + + + + + inTexCoord + + + BUILD_IN_VAR + attribute vec4 + + + + + inNormal + + + BUILD_IN_VAR + attribute vec3 + + + + + inPosition + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_SecondaryColor + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_MultiTexCoord4 + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_MultiTexCoord3 + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_ClipVertex + + + BUILD_IN_VAR + may be written from vertex shader + <html> + <head> + + </head> + <body> + The variable <i>gl_ClipVertex </i>is available only in the vertex and geometry language + and provides a place for vertex and geometry shaders to write the coordinate to be used + with the user clipping planes. The user must ensure the clip vertex and + user clipping planes are defined in the same coordinate space. User clip + planes work properly only under linear transform. It is undefined what + happens under non-linear transform. + + <p> + If <i>gl_PointSize </i>or <i>gl_ClipVertex </i>are not written to, their + values are undefined. Any of these variables can be read back by the + shader after writing to them, to retrieve what was written. Reading them + before writing them results in undefined behavior. If they are written + more than once, it is the last value written that is consumed by the + subsequent operations. These built-in variables have global scope. + </p> + </body> + </html> + + vec4 + + + + + gl_MultiTexCoord2 + + + BUILD_IN_VAR + attribute vec4 + + + + + gl_MultiTexCoord1 + + + BUILD_IN_VAR + attribute vec4 + + + + + + + gl_FogFragCoord + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + For <i>gl_FogFragCoord</i>, the value written will be used as the &quot;c&quot; + value on page 160 of the OpenGL 1.4 Specification by the fixed + functionality pipeline. For example, if the z-coordinate of the fragment + in eye space is desired as &quot;c&quot;, then that's what the vertex or geometry shader + executable should write into <i>gl_FogFragCoord</i>. + </body> + </html> + + varying out float + + + + + gl_BackColor + + + BUILD_IN_VAR + enable GL_VERTEX_PROGRAM_TWO_SIDE + varying out vec4 + + + + + gl_Layer + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + The built-in output variable <i>gl_Layer</i> is available only in the + geometry language, and provides the number of the layer of textures + attached to a FBO to direct rendering to.<p> If a shader statically assigns a + value to <i>gl_Layer</i>, layered rendering mode is enabled. See section + 2.16.4 for a detailed explanation. If a shader statically assigns a value + to <i>gl_Layer</i>, and there is an execution path through the shader that + does not set <i>gl_Layer</i>, then the value of <i>gl_Layer</i> may be + undefined for executions of the shader that take that path. + </body> +</html> + + int + + + + + gl_Position + + + BUILD_IN_VAR + must be written from vertex shader + <html> + <head> + + </head> + <body> + The variable <i>gl_Position</i> is available only in the vertex and + geometry language and is intended for writing the homogeneous vertex + position. + + <p> + It can be written at any time during shader execution. It may also be + read back by the shader after being written. This value will be used by + primitive assembly, clipping, culling, and other fixed functionality + operations that operate on primitives after vertex or geometry + processing has occurred. Compilers may generate a diagnostic message if + they detect <i>gl_Position</i> is read before being written, but not all + such cases are detectable. Writing to <i>gl_Position</i> is optional. If <i>gl_Position</i> + is not written but subsequent stages of the OpenGL pipeline consume <i>gl_Position</i>, + then results are undefined. + </p> + </body> +</html> + + vec4 + + + + + gl_TexCoord + + + BUILD_IN_VAR + INDEX<gl_MaxTextureCoords + <html> + <head> + + </head> + <body> + As with all arrays, indices used to subscript <i>gl_TexCoord </i>must + either be an integral constant expressions, or this array must be + re-declared by the shader with a size. The size can be at most <i>gl_MaxTextureCoords</i>. + Using indexes close to 0 may aid the implementation in preserving varying + resources. + </body> + </html> + + [] + varying out vec4 + + + + + gl_FogFragCoordIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in float + + + + + EmitVertex + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The function <b>EmitVertex()</b> specifies that a vertex is completed. A + vertex is added to the current output primitive using the current values + of the varying output variables and the current values of the special + built-in output variables <b>gl_PointSize</b>, <b>gl_ClipVertex</b>, <b>gl_Layer</b>, + gl_Position</b> and <b>gl_PrimitiveID</b>. + + <p> + The values of any unwritten output variables are undefined. The values + of all varying output variables and the special built-in output + variables are undefined after a call to <b>EmitVertex()</b>. If a + geometry shader, in one invocation, emits more vertices than the value <i>GEOMETRY_VERTICES_OUT_EXT</i>, + these emits may have no effect. + </p> + </body> +</html> + + () + void + + + + + gl_BackColorIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in vec4 + + + + + gl_PointSizeIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in float + + + + + gl_FrontSecondaryColor + + + BUILD_IN_VAR + varying out vec4 + + + + + gl_BackSecondaryColorIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in vec4 + + + + + gl_ClipVertexIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in vec4 + + + + + gl_BackSecondaryColor + + + BUILD_IN_VAR + enable GL_VERTEX_PROGRAM_TWO_SIDE + varying out vec4 + + + + + gl_TexCoordIn + + + BUILD_IN_VAR + value <= gl_MaxTextureCoords + +value <= gl_MaxTextureCoords + [gl_VerticesIn][] + varying in vec4 + + + + + gl_FrontColorIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in vec4 + + + + + gl_FrontColor + + + BUILD_IN_VAR + varying out vec4 + + + + + gl_FrontSecondaryColorIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in vec4 + + + + + gl_VerticesIn + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + <p> + Value set at link time. + </p> + </body> +</html> + + const int + + + + + gl_PointSize + + + BUILD_IN_VAR + may be written from vertex shader + <html> + <head> + + </head> + <body> + The variable <i>gl_PointSize </i>is available only in the vertex and geometry language + and is intended to write the size of the point to be + rasterized. It is measured in pixels. + + <p> + If <i>gl_PointSize </i>or <i>gl_ClipVertex </i>are not written to, their + values are undefined. Any of these variables can be read back by the + shader after writing to them, to retrieve what was written. Reading them + before writing them results in undefined behavior. If they are written + more than once, it is the last value written that is consumed by the + subsequent operations. These built-in variables have global scope. + </p> + </body> + </html> + + float + + + + + EndPrimitive + + + BUILD_IN_FUNC + <html> + <head> + + </head> + <body> + The function <b>EndPrimitive()</b> specifies that the current output + primitive is completed and a new output primitive (of the same type) + should be started. This function does not emit a vertex.<br> The effect of <b>EndPrimitive()</b> + is roughly equivalent to calling End followed by a new Begin, where the + primitive mode is taken from the program object parameter <i>GEOMETRY_OUTPUT_TYPE_EXT</i>. + If the output primitive type is <i>POINTS</i>, calling <b>EndPrimitive()</b> + is optional. + + <p> + A geometry shader starts with an output primitive containing no + vertices. When a geometry shader terminates, the current output + primitive is automatically completed. It is not necessary to call <b>EndPrimitive()</b> + if the geometry shader writes only a single primitive. + </p> + </body> +</html> + + () + void + + + + + gl_PositionIn + + + BUILD_IN_VAR + [gl_VerticesIn] + varying in vec4 + + + + + gl_PrimitiveID + + + BUILD_IN_VAR + <html> + <head> + + </head> + <body> + The built-in output variable <i>gl_PrimitiveID</i> is available only in the + geometry language and provides a single integer that serves as a primitive + identifier.<p> This written primitive ID is available to fragment shaders. + If a fragment shader using primitive IDs is active and a geometry shader + is also active, the geometry shader must write to <i>gl_PrimitiveID</i> or the + primitive ID in the fragment shader number is undefined. + </body> +</html> + + int + + + + + gl_ClipVertex + + + BUILD_IN_VAR + may be written from vertex shader + <html> + <head> + + </head> + <body> + The variable <i>gl_ClipVertex </i>is available only in the vertex and geometry language + and provides a place for vertex and geometry shaders to write the coordinate to be used + with the user clipping planes. The user must ensure the clip vertex and + user clipping planes are defined in the same coordinate space. User clip + planes work properly only under linear transform. It is undefined what + happens under non-linear transform. + + <p> + If <i>gl_PointSize </i>or <i>gl_ClipVertex </i>are not written to, their + values are undefined. Any of these variables can be read back by the + shader after writing to them, to retrieve what was written. Reading them + before writing them results in undefined behavior. If they are written + more than once, it is the last value written that is consumed by the + subsequent operations. These built-in variables have global scope. + </p> + </body> + </html> + + vec4 + + + + + diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/NetBeans-glsl-fontsColors.xml b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/NetBeans-glsl-fontsColors.xml new file mode 100644 index 000000000..2518c05e8 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/NetBeans-glsl-fontsColors.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/OptionsIcon.gif b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/OptionsIcon.gif new file mode 100644 index 0000000000000000000000000000000000000000..a9b5990d6eea4e825d878a441138d62c12ce0d18 GIT binary patch literal 163 zcmV;U09^k^Nk%w1VGsZi0J8u9^pc#+%>S90va_?y%*^K1)$ix$|Ns90|NoiFn_}$A zrnUe8|5a80|Nj600RR90A^8LW000jFEC2ui01yBW000C~@X1N5z18Whv1?%XJz6t; zMrt^L1~4PpsA=geF{&0Ha>TM-?`JyA47`R9C_yD1Kc=j(QY0J#DQd705VVbfK~NxP Rizkj6Jqfu(nD`_D06RHgN4Nk0 literal 0 HcmV?d00001 diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/VertexShaderIcon.gif b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/resources/VertexShaderIcon.gif new file mode 100644 index 0000000000000000000000000000000000000000..a20da903c2e8dbf9d0e3c6f274425675203da14d GIT binary patch literal 613 zcmV-r0-F6tNk%w1VGsZi0OorD^!WYy{Qg^vyzut@K0ZJ7`u^eW`yL)2^7sAw{QfwO z&gJp^xVygp|Nnk|eviQ9V5Zva@%F{u@Oh@xxy#+-@ciNL`OM<<+0%CnA7z6{SFQe_xt|l@%s7t`iQ#U)#&v*ZKBoL-M6{B)#ms} zm(x_9)!p9T8hys+=jhVr_VV}qO`6j2@bTmC`TYI<(&F=Wv)~te$Jy%mu)WKEx8ZDU zZ}|KEsm|&=ZK9370C!zW-EGnDgX!r>8=1N0;LBMBQ`ATkdcmr2nlpx zC~#p#N|g-h{0%69;z1lL7rq!sH=xcIJ5d%asDQ?Rnsj+$%A6U~kp4-h8YqX zEDVfCn$DbD|5ojmrSNQTNkL;56}cHL7bqHD- zGycu@S>v`~-)03Vg$4=Dv%L(AE`@n490m;Y?gu1s-JHA!=qCnGS3j3^P6z94|_U%+n$)~4J_E(j>nmKXXq6M>~Ll11*y0EtD z-H9V@zMi|v3jVBJ_Ta&TE6Wz1m@{)#Oa1()kQFKMpPxP5RgiV2y5!usbB{NynHd%Q zdg=UUXHQ+8(s$|jv3W6JHx|#o*W3DXO3%A@@BTix`*-bS;=S4ocVw1=>J_? z{;!z-fBlO8OXvRo|DS<$p!k!8k%2*vK?kH2!9y(I}9^tG>mXQjgD$5z7 zCWtLyI_{B?!jMp~%u&P5YULKItDPd6(o<{J-3sUuX3svKZmH(Vp`_c=s;k7|DkQGm z+ovrq&$rl_g0p{A(8p~0;hf}BE#poS2k zz(@#bZ3_AW0t=PSJ%@YlX|OA4UJxAmrt^NBAMg9{9bv6ym>OZo8trWy?7ji~wj~1H zY}Lu-<6q{-%LGR1f*PSK6=SN#-oMQ`cS>6hDLrF;xjR{@=(ghm4^9b0#6&N_tkI) zNBdU*tYjUE=jBd6;mq++ehg=j%f|sk#;MWHY`O+XE8CYr=pfw`@4EC;rP_C&`1j8= a^abBic8;DClL2x70000 mainVocabulary; + public final HashMap fragmentShaderVocabulary; + public final HashMap vertexShaderVocabulary; + public final HashMap geometryShaderVocabulary; + + + public GLSLVocabulary() { + mainVocabulary = new HashMap(); + vertexShaderVocabulary = new HashMap(); + fragmentShaderVocabulary = new HashMap(); + geometryShaderVocabulary = new HashMap(); + } + + +} diff --git a/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/vocabulary/jaxb.index b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/vocabulary/jaxb.index new file mode 100644 index 000000000..4c8c5e813 --- /dev/null +++ b/sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/vocabulary/jaxb.index @@ -0,0 +1,2 @@ +GLSLElementDescriptor +GLSLVocabulary \ No newline at end of file diff --git a/sdk/jme3-glsl-support/test/unit/src/META-INF/services/org.openide.loaders.DataLoader b/sdk/jme3-glsl-support/test/unit/src/META-INF/services/org.openide.loaders.DataLoader new file mode 100644 index 000000000..f9476ad9a --- /dev/null +++ b/sdk/jme3-glsl-support/test/unit/src/META-INF/services/org.openide.loaders.DataLoader @@ -0,0 +1 @@ +net.java.nboglpack.glsleditor.GlslGeometryShaderDataLoader diff --git a/sdk/nbproject/platform.properties b/sdk/nbproject/platform.properties index c894b7b7c..43d5cbc48 100644 --- a/sdk/nbproject/platform.properties +++ b/sdk/nbproject/platform.properties @@ -51,7 +51,6 @@ disabled.modules=\ org.netbeans.modules.jellytools.java,\ org.netbeans.modules.jellytools.platform,\ org.netbeans.modules.jemmy,\ - org.netbeans.modules.languages,\ org.netbeans.modules.maven,\ org.netbeans.modules.maven.coverage,\ org.netbeans.modules.maven.embedder,\ diff --git a/sdk/nbproject/project.properties b/sdk/nbproject/project.properties index 2053b16b5..d943196e5 100644 --- a/sdk/nbproject/project.properties +++ b/sdk/nbproject/project.properties @@ -44,6 +44,7 @@ modules=\ ${project.com.jme3.gde.obfuscate}:\ ${project.com.jme3.gde.blender}:\ ${project.com.jme3.gde.angelfont}:\ + ${project.net.java.nboglpack.glsleditor}:\ ${project.com.jme3.gde.android} project.com.jme3.gde.android=jme3-android project.com.jme3.gde.angelfont=jme3-angelfont @@ -51,6 +52,7 @@ project.com.jme3.gde.blender=jme3-blender project.com.jme3.gde.codecheck=jme3-code-check project.com.jme3.gde.customcontrols=jme3-custom-controls project.com.jme3.gde.desktop.executables=jme3-desktop-executables +project.net.java.nboglpack.glsleditor=jme3-glsl-support project.com.jme3.gde.assetpack=jme3-assetpack-support project.com.jme3.gde.cinematics=jme3-cinematics project.com.jme3.gde.codepalette=jme3-codepalette