Patch [#7743] Enable display lists when vertex arrays are enabled, by Ovidiu Sabou.
authorHamed Zaghaghi <hamed.zaghaghi@gmail.com>
Tue, 6 Nov 2007 18:39:16 +0000 (18:39 +0000)
committerHamed Zaghaghi <hamed.zaghaghi@gmail.com>
Tue, 6 Nov 2007 18:39:16 +0000 (18:39 +0000)
this patch enable GE two use both vertex array and display lists. and speed up the engine a little, by the way thanks ovidiu.

source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/GamePlayer/ghost/GPG_Application.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h

index 80db437bcd999d1cc772b84ced7e9c896ab23b97..4ae5ab67270a7df636ff27c3196ce562392abe50 100644 (file)
@@ -176,9 +176,13 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
                
                bool lock_arrays = (displaylists && useVertexArrays);
 
-               if(displaylists && !useVertexArrays)
-                       rasterizer = new RAS_ListRasterizer(canvas);
-               else if (useVertexArrays && bgl::QueryVersion(1, 1))
+               if(displaylists){
+                       if (useVertexArrays) {
+                               rasterizer = new RAS_ListRasterizer(canvas, true, lock_arrays);
+                       } else {
+                               rasterizer = new RAS_ListRasterizer(canvas);
+                       }
+               } else if (useVertexArrays && bgl::QueryVersion(1, 1))
                        rasterizer = new RAS_VAOpenGLRasterizer(canvas, lock_arrays);
                else
                        rasterizer = new RAS_OpenGLRasterizer(canvas);
@@ -663,4 +667,4 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
 
        } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME);
        if (bfd) BLO_blendfiledata_free(bfd);
-}
\ No newline at end of file
+}
index 0d2aa774394601212ae0916043eebc5236376b85..daded7a1d255e8fb7bbd1cc7f87bc17433e74e38 100644 (file)
@@ -533,7 +533,11 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
                        goto initFailed;
                
                if(useLists)
-                       m_rasterizer = new RAS_ListRasterizer(m_canvas);
+                       if (useVertexArrays) {
+                               m_rasterizer = new RAS_ListRasterizer(m_canvas, true);
+                       } else {
+                               m_rasterizer = new RAS_ListRasterizer(m_canvas);
+                       }
                else if (useVertexArrays && bgl::QueryVersion(1, 1))
                        m_rasterizer = new RAS_VAOpenGLRasterizer(m_canvas);
                else
index ed4cfb2ae429b0345675f1257ea5b6e4735bce3d..7baa6c496563fd44dd5903c7b839578538f8e12f 100644 (file)
@@ -96,8 +96,9 @@ bool RAS_ListSlot::End()
 
 
 
-RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas)
-:      RAS_OpenGLRasterizer(canvas)
+RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas, bool useVertexArrays, bool lock)
+:      RAS_VAOpenGLRasterizer(canvas, lock),
+       mUseVertexArrays(useVertexArrays)
 {
        // --
 }
@@ -159,13 +160,22 @@ void RAS_ListRasterizer::IndexPrimitives(
                if(localSlot->End()) 
                        return;
        }
-
-       RAS_OpenGLRasterizer::IndexPrimitives(
-                       vertexarrays, indexarrays,
-                       mode, polymat,
-                       rendertools, useObjectColor,
-                       rgbacolor,slot
-       );
+       
+       if (mUseVertexArrays) {
+               RAS_VAOpenGLRasterizer::IndexPrimitives(
+                               vertexarrays, indexarrays,
+                               mode, polymat,
+                               rendertools, useObjectColor,
+                               rgbacolor,slot
+               );
+       } else {
+               RAS_OpenGLRasterizer::IndexPrimitives(
+                               vertexarrays, indexarrays,
+                               mode, polymat,
+                               rendertools, useObjectColor,
+                               rgbacolor,slot
+               );
+       }
 
        if(!useObjectColor) {
                localSlot->EndList();
@@ -195,16 +205,53 @@ void RAS_ListRasterizer::IndexPrimitivesMulti(
                        return;
        }
 
-       RAS_OpenGLRasterizer::IndexPrimitivesMulti(
-                       vertexarrays, indexarrays,
-                       mode, polymat,
-                       rendertools, useObjectColor,
-                       rgbacolor,slot
-       );
+       if (mUseVertexArrays) {
+               RAS_VAOpenGLRasterizer::IndexPrimitivesMulti(
+                               vertexarrays, indexarrays,
+                               mode, polymat,
+                               rendertools, useObjectColor,
+                               rgbacolor,slot
+               );
+       } else {
+               RAS_OpenGLRasterizer::IndexPrimitivesMulti(
+                               vertexarrays, indexarrays,
+                               mode, polymat,
+                               rendertools, useObjectColor,
+                               rgbacolor,slot
+               );
+       }
+
        if(!useObjectColor) {
                localSlot->EndList();
                *slot = localSlot;
        }
 }
 
+bool RAS_ListRasterizer::Init(void)
+{
+       if (mUseVertexArrays) {
+               return RAS_VAOpenGLRasterizer::Init();
+       } else {
+               return RAS_OpenGLRasterizer::Init();
+       }
+}
+
+void RAS_ListRasterizer::SetDrawingMode(int drawingmode)
+{
+       if (mUseVertexArrays) {
+               RAS_VAOpenGLRasterizer::SetDrawingMode(drawingmode);
+       } else {
+               RAS_OpenGLRasterizer::SetDrawingMode(drawingmode);
+       }
+}
+
+void RAS_ListRasterizer::Exit()
+{
+       if (mUseVertexArrays) {
+               RAS_VAOpenGLRasterizer::Exit();
+       } else {
+               RAS_OpenGLRasterizer::Exit();
+       }
+}
+
 // eof
index 82840cd1399de41d019f00b5f09096df9f6c5376..f25f621f70cc4fbfcee4d9deee16630270ac3fc7 100644 (file)
@@ -2,7 +2,7 @@
 #define __RAS_LISTRASTERIZER_H__
 
 #include "RAS_MaterialBucket.h"
-#include "RAS_OpenGLRasterizer.h"
+#include "RAS_VAOpenGLRasterizer.h"
 #include <vector>
 
 class RAS_ListSlot : public KX_ListSlot
@@ -33,15 +33,16 @@ enum RAS_ListSlotFlags      {
 
 typedef std::map<const vecVertexArray, RAS_ListSlot*> RAS_Lists;
 
-class RAS_ListRasterizer : public RAS_OpenGLRasterizer
+class RAS_ListRasterizer : public RAS_VAOpenGLRasterizer
 {
+       bool mUseVertexArrays;
        RAS_Lists mLists;
 
        RAS_ListSlot* FindOrAdd(const vecVertexArray& vertexarrays, KX_ListSlot** slot);
        void ReleaseAlloc();
 
 public:
-       RAS_ListRasterizer(RAS_ICanvas* canvas);
+       RAS_ListRasterizer(RAS_ICanvas* canvas, bool useVertexArrays=false, bool lock=false);
        virtual ~RAS_ListRasterizer();
 
        virtual void IndexPrimitives(
@@ -66,6 +67,11 @@ public:
                        class KX_ListSlot** slot
        );
 
+       virtual bool    Init();
+       virtual void    Exit();
+
+       virtual void    SetDrawingMode(int drawingmode);
+
        virtual bool    QueryLists(){return true;}
 };