Beispiel #1
0
        public void SetData <TType>(GLBuffer buffer, int elementSize = 4, int offset = 0, int stride = 0,
                                    bool normalize = false)
        {
            if (!CheckValid())
            {
                return;
            }
            PrepareUsing();
            int glType;
            var type = typeof(TType);

            if (type == typeof(float))
            {
                glType = GL.GL_FLOAT;
            }
            else if (type == typeof(short))
            {
                glType = GL.GL_SHORT;
            }
            else if (type == typeof(ushort))
            {
                glType = GL.GL_UNSIGNED_SHORT;
            }
            else if (type == typeof(sbyte))
            {
                glType = GL.GL_BYTE;
            }
            else if (type == typeof(byte))
            {
                glType = GL.GL_UNSIGNED_BYTE;
            }
            else
            {
                throw(new Exception("Invalid type " + type));
            }

            buffer.Bind();
            GL.glVertexAttribPointer(
                (uint)Location,
                elementSize,
                glType,
                normalize,
                stride,
                (void *)offset
                );
            buffer.Unbind();
            Enable();
        }
 private GLShaderFilter(int Width, int Height, GLShader Shader)
 {
     this.Shader = Shader;
     SetSize(Width, Height);
     PositionBuffer = GLBuffer.Create().SetData(new[]
     {
         -1f, -1f,
         +1f, -1f,
         -1f, +1f,
         +1f, +1f
     });
     TexcoordsBuffer = GLBuffer.Create().SetData(new[]
     {
         0f, 0f,
         1f, 0f,
         0f, 1f,
         1f, 1f
     });
 }