/// <summary>
        /// Creates an instance of the program for the current context and associates it with the control
        /// </summary>
        /// <param name="control"></param>
        internal void Initialize(GL_ControlModern control)
        {
            if (programs.ContainsKey(control))
            {
                return;
            }

            int program = GL.CreateProgram();

            foreach (Shader shader in shaders)
            {
                GL.AttachShader(program, shader.id);
            }

            GL.LinkProgram(program);

            if (programs.Count == 0) //this is the first program instance
            {
                LoadAttributes(program);
                LoadUniorms(program);

                ShowErrors();
            }

            programs[control] = program;
        }
Beispiel #2
0
        internal void Initialize(GL_ControlModern control)
        {
            if (vaos.ContainsKey(control))
            {
                return;
            }


            GL.GenVertexArrays(1, out int vao);
            if (GL.GetError() == ErrorCode.InvalidOperation)
            {
                Debugger.Break();
            }
            GL.BindVertexArray(vao);
            if (GL.GetError() == ErrorCode.InvalidOperation)
            {
                Debugger.Break();
            }
            GL.BindBuffer(BufferTarget.ArrayBuffer, buffer);

            foreach (KeyValuePair <int, VertexAttribute> a in attributes)
            {
                GL.EnableVertexAttribArray(a.Key);
                GL.VertexAttribPointer(a.Key, a.Value.size, a.Value.type, a.Value.normalized, a.Value.stride, a.Value.offset);
            }
            vaos[control] = vao;
        }
Beispiel #3
0
        internal void Initialize(GL_ControlModern control)
        {
            if (vaos.ContainsKey(control))
            {
                return;
            }

            int vao = GL.GenVertexArray();

            GL.BindVertexArray(vao);
            GL.BindBuffer(BufferTarget.ArrayBuffer, buffer);

            foreach (KeyValuePair <int, VertexAttribute> a in attributes)
            {
                GL.EnableVertexAttribArray(a.Key);
                GL.VertexAttribPointer(a.Key, a.Value.size, a.Value.type, a.Value.normalized, a.Value.stride, a.Value.offset);
            }
            vaos[control] = vao;
        }