CheckError() public static method

public static CheckError ( ) : void
return void
コード例 #1
0
ファイル: Texture.cs プロジェクト: layshua/Alexandria
        protected void Data2D(int level, Vector2i dimensions, Format storageFormat, IntPtr pointer, Format uploadFormat = null)
        {
            int maxSize = Device.Capabilities.MaxTextureDimension2D;

            if (level < 0)
            {
                throw new ArgumentOutOfRangeException("level");
            }
            if (dimensions.X < 0 || dimensions.X > maxSize)
            {
                throw new ArgumentOutOfRangeException("dimensions.X");
            }
            if (dimensions.Y < 0 || dimensions.Y > maxSize)
            {
                throw new ArgumentOutOfRangeException("dimensions.Y");
            }
            if (storageFormat == null)
            {
                throw new ArgumentNullException("storageFormat");
            }
            if (uploadFormat == null)
            {
                uploadFormat = storageFormat;
            }

            using (Lock()) {
                GL.TexImage2D(Target, level, storageFormat.PixelInternalFormat.Value, dimensions.X, dimensions.Y, 0, uploadFormat.PixelFormat.Value, uploadFormat.PixelType.Value, pointer);
                Context.CheckError();
            }
        }
コード例 #2
0
ファイル: Texture.cs プロジェクト: layshua/Alexandria
        protected internal int Bind()
        {
            int value = Device.GetInt32(TargetBinding);

            GL.BindTexture(Target, Id);
            Context.CheckError();
            return(value);
        }
コード例 #3
0
ファイル: ProgramUniform.cs プロジェクト: layshua/Alexandria
 internal void Used()
 {
     if (IsTexture)
     {
         GL.ActiveTexture(Unit);
         Context.CheckError();
         GL.BindTexture(TextureTarget, Texture != null ? Texture.Id : 0);
         Context.CheckError();
     }
 }
コード例 #4
0
 /// <summary>
 /// Compiles the source code strings that have been stored in the shader object through <see cref="Source"/>, and return whether it compiles (which can also be checked through <see cref="CompileStatus"/>).
 /// </summary>
 /// <returns></returns>
 public bool Compile()
 {
     using (Context.Lock())
     {
         GL.CompileShader(Id);
         Context.CheckError();
         int result;
         GL.GetShader(Id, ShaderParameter.CompileStatus, out result);
         return(result != 0);
     }
 }
コード例 #5
0
 public void Dispose()
 {
     try
     {
         Context.CheckError();
     }
     finally
     {
         GL.BindVertexArray(array.Id);
         context.Dispose();
     }
 }
コード例 #6
0
ファイル: Capabilities.cs プロジェクト: layshua/Alexandria
        internal Capabilities()
        {
            computeStage               = new ComputeShaderStageCapabilities();
            fragmentStage              = new FragmentShaderStageCapabilities();
            geometryStage              = new GeometryShaderStageCapabilities();
            tesselationControlStage    = new TesselationControlShaderStageCapabilities();
            tesselationEvaluationStage = new TesselationEvaluationShaderStageCapabilities();
            vertexStage = new VertexShaderStageCapabilities();

            Context.CheckError();
            extensions = new ReadOnlyCollection <string>(GL.GetString(StringName.Extensions).Split(' '));
            GL.GetError();             // InvalidEnum set even though the call goes fine.
            extensionsSet = new HashSet <string>(extensions);
            Context.CheckError();
        }
コード例 #7
0
ファイル: ProgramStage.cs プロジェクト: layshua/Alexandria
        internal ProgramSubroutineUniform(ProgramStage stage, string name, int index)
            : base(stage, name, index)
        {
            int[] idList = new int[Get1i(ActiveSubroutineUniformParameter.NumCompatibleSubroutines)];
            GL.GetActiveSubroutineUniform(Program.Id, ShaderType, index, ActiveSubroutineUniformParameter.CompatibleSubroutines, idList);
            Context.CheckError();
            for (int idIndex = 0; idIndex < idList.Length; idIndex++)
            {
                compatible.Add(stage.Subroutines[idList[idIndex]]);
            }

            this.location = GL.GetSubroutineUniformLocation(Program.Id, ShaderType, Name);
            Context.CheckError();

            stage.ids[location] = idList[0];
        }
コード例 #8
0
 internal void DoBind()
 {
     if (bindBuffer == null)
     {
         GL.DisableVertexAttribArray(index);
         Context.CheckError();
     }
     else
     {
         GL.EnableVertexAttribArray(index);
         Context.CheckError();
         GL.BindBuffer(BufferTarget.ArrayBuffer, bindBuffer.Id);
         Context.CheckError();
         GL.VertexAttribPointer(index, bindFormat.Channels.RowCount, bindFormat.VertexAttribPointerType.Value, bindFormat.IsNormalized, bindStride, bindOffsetInBytes);
         Context.CheckError();
     }
 }
