예제 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            int includeCounter = includeBuffers.Count - 1;

            if (richTextBox2.Text != "")
            {
                //send request to recreate
                if (outputWindow.IsDisposed)
                {
                    parentForm.createOutputWindow();
                }

                outputWindow.Location = new Point(this.Location.X + 620, this.Location.Y);
                outputWindow.Show();

                richTextBox2.Text.Replace("\r", "");

                if (bTranslateAll)
                {
                    translatedHLSL = PARSER(fileName, entryName, shader, "-hlsl").Replace("\n", "\r\n");
                    outputWindow.richTextBoxOutput.Text = richTextBox1.Text + "\r\n" + translatedHLSL;

                    if (outputWindow.richTextBoxOutput.Text == null)
                    {
                        outputWindow.richTextBoxOutput.Text = "Failed to translate";
                    }

                    translatedGLSL = PARSER(fileName, entryName, shader, "-glsl").Replace("\n", "\r\n");

                    if (shader == "-hs")
                    {
                        // TODO:????
                        //need secondaryfile
                        OpenFileDialog ofd = new OpenFileDialog();
                        ofd.Title = "Select a Vertex shader needed to generate a Hull shader for Metal";
                        if (ofd.ShowDialog() == DialogResult.OK)
                        {
                            StreamReader sr = new StreamReader(ofd.FileName);
                            string       vertexShaderData = sr.ReadToEnd();
                            string       compositeData    = vertexShaderData + richTextBox2.Text;

                            translatedMSL = PARSER(fileName, entryName, shader, "-msl").Replace("\n", "\r\n");
                        }
                        else
                        {
                            outputWindow.richTextBoxOutput.Text = "Failed to load vertex shader for Metal's hull shader";
                            return;
                        }
                    }
                    else
                    {
                        translatedMSL = PARSER(fileName, entryName, shader, "-msl").Replace("\n", "\r\n");
                    }

                    outputWindow.buttonShowGLSL.PerformClick();
                }
                else if (languageString == "HLSL")
                {
                    translatedHLSL = PARSER(fileName, entryName, shader, "-hlsl").Replace("\n", "\r\n");
                    outputWindow.richTextBoxOutput.Text = richTextBox1.Text + "\r\n" + translatedHLSL;

                    if (outputWindow.richTextBoxOutput.Text == null)
                    {
                        outputWindow.richTextBoxOutput.Text = "Failed to translate";
                    }

                    //outputWindow.Update();
                    outputWindow.buttonShowHLSL.PerformClick();
                }
                else if (languageString == "GLSL")
                {
                    translatedGLSL = PARSER(fileName, entryName, shader, "-glsl").Replace("\n", "\r\n");
                    outputWindow.richTextBoxOutput.Text = richTextBox1.Text + "\r\n" + translatedGLSL;

                    if (outputWindow.richTextBoxOutput.Text == null)
                    {
                        outputWindow.richTextBoxOutput.Text = "Failed to translate";
                    }

                    //outputWindow.Update();
                    outputWindow.buttonShowGLSL.PerformClick();
                }
                else if (languageString == "MSL")
                {
                    if (shader == "-hs")
                    {
                        //need secondaryfile
                        OpenFileDialog ofd = new OpenFileDialog();
                        ofd.Title = "Select a Vertex shader needed to generate a Hull shader for Metal";
                        if (ofd.ShowDialog() == DialogResult.OK)
                        {
                            StreamReader sr = new StreamReader(ofd.FileName);
                            string       vertexShaderData = sr.ReadToEnd();
                            string       compositeData    = vertexShaderData + richTextBox2.Text;

                            translatedMSL = PARSER(fileName, entryName, shader, "-msl").Replace("\n", "\r\n");
                        }
                        else
                        {
                            outputWindow.richTextBoxOutput.Text = "Failed to load vertex shader for Metal's hull shader";
                            return;
                        }
                    }
                    else
                    {
                        translatedMSL = PARSER(fileName, entryName, shader, "-msl").Replace("\n", "\r\n");
                    }

                    outputWindow.richTextBoxOutput.Text = richTextBox1.Text + "\r\n" + translatedMSL;

                    if (outputWindow.richTextBoxOutput.Text == null)
                    {
                        outputWindow.richTextBoxOutput.Text = "Failed to translate";
                    }

                    //outputWindow.Update();
                    outputWindow.buttonShowMSL.PerformClick();
                }
            }
        }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            int includeCounter = includeBuffers.Count - 1;

            /*
             * string[] fileName = new string[fileNames.Count];
             *
             *
             * for (int i = 0; i < fileNames.Count; i++)
             * {
             *  fileName[i] = fileNames[i];
             * }
             *
             * string[] bufferForInlcuded = new string[includeCounter];
             *
             * for (int i = 0; i < includeCounter; i++)
             * {
             *  bufferForInlcuded[i] = includeBuffers[i];
             * }
             */


            if (richTextBox2.Text != "")
            {
                //send request to recreate
                if (outputWindow.IsDisposed)
                {
                    parentForm.createOutputWindow();
                }

                outputWindow.Location = new Point(this.Location.X + 620, this.Location.Y);
                outputWindow.Show();

                richTextBox2.Text.Replace("\r", "");

                if (bTranslateAll)
                {
                    translatedHLSL = PARSER(fileNames.ToArray(), richTextBox2.Text, richTextBox2.TextLength, entryName, shader, "-hlsl", includeBuffers.ToArray(), includeCounter).Replace("\n", "\r\n");
                    outputWindow.richTextBoxOutput.Text = richTextBox1.Text + "\r\n" + translatedHLSL;

                    if (outputWindow.richTextBoxOutput.Text == null)
                    {
                        outputWindow.richTextBoxOutput.Text = "Failed to translate";
                    }

                    translatedGLSL = PARSER(fileNames.ToArray(), richTextBox2.Text, richTextBox2.TextLength, entryName, shader, "-glsl", includeBuffers.ToArray(), includeCounter).Replace("\n", "\r\n");

                    if (shader == "-hs")
                    {
                        //need secondaryfile
                        OpenFileDialog ofd = new OpenFileDialog();
                        ofd.Title = "Select a Vertex shader needed to generate a Hull shader for Metal";
                        if (ofd.ShowDialog() == DialogResult.OK)
                        {
                            StreamReader sr = new StreamReader(ofd.FileName);
                            string       vertexShaderData = sr.ReadToEnd();
                            string       compositeData    = vertexShaderData + richTextBox2.Text;

                            translatedMSL = PARSER(fileNames.ToArray(), compositeData, compositeData.Length, entryName, shader, "-msl", includeBuffers.ToArray(), includeCounter).Replace("\n", "\r\n");
                        }
                        else
                        {
                            outputWindow.richTextBoxOutput.Text = "Failed to load vertex shader for Metal's hull shader";
                            return;
                        }
                    }
                    else
                    {
                        translatedMSL = PARSER(fileNames.ToArray(), richTextBox2.Text, richTextBox2.TextLength, entryName, shader, "-msl", includeBuffers.ToArray(), includeCounter).Replace("\n", "\r\n");
                    }

                    outputWindow.buttonShowGLSL.PerformClick();
                }
                else if (languageString == "HLSL")
                {
                    translatedHLSL = PARSER(fileNames.ToArray(), richTextBox2.Text, richTextBox2.TextLength, entryName, shader, "-hlsl", includeBuffers.ToArray(), includeCounter).Replace("\n", "\r\n");
                    outputWindow.richTextBoxOutput.Text = richTextBox1.Text + "\r\n" + translatedHLSL;

                    if (outputWindow.richTextBoxOutput.Text == null)
                    {
                        outputWindow.richTextBoxOutput.Text = "Failed to translate";
                    }

                    //outputWindow.Update();
                    outputWindow.buttonShowHLSL.PerformClick();
                }
                else if (languageString == "GLSL")
                {
                    translatedGLSL = PARSER(fileNames.ToArray(), richTextBox2.Text, richTextBox2.TextLength, entryName, shader, "-glsl", includeBuffers.ToArray(), includeCounter).Replace("\n", "\r\n");
                    outputWindow.richTextBoxOutput.Text = richTextBox1.Text + "\r\n" + translatedGLSL;

                    if (outputWindow.richTextBoxOutput.Text == null)
                    {
                        outputWindow.richTextBoxOutput.Text = "Failed to translate";
                    }

                    //outputWindow.Update();
                    outputWindow.buttonShowGLSL.PerformClick();
                }
                else if (languageString == "MSL")
                {
                    if (shader == "-hs")
                    {
                        //need secondaryfile
                        OpenFileDialog ofd = new OpenFileDialog();
                        ofd.Title = "Select a Vertex shader needed to generate a Hull shader for Metal";
                        if (ofd.ShowDialog() == DialogResult.OK)
                        {
                            StreamReader sr = new StreamReader(ofd.FileName);
                            string       vertexShaderData = sr.ReadToEnd();
                            string       compositeData    = vertexShaderData + richTextBox2.Text;

                            translatedMSL = PARSER(fileNames.ToArray(), compositeData, compositeData.Length, entryName, shader, "-msl", includeBuffers.ToArray(), includeCounter).Replace("\n", "\r\n");
                        }
                        else
                        {
                            outputWindow.richTextBoxOutput.Text = "Failed to load vertex shader for Metal's hull shader";
                            return;
                        }
                    }
                    else
                    {
                        translatedMSL = PARSER(fileNames.ToArray(), richTextBox2.Text, richTextBox2.TextLength, entryName, shader, "-msl", includeBuffers.ToArray(), includeCounter).Replace("\n", "\r\n");
                    }

                    outputWindow.richTextBoxOutput.Text = richTextBox1.Text + "\r\n" + translatedMSL;

                    if (outputWindow.richTextBoxOutput.Text == null)
                    {
                        outputWindow.richTextBoxOutput.Text = "Failed to translate";
                    }

                    //outputWindow.Update();
                    outputWindow.buttonShowMSL.PerformClick();
                }
            }

            //Input Label Text
            if (fileNames != null)
            {
                char[]   splitters = { '.', '\\' };
                string[] tokkens   = fileNames[fileNames.Count() - 1].Split(splitters);

                label5.Text = "Input from " + shaderString + " \"" + tokkens[tokkens.Length - 2] + "." + tokkens[tokkens.Length - 1] + "\"";
                label5.Update();
            }
        }