예제 #1
0
 public static IProgram Load(string name)
 {
     if (Configuration.useGl1)
     {
         return((IProgram)ProgramGL1.Load(name));
     }
     return((IProgram)ProgramGL3.Load(name));
 }
예제 #2
0
        public static void Pop()
        {
            var program = programStack.Pop();

            if (program != currentProgram)
            {
                if (program != null)
                {
                    program.Use(0);
                }
            }
            currentProgram = program;
        }
예제 #3
0
        public static ProgramGL3 Load(string filename)
        {
#if !DEBUG
            try
#endif
            {
                var    program  = new ProgramGL3();
                string fullpath = Configuration.ProgramSearchPathGL + filename;
                if (System.IO.File.Exists(filename))
                {
                    fullpath = filename;
                }

//#if DEBUG_PROGRAM
                Trace.WriteLine("Loading program " + fullpath);
//#endif

                program.Name = fullpath;
                string binaryPath = fullpath.Replace("res/", "data/") + ".binary";
                bool   useBinary  = Configuration.useBinaryShaders && Configuration.canUseBinaryShaders && System.IO.File.Exists(binaryPath);

                if (useBinary && program.LoadFromBinary(binaryPath))
                {
                    return(program);
                }

                program.LoadFromFiles(
                    Configuration.canUseGeometryShaders ? fullpath + ".gs" : null,
                    fullpath + ".vs",
                    fullpath + ".fs"
                    );

                if (Configuration.useBinaryShaders && Configuration.canUseBinaryShaders)
                {
                    program.StoreBinaryFile(binaryPath);
                }
                return(program);
            }
#if !DEBUG
            catch (System.Exception e)
            {
                Trace.TraceError("Program.Load(" + filename + ") failed - exception " + e.ToString());
                if (Configuration.throwProgramExceptions)
                {
                    throw;
                }
                return(null);
            }
#endif
        }
예제 #4
0
        public void Use(int baseInstance)
        {
            if (Valid)
            {
                GL.UseProgram(ProgramObject);
#if DEBUG_PROGRAM
                Trace.WriteLine("Program.Use " + this.Name + " object " + ProgramObject);
#endif
            }
            else
            {
                throw new Exception();
            }
            currentProgram = this;
        }