Add GLSL syntax highlighting

This commit is contained in:
baldurk
2015-02-09 18:14:20 +00:00
parent 8ccf071865
commit 72cfee5c0f
10 changed files with 223 additions and 109 deletions
@@ -1152,7 +1152,7 @@
this.vsShaderEdit.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.vsShaderEdit.TabIndex = 26;
this.vsShaderEdit.TabStop = false;
this.toolTip.SetToolTip(this.vsShaderEdit, "HLSL edit and replace this shader");
this.toolTip.SetToolTip(this.vsShaderEdit, "GLSL edit and replace this shader");
this.vsShaderEdit.Click += new System.EventHandler(this.shaderedit_Click);
//
// groupBox7
@@ -1521,7 +1521,7 @@
this.tcsShaderEdit.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.tcsShaderEdit.TabIndex = 28;
this.tcsShaderEdit.TabStop = false;
this.toolTip.SetToolTip(this.tcsShaderEdit, "HLSL edit and replace this shader");
this.toolTip.SetToolTip(this.tcsShaderEdit, "GLSL edit and replace this shader");
this.tcsShaderEdit.Click += new System.EventHandler(this.shaderedit_Click);
//
// tcsTexturesGroup
@@ -1847,7 +1847,7 @@
this.tesShaderEdit.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.tesShaderEdit.TabIndex = 27;
this.tesShaderEdit.TabStop = false;
this.toolTip.SetToolTip(this.tesShaderEdit, "HLSL edit and replace this shader");
this.toolTip.SetToolTip(this.tesShaderEdit, "GLSL edit and replace this shader");
this.tesShaderEdit.Click += new System.EventHandler(this.shaderedit_Click);
//
// tesTexturesGroup
@@ -2265,7 +2265,7 @@
this.gsShaderEdit.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.gsShaderEdit.TabIndex = 28;
this.gsShaderEdit.TabStop = false;
this.toolTip.SetToolTip(this.gsShaderEdit, "HLSL edit and replace this shader");
this.toolTip.SetToolTip(this.gsShaderEdit, "GLSL edit and replace this shader");
this.gsShaderEdit.Click += new System.EventHandler(this.shaderedit_Click);
//
// groupBox24
@@ -3443,7 +3443,7 @@
this.psShaderEdit.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.psShaderEdit.TabIndex = 29;
this.psShaderEdit.TabStop = false;
this.toolTip.SetToolTip(this.psShaderEdit, "HLSL edit and replace this shader");
this.toolTip.SetToolTip(this.psShaderEdit, "GLSL edit and replace this shader");
this.psShaderEdit.Click += new System.EventHandler(this.shaderedit_Click);
//
// groupBox28
@@ -4291,7 +4291,7 @@
this.csShaderEdit.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.csShaderEdit.TabIndex = 36;
this.csShaderEdit.TabStop = false;
this.toolTip.SetToolTip(this.csShaderEdit, "HLSL edit and replace this shader");
this.toolTip.SetToolTip(this.csShaderEdit, "GLSL edit and replace this shader");
this.csShaderEdit.Click += new System.EventHandler(this.shaderedit_Click);
//
// computeDebugControls
@@ -1713,7 +1713,7 @@ namespace renderdocui.Windows.PipelineState
s.Show(m_DockContent.DockPanel);
}
private void MakeShaderVariablesHLSL(bool cbufferContents, ShaderConstant[] vars, ref string struct_contents, ref string struct_defs)
private void MakeShaderVariablesGLSL(bool cbufferContents, ShaderConstant[] vars, ref string struct_contents, ref string struct_defs)
{
var nl = Environment.NewLine;
var nl2 = Environment.NewLine + Environment.NewLine;
@@ -1727,7 +1727,7 @@ namespace renderdocui.Windows.PipelineState
if(!struct_defs.Contains(def))
{
string contents = "";
MakeShaderVariablesHLSL(false, v.type.members, ref contents, ref struct_defs);
MakeShaderVariablesGLSL(false, v.type.members, ref contents, ref struct_defs);
struct_defs += def + contents + "};" + nl2;
}
+10 -9
View File
@@ -517,7 +517,7 @@ namespace renderdocui.Windows
this.ResumeLayout(false);
}
private ScintillaNET.Scintilla MakeEditor(string name, string text, bool hlsl)
private ScintillaNET.Scintilla MakeEditor(string name, string text, bool src)
{
ScintillaNET.Scintilla scintilla1 = new ScintillaNET.Scintilla();
((System.ComponentModel.ISupportInitialize)(scintilla1)).BeginInit();
@@ -547,25 +547,26 @@ namespace renderdocui.Windows
((System.ComponentModel.ISupportInitialize)(scintilla1)).EndInit();
var hlslpath = Path.Combine(Core.ConfigDirectory, "hlsl.xml");
string syntaxtype = m_Core.APIProps.ShaderExtension.Substring(1);
var syntaxpath = Path.Combine(Core.ConfigDirectory, syntaxtype + ".xml");
if (!File.Exists(hlslpath) ||
File.GetLastWriteTimeUtc(hlslpath).CompareTo(File.GetLastWriteTimeUtc(Assembly.GetExecutingAssembly().Location)) < 0)
if (!File.Exists(syntaxpath) ||
File.GetLastWriteTimeUtc(syntaxpath).CompareTo(File.GetLastWriteTimeUtc(Assembly.GetExecutingAssembly().Location)) < 0)
{
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("renderdocui.Resources.hlsl.xml"))
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("renderdocui.Resources." + syntaxtype + ".xml"))
{
using (StreamReader reader = new StreamReader(stream))
{
File.WriteAllText(hlslpath, reader.ReadToEnd());
File.WriteAllText(syntaxpath, reader.ReadToEnd());
}
}
}
if (hlsl)
if (src)
{
scintilla1.Lexing.LexerLanguageMap["hlsl"] = "cpp";
scintilla1.Lexing.LexerLanguageMap[syntaxtype] = "cpp";
scintilla1.ConfigurationManager.CustomLocation = Core.ConfigDirectory;
scintilla1.ConfigurationManager.Language = "hlsl";
scintilla1.ConfigurationManager.Language = syntaxtype;
scintilla1.Lexing.SetProperty("lexer.cpp.track.preprocessor", "0");
}
else
+6 -6
View File
@@ -546,7 +546,7 @@ namespace renderdocui.Windows
}
}
foreach (var f in Directory.EnumerateFiles(Core.ConfigDirectory, "*.hlsl"))
foreach (var f in Directory.EnumerateFiles(Core.ConfigDirectory, "*" + m_Core.APIProps.ShaderExtension))
{
var fn = Path.GetFileNameWithoutExtension(f);
var key = fn.ToUpperInvariant();
@@ -601,7 +601,7 @@ namespace renderdocui.Windows
return;
}
var path = Path.Combine(Core.ConfigDirectory, customShader.Text + ".hlsl");
var path = Path.Combine(Core.ConfigDirectory, customShader.Text + m_Core.APIProps.ShaderExtension);
File.WriteAllText(path, "float4 main(float4 pos : SV_Position, float4 uv : TEXCOORD0) : SV_Target0\n{\n\treturn float4(0,0,0,1);\n}\n");
// auto-open edit window
@@ -613,7 +613,7 @@ namespace renderdocui.Windows
var filename = customShader.Text;
var files = new Dictionary<string, string>();
files.Add(filename, File.ReadAllText(Path.Combine(Core.ConfigDirectory, filename + ".hlsl")));
files.Add(filename, File.ReadAllText(Path.Combine(Core.ConfigDirectory, filename + m_Core.APIProps.ShaderExtension)));
ShaderViewer s = new ShaderViewer(m_Core, true, "Custom Shader", files,
// Save Callback
@@ -621,7 +621,7 @@ namespace renderdocui.Windows
{
foreach (var f in updatedfiles)
{
var path = Path.Combine(Core.ConfigDirectory, f.Key + ".hlsl");
var path = Path.Combine(Core.ConfigDirectory, f.Key + m_Core.APIProps.ShaderExtension);
File.WriteAllText(path, f.Value);
}
},
@@ -655,7 +655,7 @@ namespace renderdocui.Windows
if (res == DialogResult.Yes)
{
var path = Path.Combine(Core.ConfigDirectory, customShader.Text + ".hlsl");
var path = Path.Combine(Core.ConfigDirectory, customShader.Text + m_Core.APIProps.ShaderExtension);
if(!File.Exists(path))
{
MessageBox.Show(String.Format("Shader file {0} can't be found.\nSelect a custom shader from the drop-down", customShader.Text),
@@ -703,7 +703,7 @@ namespace renderdocui.Windows
this.BeginInvoke(new Action(UI_CreateThumbnails));
});
m_FSWatcher = new FileSystemWatcher(Core.ConfigDirectory, "*.hlsl");
m_FSWatcher = new FileSystemWatcher(Core.ConfigDirectory, "*" + m_Core.APIProps.ShaderExtension);
m_FSWatcher.EnableRaisingEvents = true;
m_FSWatcher.Changed += new FileSystemEventHandler(CustomShaderModified);
m_FSWatcher.Renamed += new RenamedEventHandler(CustomShaderModified);