Quantcast
Channel: SharpGL
Viewing all articles
Browse latest Browse all 104

New Post: VBO

$
0
0
In past few days i am traing to display a mesh with VBO. Unfortunatly without any success...
If someone can point me in any direction what i am doing wrong i will be very thankful .
private void DrawMesh_New()
        {
            SharpGL.OpenGL gl = this.openGLControl1.OpenGL;
            gl.ClearColor(0.39f, 0.53f, 0.92f, 1);
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.LoadIdentity();
            gl.LookAt(50, 50, 50, 0, 0.5f, 0, 0, 1, 0);
            gl.Rotate(0, rotation++, rotation / 2);

            gl.EnableClientState(OpenGL.GL_VERTEX_ARRAY);
            gl.EnableClientState(OpenGL.GL_NORMAL_ARRAY);
            unsafe
            {
                fixed (float* verts = vertices)
                {
                     var ptr = new IntPtr(verts);
                     gl.VertexPointer(3, OpenGL.GL_FLOAT, 3 * sizeof(float), ptr);
                }
            }
            unsafe
            {
                fixed (float* norms = normals)
                {
                    var pNormals = new IntPtr(norms);
                    gl.NormalPointer(OpenGL.GL_FLOAT, sizeof(float) * 2, pNormals);
                }
            }

            for (int i = 0; i < m_Model.Surfices.Count; i++)
            {
                unsafe
                {
                    uint[] surfice_indices = new uint[m_Model.Surfices[i].triangle_count * 3];
                    Array.Copy(indices, m_Model.Surfices[i].index_offset, surfice_indices, 0, surfice_indices.Length);
                    //gl.EnableClientState(OpenGL.GL_VERTEX_ARRAY);
                    //gl.EnableVertexAttribArray(0);
                    //gl.VertexAttribPointer(0, 3, OpenGL.GL_FLOAT, false, 0, new IntPtr(0));
                    fixed (uint* s = surfice_indices)
                    {
                         var ptr = new IntPtr(s);
                         gl.DrawElements(OpenGL.GL_TRIANGLES, surfice_indices.Length, OpenGL.GL_INT, ptr);                        
                    }
                }
            }
        }
Just nothing drawed.
and in same moment if i build an GL_ARRAY_BUFFER everything is working just fine.

Viewing all articles
Browse latest Browse all 104

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>