Example #1
0
        /// <summary>
        /// copies points into the VBOs. returns number of points that were copied
        /// </summary>
        /// <param name="nbrPts"></param>
        /// <param name="vertices"></param>
        /// <param name="normals"></param>
        /// <param name="colors"></param>
        /// <param name="serverBufferIds"></param>
        /// <returns></returns>
        unsafe public static void CopyPointsToVBOs(float[] interleavedData, VBOStorageInformation serverBufferIds)
        {
            //create and initialize vertexbuffer
            Gl.glBindBuffer(Gl.GL_ARRAY_BUFFER, serverBufferIds.InterleavedVBO);
            VBOUtils.CheckGlError("Tried first binding of interleaved VBO during glBegin() and glEnd()");

            long bytesCopied = 0;
            int  size        = 0;

            fixed(float *vptr = interleavedData)
            {
                size         = (sizeof(float) * interleavedData.Length);
                bytesCopied += size;
                Gl.glBufferData(Gl.GL_ARRAY_BUFFER, (IntPtr)size, (IntPtr)vptr, Gl.GL_STATIC_DRAW);
            }

            VBOUtils.CheckGlError("Error copying interleaved data to VBO");

            LasMetrics.GetInstance().bytesTransferedToGPU += bytesCopied;
            LasMetrics.GetInstance().numberOfPointsLoadedIntoExistingVBOs += serverBufferIds.NumberOfPoints;
        }
Example #2
0
        unsafe public static VBOStorageInformation GenerateVBOs(int numberOfPoints)
        {
            //generate free buffer names for 3 different buffers
            int bufferId = 0;

            Gl.glGenBuffers(1, out bufferId);

            VBOUtils.CheckGlError("Tried first binding of VBO during glBegin() and glEnd()");

            if (bufferId == 0)
            {
                throw new ApplicationException("ID of VBO should be set but was not!!!");
            }

            VBOStorageInformation vboSI = new VBOStorageInformation();

            vboSI.InterleavedVBO = bufferId;
            vboSI.NumberOfPoints = numberOfPoints;

            LasMetrics.GetInstance().numberOfExistingVBOs++;
            return(vboSI);
        }