Changeset 594 for trunk

Show
Ignore:
Timestamp:
06/01/08 14:45:49 (7 months ago)
Author:
LeoD
Message:

using glBufferSubData for updating the VBOs now

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/defend/sim/Core.d

    r590 r594  
    935935        { 
    936936            logger = Log.getLogger("sim.object." ~ Integer.toString(id)); 
    937             //logger.level = LogLevel.Info; 
     937            logger.level = LogLevel.Info; 
    938938        } 
    939939    } 
  • trunk/src/defend/terrain/Terrain.d

    r592 r594  
    381381        { 
    382382            if(!texture) continue; 
    383              
    384383            Texture.release(texture); 
     384        } 
     385         
     386        foreach(texture; alphaMaps) 
     387        { 
     388            if(!texture) continue; 
     389            delete texture; 
    385390        } 
    386391    } 
  • trunk/src/engine/math/Frustum.d

    r583 r594  
    6363    bool sphereVisible(Vec3!(T) v, T radius) 
    6464    { 
    65         statistics.frustum_bsphere_checks++; 
    66          
    6765        foreach(index, plane; frustum) 
    6866        { 
     
    9189    { 
    9290        statistics.frustum_bbox_checks++; 
    93         //return true; 
    94          
     91 
    9592        with(bbox) 
    9693        { 
  • trunk/src/engine/model/ModelMD2.d

    r593 r594  
    166166        void render(MD2ModelInstance state) 
    167167        { 
    168             BoundingBox!(float) bbox; 
    169          
    170168            auto currFrame = &frames[state.currentFrame]; 
    171169            auto nextFrame = &frames[state.nextFrame]; 
     
    177175            for(uint i = 0; i < header.numTriangles * 3; i++) 
    178176            { 
     177                statistics.vertices_animated++; 
     178             
    179179                target.position.x = currPos.x + state.interp * (nextPos.x - currPos.x); 
    180180                target.position.y = currPos.y + state.interp * (nextPos.y - currPos.y); 
  • trunk/src/engine/rend/opengl/Renderer.d

    r592 r594  
    9999    Texture[9] currentTexture; 
    100100 
     101    OGLVertexArrayBase currentArray; 
     102    OGLVertexFormat currentFormat; 
     103 
    101104    version(UseSDL) 
    102105    { 
     
    428431        auto array = cast(OGLVertexArrayBase)a; 
    429432        assert(array !is null); 
    430          
    431         array.bind(); 
    432          
     433 
    433434        debug statistics.triangles_rendered += (indices ? indices.length : array.length) / 3; 
    434435         
    435         array.format.set(array.offset()); 
     436        if(array !is currentArray) 
     437        { 
     438            statistics.array_format_changes++; 
     439         
     440            if(currentFormat !is null) 
     441                currentFormat.unset(); 
     442                 
     443            if(currentArray !is null) 
     444                currentArray.unbind(); 
     445 
     446            array.bind(); 
     447            array.format.set(array.offset()); 
     448        } 
     449         
     450        currentArray = array; 
     451        currentFormat = currentArray.format; 
    436452         
    437453        if(!indices) 
     
    440456            glDrawElements(primitiveMap[type], count == 0 ? indices.length : count,  
    441457                           GL_UNSIGNED_SHORT, (cast(OGLIndexBuffer)indices).buffer.ptr); 
    442           
    443         array.format.unset(); 
    444         array.unbind(); 
    445458    } 
    446459 
  • trunk/src/engine/rend/opengl/VertexArray.d

    r593 r594  
    1414    uint count; 
    1515    uint size; 
    16      
    17     ~this() 
    18     { 
    19         assert(format !is null); 
    20         delete format; 
    21     } 
    22      
     16 
    2317    uint numberVertices() 
    2418    { 
  • trunk/src/engine/rend/opengl/VertexBuffer.d

    r593 r594  
    33import tango.io.Stdout; 
    44 
     5import engine.util.Profiler; 
    56import engine.util.Memory; 
    67import engine.rend.VertexArray; 
     
    8081        bind(); 
    8182         
    82         /+if(!initialSet) 
     83        if(!initialSet) 
    8384        { 
    84             initialSet = true;+/ 
    85              
    86             //if(firstSet == 0 && lastSet == count * size) 
    87             //{ 
    88                 glBufferDataARB(GL_ARRAY_BUFFER_ARB, count * size, copy.ptr, 
    89                                 vertexArrayUsageMap[usage]); 
    90                  
    91                 return; 
    92             //} 
    93             //else 
    94             //  glBufferDataARB(GL_ARRAY_BUFFER_ARB, count * size, null, 
    95             //                  vertexArrayUsageMap[usage]); 
    96         //} 
    97         /+ 
    98         if(glBufferSubData !is null && false) 
     85            initialSet = true; 
     86     
     87            glBufferDataARB(GL_ARRAY_BUFFER_ARB, count * size, copy.ptr, 
     88                            vertexArrayUsageMap[usage]); 
     89            return; 
     90        } 
     91         
     92        if(GL_VBO.glBufferSubDataARB !is null) 
     93        { 
    9994            glBufferSubDataARB(GL_ARRAY_BUFFER, firstSet, lastSet - firstSet, 
    100                                copy[firstSet .. lastSet].ptr); 
     95                               copy[firstSet .. lastSet].ptr);       
     96        } 
    10197        else 
    10298        { 
     
    105101            buffer[firstSet .. lastSet] = copy[firstSet .. lastSet][]; 
    106102            glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); 
    107         }+/ 
     103        } 
    108104    } 
    109105     
  • trunk/src/engine/rend/opengl/VertexFormat.d

    r583 r594  
    2323     
    2424public: 
    25     mixin MAllocator; 
    26  
    2725    this(VertexFormat format) 
    2826    { 
    29         _elements.alloc(format.elements.length)
     27        _elements.length = format.elements.length
    3028         
    3129        foreach(i, element; format.elements) 
     
    6664        assert(_stride == format.vsize); 
    6765    } 
    68      
    69     ~this() 
    70     { 
    71         _elements.free(); 
    72     } 
    73      
     66 
    7467    VertexElement[] elements() 
    7568    { 
  • trunk/src/engine/util/Statistics.d

    r583 r594  
    5252    mixin(generateEntries("triangles rendered"[], 
    5353                          "frustum bbox checks"[], 
    54                           "frustum bsphere checks"[], 
    5554                          "texture changes"[], 
    5655                          "shader changes"[], 
    57                           "vertices skinned"[])); 
     56                          "vertices animated"[], 
     57                          "array format changes"[])); 
    5858     
    5959    void render(GuiRenderer renderer, vec2i pos, Font font)