@ -1,10 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<!-- You may freely edit this file. See harness/README in the NetBeans platform --> |
|
||||||
<!-- for some information on what you could do (e.g. targets to override). --> |
|
||||||
<!-- If you delete this file and reopen the project it will be recreated. --> |
|
||||||
<project name="net.java.nboglpack.glsleditor" default="netbeans" basedir="."> |
|
||||||
<description>Builds, tests, and runs the project net.java.nboglpack.glsleditor.</description> |
|
||||||
<!--property file="./../nbproject/global.properties"/> |
|
||||||
<property file="./../nbproject/private/global_private.properties"/--> |
|
||||||
<import file="nbproject/build-impl.xml"/> |
|
||||||
</project> |
|
@ -1,27 +0,0 @@ |
|||||||
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. |
|
@ -1,14 +0,0 @@ |
|||||||
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 |
|
@ -1,45 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<!-- |
|
||||||
*** GENERATED FROM project.xml - DO NOT EDIT *** |
|
||||||
*** EDIT ../build.xml INSTEAD *** |
|
||||||
--> |
|
||||||
<project name="net.java.nboglpack.glsleditor-impl" basedir=".."> |
|
||||||
<fail message="Please build using Ant 1.7.1 or higher."> |
|
||||||
<condition> |
|
||||||
<not> |
|
||||||
<antversion atleast="1.7.1"/> |
|
||||||
</not> |
|
||||||
</condition> |
|
||||||
</fail> |
|
||||||
<property file="nbproject/private/suite-private.properties"/> |
|
||||||
<property file="nbproject/suite.properties"/> |
|
||||||
<fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail> |
|
||||||
<property file="${suite.dir}/nbproject/private/platform-private.properties"/> |
|
||||||
<property file="${suite.dir}/nbproject/platform.properties"/> |
|
||||||
<macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2"> |
|
||||||
<attribute name="name"/> |
|
||||||
<attribute name="value"/> |
|
||||||
<sequential> |
|
||||||
<property name="@{name}" value="${@{value}}"/> |
|
||||||
</sequential> |
|
||||||
</macrodef> |
|
||||||
<macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2"> |
|
||||||
<attribute name="property"/> |
|
||||||
<attribute name="value"/> |
|
||||||
<sequential> |
|
||||||
<property name="@{property}" value="@{value}"/> |
|
||||||
</sequential> |
|
||||||
</macrodef> |
|
||||||
<property file="${user.properties.file}"/> |
|
||||||
<nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> |
|
||||||
<nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> |
|
||||||
<nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> |
|
||||||
<fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness)."> |
|
||||||
<condition> |
|
||||||
<not> |
|
||||||
<contains string="${cluster.path.evaluated}" substring="platform"/> |
|
||||||
</not> |
|
||||||
</condition> |
|
||||||
</fail> |
|
||||||
<import file="${harness.dir}/build.xml"/> |
|
||||||
</project> |
|
@ -1,8 +0,0 @@ |
|||||||
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=7f14124d |
|
||||||
nbproject/build-impl.xml.script.CRC32=d103b190 |
|
||||||
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.67.1 |
|
@ -1,6 +0,0 @@ |
|||||||
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, Dany Rioux |
|
||||||
spec.version.base=3.1.0 |
|
@ -1,111 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project xmlns="http://www.netbeans.org/ns/project/1"> |
|
||||||
<type>org.netbeans.modules.apisupport.project</type> |
|
||||||
<configuration> |
|
||||||
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> |
|
||||||
<code-name-base>net.java.nboglpack.glsleditor</code-name-base> |
|
||||||
<suite-component/> |
|
||||||
<module-dependencies> |
|
||||||
<dependency> |
|
||||||
<code-name-base>org.netbeans.modules.editor.completion</code-name-base> |
|
||||||
<build-prerequisite/> |
|
||||||
<compile-dependency/> |
|
||||||
<run-dependency> |
|
||||||
<release-version>1</release-version> |
|
||||||
<specification-version>1.40.1.2</specification-version> |
|
||||||
</run-dependency> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<code-name-base>org.netbeans.modules.editor.lib</code-name-base> |
|
||||||
<build-prerequisite/> |
|
||||||
<compile-dependency/> |
|
||||||
<run-dependency> |
|
||||||
<release-version>3</release-version> |
|
||||||
<specification-version>3.49.2.22.43</specification-version> |
|
||||||
</run-dependency> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<code-name-base>org.netbeans.modules.languages</code-name-base> |
|
||||||
<build-prerequisite/> |
|
||||||
<compile-dependency/> |
|
||||||
<run-dependency> |
|
||||||
<release-version>0-1</release-version> |
|
||||||
<specification-version>1.117.1.2</specification-version> |
|
||||||
</run-dependency> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<code-name-base>org.netbeans.modules.lexer</code-name-base> |
|
||||||
<build-prerequisite/> |
|
||||||
<compile-dependency/> |
|
||||||
<run-dependency> |
|
||||||
<release-version>2</release-version> |
|
||||||
<specification-version>1.59.1.1</specification-version> |
|
||||||
</run-dependency> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<code-name-base>org.openide.filesystems</code-name-base> |
|
||||||
<build-prerequisite/> |
|
||||||
<compile-dependency/> |
|
||||||
<run-dependency> |
|
||||||
<specification-version>8.12.1</specification-version> |
|
||||||
</run-dependency> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<code-name-base>org.openide.loaders</code-name-base> |
|
||||||
<build-prerequisite/> |
|
||||||
<compile-dependency/> |
|
||||||
<run-dependency> |
|
||||||
<specification-version>7.57.2</specification-version> |
|
||||||
</run-dependency> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<code-name-base>org.openide.nodes</code-name-base> |
|
||||||
<build-prerequisite/> |
|
||||||
<compile-dependency/> |
|
||||||
<run-dependency> |
|
||||||
<specification-version>7.39.1</specification-version> |
|
||||||
</run-dependency> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<code-name-base>org.openide.text</code-name-base> |
|
||||||
<build-prerequisite/> |
|
||||||
<compile-dependency/> |
|
||||||
<run-dependency> |
|
||||||
<specification-version>6.62.2</specification-version> |
|
||||||
</run-dependency> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<code-name-base>org.openide.util</code-name-base> |
|
||||||
<build-prerequisite/> |
|
||||||
<compile-dependency/> |
|
||||||
<run-dependency> |
|
||||||
<specification-version>8.39.1</specification-version> |
|
||||||
</run-dependency> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<code-name-base>org.openide.util.lookup</code-name-base> |
|
||||||
<build-prerequisite/> |
|
||||||
<compile-dependency/> |
|
||||||
<run-dependency> |
|
||||||
<specification-version>8.25.1</specification-version> |
|
||||||
</run-dependency> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<code-name-base>org.openide.windows</code-name-base> |
|
||||||
<build-prerequisite/> |
|
||||||
<compile-dependency/> |
|
||||||
<run-dependency> |
|
||||||
<specification-version>6.71.1</specification-version> |
|
||||||
</run-dependency> |
|
||||||
</dependency> |
|
||||||
</module-dependencies> |
|
||||||
<public-packages> |
|
||||||
<package>net.java.nboglpack.glsleditor</package> |
|
||||||
<package>net.java.nboglpack.glsleditor.dataobject</package> |
|
||||||
<package>net.java.nboglpack.glsleditor.glsl</package> |
|
||||||
<package>net.java.nboglpack.glsleditor.lexer</package> |
|
||||||
<package>net.java.nboglpack.glsleditor.vocabulary</package> |
|
||||||
</public-packages> |
|
||||||
</data> |
|
||||||
</configuration> |
|
||||||
</project> |
|
@ -1 +0,0 @@ |
|||||||
suite.dir=${basedir}/.. |
|
@ -1,28 +0,0 @@ |
|||||||
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 |
|
||||||
|
|
@ -1,64 +0,0 @@ |
|||||||
package net.java.nboglpack.glsleditor; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created on 26. March 2007, 00:49 |
|
||||||
* |
|
||||||
*/ |
|
||||||
import javax.swing.event.DocumentEvent; |
|
||||||
import javax.swing.event.DocumentListener; |
|
||||||
import org.openide.loaders.DataObject; |
|
||||||
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; |
|
||||||
} |
|
||||||
} |
|
@ -1,170 +0,0 @@ |
|||||||
/* |
|
||||||
* 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<String, GlslVocabularyManager> instances = new HashMap<String, GlslVocabularyManager>(); |
|
||||||
private static GLSLVocabulary vocabulary = null; |
|
||||||
private final String mimetype; |
|
||||||
private final Set<String> keySet; |
|
||||||
private final Map<String, GLSLElementDescriptor[]> 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<String>() { |
|
||||||
|
|
||||||
private final Set<String> mainSet = vocabulary.mainVocabulary.keySet(); |
|
||||||
private final Set<String> extSet = vocabularyExtention.keySet(); |
|
||||||
|
|
||||||
public Iterator<String> iterator() { |
|
||||||
return new Iterator<String>() { |
|
||||||
|
|
||||||
Iterator<String> mainIt = mainSet.iterator(); |
|
||||||
Iterator<String> 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; |
|
||||||
} |
|
||||||
} |
|
@ -1,11 +0,0 @@ |
|||||||
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 |
|
@ -1,40 +0,0 @@ |
|||||||
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"; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,32 +0,0 @@ |
|||||||
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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,24 +0,0 @@ |
|||||||
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;
|
|
||||||
// }
|
|
||||||
} |
|
@ -1,59 +0,0 @@ |
|||||||
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 PropertyChangeListenerImpl(support)); |
|
||||||
cookies.add((Node.Cookie) support); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected Node createNodeDelegate() { |
|
||||||
return new GlslFragmentShaderDataNode(this); |
|
||||||
} |
|
||||||
|
|
||||||
private class PropertyChangeListenerImpl implements PropertyChangeListener { |
|
||||||
|
|
||||||
private final CloneableEditorSupport support; |
|
||||||
|
|
||||||
public PropertyChangeListenerImpl(CloneableEditorSupport support) { |
|
||||||
this.support = support; |
|
||||||
} |
|
||||||
|
|
||||||
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); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,44 +0,0 @@ |
|||||||
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"; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,37 +0,0 @@ |
|||||||
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; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,34 +0,0 @@ |
|||||||
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;
|
|
||||||
// }
|
|
||||||
|
|
||||||
} |
|
@ -1,67 +0,0 @@ |
|||||||
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 PropertyChangeListenerImpl(support)); |
|
||||||
cookies.add((Node.Cookie) support); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected Node createNodeDelegate() { |
|
||||||
return new GlslGeometryShaderDataNode(this, getLookup()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Lookup getLookup() { |
|
||||||
return getCookieSet().getLookup(); |
|
||||||
} |
|
||||||
|
|
||||||
private class PropertyChangeListenerImpl implements PropertyChangeListener { |
|
||||||
|
|
||||||
private final CloneableEditorSupport support; |
|
||||||
|
|
||||||
public PropertyChangeListenerImpl(CloneableEditorSupport support) { |
|
||||||
this.support = support; |
|
||||||
} |
|
||||||
|
|
||||||
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); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,40 +0,0 @@ |
|||||||
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"; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,32 +0,0 @@ |
|||||||
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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,24 +0,0 @@ |
|||||||
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;
|
|
||||||
// }
|
|
||||||
} |
|
@ -1,58 +0,0 @@ |
|||||||
package net.java.nboglpack.glsleditor.dataobject; |
|
||||||
|
|
||||||
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 PropertyChangeListenerImpl(support)); |
|
||||||
cookies.add((Node.Cookie) support); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected Node createNodeDelegate() { |
|
||||||
return new GlslVertexShaderDataNode(this); |
|
||||||
} |
|
||||||
|
|
||||||
private class PropertyChangeListenerImpl implements PropertyChangeListener { |
|
||||||
|
|
||||||
private final CloneableEditorSupport support; |
|
||||||
|
|
||||||
public PropertyChangeListenerImpl(CloneableEditorSupport support) { |
|
||||||
this.support = support; |
|
||||||
} |
|
||||||
|
|
||||||
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); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,4 +0,0 @@ |
|||||||
LBL_SYNTAX_ERROR=Syntax error. |
|
||||||
LBL_UNEXPECTED_CHARACTER=Unexpected character. |
|
||||||
LBL_RESERVED_KEYWORD=Reserved keyword. |
|
||||||
|
|
@ -1,316 +0,0 @@ |
|||||||
################################################################################ |
|
||||||
# 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 | <IDENTIFIER>; |
|
||||||
|
|
||||||
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 = <EQ> |
|
||||||
| <MUL_ASSIGN> |
|
||||||
| <DIV_ASSIGN> |
|
||||||
| <ADD_ASSIGN> |
|
||||||
| <SUB_ASSIGN> |
|
||||||
| <MOD_ASSIGN> # reserved |
|
||||||
| <LEFT_BITSHIFT_ASSIGN> # reserved |
|
||||||
| <RIGHT_BITSHIFT_ASSIGN> # reserved |
|
||||||
| <AND_ASSIGN> # reserved |
|
||||||
| <XOR_ASSIGN> # reserved |
|
||||||
| <OR_ASSIGN>; # reserved |
|
||||||
|
|
||||||
comperator = <LEFT_ANGLE> | <RIGHT_ANGLE> | <LE> | <GE> | <EQEQ> | <NE>; |
|
||||||
|
|
||||||
operator = <PLUS> |
|
||||||
| <MINUS> |
|
||||||
| <STAR> |
|
||||||
| <SLASH> |
|
||||||
| <AMP> |
|
||||||
| <AMPAMP> |
|
||||||
| <BAR> # reserved |
|
||||||
| <BARBAR> |
|
||||||
| <CARETCARET> |
|
||||||
| <CARET> # reserved |
|
||||||
| <PERCENT> # reserved |
|
||||||
| <RIGHT_BITSHIFT> # reserved |
|
||||||
| <LEFT_BITSHIFT>; # reserved |
|
||||||
|
|
||||||
unary_operator = <PLUS> |
|
||||||
| <MINUS> |
|
||||||
| <BANG> |
|
||||||
| <TILDE>; # reserved |
|
||||||
|
|
||||||
increment_or_decrement_operator = <PLUSPLUS> | <MINUSMINUS>; |
|
||||||
|
|
||||||
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 <SEMICOLON>)); |
|
||||||
declaration = "void" function; |
|
||||||
declaration = global_type_qualifier struct_declaration <SEMICOLON>; |
|
||||||
declaration = global_type_qualifier global_type_declaration <SEMICOLON>; |
|
||||||
declaration = struct_declaration <SEMICOLON>; |
|
||||||
declaration = global_preprocessor; |
|
||||||
|
|
||||||
global_identifier_list = global_declared_identifier [array_index] (<COMMA> global_declared_identifier [array_index])*; |
|
||||||
global_declared_identifier = <IDENTIFIER>; |
|
||||||
global_preprocessor = <PREPROCESSOR>; |
|
||||||
|
|
||||||
struct_declaration = "struct" <IDENTIFIER> struct_body [global_identifier_list]; |
|
||||||
struct_body = "{" (local_type_declaration <SEMICOLON>)+ "}"; |
|
||||||
|
|
||||||
global_type_declaration = type_specifier_or_identifier [array_index] global_identifier_list [<EQ> expression]; |
|
||||||
type_declaration = type_specifier_or_identifier [array_index] <IDENTIFIER> [array_index] (<COMMA> <IDENTIFIER> [array_index])*; |
|
||||||
|
|
||||||
local_type_declaration = [type_qualifier] type_declaration; |
|
||||||
|
|
||||||
## function #################################################################### |
|
||||||
function = <FUNCTION> "(" [parameter_declaration_list] ")" (function_body | <SEMICOLON>); |
|
||||||
function_body = code_block; |
|
||||||
|
|
||||||
parameter_declaration = [type_qualifier] [parameter_declaration_qualifier] type_specifier_or_identifier ((array_index <IDENTIFIER>) | (<IDENTIFIER> [array_index])); |
|
||||||
parameter_declaration_list = "void" | (parameter_declaration (<COMMA> parameter_declaration)*); |
|
||||||
|
|
||||||
statement = <PREPROCESSOR>; |
|
||||||
statement = expression_hack <SEMICOLON>; # statement = local_type_declaration [<EQ> expression] <SEMICOLON>; |
|
||||||
statement = conditional_statement; |
|
||||||
statement = "return" [expression] <SEMICOLON>; |
|
||||||
statement = "break" <SEMICOLON>; # break just in loops allowed |
|
||||||
statement = "continue" <SEMICOLON>;# continue just in loops allowed |
|
||||||
statement = "discard" <SEMICOLON>; # 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] (<IDENTIFIER> | <BUILD_IN_VAR>) (field_access)* [increment_or_decrement_operator] [assignment]) |
|
||||||
| ((function_call | constructor_call) (field_access)*) |
|
||||||
| <INTEGER_LITERAL> |
|
||||||
| <FLOAT_LITERAL> |
|
||||||
| 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 = <IDENTIFIER> (field_access)* [increment_or_decrement_operator] [assignment]; |
|
||||||
expression_hack = <IDENTIFIER> (field_access)* <IDENTIFIER> [array_index] (<COMMA> <IDENTIFIER> [array_index])*; |
|
||||||
expression_hack = type_specifier (field_access)* <IDENTIFIER> [array_index] (<COMMA> <IDENTIFIER> [array_index])*; |
|
||||||
|
|
||||||
expression1_hack = (increment_or_decrement_operator (<IDENTIFIER> | <BUILD_IN_VAR>) (field_access)* [increment_or_decrement_operator] [assignment]) |
|
||||||
| (<BUILD_IN_VAR> (field_access)* [increment_or_decrement_operator] [assignment]) |
|
||||||
| ((function_call | constructor_call) (field_access)*) |
|
||||||
| <INTEGER_LITERAL> |
|
||||||
| <FLOAT_LITERAL> |
|
||||||
| boolean_literal; |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
assignment = assignment_operator expression; |
|
||||||
operation_or_comparison = (comperator | operator) expression; |
|
||||||
|
|
||||||
field_access = array_index; |
|
||||||
field_access = <DOT> <IDENTIFIER>; |
|
||||||
|
|
||||||
array_index = "[" [expression] "]"; |
|
||||||
|
|
||||||
function_call = (<FUNCTION> | <BUILD_IN_FUNC>) "(" [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 (<COMMA> 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 <SEMICOLON>; |
|
||||||
# TODO for rule could be more restrictive |
|
||||||
for_statement = "for" "(" [[type_specifier] <IDENTIFIER> assignment] <SEMICOLON> [expression] <SEMICOLON> [expression] ")" statement_or_code_block; |
|
||||||
|
|
||||||
condition = "(" expression ")"; |
|
||||||
statement_or_code_block = (statement | code_block); |
|
||||||
|
|
||||||
|
|
@ -1,390 +0,0 @@ |
|||||||
################################################################################ |
|
||||||
# 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 | <IDENTIFIER>; |
|
||||||
|
|
||||||
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 = <EQ> |
|
||||||
| <MUL_ASSIGN> |
|
||||||
| <DIV_ASSIGN> |
|
||||||
| <ADD_ASSIGN> |
|
||||||
| <SUB_ASSIGN> |
|
||||||
| <MOD_ASSIGN> # reserved |
|
||||||
| <LEFT_BITSHIFT_ASSIGN> # reserved |
|
||||||
| <RIGHT_BITSHIFT_ASSIGN> # reserved |
|
||||||
| <AND_ASSIGN> # reserved |
|
||||||
| <XOR_ASSIGN> # reserved |
|
||||||
| <OR_ASSIGN>; # reserved |
|
||||||
|
|
||||||
comperator = <LEFT_ANGLE> | <RIGHT_ANGLE> | <LE> | <GE> | <EQEQ> | <NE>; |
|
||||||
|
|
||||||
operator = <PLUS> |
|
||||||
| <MINUS> |
|
||||||
| <STAR> |
|
||||||
| <SLASH> |
|
||||||
| <AMP> |
|
||||||
| <AMPAMP> |
|
||||||
| <BAR> # reserved |
|
||||||
| <BARBAR> |
|
||||||
| <CARETCARET> |
|
||||||
| <CARET> # reserved |
|
||||||
| <PERCENT> # reserved |
|
||||||
| <RIGHT_BITSHIFT> # reserved |
|
||||||
| <LEFT_BITSHIFT>; # reserved |
|
||||||
|
|
||||||
unary_operator = <PLUS> |
|
||||||
| <MINUS> |
|
||||||
| <BANG> |
|
||||||
| <TILDE>; # reserved |
|
||||||
|
|
||||||
increment_or_decrement_operator = <PLUSPLUS> | <MINUSMINUS>; |
|
||||||
|
|
||||||
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] <SEMICOLON>)); |
|
||||||
declaration = "void" function; |
|
||||||
declaration = field_declaration <SEMICOLON>; |
|
||||||
declaration = struct_declaration <SEMICOLON>; |
|
||||||
declaration = precision_declaration <SEMICOLON>; |
|
||||||
declaration = global_preprocessor; |
|
||||||
|
|
||||||
global_identifier_list = global_declared_identifier [array_index] (<COMMA> global_declared_identifier [array_index])*; |
|
||||||
global_declared_identifier = <IDENTIFIER>; |
|
||||||
global_preprocessor = <PREPROCESSOR>; |
|
||||||
|
|
||||||
field_declaration = ("in" | "uniform") type_specifier_or_identifier <BUILD_IN_VAR> ; |
|
||||||
field_declaration = global_type_qualifier struct_declaration; |
|
||||||
field_declaration = global_type_qualifier global_type_declaration [assignment2]; |
|
||||||
|
|
||||||
struct_declaration = "struct" <IDENTIFIER> struct_body [global_identifier_list]; |
|
||||||
struct_body = "{" (local_type_declaration <SEMICOLON>)+ "}"; |
|
||||||
|
|
||||||
global_type_declaration = [precision_qualifier] type_specifier_or_identifier [array_index] global_identifier_list [<EQ> expression]; |
|
||||||
type_declaration = [precision_qualifier] type_specifier_or_identifier [array_index] <IDENTIFIER> [array_index] (<COMMA> <IDENTIFIER> [array_index])*; |
|
||||||
|
|
||||||
local_type_declaration = [type_qualifier] type_declaration; |
|
||||||
|
|
||||||
precision_declaration = "precision" precision_qualifier type_specifier; |
|
||||||
|
|
||||||
## function #################################################################### |
|
||||||
function = <FUNCTION> "(" [parameter_declaration_list] ")" (function_body | <SEMICOLON>); |
|
||||||
function_body = code_block; |
|
||||||
|
|
||||||
parameter_declaration = [type_qualifier] [parameter_declaration_qualifier] [precision_qualifier] type_specifier_or_identifier ((array_index <IDENTIFIER>) | (<IDENTIFIER> [array_index])); |
|
||||||
parameter_declaration_list = "void" | (parameter_declaration (<COMMA> parameter_declaration)*); |
|
||||||
|
|
||||||
statement = <PREPROCESSOR>; |
|
||||||
statement = expression_hack <SEMICOLON>; # statement = local_type_declaration [<EQ> expression] <SEMICOLON>; |
|
||||||
statement = conditional_statement; |
|
||||||
statement = "return" [expression] <SEMICOLON>; |
|
||||||
statement = "break" <SEMICOLON>; # break just in loops allowed |
|
||||||
statement = "continue" <SEMICOLON>;# continue just in loops allowed |
|
||||||
statement = "discard" <SEMICOLON>; # 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] (<IDENTIFIER> | <BUILD_IN_VAR>) (field_access)* [increment_or_decrement_operator] [assignment]) |
|
||||||
| ((function_call | constructor_call) (field_access)*) |
|
||||||
| <INTEGER_LITERAL> |
|
||||||
| <FLOAT_LITERAL> |
|
||||||
| 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 = <IDENTIFIER> (field_access)* [increment_or_decrement_operator] [assignment]; |
|
||||||
expression_hack = <IDENTIFIER> (field_access)* <IDENTIFIER> [array_index] (<COMMA> <IDENTIFIER> [array_index])*; |
|
||||||
expression_hack = type_specifier (field_access)* <IDENTIFIER> [array_index] (<COMMA> <IDENTIFIER> [array_index])*; |
|
||||||
|
|
||||||
expression1_hack = (increment_or_decrement_operator (<IDENTIFIER> | <BUILD_IN_VAR>) (field_access)* [increment_or_decrement_operator] [assignment]) |
|
||||||
| (<BUILD_IN_VAR> (field_access)* [increment_or_decrement_operator] [assignment]) |
|
||||||
| ((function_call | constructor_call) (field_access)*) |
|
||||||
| <INTEGER_LITERAL> |
|
||||||
| <FLOAT_LITERAL> |
|
||||||
| boolean_literal; |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
assignment = assignment_operator expression; |
|
||||||
assignment2 = <EQ> expression; |
|
||||||
operation_or_comparison = (comperator | operator) expression; |
|
||||||
|
|
||||||
field_access = array_index; |
|
||||||
field_access = <DOT> <IDENTIFIER>; |
|
||||||
|
|
||||||
array_index = "[" [expression] "]"; |
|
||||||
|
|
||||||
function_call = (<FUNCTION> | <BUILD_IN_FUNC>) "(" [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 (<COMMA> 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 <SEMICOLON>; |
|
||||||
|
|
||||||
# TODO for rule could be more restrictive |
|
||||||
for_statement = "for" "(" [[type_specifier] <IDENTIFIER> assignment] <SEMICOLON> [expression] <SEMICOLON> [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); |
|
||||||
|
|
||||||
|
|
@ -1,373 +0,0 @@ |
|||||||
/* |
|
||||||
* 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 = "<font color=808080>"; |
|
||||||
public final static Map<String, GLSLElementDescriptor> declaredFunctions = new HashMap<String, GLSLElementDescriptor>(); |
|
||||||
|
|
||||||
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("<html>"); |
|
||||||
|
|
||||||
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("</font>"); |
|
||||||
} |
|
||||||
|
|
||||||
while (moved-- >= 0) { |
|
||||||
sequence.movePrevious(); |
|
||||||
} |
|
||||||
|
|
||||||
sb.append(token.text()); |
|
||||||
|
|
||||||
if (token.id() == GlslTokenId.COMMA) { |
|
||||||
sb.append(KEYWORD_FONT_COLOR); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
first = false; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
sb.append("</font>)"); |
|
||||||
|
|
||||||
if (!"void".equals(type)) { |
|
||||||
sb.append(" : "); |
|
||||||
sb.append(KEYWORD_FONT_COLOR); |
|
||||||
sb.append(type); |
|
||||||
sb.append("</font>"); |
|
||||||
} |
|
||||||
sb.append("</html>"); |
|
||||||
|
|
||||||
} 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("<html>"); |
|
||||||
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("</font></html>"); |
|
||||||
} finally { |
|
||||||
document.readUnlock(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
return sb.toString(); |
|
||||||
} |
|
||||||
|
|
||||||
public static final String createPreprocessorString(SyntaxContext context) { |
|
||||||
|
|
||||||
ASTNode node = (ASTNode) context.getASTPath().getLeaf(); |
|
||||||
List<ASTItem> 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 functions for auto-completion
|
|
||||||
synchronized (declaredFunctions) { |
|
||||||
declaredFunctions.clear(); |
|
||||||
} |
|
||||||
|
|
||||||
List<ASTItem> declarations = context.getASTPath().getLeaf().getChildren(); |
|
||||||
|
|
||||||
for (ASTItem declaration : declarations) { |
|
||||||
|
|
||||||
for (ASTItem declarationItem : declaration.getChildren()) { |
|
||||||
|
|
||||||
if (isNode(declarationItem, "function")) { |
|
||||||
|
|
||||||
List<ASTItem> 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 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 boolean isIgnoredToken(Token token) { |
|
||||||
return token.id() == GlslTokenId.WHITESPACE |
|
||||||
|| token.id() == GlslTokenId.COMMENT |
|
||||||
|| token.id() == GlslTokenId.PREPROCESSOR; |
|
||||||
} |
|
||||||
|
|
||||||
private static boolean isNode(ASTItem item, String nodeToken) { |
|
||||||
return item != null && item instanceof ASTNode && ((ASTNode) item).getNT().equals(nodeToken); |
|
||||||
} |
|
||||||
|
|
||||||
private static boolean isToken(ASTItem item, String id) { |
|
||||||
return item != null && item instanceof ASTToken && ((ASTToken) item).getIdentifier().equals(id); |
|
||||||
} |
|
||||||
|
|
||||||
private static boolean isTokenType(ASTItem item, String type) { |
|
||||||
return item != null && item instanceof ASTToken && ((ASTToken) item).getTypeName().equals(type); |
|
||||||
} |
|
||||||
} |
|
@ -1,289 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd"> |
|
||||||
<filesystem> |
|
||||||
<folder name="Editors"> |
|
||||||
<folder name="text"> |
|
||||||
|
|
||||||
<folder name="x-glsl-vertex-shader"> |
|
||||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="net.java.nboglpack.glsleditor.Bundle"/> |
|
||||||
<file name="vocabulary.xml" url="resources/JmeVocabulary.xml"/> |
|
||||||
<folder name="CompletionProviders"> |
|
||||||
<file name="GlslCompletionProvider.instance"> |
|
||||||
<attr name="instanceCreate" methodvalue="net.java.nboglpack.glsleditor.GlslCompletionProvider.createVSCompletionProvider"/> |
|
||||||
<attr name="instanceClass" stringvalue="net.java.nboglpack.glsleditor.GlslCompletionProvider"/> |
|
||||||
</file> |
|
||||||
</folder> |
|
||||||
<folder name="FontsColors"> |
|
||||||
<folder name="NetBeans"> |
|
||||||
<folder name="Defaults"> |
|
||||||
<file name="coloring.xml" url="resources/NetBeans-glsl-fontsColors.xml"> |
|
||||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="net.java.nboglpack.glsleditor.Bundle"/> |
|
||||||
</file> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
<file name="language.instance"> |
|
||||||
<attr name="instanceCreate" methodvalue="net.java.nboglpack.glsleditor.lexer.Glsl.vertexLanguage"/> |
|
||||||
<attr name="instanceOf" stringvalue="org.netbeans.api.lexer.Language"/> |
|
||||||
</file> |
|
||||||
<!-- <file name="EditorKit.instance"> |
|
||||||
<attr name="instanceCreate" methodvalue="org.netbeans.modules.lexer.editorbridge.LexerEditorKit.create"/> |
|
||||||
<attr name="instanceClass" stringvalue="org.netbeans.modules.lexer.editorbridge.LexerEditorKit"/> |
|
||||||
</file>--> |
|
||||||
<attr name="createDataObject" boolvalue="false"/> |
|
||||||
<file name="language.nbs" url="glsl/GLSL_130.nbs"/> |
|
||||||
</folder> |
|
||||||
|
|
||||||
<folder name="x-glsl-fragment-shader"> |
|
||||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="net.java.nboglpack.glsleditor.Bundle"/> |
|
||||||
<file name="vocabulary.xml" url="resources/JmeVocabulary.xml"/> |
|
||||||
<folder name="CompletionProviders"> |
|
||||||
<file name="GlslCompletionProvider.instance"> |
|
||||||
<attr name="instanceCreate" methodvalue="net.java.nboglpack.glsleditor.GlslCompletionProvider.createFSCompletionProvider"/> |
|
||||||
<attr name="instanceClass" stringvalue="net.java.nboglpack.glsleditor.GlslCompletionProvider"/> |
|
||||||
</file> |
|
||||||
</folder> |
|
||||||
<folder name="FontsColors"> |
|
||||||
<folder name="NetBeans"> |
|
||||||
<folder name="Defaults"> |
|
||||||
<file name="coloring.xml" url="resources/NetBeans-glsl-fontsColors.xml"> |
|
||||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="net.java.nboglpack.glsleditor.Bundle"/> |
|
||||||
</file> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
<file name="language.instance"> |
|
||||||
<attr name="instanceCreate" methodvalue="net.java.nboglpack.glsleditor.lexer.Glsl.fragmentLanguage"/> |
|
||||||
<attr name="instanceOf" stringvalue="org.netbeans.api.lexer.Language"/> |
|
||||||
</file> |
|
||||||
<!-- <file name="EditorKit.instance"> |
|
||||||
<attr name="instanceCreate" methodvalue="org.netbeans.modules.lexer.editorbridge.LexerEditorKit.create"/> |
|
||||||
<attr name="instanceClass" stringvalue="org.netbeans.modules.lexer.editorbridge.LexerEditorKit"/> |
|
||||||
</file>--> |
|
||||||
<attr name="createDataObject" boolvalue="false"/> |
|
||||||
<file name="language.nbs" url="glsl/GLSL_130.nbs"/> |
|
||||||
</folder> |
|
||||||
|
|
||||||
<folder name="x-glsl-geometry-shader"> |
|
||||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="net.java.nboglpack.glsleditor.Bundle"/> |
|
||||||
<file name="vocabulary.xml" url="resources/JmeVocabulary.xml"/> |
|
||||||
<folder name="CompletionProviders"> |
|
||||||
<file name="GlslCompletionProvider.instance"> |
|
||||||
<attr name="instanceCreate" methodvalue="net.java.nboglpack.glsleditor.GlslCompletionProvider.createGSCompletionProvider"/> |
|
||||||
<attr name="instanceClass" stringvalue="net.java.nboglpack.glsleditor.GlslCompletionProvider"/> |
|
||||||
</file> |
|
||||||
</folder> |
|
||||||
<folder name="FontsColors"> |
|
||||||
<folder name="NetBeans"> |
|
||||||
<folder name="Defaults"> |
|
||||||
<file name="coloring.xml" url="resources/NetBeans-glsl-fontsColors.xml"> |
|
||||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="net.java.nboglpack.glsleditor.Bundle"/> |
|
||||||
</file> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
<file name="language.instance"> |
|
||||||
<attr name="instanceCreate" methodvalue="net.java.nboglpack.glsleditor.lexer.Glsl.geometryLanguage"/> |
|
||||||
<attr name="instanceOf" stringvalue="org.netbeans.api.lexer.Language"/> |
|
||||||
</file> |
|
||||||
<!-- <file name="EditorKit.instance"> |
|
||||||
<attr name="instanceCreate" methodvalue="org.netbeans.modules.lexer.editorbridge.LexerEditorKit.create"/> |
|
||||||
<attr name="instanceClass" stringvalue="org.netbeans.modules.lexer.editorbridge.LexerEditorKit"/> |
|
||||||
</file>--> |
|
||||||
<attr name="createDataObject" boolvalue="false"/> |
|
||||||
<file name="language.nbs" url="glsl/GLSL_130.nbs"/> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
|
|
||||||
<folder name="OptionsDialog"> |
|
||||||
<folder name="PreviewExamples"> |
|
||||||
<folder name="text"> |
|
||||||
<file name="x-glsl-vertex-shader" url="resources/GlslVertexShaderExample.vert"/> |
|
||||||
<file name="x-glsl-fragment-shader" url="resources/GlslFragmentShaderExample.frag"/> |
|
||||||
<file name="x-glsl-geometry-shader" url="resources/GlslGeometryShaderExample.geom"/> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
|
|
||||||
<folder name="Loaders"> |
|
||||||
<folder name="text"> |
|
||||||
<folder name="x-glsl-geometry-shader"> |
|
||||||
<folder name="Actions"> |
|
||||||
<file name="org-openide-actions-CopyAction.instance"> |
|
||||||
<attr name="position" intvalue="500"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-CutAction.instance"> |
|
||||||
<attr name="position" intvalue="400"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-DeleteAction.instance"> |
|
||||||
<attr name="position" intvalue="700"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-FileSystemAction.instance"> |
|
||||||
<attr name="position" intvalue="200"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-OpenAction.instance"> |
|
||||||
<attr name="position" intvalue="100"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-PropertiesAction.instance"> |
|
||||||
<attr name="position" intvalue="1300"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-RenameAction.instance"> |
|
||||||
<attr name="position" intvalue="800"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-SaveAsTemplateAction.instance"> |
|
||||||
<attr name="position" intvalue="1000"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-ToolsAction.instance"> |
|
||||||
<attr name="position" intvalue="1200"/> |
|
||||||
</file> |
|
||||||
<file name="sep-1.instance"> |
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/> |
|
||||||
<attr name="position" intvalue="300"/> |
|
||||||
</file> |
|
||||||
<file name="sep-2.instance"> |
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/> |
|
||||||
<attr name="position" intvalue="600"/> |
|
||||||
</file> |
|
||||||
<file name="sep-3.instance"> |
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/> |
|
||||||
<attr name="position" intvalue="900"/> |
|
||||||
</file> |
|
||||||
<file name="sep-4.instance"> |
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/> |
|
||||||
<attr name="position" intvalue="1100"/> |
|
||||||
</file> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
<folder name="x-glsl-vertex-shader"> |
|
||||||
<folder name="Actions"> |
|
||||||
<file name="org-openide-actions-CopyAction.instance"> |
|
||||||
<attr name="position" intvalue="500"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-CutAction.instance"> |
|
||||||
<attr name="position" intvalue="400"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-DeleteAction.instance"> |
|
||||||
<attr name="position" intvalue="700"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-FileSystemAction.instance"> |
|
||||||
<attr name="position" intvalue="200"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-OpenAction.instance"> |
|
||||||
<attr name="position" intvalue="100"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-PropertiesAction.instance"> |
|
||||||
<attr name="position" intvalue="1300"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-RenameAction.instance"> |
|
||||||
<attr name="position" intvalue="800"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-SaveAsTemplateAction.instance"> |
|
||||||
<attr name="position" intvalue="1000"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-ToolsAction.instance"> |
|
||||||
<attr name="position" intvalue="1200"/> |
|
||||||
</file> |
|
||||||
<file name="sep-1.instance"> |
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/> |
|
||||||
<attr name="position" intvalue="300"/> |
|
||||||
</file> |
|
||||||
<file name="sep-2.instance"> |
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/> |
|
||||||
<attr name="position" intvalue="600"/> |
|
||||||
</file> |
|
||||||
<file name="sep-3.instance"> |
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/> |
|
||||||
<attr name="position" intvalue="900"/> |
|
||||||
</file> |
|
||||||
<file name="sep-4.instance"> |
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/> |
|
||||||
<attr name="position" intvalue="1100"/> |
|
||||||
</file> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
<folder name="x-glsl-fragment-shader"> |
|
||||||
<folder name="Actions"> |
|
||||||
<file name="org-openide-actions-CopyAction.instance"> |
|
||||||
<attr name="position" intvalue="500"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-CutAction.instance"> |
|
||||||
<attr name="position" intvalue="400"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-DeleteAction.instance"> |
|
||||||
<attr name="position" intvalue="700"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-FileSystemAction.instance"> |
|
||||||
<attr name="position" intvalue="200"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-OpenAction.instance"> |
|
||||||
<attr name="position" intvalue="100"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-PropertiesAction.instance"> |
|
||||||
<attr name="position" intvalue="1300"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-RenameAction.instance"> |
|
||||||
<attr name="position" intvalue="800"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-SaveAsTemplateAction.instance"> |
|
||||||
<attr name="position" intvalue="1000"/> |
|
||||||
</file> |
|
||||||
<file name="org-openide-actions-ToolsAction.instance"> |
|
||||||
<attr name="position" intvalue="1200"/> |
|
||||||
</file> |
|
||||||
<file name="sep-1.instance"> |
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/> |
|
||||||
<attr name="position" intvalue="300"/> |
|
||||||
</file> |
|
||||||
<file name="sep-2.instance"> |
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/> |
|
||||||
<attr name="position" intvalue="600"/> |
|
||||||
</file> |
|
||||||
<file name="sep-3.instance"> |
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/> |
|
||||||
<attr name="position" intvalue="900"/> |
|
||||||
</file> |
|
||||||
<file name="sep-4.instance"> |
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/> |
|
||||||
<attr name="position" intvalue="1100"/> |
|
||||||
</file> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
|
|
||||||
<folder name="Services"> |
|
||||||
<folder name="MIMEResolver"> |
|
||||||
<file name="GlslFragmentShaderResolver.xml" url="resources/GlslFragmentShaderResolver.xml"> |
|
||||||
<attr name="SystemFileSystem.icon" urlvalue="nbresloc:/net/java/nboglpack/glsleditor/resources/FragmentShaderIcon.gif"/> |
|
||||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="net.java.nboglpack.glsleditor.dataobject.Bundle"/> |
|
||||||
</file> |
|
||||||
<file name="GlslGeometryShaderResolver.xml" url="resources/GlslGeometryShaderResolver.xml"> |
|
||||||
<attr name="SystemFileSystem.icon" urlvalue="nbresloc:/net/java/nboglpack/glsleditor/resources/GeometryShaderIcon.gif"/> |
|
||||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="net.java.nboglpack.glsleditor.dataobject.Bundle"/> |
|
||||||
</file> |
|
||||||
<file name="GlslVertexShaderResolver.xml" url="resources/GlslVertexShaderResolver.xml"> |
|
||||||
<attr name="SystemFileSystem.icon" urlvalue="nbresloc:/net/java/nboglpack/glsleditor/resources/VertexShaderIcon.gif"/> |
|
||||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="net.java.nboglpack.glsleditor.dataobject.Bundle"/> |
|
||||||
</file> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
|
|
||||||
<folder name="Templates"> |
|
||||||
<folder name="OpenGL"> |
|
||||||
<file name="FragmentShader.frag" url="resources/FragmentShaderTemplate.frag"> |
|
||||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="net.java.nboglpack.glsleditor.dataobject.Bundle"/> |
|
||||||
<attr name="template" boolvalue="true"/> |
|
||||||
</file> |
|
||||||
<file name="GeometryShader.geom" url="resources/GeometryShaderTemplate.geom"> |
|
||||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="net.java.nboglpack.glsleditor.dataobject.Bundle"/> |
|
||||||
<attr name="template" boolvalue="true"/> |
|
||||||
</file> |
|
||||||
<file name="VertexShader.vert" url="resources/VertexShaderTemplate.vert"> |
|
||||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="net.java.nboglpack.glsleditor.dataobject.Bundle"/> |
|
||||||
<attr name="template" boolvalue="true"/> |
|
||||||
</file> |
|
||||||
<attr name="position" intvalue="2000"/> |
|
||||||
</folder> |
|
||||||
</folder> |
|
||||||
</filesystem> |
|
@ -1,61 +0,0 @@ |
|||||||
/* |
|
||||||
* 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<GlslTokenId> { |
|
||||||
|
|
||||||
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<GlslTokenId> createTokenIds() { |
|
||||||
return EnumSet.allOf(GlslTokenId.class); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected Lexer<GlslTokenId> createLexer(LexerRestartInfo<GlslTokenId> info) { |
|
||||||
return new GlslLexer(info, GlslVocabularyManager.getInstance(mimeType())); |
|
||||||
} |
|
||||||
|
|
||||||
public static Language<GlslTokenId> vertexLanguage() { |
|
||||||
return VERTEX_LANGUAGE.language(); |
|
||||||
} |
|
||||||
|
|
||||||
public static Language<GlslTokenId> fragmentLanguage() { |
|
||||||
return FRAGMENT_LANGUAGE.language(); |
|
||||||
} |
|
||||||
|
|
||||||
public static Language<GlslTokenId> geometryLanguage() { |
|
||||||
return GEOMETRY_LANGUAGE.language(); |
|
||||||
} |
|
||||||
} |
|
@ -1,339 +0,0 @@ |
|||||||
/* |
|
||||||
* 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<GlslTokenId> { |
|
||||||
|
|
||||||
private final LexerInput input; |
|
||||||
private final TokenFactory<GlslTokenId> factory; |
|
||||||
private final GlslVocabularyManager manager; |
|
||||||
private final StringBuilder stringBuilder; |
|
||||||
|
|
||||||
public GlslLexer(LexerRestartInfo<GlslTokenId> info, GlslVocabularyManager manager) { |
|
||||||
this.input = info.input(); |
|
||||||
this.factory = info.tokenFactory(); |
|
||||||
this.manager = manager; |
|
||||||
this.stringBuilder = new StringBuilder(); |
|
||||||
} |
|
||||||
|
|
||||||
@SuppressWarnings("fallthrough") |
|
||||||
public Token<GlslTokenId> 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 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 Token<GlslTokenId> 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 Token<GlslTokenId> 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); |
|
||||||
} |
|
||||||
|
|
||||||
return factory.createToken(GlslTokenId.INTEGER_LITERAL); |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private Token<GlslTokenId> 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() { |
|
||||||
} |
|
||||||
} |
|
@ -1,89 +0,0 @@ |
|||||||
/* |
|
||||||
* 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; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 607 B |
@ -1,8 +0,0 @@ |
|||||||
/* |
|
||||||
* 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); |
|
||||||
} |
|
||||||
|
|
Before Width: | Height: | Size: 614 B |
@ -1,26 +0,0 @@ |
|||||||
/* |
|
||||||
* geometry shader template |
|
||||||
*/ |
|
||||||
|
|
||||||
#version 120 |
|
||||||
#extension GL_EXT_geometry_shader4 : enable |
|
||||||
|
|
||||||
// a passthrough geometry shader for color and position |
|
||||||
void main(void) { |
|
||||||
|
|
||||||
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(); |
|
||||||
|
|
||||||
} |
|
@ -1,28 +0,0 @@ |
|||||||
// ------ Fragment shader ------ // |
|
||||||
|
|
||||||
#pragma debug(on) |
|
||||||
|
|
||||||
varying vec3 normal; |
|
||||||
|
|
||||||
/* |
|
||||||
* Toon shader |
|
||||||
*/ |
|
||||||
void main() { |
|
||||||
|
|
||||||
float intensity; |
|
||||||
vec4 color; |
|
||||||
vec3 n = normalize(normal); |
|
||||||
|
|
||||||
intensity = dot(vec3(gl_LightSource[0].position),n); |
|
||||||
|
|
||||||
if (intensity > 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; |
|
||||||
} |
|
@ -1,18 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN" "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd"> |
|
||||||
<MIME-resolver> |
|
||||||
<file> |
|
||||||
<ext name="frag"/> |
|
||||||
<ext name="fragment"/> |
|
||||||
<ext name="glfrag"/> |
|
||||||
<ext name="glslfrag"/> |
|
||||||
<ext name="glslfragment"/> |
|
||||||
<ext name="glfragmentshader"/> |
|
||||||
<ext name="glslfragmentshader"/> |
|
||||||
<ext name="glsl-frag"/> |
|
||||||
<ext name="glsl-fragment"/> |
|
||||||
<ext name="gl-fragment-shader"/> |
|
||||||
<ext name="glsl-fragment-shader"/> |
|
||||||
<resolver mime="text/x-glsl-fragment-shader"/> |
|
||||||
</file> |
|
||||||
</MIME-resolver> |
|
@ -1,26 +0,0 @@ |
|||||||
// ------ 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(); |
|
||||||
|
|
||||||
} |
|
@ -1,18 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN" "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd"> |
|
||||||
<MIME-resolver> |
|
||||||
<file> |
|
||||||
<ext name="geom"/> |
|
||||||
<ext name="geometry"/> |
|
||||||
<ext name="glgeom"/> |
|
||||||
<ext name="glslgeom"/> |
|
||||||
<ext name="glslgeometry"/> |
|
||||||
<ext name="glgeometryshader"/> |
|
||||||
<ext name="glslgeometryshader"/> |
|
||||||
<ext name="glsl-geom"/> |
|
||||||
<ext name="glsl-geometry"/> |
|
||||||
<ext name="gl-geometry-shader"/> |
|
||||||
<ext name="glsl-geometry-shader"/> |
|
||||||
<resolver mime="text/x-glsl-geometry-shader"/> |
|
||||||
</file> |
|
||||||
</MIME-resolver> |
|
@ -1,29 +0,0 @@ |
|||||||
// ------ 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(); |
|
||||||
} |
|
@ -1,18 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN" "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd"> |
|
||||||
<MIME-resolver> |
|
||||||
<file> |
|
||||||
<ext name="vert"/> |
|
||||||
<ext name="vertex"/> |
|
||||||
<ext name="glvert"/> |
|
||||||
<ext name="glslvert"/> |
|
||||||
<ext name="glslvertex"/> |
|
||||||
<ext name="glvertexshader"/> |
|
||||||
<ext name="glslvertexshader"/> |
|
||||||
<ext name="glsl-vert"/> |
|
||||||
<ext name="glsl-vertex"/> |
|
||||||
<ext name="gl-vertex-shader"/> |
|
||||||
<ext name="glsl-vertex-shader"/> |
|
||||||
<resolver mime="text/x-glsl-vertex-shader"/> |
|
||||||
</file> |
|
||||||
</MIME-resolver> |
|
@ -1,26 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<!DOCTYPE fontscolors PUBLIC "-//NetBeans//DTD Editor Fonts and Colors settings 1.1//EN" "http://www.netbeans.org/dtds/EditorFontsColors-1_1.dtd"> |
|
||||||
<fontscolors> |
|
||||||
<fontcolor name="glsl-keyword" default="keyword"/> |
|
||||||
<fontcolor name="glsl-name" default="identifier"/> |
|
||||||
<fontcolor name="glsl-function" default="identifier"> |
|
||||||
<font style="bold"/> |
|
||||||
</fontcolor> |
|
||||||
<fontcolor name="glsl-brace" default="operator"/> |
|
||||||
<fontcolor name="glsl-value" default="number"/> |
|
||||||
<fontcolor name="glsl-curly-brace" default="operator"/> |
|
||||||
<fontcolor name="glsl-string-value" default="default"/> |
|
||||||
<fontcolor name="glsl-comment" default="comment"/> |
|
||||||
<fontcolor name="glsl-separator" default="operator"/> |
|
||||||
<fontcolor name="glsl-whitespace" default="whitespace"/> |
|
||||||
<fontcolor name="glsl-end-of-line" default="whitespace"/> |
|
||||||
<fontcolor name="glsl-build-in-var" default="string"> |
|
||||||
<font style="bold"/> |
|
||||||
</fontcolor> |
|
||||||
<fontcolor name="glsl-build-in-func" default="identifier"> |
|
||||||
<font style="bold,italic"/> |
|
||||||
</fontcolor> |
|
||||||
<fontcolor name="glsl-preprocessor" foreColor="ff6060D0"> |
|
||||||
<font style="bold,italic" /> |
|
||||||
</fontcolor> |
|
||||||
</fontscolors> |
|
Before Width: | Height: | Size: 163 B |
Before Width: | Height: | Size: 613 B |
@ -1,7 +0,0 @@ |
|||||||
/* |
|
||||||
* vertex shader template |
|
||||||
*/ |
|
||||||
void main() { |
|
||||||
// Vertex transformation |
|
||||||
gl_Position = ftransform(); |
|
||||||
} |
|
Before Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 346 B |
Before Width: | Height: | Size: 432 B |
@ -1,58 +0,0 @@ |
|||||||
/* |
|
||||||
* GLSLElementDescriptor.java |
|
||||||
* |
|
||||||
* Created on 03.06.2007, 23:03:57 |
|
||||||
* |
|
||||||
*/ |
|
||||||
package net.java.nboglpack.glsleditor.vocabulary; |
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement; |
|
||||||
import javax.xml.bind.annotation.XmlEnum; |
|
||||||
import javax.xml.bind.annotation.XmlType; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author Michael Bien |
|
||||||
*/ |
|
||||||
public class GLSLElementDescriptor { |
|
||||||
|
|
||||||
@XmlType |
|
||||||
@XmlEnum(String.class) |
|
||||||
public enum Category { |
|
||||||
BUILD_IN_FUNC, BUILD_IN_VAR, USER_FUNC, JUMP, ITERATION, SELECTION, QUALIFIER, TYPE, KEYWORD |
|
||||||
} |
|
||||||
|
|
||||||
@XmlElement |
|
||||||
public final Category category; |
|
||||||
|
|
||||||
@XmlElement(required = true) |
|
||||||
public final String tooltip; |
|
||||||
|
|
||||||
@XmlElement(required = true) |
|
||||||
public final String doc; |
|
||||||
|
|
||||||
@XmlElement(required = true) |
|
||||||
public final String arguments; |
|
||||||
|
|
||||||
@XmlElement(required = true) |
|
||||||
public final String type; |
|
||||||
|
|
||||||
/** |
|
||||||
* Bean constructor, fields are directly injected. |
|
||||||
*/ |
|
||||||
public GLSLElementDescriptor() { |
|
||||||
category = Category.KEYWORD; |
|
||||||
tooltip = null; |
|
||||||
doc = null; |
|
||||||
arguments = null; |
|
||||||
type = null; |
|
||||||
} |
|
||||||
|
|
||||||
public GLSLElementDescriptor(Category category, String tooltip, String doc, String arguments, String type) { |
|
||||||
this.category = category; |
|
||||||
this.tooltip = tooltip; |
|
||||||
this.doc = doc; |
|
||||||
this.arguments = arguments; |
|
||||||
this.type = type; |
|
||||||
} |
|
||||||
} |
|
@ -1,30 +0,0 @@ |
|||||||
/* |
|
||||||
* GLSLVocabulary.java |
|
||||||
* |
|
||||||
* Created on 03.06.2007, 23:03:57 |
|
||||||
* |
|
||||||
*/ |
|
||||||
package net.java.nboglpack.glsleditor.vocabulary; |
|
||||||
|
|
||||||
import java.util.HashMap; |
|
||||||
import javax.xml.bind.annotation.XmlRootElement; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author Michael Bien |
|
||||||
*/ |
|
||||||
@XmlRootElement |
|
||||||
public class GLSLVocabulary { |
|
||||||
|
|
||||||
public final HashMap<String, GLSLElementDescriptor[]> mainVocabulary; |
|
||||||
public final HashMap<String, GLSLElementDescriptor[]> fragmentShaderVocabulary; |
|
||||||
public final HashMap<String, GLSLElementDescriptor[]> vertexShaderVocabulary; |
|
||||||
public final HashMap<String, GLSLElementDescriptor[]> geometryShaderVocabulary; |
|
||||||
|
|
||||||
public GLSLVocabulary() { |
|
||||||
mainVocabulary = new HashMap<String, GLSLElementDescriptor[]>(); |
|
||||||
vertexShaderVocabulary = new HashMap<String, GLSLElementDescriptor[]>(); |
|
||||||
fragmentShaderVocabulary = new HashMap<String, GLSLElementDescriptor[]>(); |
|
||||||
geometryShaderVocabulary = new HashMap<String, GLSLElementDescriptor[]>(); |
|
||||||
} |
|
||||||
} |
|
@ -1,2 +0,0 @@ |
|||||||
GLSLElementDescriptor |
|
||||||
GLSLVocabulary |
|
@ -1 +0,0 @@ |
|||||||
net.java.nboglpack.glsleditor.GlslGeometryShaderDataLoader |
|