Changeset 3293 for GTP


Ignore:
Timestamp:
01/28/09 21:58:44 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/MainApp.vcproj

    r3292 r3293  
    156156                                IgnoreAllDefaultLibraries="false" 
    157157                                IgnoreDefaultLibraryNames="LIBCMT" 
    158                                 GenerateDebugInformation="false" 
     158                                GenerateDebugInformation="true" 
    159159                                SubSystem="1" 
    160160                                LargeAddressAware="2" 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp

    r3291 r3293  
    658658        { 
    659659                glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId); 
     660                //glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mVboId2); 
     661 
    660662                // set the vertex pointer to the vertex buffer 
    661663                glVertexPointer(3, GL_FLOAT, 0, (char *)NULL);   
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp

    r3284 r3293  
    3131mTangents(tangents), 
    3232mNumVertices(numVertices),  
    33 mVboId(-1) 
     33mVboId(-1), 
     34mVboId2(-1), 
     35mIndices(NULL) 
    3436{ 
    3537        mHasTexture = (mTexCoords != NULL); 
     
    3739 
    3840        Prepare(); 
     41 
     42        mIndices = new unsigned int[mNumVertices]; 
     43 
     44        for (int i = 0; i < mNumVertices; ++ i) 
     45        { 
     46                mIndices[i] = i; 
     47        } 
    3948 
    4049        if (delData) 
     
    5463        DEL_ARRAY_PTR(mTexCoords); 
    5564        DEL_ARRAY_PTR(mTangents); 
     65        DEL_ARRAY_PTR(mIndices); 
    5666 
    5767        // delete vbo 
     
    8797 
    8898                        float dotProd = DotProd(tangent, normal); 
    89                         //tangent -= normal * dotProd;tangent = Normalize(tangent); 
    90  
     99                        //tangent -= normal * dotProd; tangent = Normalize(tangent); 
    91100                        //mTangents[i] = tangent; 
    92101                        mTangents[i] = tangent * 0.5f + Vector3(0.5f); 
     
    94103 
    95104                for (int i = 0; i < mNumVertices; ++ i) 
     105                { 
    96106                        ((Vector3 *)data)[mNumVertices * 2 + i] = mTangents[i]; 
     107                } 
    97108 
    98109                currentPData += mNumVertices * 3; 
     
    102113        { 
    103114                for (int i = 0; i < mNumVertices; ++ i) 
     115                { 
    104116                        ((Texcoord2 *)currentPData)[i] = mTexCoords[i]; 
     117                } 
    105118        } 
    106119 
     
    120133        if (mTangents) 
    121134        { 
    122                 //cout << "dotprods: " << endl; 
    123  
    124                 /*for (int i = 0; i < 100; ++ i) 
    125                 { 
    126                         //cout << mTangents[i] << " " << mNormals[i] << " " << DotProd(Normalize(mTangents[i]), Normalize(mNormals[i])) << endl; 
    127                         float d = fabs(DotProd(Normalize(mTangents[i]), Normalize(mNormals[i]))); 
    128                         if (d > 0.01) cout << d << " "; 
    129                         //cout << d << " "; 
    130                 } 
    131                 cout << endl; 
    132                 */ 
    133          
    134                 for (int i = 0; i < 50; ++ i) 
    135                 { 
    136                         cout << mTexCoords[i].first << "," << mTexCoords[i].second << " "; 
    137                 } 
    138  
     135                // hack: use color pointer to store tangents 
    139136                glColorPointer(3, GL_FLOAT, 0, (char *)NULL + currentPVbo); 
    140137                currentPVbo += mNumVertices * sizeof(Vector3); 
     
    151148        glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); 
    152149 
     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); 
     161 
    153162        // data handled by graphics driver from now on 
    154163        delete [] data; 
     
    166175        { 
    167176                glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId); 
    168                  
     177                //glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mVboId2); 
     178 
    169179                int currentPointer; 
    170  
    171180                glNormalPointer(GL_FLOAT, 0, (char *)NULL + mNumVertices * sizeof(Vector3)); 
    172181 
     
    182191                } 
    183192                else 
     193                { 
    184194                        currentPointer = mNumVertices * 2 * sizeof(Vector3); 
     195                } 
    185196 
    186197                if (mHasTexture) 
     198                { 
    187199                        glTexCoordPointer(2, GL_FLOAT, 0, (char *)NULL + currentPointer); 
     200                } 
    188201 
    189202                glVertexPointer(3, GL_FLOAT, 0, (char *)NULL);   
    190  
     203                /// update state 
    191204                state->SetCurrentVboId(mVboId); 
    192  
    193         } 
    194  
    195         // don't render first degenerate index 
     205        } 
     206 
    196207        glDrawArrays(GL_TRIANGLES, 0, mNumVertices); 
    197  
    198         if (mHasTangents) 
    199                 glDisableClientState(GL_COLOR_ARRAY); 
     208        //glDrawElements(GL_TRIANGLES, mNumVertices, GL_UNSIGNED_INT, mIndices); 
     209        //glDrawElements(GL_TRIANGLES, mNumVertices, GL_UNSIGNED_INT, 0);  
     210 
     211        //glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); 
     212        //glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); 
     213 
     214        if (mHasTangents) glDisableClientState(GL_COLOR_ARRAY); 
    200215} 
    201216 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.h

    r3260 r3293  
    8181        Texcoord2 *mTexCoords; 
    8282 
     83        unsigned int *mIndices; 
     84 
    8385        unsigned int mVboId; 
     86        unsigned int mVboId2; 
    8487 
    8588        int mNumVertices; 
Note: See TracChangeset for help on using the changeset viewer.