Ignore:
Timestamp:
01/29/09 18:46:32 (15 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp

    r3293 r3294  
    3737        mHasTexture = (mTexCoords != NULL); 
    3838        mHasTangents = (mTangents != NULL); 
    39  
     39/* 
     40        mIndices = new unsigned int[mNumVertices]; 
     41 
     42        for (int i = 0; i < mNumVertices; ++ i) 
     43        { 
     44                mIndices[i] = i; 
     45        }*/ 
     46 
     47        // prepare vbos 
    4048        Prepare(); 
    4149 
    42         mIndices = new unsigned int[mNumVertices]; 
    43  
    44         for (int i = 0; i < mNumVertices; ++ i) 
    45         { 
    46                 mIndices[i] = i; 
    47         } 
    48  
    4950        if (delData) 
    5051        { 
    5152                DEL_ARRAY_PTR(mVertices); 
     53                DEL_ARRAY_PTR(mIndices); 
    5254                DEL_ARRAY_PTR(mNormals); 
    5355                DEL_ARRAY_PTR(mTexCoords); 
     
    6567        DEL_ARRAY_PTR(mIndices); 
    6668 
    67         // delete vbo 
     69        // delete vbos 
    6870        glDeleteBuffersARB(1, &mVboId); 
     71        glDeleteBuffersARB(1, &mVboId2); 
    6972} 
    7073 
     
    144147 
    145148        glBufferDataARB(GL_ARRAY_BUFFER_ARB, dataSize * sizeof(float),  
    146                             (float *)data, GL_STATIC_DRAW_ARB); 
     149                            data, GL_STATIC_DRAW_ARB); 
    147150 
    148151        glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); 
    149152 
    150         glGenBuffersARB(1, &mVboId2); 
    151          
    152         glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mVboId2); 
    153         glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mNumVertices * sizeof(unsigned int),  
    154                             mIndices, GL_STATIC_DRAW_ARB); 
    155  
    156         int bufferSize; 
    157         glGetBufferParameterivARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &bufferSize); 
    158         // cout << "Index Array in VBO: " << bufferSize << " bytes\n"; 
    159  
    160         glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); 
     153 
     154        /////////// 
     155        //-- the index array 
     156 
     157        if (mIndices) 
     158        { 
     159                glGenBuffersARB(1, &mVboId2); 
     160 
     161                glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mVboId2); 
     162                glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mNumVertices * sizeof(unsigned int),  
     163                        mIndices, GL_STATIC_DRAW_ARB); 
     164 
     165                int bufferSize; 
     166                glGetBufferParameterivARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &bufferSize); 
     167                //cout << "Index Array in VBO: " << bufferSize << " bytes\n" << "id: " << mVboId2 << endl; 
     168 
     169                glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); 
     170        } 
    161171 
    162172        // data handled by graphics driver from now on 
     
    175185        { 
    176186                glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId); 
    177                 //glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mVboId2); 
    178187 
    179188                int currentPointer; 
     
    182191                if (mHasTangents) 
    183192                { 
    184                         //glClientActiveTextureARB(GL_TEXTURE1_ARB); 
    185                         //glTexCoordPointer(2, GL_FLOAT, (char *)NULL + mNumVertices * sizeof(Vector3)); 
    186  
    187193                        glColorPointer(3, GL_FLOAT, 0, (char *)NULL + mNumVertices * 2 * sizeof(Vector3)); 
    188194                        currentPointer = mNumVertices * 3 * sizeof(Vector3); 
    189                         //glClientActiveTextureARB(GL_TEXTURE0_ARB); 
    190  
    191195                } 
    192196                else 
     
    201205 
    202206                glVertexPointer(3, GL_FLOAT, 0, (char *)NULL);   
     207                //glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mVboId2); 
     208 
    203209                /// update state 
    204210                state->SetCurrentVboId(mVboId); 
     
    206212 
    207213        glDrawArrays(GL_TRIANGLES, 0, mNumVertices); 
    208         //glDrawElements(GL_TRIANGLES, mNumVertices, GL_UNSIGNED_INT, mIndices); 
    209214        //glDrawElements(GL_TRIANGLES, mNumVertices, GL_UNSIGNED_INT, 0);  
    210  
    211         //glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); 
    212         //glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); 
    213215 
    214216        if (mHasTangents) glDisableClientState(GL_COLOR_ARRAY); 
Note: See TracChangeset for help on using the changeset viewer.