コード例 #9
0
ファイル: ProgramUniform.cs プロジェクト: layshua/Alexandria
        void Set(Texture texture, ActiveUniformType required, Type givenType)
        {
            if (type != required)
            {
                throw ConversionException(givenType);
            }

            if (object.ReferenceEquals(Context.Current.program, Program))
            {
                using (Context.Lock()) {
                    GL.ActiveTexture(Unit);
                    Context.CheckError();
                    GL.BindTexture(TextureTarget, texture != null ? texture.Id : 0);
                }
            }

            Texture = texture;
        }
コード例 #10
0
 public void Dispose()
 {
     try { Context.CheckError(); } finally { buffer.GLUnbind(bound); }
 }
コード例 #11
0
ファイル: Program.cs プロジェクト: layshua/Alexandria
		public void Dispose() {
			Context.CheckError();
			GL.UseProgram(Device.Program != null ? Device.Program.Id : 0);
			contextLock.Dispose();
		}
コード例 #12
0
ファイル: Program.cs プロジェクト: layshua/Alexandria
		internal ProgramBinding(Program program) {
			contextLock = Context.Lock();
			GL.UseProgram(program.Id);
			Context.CheckError();
		}
コード例 #13
0
ファイル: Device.cs プロジェクト: layshua/Alexandria
 internal static void CheckError()
 {
     Context.CheckError();
 }
コード例 #14
0
ファイル: Texture.cs プロジェクト: layshua/Alexandria
 public void Dispose()
 {
     try { Context.CheckError(); } finally { GL.BindTexture(texture.Target, old); }
 }
コード例 #15
0
ファイル: Texture.cs プロジェクト: layshua/Alexandria
 protected internal void Unbind(int old)
 {
     GL.BindTexture(Target, Id);
     Context.CheckError();
 }
