diff --git a/release/scripts/startup/bl_ui/properties_game.py b/release/scripts/startup/bl_ui/properties_game.py index 6b72830c875e..bc3e6a897eab 100644 --- a/release/scripts/startup/bl_ui/properties_game.py +++ b/release/scripts/startup/bl_ui/properties_game.py @@ -404,30 +404,21 @@ def draw(self, context): layout = self.layout gs = context.scene.game_settings - col = layout.column() - row = col.row() - col = row.column() + split = layout.split(percentage=0.4) + + col = split.column() col.prop(gs, "use_frame_rate") col.prop(gs, "use_restrict_animation_updates") - col = row.column() - col.prop(gs, "use_display_lists") - col.active = gs.raster_storage != 'VERTEX_BUFFER_OBJECT' - - row = layout.row() - row.prop(gs, "vsync") - row = layout.row() - row.prop(gs, "raster_storage") - - row = layout.row() - row.prop(gs, "samples") - - row = layout.row() - row.prop(gs, "hdr") + col = split.column() + col.prop(gs, "vsync") + col.prop(gs, "samples") + col.prop(gs, "hdr") row = layout.row() - row.label("Exit Key") - row.prop(gs, "exit_key", text="", event=True) + col = row.column() + col.label("Exit Key:") + col.prop(gs, "exit_key", text="", event=True) class RENDER_PT_game_display(RenderButtonsPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 1dc649938b3a..fb88a4181110 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -674,7 +674,7 @@ def draw(self, context): col.prop(game, "face_orientation", text="") col.label(text="Alpha Blend:") col.prop(game, "alpha_blend", text="") - + col = split.column() col.label(text="Constant Values:") col.prop(mat, "use_constant_material") @@ -683,15 +683,6 @@ def draw(self, context): col.prop(mat, "use_constant_world") col.prop(mat, "use_constant_mist") - col = layout.column() - col.label(text="Storage:") - - row = col.row() - row.prop(game, "storage", text="") - col = row.column() - col.active = game.storage not in ("VERTEX_BUFFER_OBJECT", "SCENE") - col.prop(game, "use_display_lists") - class MATERIAL_PT_strand(MaterialButtonsPanel, Panel): bl_label = "Strand" bl_options = {'DEFAULT_CLOSED'} diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index c5210d19073b..cf41f2e45011 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -201,8 +201,6 @@ void BKE_material_init(Material *ma) ma->game.flag = GEMAT_BACKCULL; ma->game.alpha_blend = 0; ma->game.face_orientation = 0; - ma->game.storage = GAME_STORAGE_SCENE; - ma->game.storage_flag = 0; ma->depthtranspfactor = 1.0f; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index aaaa1b9dc363..2be685a4ec87 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -713,9 +713,6 @@ void BKE_scene_init(Scene *sce) sce->gm.angulardeactthreshold = 1.0f; sce->gm.deactivationtime = 0.0f; - sce->gm.raster_storage = GAME_STORAGE_VA; - sce->gm.flag = GAME_DISPLAY_LISTS; - sce->gm.obstacleSimulation = OBSTSIMULATION_NONE; sce->gm.levelHeight = 2.f; diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 7cc8f9c38644..4e672c3a3fc0 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -1099,8 +1099,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) sce->gm.flag |= GAME_GLSL_NO_ENV_LIGHTING; if (fd->fileflags & G_FILE_IGNORE_DEPRECATION_WARNINGS) sce->gm.flag |= GAME_IGNORE_DEPRECATION_WARNINGS; - - sce->gm.flag |= GAME_DISPLAY_LISTS; } for (ob = main->object.first; ob; ob = ob->id.next) { diff --git a/source/blender/blenloader/intern/versioning_upbge.c b/source/blender/blenloader/intern/versioning_upbge.c index e841ea790853..cd46562cda11 100644 --- a/source/blender/blenloader/intern/versioning_upbge.c +++ b/source/blender/blenloader/intern/versioning_upbge.c @@ -91,24 +91,12 @@ void blo_do_versions_upbge(FileData *fd, Library *UNUSED(lib), Main *main) } } if (!MAIN_VERSION_UPBGE_ATLEAST(main, 0, 10)) { - if (!DNA_struct_elem_find(fd->filesdna, "GameSettings", "short", "storage")) { - for (Material *ma = main->mat.first; ma; ma = ma->id.next) { - ma->game.storage = GAME_STORAGE_SCENE; - } - } - if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "depthtranspfactor")) { for (Material *ma = main->mat.first; ma; ma = ma->id.next) { ma->depthtranspfactor = 1.0f; } } - for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { - if (scene->gm.raster_storage == GAME_STORAGE_AUTO || scene->gm.raster_storage == GAME_STORAGE_IMMEDIATE) { - scene->gm.raster_storage = GAME_STORAGE_VA; - } - } - if (!DNA_struct_elem_find(fd->filesdna, "EnvMap", "short", "flag")) { for (Tex *tex = main->tex.first; tex; tex = tex->id.next) { if (tex->env) { diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index d828ff65ee70..afaa7e0b910b 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -80,8 +80,7 @@ typedef struct GameSettings { int flag; int alpha_blend; int face_orientation; - short storage; - short storage_flag; + int pad; } GameSettings; typedef struct TexPaintSlot { @@ -251,17 +250,6 @@ typedef struct Material { #define MA_CONSTANT_WORLD (1 << 3) #define MA_CONSTANT_MIST (1 << 4) -/* Raster storage */ -#ifdef DNA_DEPRECATED -# define GAME_STORAGE_AUTO 0 -# define GAME_STORAGE_IMMEDIATE 1 -#endif -#define GAME_STORAGE_VA 2 -#define GAME_STORAGE_VBO 3 -#define GAME_STORAGE_SCENE 4 - -#define GEMAT_DISPLAY_LISTS (1 << 0) - /* flag */ /* for render */ #define MA_IS_USED 1 diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 36b5f1b87b9e..02847262f34c 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -845,7 +845,7 @@ typedef struct GameData { * bit 5: (gameengine) : enable Bullet DBVT tree for view frustum culling */ int flag; - short mode, pad1; + short mode; short occlusionRes; /* resolution of occlusion Z buffer in pixel */ short physicsEngine; short exitkey; @@ -853,13 +853,12 @@ typedef struct GameData { short vsync; /* Controls vsync: off, on, or adaptive (if supported) */ short ticrate, maxlogicstep, physubstep, maxphystep; short obstacleSimulation; - short raster_storage; float levelHeight; float deactivationtime, lineardeactthreshold, angulardeactthreshold; /* Scene LoD */ short lodflag, pad2; - int scehysteresis, pad5; + int scehysteresis; } GameData; @@ -894,7 +893,6 @@ typedef struct GameData { #define GAME_SHOW_DEBUG_PROPS (1 << 2) #define GAME_SHOW_FRAMERATE (1 << 3) #define GAME_SHOW_PHYSICS (1 << 4) -#define GAME_DISPLAY_LISTS (1 << 5) #define GAME_GLSL_NO_LIGHTS (1 << 6) #define GAME_GLSL_NO_SHADERS (1 << 7) #define GAME_GLSL_NO_SHADOWS (1 << 8) diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 961041bf9b85..2f7616858184 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -898,14 +898,6 @@ static void rna_def_material_gamesettings(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem storage_items[] = { - {GAME_STORAGE_VA, "VERTEX_ARRAY", 0, "Vertex Arrays", "Usually the best choice (good performance with display lists)"}, - {GAME_STORAGE_VBO, "VERTEX_BUFFER_OBJECT", 0, "Vertex Buffer Objects", - "Typically slower than vertex arrays with display lists, requires at least OpenGL 1.4"}, - {GAME_STORAGE_SCENE, "SCENE", 0, "Scene Default", "Use scene storage mode"}, - {0, NULL, 0, NULL, NULL} - }; - srna = RNA_def_struct(brna, "MaterialGameSettings", NULL); RNA_def_struct_sdna(srna, "GameSettings"); RNA_def_struct_nested(brna, srna, "Material"); @@ -930,16 +922,6 @@ static void rna_def_material_gamesettings(BlenderRNA *brna) prop = RNA_def_property(srna, "face_orientation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_face_orientation_items); RNA_def_property_ui_text(prop, "Face Orientations", "Especial face orientation options"); - - prop = RNA_def_property(srna, "storage", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "storage"); - RNA_def_property_enum_items(prop, storage_items); - RNA_def_property_ui_text(prop, "Storage", "Set the storage mode used by the rasterizer"); - - prop = RNA_def_property(srna, "use_display_lists", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "storage_flag", GEMAT_DISPLAY_LISTS); - RNA_def_property_ui_text(prop, "Display Lists", - "Use display lists to speed up rendering by keeping geometry on the GPU"); } static void rna_def_material_colors(StructRNA *srna) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index f5e4e4ccb377..ce1171d1720a 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2256,7 +2256,7 @@ static void rna_def_gpencil_brush(BlenderRNA *brna) RNA_def_property_range(prop, -M_PI_2, M_PI_2); RNA_def_property_ui_text(prop, "Angle", "Direction of the stroke at which brush gives maximal thickness " - "(0° for horizontal)"); + "(0?? for horizontal)"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); /* Factor to change brush size depending of angle */ @@ -4422,12 +4422,6 @@ static void rna_def_scene_game_data(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem storage_items[] = { - {GAME_STORAGE_VA, "VERTEX_ARRAY", 0, "Vertex Arrays", "Usually the best choice (good performance with display lists)"}, - {GAME_STORAGE_VBO, "VERTEX_BUFFER_OBJECT", 0, "Vertex Buffer Objects", - "Typically slower than vertex arrays with display lists, requires at least OpenGL 1.4"}, - {0, NULL, 0, NULL, NULL}}; - srna = RNA_def_struct(brna, "SceneGameData", NULL); RNA_def_struct_sdna(srna, "GameData"); RNA_def_struct_nested(brna, srna, "Scene"); @@ -4477,13 +4471,7 @@ static void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_property_enum_funcs(prop, NULL, "rna_GameSettings_exit_key_set", NULL); RNA_def_property_ui_text(prop, "Exit Key", "The key that exits the Game Engine"); RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "raster_storage", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "raster_storage"); - RNA_def_property_enum_items(prop, storage_items); - RNA_def_property_ui_text(prop, "Storage", "Set the storage mode used by the rasterizer"); - RNA_def_property_update(prop, NC_SCENE, NULL); - + /* Do we need it here ? (since we already have it in World */ prop = RNA_def_property(srna, "frequency", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "freqplay"); @@ -4677,11 +4665,6 @@ static void rna_def_scene_game_data(BlenderRNA *brna) "Respect the frame rate from the Physics panel in the world properties " "rather than rendering as many frames as possible"); - prop = RNA_def_property(srna, "use_display_lists", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_DISPLAY_LISTS); - RNA_def_property_ui_text(prop, "Display Lists", - "Use display lists to speed up rendering by keeping geometry on the GPU"); - prop = RNA_def_property(srna, "use_deprecation_warnings", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_IGNORE_DEPRECATION_WARNINGS); RNA_def_property_ui_text(prop, "Deprecation Warnings", diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 5b7f88252cc3..1cfc95233062 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -84,30 +84,6 @@ KX_BlenderMaterial::KX_BlenderMaterial( ME_MTEXFACE_CPY(m_mtexPoly, mtface); } - short storage = game->storage; - // If the material storage is set to RAS_STORE_SCENE then we use the storage set in scene. - if (storage == GAME_STORAGE_SCENE) { - Scene *blenderScene = scene->GetBlenderScene(); - storage = blenderScene->gm.raster_storage; - m_flag |= (blenderScene->gm.flag & GAME_DISPLAY_LISTS) ? RAS_DISPLAYLISTS : 0; - } - else { - m_flag |= (game->storage_flag & GEMAT_DISPLAY_LISTS) ? RAS_DISPLAYLISTS : 0; - } - - switch (storage) { - case GAME_STORAGE_VA: - { - m_storageType = RAS_IRasterizer::RAS_STORAGE_VA; - break; - } - case GAME_STORAGE_VBO: - { - m_storageType = RAS_IRasterizer::RAS_STORAGE_VBO; - break; - } - }; - // with ztransp enabled, enforce alpha blending mode if ((mat->mode & MA_TRANSP) && (mat->mode & MA_ZTRANSP) && (m_alphablend == GEMAT_SOLID)) { m_alphablend = GEMAT_ALPHA; diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp index f976505c10c2..0c0cafa6d7c5 100644 --- a/source/gameengine/Ketsji/KX_FontObject.cpp +++ b/source/gameengine/Ketsji/KX_FontObject.cpp @@ -137,7 +137,7 @@ void KX_FontObject::AddMeshUser() RAS_TexVertFormat format; format.uvSize = 1; format.colorSize = 1; - bucket->AddMesh(NULL, NULL, format); + bucket->NewMesh(NULL, NULL, format); } /* We copy the original mesh slot which is at the begin of the list, if it's not the case it diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt index 6d30db18c818..0b516456c295 100644 --- a/source/gameengine/Rasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/CMakeLists.txt @@ -84,7 +84,7 @@ set(SRC RAS_IDisplayArray.h RAS_IPolygonMaterial.h RAS_IRasterizer.h - RAS_IStorage.h + RAS_IStorageInfo.h RAS_ILightObject.h RAS_InstancingBuffer.h RAS_ISync.h diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 329e92b6431d..97fff94d4575 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -174,11 +174,11 @@ void RAS_BucketManager::RenderSortedBuckets(const MT_Transform& cameratrans, RAS RAS_DisplayArrayBucket *displayArrayBucket = sit->m_ms->m_displayArrayBucket; /* Unbind display array here before unset material to use the proper - * number of attributs in RAS_IStorage::Unbind since this variable is + * number of attributs in storage unbind since this variable is * global and mutated by all material during its activation. */ if (displayArrayBucket != lastDisplayArrayBucket && lastDisplayArrayBucket) { - rasty->UnbindPrimitives(lastDisplayArrayBucket->GetStorageType(), lastDisplayArrayBucket); + rasty->UnbindPrimitives(lastDisplayArrayBucket); } if (bucket != lastMaterialBucket) { if (matactivated) { @@ -192,7 +192,7 @@ void RAS_BucketManager::RenderSortedBuckets(const MT_Transform& cameratrans, RAS * proper attributs numbers, same as display array unbind before. */ if (displayArrayBucket != lastDisplayArrayBucket) { - rasty->BindPrimitives(displayArrayBucket->GetStorageType(), displayArrayBucket); + rasty->BindPrimitives(displayArrayBucket); lastDisplayArrayBucket = displayArrayBucket; } @@ -200,7 +200,7 @@ void RAS_BucketManager::RenderSortedBuckets(const MT_Transform& cameratrans, RAS } // Always unbind VBO or VA before unset the material to use the correct material attributs. - rasty->UnbindPrimitives(lastDisplayArrayBucket->GetStorageType(), lastDisplayArrayBucket); + rasty->UnbindPrimitives(lastDisplayArrayBucket); if (matactivated) { lastMaterialBucket->DesactivateMaterial(rasty); diff --git a/source/gameengine/Rasterizer/RAS_DisplayArrayBucket.cpp b/source/gameengine/Rasterizer/RAS_DisplayArrayBucket.cpp index ab7d3eed8f22..3680081a5a3a 100644 --- a/source/gameengine/Rasterizer/RAS_DisplayArrayBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_DisplayArrayBucket.cpp @@ -36,7 +36,7 @@ #include "RAS_MeshObject.h" #include "RAS_Deformer.h" #include "RAS_IRasterizer.h" -#include "RAS_IStorage.h" +#include "RAS_IStorageInfo.h" #include "RAS_InstancingBuffer.h" #include "RAS_BucketManager.h" @@ -251,11 +251,6 @@ void RAS_DisplayArrayBucket::DestructStorageInfo() } } -RAS_IRasterizer::StorageType RAS_DisplayArrayBucket::GetStorageType() const -{ - return m_bucket->GetPolyMaterial()->GetStorageType(); -} - void RAS_DisplayArrayBucket::GenerateAttribLayers() { if (!m_mesh) { @@ -281,15 +276,14 @@ void RAS_DisplayArrayBucket::RenderMeshSlots(const MT_Transform& cameratrans, RA // Update deformer and render settings. UpdateActiveMeshSlots(rasty); - const RAS_IRasterizer::StorageType storage = GetStorageType(); - rasty->BindPrimitives(storage, this); + rasty->BindPrimitives(this); for (RAS_MeshSlotList::iterator it = m_activeMeshSlots.begin(), end = m_activeMeshSlots.end(); it != end; ++it) { RAS_MeshSlot *ms = *it; m_bucket->RenderMeshSlot(cameratrans, rasty, ms); } - rasty->UnbindPrimitives(storage, this); + rasty->UnbindPrimitives(this); } void RAS_DisplayArrayBucket::RenderMeshSlotsInstancing(const MT_Transform& cameratrans, RAS_IRasterizer *rasty, bool alpha) @@ -365,10 +359,9 @@ void RAS_DisplayArrayBucket::RenderMeshSlotsInstancing(const MT_Transform& camer // Unbind the buffer to avoid conflict with the render after. m_instancingBuffer->Unbind(); - const RAS_IRasterizer::StorageType storage = GetStorageType(); - rasty->BindPrimitives(storage, this); + rasty->BindPrimitives(this); - rasty->IndexPrimitivesInstancing(storage, this); + rasty->IndexPrimitivesInstancing(this); // Unbind vertex attributs. if (rasty->GetOverrideShader() == RAS_IRasterizer::RAS_OVERRIDE_SHADER_NONE) { material->DesactivateInstancing(); @@ -377,7 +370,7 @@ void RAS_DisplayArrayBucket::RenderMeshSlotsInstancing(const MT_Transform& camer rasty->DesactivateOverrideShaderInstancing(); } - rasty->UnbindPrimitives(storage, this); + rasty->UnbindPrimitives(this); } void RAS_DisplayArrayBucket::ChangeMaterialBucket(RAS_MaterialBucket *bucket) diff --git a/source/gameengine/Rasterizer/RAS_DisplayArrayBucket.h b/source/gameengine/Rasterizer/RAS_DisplayArrayBucket.h index 02294e0f50b3..89d8ed10189c 100644 --- a/source/gameengine/Rasterizer/RAS_DisplayArrayBucket.h +++ b/source/gameengine/Rasterizer/RAS_DisplayArrayBucket.h @@ -134,7 +134,6 @@ class RAS_DisplayArrayBucket RAS_IStorageInfo *GetStorageInfo() const; void SetStorageInfo(RAS_IStorageInfo *info); void DestructStorageInfo(); - RAS_IRasterizer::StorageType GetStorageType() const; /** Generate the attribute's layers for the used mesh and material couple. * WARNING: Always call when shader in the material are valid. diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp index 7a9b7f4f3148..2ec535db458f 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp @@ -40,8 +40,7 @@ RAS_IPolyMaterial::RAS_IPolyMaterial( :m_name(name), m_alphablend(0), m_rasMode(0), - m_flag(0), - m_storageType(RAS_IRasterizer::RAS_STORAGE_NONE) + m_flag(0) { if (game) { m_drawingmode = ConvertFaceMode(game); @@ -162,8 +161,3 @@ bool RAS_IPolyMaterial::UseDisplayLists() const { return (m_flag & RAS_DISPLAYLISTS); } - -RAS_IRasterizer::StorageType RAS_IPolyMaterial::GetStorageType() const -{ - return m_storageType; -} diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h index bef3f916ce0b..e917e7365913 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h @@ -88,9 +88,6 @@ class RAS_IPolyMaterial RAS_Texture *m_textures[RAS_Texture::MaxUnits]; - /// The storage type used to render with this material. - RAS_IRasterizer::StorageType m_storageType; - public: // care! these are taken from blender polygonflags, see file DNA_mesh_types.h for #define TF_BILLBOARD etc. @@ -127,7 +124,6 @@ class RAS_IPolyMaterial bool OnlyShadow() const; RAS_Texture *GetTexture(unsigned int index); bool UseDisplayLists() const; - RAS_IRasterizer::StorageType GetStorageType() const; virtual const STR_String& GetTextureName() const = 0; virtual Material *GetBlenderMaterial() const = 0; diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 3d38c7028e78..bfc459019b05 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -228,13 +228,6 @@ class RAS_IRasterizer RAS_STENCIL_BUFFER_BIT = 0x8 }; - enum StorageType { - RAS_STORAGE_NONE = -1, - RAS_STORAGE_VA = 0, - RAS_STORAGE_VBO, - RAS_STORAGE_MAX - }; - enum OffScreen { RAS_OFFSCREEN_COLOR = 0, RAS_OFFSCREEN_DEPTH = 1, @@ -446,19 +439,19 @@ class RAS_IRasterizer // Drawing Functions /// Set all pre render attributs for given display array bucket. - virtual void BindPrimitives(StorageType storage, RAS_DisplayArrayBucket *arrayBucket) = 0; + virtual void BindPrimitives(RAS_DisplayArrayBucket *arrayBucket) = 0; /// UnSet all pre render attributs for given display array bucket. - virtual void UnbindPrimitives(StorageType storage, RAS_DisplayArrayBucket *arrayBucket) = 0; + virtual void UnbindPrimitives(RAS_DisplayArrayBucket *arrayBucket) = 0; /** * IndexPrimitives: Renders primitives from mesh slot. */ - virtual void IndexPrimitives(StorageType storage, RAS_MeshSlot *ms) = 0; + virtual void IndexPrimitives(RAS_MeshSlot *ms) = 0; /** * Renders all primitives from mesh slots contained in this display array * bucket with the geometry instancing way. */ - virtual void IndexPrimitivesInstancing(StorageType storage, RAS_DisplayArrayBucket *arrayBucket) = 0; + virtual void IndexPrimitivesInstancing(RAS_DisplayArrayBucket *arrayBucket) = 0; /// Render text mesh slot using BLF functions. virtual void IndexPrimitivesText(RAS_MeshSlot *ms) = 0; diff --git a/source/gameengine/Rasterizer/RAS_IStorage.h b/source/gameengine/Rasterizer/RAS_IStorageInfo.h similarity index 52% rename from source/gameengine/Rasterizer/RAS_IStorage.h rename to source/gameengine/Rasterizer/RAS_IStorageInfo.h index de6396526e4e..7f2faad8842c 100644 --- a/source/gameengine/Rasterizer/RAS_IStorage.h +++ b/source/gameengine/Rasterizer/RAS_IStorageInfo.h @@ -15,31 +15,18 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. + * Contributor(s): Tristan Porteries. * * ***** END GPL LICENSE BLOCK ***** */ -#ifndef __KX_STORAGE -#define __KX_STORAGE +#ifndef __RAS_ISTORAGE_INFO_H__ +#define __RAS_ISTORAGE_INFO_H__ #include "RAS_IRasterizer.h" -#ifdef WITH_CXX_GUARDEDALLOC - #include "MEM_guardedalloc.h" -#endif - -class RAS_MeshSlot; -class RAS_DisplayArrayBucket; - /** This class is used to store special storage infos for an array - * like VBO/IBO ID for VBO storage or DL for VA storage. - * Currently it only exists for the virtual destructor. + * like VBO/IBO ID for VBO storage. */ class RAS_IStorageInfo { @@ -59,30 +46,4 @@ class RAS_IStorageInfo virtual void SetDataModified(RAS_IRasterizer::DrawType drawType, DataType dataType) = 0; }; -class RAS_IStorage -{ - -public: - virtual ~RAS_IStorage() - { - }; - - virtual bool Init() = 0; - virtual void Exit() = 0; - - virtual void BindPrimitives(RAS_DisplayArrayBucket *arrayBucket) = 0; - virtual void UnbindPrimitives(RAS_DisplayArrayBucket *arrayBucket) = 0; - - virtual void IndexPrimitives(RAS_MeshSlot *ms) = 0; - virtual void IndexPrimitivesInstancing(RAS_DisplayArrayBucket *arrayBucket) - { - } - - virtual void SetDrawingMode(RAS_IRasterizer::DrawType drawingmode) = 0; - -#ifdef WITH_CXX_GUARDEDALLOC - MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IStorage") -#endif -}; - -#endif //__KX_STORAGE +#endif // __RAS_ISTORAGE_INFO_H__ diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 12277fcda5fc..1caf14a137c9 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -83,7 +83,7 @@ bool RAS_MaterialBucket::UseInstancing() const return (m_material->UseInstancing()); } -RAS_MeshSlot *RAS_MaterialBucket::AddMesh(RAS_MeshObject *mesh, RAS_MeshMaterial *meshmat, const RAS_TexVertFormat& format) +RAS_MeshSlot *RAS_MaterialBucket::NewMesh(RAS_MeshObject *mesh, RAS_MeshMaterial *meshmat, const RAS_TexVertFormat& format) { RAS_MeshSlot *ms = new RAS_MeshSlot(); ms->init(this, mesh, meshmat, format); @@ -201,7 +201,7 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa rasty->IndexPrimitivesText(ms); } else { - rasty->IndexPrimitives(ms->m_displayArrayBucket->GetStorageType(), ms); + rasty->IndexPrimitives(ms); } rasty->PopMatrix(); diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h index 8bb60d384244..0c5f0eb416e1 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h @@ -66,7 +66,7 @@ class RAS_MaterialBucket RAS_MeshSlotList::iterator msBegin(); RAS_MeshSlotList::iterator msEnd(); - RAS_MeshSlot *AddMesh(RAS_MeshObject *mesh, RAS_MeshMaterial *meshmat, const RAS_TexVertFormat& format); + RAS_MeshSlot *NewMesh(RAS_MeshObject *mesh, RAS_MeshMaterial *meshmat, const RAS_TexVertFormat& format); RAS_MeshSlot *CopyMesh(RAS_MeshSlot *ms); void AddMesh(RAS_MeshSlot *ms); void RemoveMesh(RAS_MeshSlot *ms); diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index 8ab0c972124a..f61b1c27c5b5 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -272,7 +272,7 @@ RAS_MeshMaterial *RAS_MeshObject::AddMaterial(RAS_MaterialBucket *bucket, unsign m_materials.push_back(meshmat); meshmat->m_bucket = bucket; meshmat->m_index = index; - meshmat->m_baseslot = meshmat->m_bucket->AddMesh(this, meshmat, format); + meshmat->m_baseslot = meshmat->m_bucket->NewMesh(this, meshmat, format); } return meshmat; diff --git a/source/gameengine/Rasterizer/RAS_MeshSlot.cpp b/source/gameengine/Rasterizer/RAS_MeshSlot.cpp index 3efdaf796357..07f700f684d0 100644 --- a/source/gameengine/Rasterizer/RAS_MeshSlot.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshSlot.cpp @@ -91,8 +91,11 @@ void RAS_MeshSlot::init(RAS_MaterialBucket *bucket, RAS_MeshObject *mesh, m_mesh = mesh; m_meshMaterial = meshmat; - RAS_IDisplayArray::PrimitiveType type = (bucket->IsWire()) ? RAS_IDisplayArray::LINES : RAS_IDisplayArray::TRIANGLES; - m_displayArray = RAS_IDisplayArray::ConstructArray(type, format); + // Test if the mesh slot is not owned by a font object, no mesh. + if (mesh && meshmat) { + RAS_IDisplayArray::PrimitiveType type = (bucket->IsWire()) ? RAS_IDisplayArray::LINES : RAS_IDisplayArray::TRIANGLES; + m_displayArray = RAS_IDisplayArray::ConstructArray(type, format); + } m_displayArrayBucket = new RAS_DisplayArrayBucket(bucket, m_displayArray, m_mesh, meshmat); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt index c4841933e249..9df7a696e475 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt @@ -53,13 +53,11 @@ set(SRC RAS_OpenGLLight.cpp RAS_OpenGLSync.cpp RAS_OpenGLRasterizer.cpp - RAS_StorageVA.cpp RAS_StorageVBO.cpp RAS_OpenGLLight.h RAS_OpenGLSync.h RAS_OpenGLRasterizer.h - RAS_StorageVA.h RAS_StorageVBO.h ) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 609b565db921..211dfa3e0474 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -50,7 +50,6 @@ #include "RAS_OpenGLLight.h" #include "RAS_OpenGLSync.h" -#include "RAS_StorageVA.h" #include "RAS_StorageVBO.h" #include "GPU_draw.h" @@ -437,8 +436,7 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer() m_viewmatrix.setIdentity(); m_viewinvmatrix.setIdentity(); - m_storages[RAS_STORAGE_VA] = new RAS_StorageVA(&m_storageAttribs); - m_storages[RAS_STORAGE_VBO] = new RAS_StorageVBO(&m_storageAttribs); + m_storage = new RAS_StorageVBO(&m_storageAttribs); glGetIntegerv(GL_MAX_LIGHTS, (GLint *)&m_numgllights); if (m_numgllights < 8) @@ -449,9 +447,7 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer() RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer() { - for (unsigned short i = 0; i < RAS_STORAGE_MAX; ++i) { - delete m_storages[i]; - } + delete m_storage; } void RAS_OpenGLRasterizer::Enable(RAS_IRasterizer::EnableBit bit) @@ -492,10 +488,6 @@ void RAS_OpenGLRasterizer::Init() SetColorMask(true, true, true, true); glShadeModel(GL_SMOOTH); - - for (unsigned short i = 0; i < RAS_STORAGE_MAX; ++i) { - m_storages[i]->Init(); - } } void RAS_OpenGLRasterizer::SetAmbientColor(float color[3]) @@ -538,10 +530,6 @@ void RAS_OpenGLRasterizer::DisplayFog() void RAS_OpenGLRasterizer::Exit() { - for (unsigned short i = 0; i < RAS_STORAGE_MAX; ++i) { - m_storages[i]->Exit(); - } - Enable(RAS_CULL_FACE); Enable(RAS_DEPTH_TEST); @@ -614,9 +602,7 @@ void RAS_OpenGLRasterizer::SetDrawingMode(RAS_IRasterizer::DrawType drawingmode) { m_drawingmode = drawingmode; - for (unsigned short i = 0; i < RAS_STORAGE_MAX; ++i) { - m_storages[i]->SetDrawingMode(drawingmode); - } + m_storage->SetDrawingMode(drawingmode); } RAS_IRasterizer::DrawType RAS_OpenGLRasterizer::GetDrawingMode() @@ -1240,35 +1226,35 @@ void RAS_OpenGLRasterizer::SetAttribLayers(const RAS_IRasterizer::AttribLayerLis m_storageAttribs.layers = layers; } -void RAS_OpenGLRasterizer::BindPrimitives(StorageType storage, RAS_DisplayArrayBucket *arrayBucket) +void RAS_OpenGLRasterizer::BindPrimitives(RAS_DisplayArrayBucket *arrayBucket) { - if (arrayBucket && arrayBucket->GetDisplayArray() && storage != RAS_STORAGE_NONE) { + if (arrayBucket && arrayBucket->GetDisplayArray()) { // Set the proper uv layer for uv attributes. arrayBucket->SetAttribLayers(this); - m_storages[storage]->BindPrimitives(arrayBucket); + m_storage->BindPrimitives(arrayBucket); } } -void RAS_OpenGLRasterizer::UnbindPrimitives(StorageType storage, RAS_DisplayArrayBucket *arrayBucket) +void RAS_OpenGLRasterizer::UnbindPrimitives(RAS_DisplayArrayBucket *arrayBucket) { - if (arrayBucket && arrayBucket->GetDisplayArray() && storage != RAS_STORAGE_NONE) { - m_storages[storage]->UnbindPrimitives(arrayBucket); + if (arrayBucket && arrayBucket->GetDisplayArray()) { + m_storage->UnbindPrimitives(arrayBucket); } } -void RAS_OpenGLRasterizer::IndexPrimitives(StorageType storage, RAS_MeshSlot *ms) +void RAS_OpenGLRasterizer::IndexPrimitives(RAS_MeshSlot *ms) { if (ms->m_pDerivedMesh) { DrawDerivedMesh(ms); } - else if (storage != RAS_STORAGE_NONE) { - m_storages[storage]->IndexPrimitives(ms); + else { + m_storage->IndexPrimitives(ms); } } -void RAS_OpenGLRasterizer::IndexPrimitivesInstancing(StorageType storage, RAS_DisplayArrayBucket *arrayBucket) +void RAS_OpenGLRasterizer::IndexPrimitivesInstancing(RAS_DisplayArrayBucket *arrayBucket) { - m_storages[storage]->IndexPrimitivesInstancing(arrayBucket); + m_storage->IndexPrimitivesInstancing(arrayBucket); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 50c9ddd08633..c310556bce1d 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -46,7 +46,7 @@ #include "BLI_utildefines.h" -class RAS_IStorage; +class RAS_StorageVBO; class RAS_ICanvas; class RAS_OpenGLLight; struct GPUOffScreen; @@ -217,9 +217,7 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer OverrideShaderType m_overrideShader; - /* Making use of a Strategy design pattern for storage behavior. - * Examples of concrete strategies: Vertex Arrays, VBOs, Immediate Mode*/ - RAS_IStorage *m_storages[RAS_STORAGE_MAX]; + RAS_StorageVBO *m_storage; /// Initialize custom shader interface containing uniform location. void InitOverrideShadersInterface(); @@ -276,10 +274,10 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer virtual RAS_ISync *CreateSync(int type); virtual void SwapBuffers(RAS_ICanvas *canvas); - virtual void BindPrimitives(StorageType storage, RAS_DisplayArrayBucket *arrayBucket); - virtual void UnbindPrimitives(StorageType storage, RAS_DisplayArrayBucket *arrayBucket); - virtual void IndexPrimitives(StorageType storage, RAS_MeshSlot *ms); - virtual void IndexPrimitivesInstancing(StorageType storage, RAS_DisplayArrayBucket *arrayBucket); + virtual void BindPrimitives(RAS_DisplayArrayBucket *arrayBucket); + virtual void UnbindPrimitives(RAS_DisplayArrayBucket *arrayBucket); + virtual void IndexPrimitives(RAS_MeshSlot *ms); + virtual void IndexPrimitivesInstancing(RAS_DisplayArrayBucket *arrayBucket); virtual void IndexPrimitivesText(RAS_MeshSlot *ms); virtual void DrawDerivedMesh(class RAS_MeshSlot *ms); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp deleted file mode 100644 index 684c95a13458..000000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "RAS_StorageVA.h" -#include "RAS_IPolygonMaterial.h" -#include "RAS_DisplayArray.h" -#include "RAS_MaterialBucket.h" -#include "RAS_MeshUser.h" - -#include "glew-mx.h" - -RAS_DisplayList::RAS_DisplayList() -{ - for (unsigned short i = 0; i < RAS_IRasterizer::RAS_DRAW_MAX; ++i) { - for (unsigned short j = 0; j < NUM_LIST; ++j) { - m_list[i][j] = -1; - } - } -} - -RAS_DisplayList::~RAS_DisplayList() -{ - for (unsigned short i = 0; i < RAS_IRasterizer::RAS_DRAW_MAX; ++i) { - RemoveAllList((RAS_IRasterizer::DrawType)i); - } -} - -void RAS_DisplayList::RemoveAllList(RAS_IRasterizer::DrawType drawmode) -{ - for (unsigned short j = 0; j < NUM_LIST; ++j) { - int list = m_list[drawmode][j]; - if (list != -1) { - glDeleteLists(list, 1); - } - m_list[drawmode][j] = -1; - } -} - -void RAS_DisplayList::SetDataModified(RAS_IRasterizer::DrawType drawmode, DataType dataType) -{ - RemoveAllList(drawmode); -} - -bool RAS_DisplayList::Draw(RAS_IRasterizer::DrawType drawmode, LIST_TYPE type) -{ - int list = m_list[drawmode][type]; - if (list == -1) { - m_list[drawmode][type] = list = glGenLists(1); - glNewList(list, GL_COMPILE); - - return false; - } - - glCallList(list); - - return true; -} - -void RAS_DisplayList::End(RAS_IRasterizer::DrawType drawmode, LIST_TYPE type) -{ - glEndList(); - glCallList(m_list[drawmode][type]); -} - -RAS_StorageVA::RAS_StorageVA(RAS_OpenGLRasterizer::StorageAttribs *storageAttribs) - :m_drawingmode(RAS_IRasterizer::RAS_TEXTURED), - m_storageAttribs(storageAttribs) -{ -} - -RAS_StorageVA::~RAS_StorageVA() -{ -} - -bool RAS_StorageVA::Init() -{ - return true; -} - -void RAS_StorageVA::Exit() -{ -} - -void RAS_StorageVA::BindPrimitives(RAS_DisplayArrayBucket *arrayBucket) -{ - RAS_DisplayList *displayList = GetDisplayList(arrayBucket); - if (displayList && displayList->Draw(m_drawingmode, RAS_DisplayList::BIND_LIST)) { - return; - } - - RAS_IDisplayArray *array = arrayBucket->GetDisplayArray(); - bool wireframe = m_drawingmode <= RAS_IRasterizer::RAS_WIREFRAME; - const RAS_ITexVert *vertexarray = array->GetVertexPointer(); - const unsigned int stride = array->GetVertexMemorySize(); - - if (!wireframe) - EnableTextures(true); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_NORMAL_ARRAY); - - glVertexPointer(3, GL_FLOAT, stride, vertexarray->getXYZ()); - glNormalPointer(GL_FLOAT, stride, vertexarray->getNormal()); - - if (!wireframe) { - glEnableClientState(GL_COLOR_ARRAY); - glColorPointer(4, GL_UNSIGNED_BYTE, stride, vertexarray->getRGBA(0)); - TexCoordPtr(vertexarray, stride); - } - - if (displayList) { - displayList->End(m_drawingmode, RAS_DisplayList::BIND_LIST); - } -} - -void RAS_StorageVA::UnbindPrimitives(RAS_DisplayArrayBucket *arrayBucket) -{ - RAS_DisplayList *displayList = GetDisplayList(arrayBucket); - if (displayList && displayList->Draw(m_drawingmode, RAS_DisplayList::UNBIND_LIST)) { - return; - } - - bool wireframe = m_drawingmode <= RAS_IRasterizer::RAS_WIREFRAME; - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - if (!wireframe) { - glDisableClientState(GL_COLOR_ARRAY); - EnableTextures(false); - } - - if (displayList) { - displayList->End(m_drawingmode, RAS_DisplayList::UNBIND_LIST); - } - -} - -void RAS_StorageVA::IndexPrimitives(RAS_MeshSlot *ms) -{ - RAS_DisplayArrayBucket *arrayBucket = ms->m_displayArrayBucket; - - RAS_DisplayList *displayList = GetDisplayList(arrayBucket); - if (displayList && displayList->Draw(m_drawingmode, RAS_DisplayList::DRAW_LIST)) { - return; - } - - bool wireframe = m_drawingmode <= RAS_IRasterizer::RAS_WIREFRAME; - RAS_IDisplayArray *array = ms->GetDisplayArray(); - RAS_IPolyMaterial *material = ms->m_bucket->GetPolyMaterial(); - - // colors - if (!wireframe && material->UsesObjectColor()) { - const MT_Vector4& rgba = ms->m_meshUser->GetColor(); - glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]); - } - else - glColor4f(0.0f, 0.0f, 0.0f, 1.0f); - - // here the actual drawing takes places - glDrawElements(array->GetOpenGLPrimitiveType(), array->GetIndexCount(), GL_UNSIGNED_INT, array->GetIndexPointer()); - - if (displayList) { - displayList->End(m_drawingmode, RAS_DisplayList::DRAW_LIST); - } -} - -void RAS_StorageVA::IndexPrimitivesInstancing(RAS_DisplayArrayBucket *arrayBucket) -{ - RAS_IDisplayArray *array = arrayBucket->GetDisplayArray(); - - // here the actual drawing takes places - glDrawElementsInstancedARB(array->GetOpenGLPrimitiveType(), array->GetIndexCount(), GL_UNSIGNED_INT, array->GetIndexPointer(), arrayBucket->GetNumActiveMeshSlots()); -} - -RAS_DisplayList *RAS_StorageVA::GetDisplayList(RAS_DisplayArrayBucket *arrayBucket) -{ - if (!arrayBucket->UseDisplayList()) { - return NULL; - } - - RAS_DisplayList *displayList = (RAS_DisplayList *)arrayBucket->GetStorageInfo(); - if (!displayList) { - displayList = new RAS_DisplayList(); - arrayBucket->SetStorageInfo(displayList); - } - - return displayList; -} - -void RAS_StorageVA::TexCoordPtr(const RAS_ITexVert *tv, const unsigned int stride) -{ - // Can be NULL for empty display arrays. - if (!tv) { - return; - } - - /* note: this function must closely match EnableTextures to enable/disable - * the right arrays, otherwise coordinate and attribute pointers from other - * materials can still be used and cause crashes */ - - for (unsigned short unit = 0, size = m_storageAttribs->texcos.size(); unit < size; ++unit) { - glClientActiveTextureARB(GL_TEXTURE0_ARB + unit); - switch (m_storageAttribs->texcos[unit]) { - case RAS_IRasterizer::RAS_TEXCO_ORCO: - case RAS_IRasterizer::RAS_TEXCO_GLOB: - { - glTexCoordPointer(3, GL_FLOAT, stride, tv->getXYZ()); - break; - } - case RAS_IRasterizer::RAS_TEXCO_UV: - { - glTexCoordPointer(2, GL_FLOAT, stride, tv->getUV(unit)); - break; - } - case RAS_IRasterizer::RAS_TEXCO_NORM: - { - glTexCoordPointer(3, GL_FLOAT, stride, tv->getNormal()); - break; - } - case RAS_IRasterizer::RAS_TEXTANGENT: - { - glTexCoordPointer(4, GL_FLOAT, stride, tv->getTangent()); - break; - } - default: - break; - } - } - - glClientActiveTextureARB(GL_TEXTURE0_ARB); - - for (unsigned short unit = 0, size = m_storageAttribs->attribs.size(); unit < size; ++unit) { - switch (m_storageAttribs->attribs[unit]) { - case RAS_IRasterizer::RAS_TEXCO_ORCO: - case RAS_IRasterizer::RAS_TEXCO_GLOB: - { - glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, stride, tv->getXYZ()); - break; - } - case RAS_IRasterizer::RAS_TEXCO_UV: - { - glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, stride, tv->getUV(m_storageAttribs->layers[unit])); - break; - } - case RAS_IRasterizer::RAS_TEXCO_NORM: - { - glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, stride, tv->getNormal()); - break; - } - case RAS_IRasterizer::RAS_TEXTANGENT: - { - glVertexAttribPointerARB(unit, 4, GL_FLOAT, GL_FALSE, stride, tv->getTangent()); - break; - } - case RAS_IRasterizer::RAS_TEXCO_VCOL: - { - glVertexAttribPointerARB(unit, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, tv->getRGBA(m_storageAttribs->layers[unit])); - break; - } - default: - break; - } - } -} - -void RAS_StorageVA::EnableTextures(bool enable) -{ - for (unsigned short unit = 0, size = m_storageAttribs->texcos.size(); unit < size; ++unit) { - switch (m_storageAttribs->texcos[unit]) { - case RAS_IRasterizer::RAS_TEXCO_ORCO: - case RAS_IRasterizer::RAS_TEXCO_GLOB: - case RAS_IRasterizer::RAS_TEXCO_UV: - case RAS_IRasterizer::RAS_TEXCO_NORM: - case RAS_IRasterizer::RAS_TEXTANGENT: - { - glClientActiveTextureARB(GL_TEXTURE0_ARB + unit); - if (enable) { - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - } - else { - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } - break; - } - default: - { - break; - } - } - } - - glClientActiveTextureARB(GL_TEXTURE0_ARB); - - for (unsigned short unit = 0, size = m_storageAttribs->attribs.size(); unit < size; ++unit) { - switch (m_storageAttribs->attribs[unit]) { - case RAS_IRasterizer::RAS_TEXCO_ORCO: - case RAS_IRasterizer::RAS_TEXCO_GLOB: - case RAS_IRasterizer::RAS_TEXCO_UV: - case RAS_IRasterizer::RAS_TEXCO_NORM: - case RAS_IRasterizer::RAS_TEXTANGENT: - case RAS_IRasterizer::RAS_TEXCO_VCOL: - { - if (enable) { - glEnableVertexAttribArrayARB(unit); - } - else { - glDisableVertexAttribArrayARB(unit); - } - break; - } - default: - { - break; - } - } - } -} diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h deleted file mode 100644 index 11de365f6c6b..000000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __KX_VERTEXARRAYSTORAGE -#define __KX_VERTEXARRAYSTORAGE - -#include "RAS_IStorage.h" -#include "RAS_OpenGLRasterizer.h" - -class RAS_DisplayList : public RAS_IStorageInfo -{ -public: - enum LIST_TYPE { - BIND_LIST = 0, - UNBIND_LIST = 1, - DRAW_LIST = 2, - NUM_LIST = 3 - }; - -private: - int m_list[RAS_IRasterizer::RAS_DRAW_MAX][NUM_LIST]; - - void RemoveAllList(RAS_IRasterizer::DrawType drawmode); - -public: - RAS_DisplayList(); - virtual ~RAS_DisplayList(); - - virtual void SetDataModified(RAS_IRasterizer::DrawType drawmode, DataType dataType); - - /** Return true if the list already exists and was called. - * False mean : we need call all opengl functions and finish - * with an End call. - */ - bool Draw(RAS_IRasterizer::DrawType drawmode, LIST_TYPE type); - /// Finish the display list, must be called after Draw when it return false. - void End(RAS_IRasterizer::DrawType drawmode, LIST_TYPE type); -}; - -class RAS_StorageVA : public RAS_IStorage -{ -public: - RAS_StorageVA(RAS_OpenGLRasterizer::StorageAttribs *storageAttribs); - virtual ~RAS_StorageVA(); - - virtual bool Init(); - virtual void Exit(); - - virtual void BindPrimitives(RAS_DisplayArrayBucket *arrayBucket); - virtual void UnbindPrimitives(RAS_DisplayArrayBucket *arrayBucket); - virtual void IndexPrimitives(RAS_MeshSlot *ms); - virtual void IndexPrimitivesInstancing(RAS_DisplayArrayBucket *arrayBucket); - - virtual void SetDrawingMode(RAS_IRasterizer::DrawType drawingmode) - { - m_drawingmode = drawingmode; - }; - -protected: - RAS_IRasterizer::DrawType m_drawingmode; - - RAS_OpenGLRasterizer::StorageAttribs *m_storageAttribs; - - RAS_DisplayList *GetDisplayList(RAS_DisplayArrayBucket *arrayBucket); - - virtual void EnableTextures(bool enable); - virtual void TexCoordPtr(const RAS_ITexVert *tv, const unsigned int stride); - - -#ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) - { - return MEM_mallocN(num_bytes, "GE:RAS_StorageVA"); - } - void operator delete(void *mem) - { - MEM_freeN(mem); - } -#endif -}; - -#endif //__KX_VERTEXARRAYSTORAGE diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp index 5f4e0e6a51d9..1e2e9a899547 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp @@ -286,15 +286,6 @@ RAS_StorageVBO::~RAS_StorageVBO() { } -bool RAS_StorageVBO::Init() -{ - return true; -} - -void RAS_StorageVBO::Exit() -{ -} - VBO *RAS_StorageVBO::GetVBO(RAS_DisplayArrayBucket *arrayBucket) { VBO *vbo = (VBO *)arrayBucket->GetStorageInfo(); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h index 30467253cb41..6b404204d2e9 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h @@ -25,13 +25,12 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifndef __KX_VERTEXBUFFEROBJECTSTORAGE -#define __KX_VERTEXBUFFEROBJECTSTORAGE +#ifndef __RAS_STORAGE_VBO_H__ +#define __RAS_STORAGE_VBO_H__ -#include #include "glew-mx.h" -#include "RAS_IStorage.h" +#include "RAS_IStorageInfo.h" #include "RAS_OpenGLRasterizer.h" @@ -76,21 +75,18 @@ class VBO : public RAS_IStorageInfo void *m_uv_offset; }; -class RAS_StorageVBO : public RAS_IStorage +class RAS_StorageVBO { public: RAS_StorageVBO(RAS_OpenGLRasterizer::StorageAttribs *storageAttribs); - virtual ~RAS_StorageVBO(); + ~RAS_StorageVBO(); - virtual bool Init(); - virtual void Exit(); + void BindPrimitives(RAS_DisplayArrayBucket *arrayBucket); + void UnbindPrimitives(RAS_DisplayArrayBucket *arrayBucket); + void IndexPrimitives(RAS_MeshSlot *ms); + void IndexPrimitivesInstancing(RAS_DisplayArrayBucket *arrayBucket); - virtual void BindPrimitives(RAS_DisplayArrayBucket *arrayBucket); - virtual void UnbindPrimitives(RAS_DisplayArrayBucket *arrayBucket); - virtual void IndexPrimitives(RAS_MeshSlot *ms); - virtual void IndexPrimitivesInstancing(RAS_DisplayArrayBucket *arrayBucket); - - virtual void SetDrawingMode(RAS_IRasterizer::DrawType drawingmode) + void SetDrawingMode(RAS_IRasterizer::DrawType drawingmode) { m_drawingmode = drawingmode; }; @@ -115,4 +111,4 @@ class RAS_StorageVBO : public RAS_IStorage #endif }; -#endif //__KX_VERTEXBUFFEROBJECTSTORAGE +#endif // __RAS_STORAGE_VBO_H__