SDK: fix build error
This commit is contained in:
parent
15465a020f
commit
85feb305ef
@ -59,7 +59,7 @@ public abstract class ShaderGenerator {
|
||||
/**
|
||||
* the technique def to use for the shader generation
|
||||
*/
|
||||
protected TechniqueDef techniqueDef = null;
|
||||
protected TechniqueDef techniqueDef = null;
|
||||
|
||||
/**
|
||||
* Build a shaderGenerator
|
||||
@ -67,16 +67,18 @@ public abstract class ShaderGenerator {
|
||||
* @param assetManager
|
||||
*/
|
||||
protected ShaderGenerator(AssetManager assetManager) {
|
||||
this.assetManager = assetManager;
|
||||
this.assetManager = assetManager;
|
||||
}
|
||||
|
||||
public void initialize(TechniqueDef techniqueDef){
|
||||
|
||||
public void initialize(TechniqueDef techniqueDef) {
|
||||
this.techniqueDef = techniqueDef;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate vertex and fragment shaders for the given technique
|
||||
*
|
||||
* @param definesSourceCode Defines to include alongside the shader. May be
|
||||
* null.
|
||||
* @return a Shader program
|
||||
*/
|
||||
public Shader generateShader(String definesSourceCode) {
|
||||
@ -94,13 +96,13 @@ public abstract class ShaderGenerator {
|
||||
String extension = type.getExtension();
|
||||
String language = getLanguageAndVersion(type);
|
||||
String shaderSourceCode = buildShader(techniqueDef.getShaderNodes(), info, type);
|
||||
|
||||
|
||||
if (shaderSourceCode != null) {
|
||||
String shaderSourceAssetName = techniqueName + "." + extension;
|
||||
shader.addSource(type, shaderSourceAssetName, shaderSourceCode, definesSourceCode, language);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
techniqueDef = null;
|
||||
return shader;
|
||||
}
|
||||
@ -114,14 +116,14 @@ public abstract class ShaderGenerator {
|
||||
* @return the code of the generated vertex shader
|
||||
*/
|
||||
protected String buildShader(List<ShaderNode> shaderNodes, ShaderGenerationInfo info, ShaderType type) {
|
||||
if (type == ShaderType.TessellationControl ||
|
||||
type == ShaderType.TessellationEvaluation ||
|
||||
type == ShaderType.Geometry) {
|
||||
if (type == ShaderType.TessellationControl
|
||||
|| type == ShaderType.TessellationEvaluation
|
||||
|| type == ShaderType.Geometry) {
|
||||
// TODO: Those are not supported.
|
||||
// Too much code assumes that type is either Vertex or Fragment
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
indent = 0;
|
||||
|
||||
StringBuilder sourceDeclaration = new StringBuilder();
|
||||
@ -192,8 +194,8 @@ public abstract class ShaderGenerator {
|
||||
if (loadedSource.length() > 1) {
|
||||
loadedSource = loadedSource.substring(0, loadedSource.lastIndexOf("}"));
|
||||
String[] sourceParts = loadedSource.split("\\s*void\\s*main\\s*\\(\\s*\\)\\s*\\{");
|
||||
if(sourceParts.length<2){
|
||||
throw new IllegalArgumentException("Syntax error in "+ shaderPath +". Cannot find 'void main(){' in \n"+ loadedSource);
|
||||
if (sourceParts.length < 2) {
|
||||
throw new IllegalArgumentException("Syntax error in " + shaderPath + ". Cannot find 'void main(){' in \n" + loadedSource);
|
||||
}
|
||||
generateDeclarativeSection(sourceDeclaration, shaderNode, sourceParts[0], info);
|
||||
generateNodeMainSection(source, shaderNode, sourceParts[1], info);
|
||||
@ -250,7 +252,7 @@ public abstract class ShaderGenerator {
|
||||
*
|
||||
* @see ShaderNode#getDefinition()
|
||||
* @see ShaderNodeDefinition#getType()
|
||||
*
|
||||
*
|
||||
* @param nodeDecalarationSource the declaration part of the node
|
||||
* @param source the StringBuilder to append generated code.
|
||||
* @param shaderNode the shaderNode.
|
||||
@ -319,5 +321,5 @@ public abstract class ShaderGenerator {
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,8 +62,8 @@ public class EditableMatDefFile {
|
||||
private MaterialDef materialDef;
|
||||
private ProjectAssetManager assetManager;
|
||||
private ShaderGenerator glsl100;
|
||||
private ShaderGenerator glsl150;
|
||||
private final static String GLSL100 = "GLSL100";
|
||||
private ShaderGenerator glsl150;
|
||||
private final static String GLSL100 = "GLSL100";
|
||||
private Lookup lookup;
|
||||
private boolean loaded = false;
|
||||
private boolean dirty = false;
|
||||
@ -97,7 +97,7 @@ public class EditableMatDefFile {
|
||||
}
|
||||
FileLock lock = null;
|
||||
InputStream in = null;
|
||||
boolean matParseError = false;
|
||||
boolean matParseError = false;
|
||||
try {
|
||||
lock = matDefFile.lock();
|
||||
in = obj.getPrimaryFile().getInputStream();
|
||||
@ -134,7 +134,7 @@ public class EditableMatDefFile {
|
||||
}
|
||||
}
|
||||
if (materialDef != null && !matParseError) {
|
||||
if(currentTechnique == null){
|
||||
if (currentTechnique == null) {
|
||||
currentTechnique = matDefStructure.getTechniques().get(0);
|
||||
}
|
||||
registerListener(matDefStructure);
|
||||
@ -172,11 +172,11 @@ public class EditableMatDefFile {
|
||||
material.selectTechnique(currentTechnique.getName(), SceneApplication.getApplication().getRenderManager());
|
||||
Shader s;
|
||||
if (version.equals(GLSL100)) {
|
||||
glsl100.initialize(material.getActiveTechnique());
|
||||
s = glsl100.generateShader();
|
||||
glsl100.initialize(material.getActiveTechnique().getDef());
|
||||
s = glsl100.generateShader(null);
|
||||
} else {
|
||||
glsl150.initialize(material.getActiveTechnique());
|
||||
s = glsl150.generateShader();
|
||||
glsl150.initialize(material.getActiveTechnique().getDef());
|
||||
s = glsl150.generateShader(null);
|
||||
}
|
||||
for (Shader.ShaderSource source : s.getSources()) {
|
||||
if (source.getType() == type) {
|
||||
@ -193,8 +193,8 @@ public class EditableMatDefFile {
|
||||
public TechniqueBlock getCurrentTechnique() {
|
||||
return currentTechnique;
|
||||
}
|
||||
|
||||
public void setCurrentTechnique(TechniqueBlock tech){
|
||||
|
||||
public void setCurrentTechnique(TechniqueBlock tech) {
|
||||
this.currentTechnique = tech;
|
||||
}
|
||||
|
||||
@ -318,10 +318,10 @@ public class EditableMatDefFile {
|
||||
NbDocument.runAtomicAsUser(ec.getDocument(), new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
doc.remove(0, doc.getLength());
|
||||
doc.insertString(doc.getLength(),
|
||||
matDefStructure.toString(),
|
||||
SimpleAttributeSet.EMPTY);
|
||||
doc.remove(0, doc.getLength());
|
||||
doc.insertString(doc.getLength(),
|
||||
matDefStructure.toString(),
|
||||
SimpleAttributeSet.EMPTY);
|
||||
} catch (BadLocationException e) {
|
||||
exc[0] = e;
|
||||
}
|
||||
@ -343,8 +343,8 @@ public class EditableMatDefFile {
|
||||
}
|
||||
updateLookupWithMaterialData(obj);
|
||||
}
|
||||
|
||||
public void cleanup(){
|
||||
|
||||
public void cleanup() {
|
||||
if (matDefStructure != null) {
|
||||
obj.getLookupContents().remove(matDefStructure);
|
||||
matDefStructure = null;
|
||||
@ -358,7 +358,7 @@ public class EditableMatDefFile {
|
||||
matToRemove = material;
|
||||
material = null;
|
||||
}
|
||||
|
||||
|
||||
setCurrentTechnique(null);
|
||||
setLoaded(false);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user