コード例 #16
0
ファイル: Program.cs プロジェクト: layshua/Alexandria
		/// <summary>Attempt to link a <see cref="Program"/> object, returning success.</summary>
		/// <remarks>
		/// If any <see cref="Shader"/> objects of type <see cref="VertexShader"/>​ are attached to the <see cref="Program"/>​, they will be used to create an executable that will run on the programmable vertex processor. If any shader objects of type <see cref="GeometryShader"/>​ are attached to the <see cref="Program"/>​, they will be used to create an executable that will run on the programmable geometry processor. If any shader objects of type <see cref="FragmentShader"/> are attached to the <see cref="Program"/>​, they will be used to create an executable that will run on the programmable fragment processor.
		///  
		/// The status of the link operation will be stored as part of the program object's state. This value will be set to <c>true</c>​ if the program object was linked without errors and is ready for use, and <c>false</c>​ otherwise. It can be queried through <see cref="IsLinked"/>.
		/// 
		/// As a result of a successful link operation, all active user-defined uniform variables belonging to program​ will be initialized to 0, and each of the program object's active uniform variables can be accessed through <see cref="Uniforms"/>. Also, any active user-defined attribute variables that have not been bound to a generic vertex attribute index will be bound to one at this time and accessed through <see cref="Attributes"/>.
		/// 
		/// Linking of a program object can fail for a number of reasons as specified in the OpenGL Shading Language Specification. The following lists some of the conditions that will cause a link error.
		/// <list type="bullet">
		/// <item><description>The number of active attribute variables supported by the implementation has been exceeded.</description></item>
		/// <item><description>The storage limit for uniform variables has been exceeded.</description></item>
		/// <item><description>The number of active uniform variables supported by the implementation has been exceeded.</description></item>
		/// <item><description>The main function is missing for the vertex, geometry or fragment shader.</description></item>
		/// <item><description>A varying variable actually used in the fragment shader is not declared in the same way (or is not declared at all) in the vertex shader, or geometry shader shader if present.</description></item>
		/// <item><description>A reference to a function or variable name is unresolved.</description></item>
		/// <item><description>A shared global is declared with two different types or two different initial values.</description></item>
		/// <item><description>One or more of the attached shader objects has not been successfully compiled.</description></item>
		/// <item><description>Binding a generic attribute matrix caused some rows of the matrix to fall outside the allowed maximum of <see cref="VertexShaderStageCapabilities.MaxAttributes"/>​.</description></item>
		/// <item><description>Not enough contiguous vertex attribute slots could be found to bind attribute matrices.</description></item>
		/// <item><description>The program object contains objects to form a fragment shader but does not contain objects to form a vertex shader.</description></item>
		/// <item><description>The program object contains objects to form a geometry shader but does not contain objects to form a vertex shader.</description></item>
		/// <item><description>The program object contains objects to form a geometry shader and the input primitive type, output primitive type, or maximum output vertex count is not specified in any compiled geometry shader object.</description></item>
		/// <item><description>The program object contains objects to form a geometry shader and the input primitive type, output primitive type, or maximum output vertex count is specified differently in multiple geometry shader objects.</description></item>
		/// <item><description>The number of active outputs in the fragment shader is greater than the value of <see cref="GraphicsProgram.MaxDrawBuffers"/>​.</description></item>
		/// <item><description>The program has an active output assigned to a location greater than or equal to the value of <see cref="GraphicsProgram.MaxDualSourceDrawBuffers"/> ​and has an active output assigned an index greater than or equal to one.</description></item>
		/// <item><description>More than one varying out variable is bound to the same number and index.</description></item>
		/// <item><description>The explicit binding assigments do not leave enough space for the linker to automatically assign a location for a varying out array, which requires multiple contiguous locations.</description></item>
		/// <item><description>The count​ specified by glTransformFeedbackVaryings​ is non-zero, but the program object has no vertex or geometry shader.</description></item>
		/// <item><description>Any variable name specified to glTransformFeedbackVaryings​ in the varyings​ array is not declared as an output in the vertex shader (or the geometry shader, if active).</description></item>
		/// <item><description>Any two entries in the varyings​ array given glTransformFeedbackVaryings​ specify the same varying variable.</description></item>
		/// <item><description>The total number of components to capture in any transform feedback varying variable is greater than the constant <see cref="Context.MaxTransformFeedbackSeparateComponents"/>​ and the buffer mode is <see cref="TransformFeedbackMode.SeparateAttributes"/>​.</description></item>
		/// </list>
		///
		/// When a program object has been successfully linked, the program object can be made part of current state by drawing with it​. Whether or not the link operation was successful, the program object's information log will be overwritten. The information log can be retrieved through <see cref="InfoLog"/>.
		/// 
		/// <see cref="Link"/> will also install the generated executables as part of the current rendering state if the link operation was successful and the specified program object is already currently in use as a result of a previous drawing call. If the program object currently in use is relinked unsuccessfully, its link status will be set to <c>false</c>​ , but the executables and associated state will remain part of the current state until a subsequent drawing operation removes it from use. After it is removed from use, it cannot be made part of current state until it has been successfully relinked.
		/// 
		/// If program​ contains shader objects of type <see cref="VertexShader"/>​, and optionally of type <see cref="GeometryShader"/>​, but does not contain shader objects of type <see cref="FragmentShader"/>​, the vertex shader executable will be installed on the programmable vertex processor, the geometry shader executable, if present, will be installed on the programmable geometry processor, but no executable will be installed on the fragment processor. The results of rasterizing primitives with such a program will be undefined.
		/// 
		/// The program object's information log is updated and the program is generated at the time of the link operation. After the link operation, applications are free to modify attached shader objects, compile attached shader objects, detach shader objects, delete shader objects, and attach additional shader objects. None of these operations affects the information log or the program that is part of the program object.
		/// </remarks>
		/// <returns></returns>
		public virtual bool Link() {
			using (Context.Lock()) {
				foreach (ProgramStage stage in stagesByShaderStage.Values)
					stage.Unlink();

				GL.LinkProgram(Id);
				Context.CheckError();
				int result;
				GL.GetProgram(Id, GetProgramParameterName.LinkStatus, out result);

				attributes.Clear();

				if (result != 0) {
					int count, maxNameLength, length;
					StringBuilder name;

					// Gather the attributes
					GL.GetProgram(Id, GetProgramParameterName.ActiveAttributes, out count);
					GL.GetProgram(Id, GetProgramParameterName.ActiveAttributeMaxLength, out maxNameLength);
					name = new StringBuilder(maxNameLength);
					for (int index = 0; index < count; index++) {
						ActiveAttribType type;
						int size;

						name.Clear();
						GL.GetActiveAttrib(Id, index, maxNameLength, out length, out size, out type, name);
						attributes.Add(new ProgramAttribute(this, name.ToString(), index, size, type));
					}

					// Gather the uniforms
					GL.GetProgram(Id, GetProgramParameterName.ActiveUniforms, out count);
					GL.GetProgram(Id, GetProgramParameterName.ActiveUniformMaxLength, out maxNameLength);
					name = new StringBuilder(maxNameLength);
					for (int index = 0; index < count; index++) {
						int size;
						ActiveUniformType type;

						GL.GetActiveUniform(Id, index, maxNameLength, out length, out size, out type, name);
						Context.CheckError();

						string nameString = name.ToString();
						int location = GL.GetUniformLocation(Id, nameString);
						Context.CheckError();

						uniforms.Add(new ProgramUniform(this, nameString, index, location, type, size));
					}

					// Find slots for the textures.
					for (int index = 0, slot = 0; index < count; index++) {
						var uniform = Uniforms[index];
						if (uniform.IsTexture)
							uniform.Unit = TextureUnit.Texture0 + slot++;
					}

					// Have the stages gather data.
					//foreach (ProgramStage stage in stagesByShaderStage.Values)
						//stage.Link();
				}

				return result != 0;
			}
		}
コード例 #17
0
ファイル: Context.cs プロジェクト: layshua/Alexandria
 public void Dispose()
 {
     Context.CheckError();
 }