/// <summary> /// Attach another GLSL Shader to this one. /// </summary> /// <param name="name"></param> public void AttachChildShader(string name) { // is the name valid and already loaded? // check with the high level program manager to see if it was loaded HighLevelGpuProgram hlProgram = HighLevelGpuProgramManager.Instance.GetByName(name); if (hlProgram != null) { if (hlProgram.SyntaxCode == "glsl") { // make sure attached program source gets loaded and compiled // don't need a low level implementation for attached shader objects // loadHighLevelImpl will only load the source and compile once // so don't worry about calling it several times GLSLProgram childShader = (GLSLProgram)hlProgram; // load the source and attach the child shader only if supported if (IsSupported) { childShader.LoadHighLevelImpl(); // add to the constainer attachedGLSLPrograms.Add(childShader); attachedShaderNames += name + " "; } } } }
public GLSLGpuProgram(GLSLProgram parent) : base(parent.Creator, parent.Name, parent.Handle, parent.Group, false, null) { // store off the reference to the parent program this.glslProgram = parent; type = parent.Type; syntaxCode = "glsl"; if (parent.Type == GpuProgramType.Vertex) { programId = ++vertexShaderCount; } else if (parent.Type == GpuProgramType.Fragment) { programId = ++fragmentShaderCount; } else { programId = ++geometryShaderCount; } // transfer skeletal animation status from parent isSkeletalAnimationIncluded = this.glslProgram.IsSkeletalAnimationIncluded; // there is nothing to load LoadFromFile = false; }
public GLSLGpuProgram( GLSLProgram parent ) : base( parent.Creator, parent.Name, parent.Handle, parent.Group, false, null ) { this.Type = parent.Type; this.SyntaxCode = "glsl"; // store off the reference to the parent program glslProgram = parent; if ( parent.Type == GpuProgramType.Vertex ) { programId = ++vertexShaderCount; } else if (parent.Type == GpuProgramType.Fragment) { programId = ++fragmentShaderCount; } else { programId = ++geometryShaderCount; } // transfer skeletal animation status from parent this.IsSkeletalAnimationIncluded = glslProgram.IsSkeletalAnimationIncluded; // there is nothing to load //LoadFromFile = false; }
public GLSLGpuProgram(GLSLProgram parent) : base(parent.Name, parent.Type, "glsl") { // store off the reference to the parent program glslProgram = parent; if(parent.Type == GpuProgramType.Vertex) { programId = ++vertexShaderCount; } else { programId = ++fragmentShaderCount; } // there is nothing to load loadFromFile = false; }
public GLSLGpuProgram(GLSLProgram parent) : base(parent.Name, parent.Type, "glsl") { // store off the reference to the parent program glslProgram = parent; if (parent.Type == GpuProgramType.Vertex) { programId = ++vertexShaderCount; } else { programId = ++fragmentShaderCount; } // there is nothing to load loadFromFile = false; }
/// <summary> /// /// </summary> /// <param name="programObject"></param> public void AttachToProgramObject(int programObject) { Gl.glAttachObjectARB(programObject, glHandle); GLSLHelper.CheckForGLSLError("Error attaching " + this.name + " shader object to GLSL Program Object.", programObject); // atach child objects for (int i = 0; i < attachedGLSLPrograms.Count; i++) { GLSLProgram childShader = (GLSLProgram)attachedGLSLPrograms[i]; // bug in ATI GLSL linker : modules without main function must be recompiled each time // they are linked to a different program object // don't check for compile errors since there won't be any // *** minor inconvenience until ATI fixes there driver childShader.Compile(false); childShader.AttachToProgramObject(programObject); } }