diff options
10 files changed, 125 insertions, 403 deletions
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 30112885b33..4f9fe8b45ab 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -3774,12 +3774,9 @@ static void rna_def_scene_game_data(BlenderRNA *brna) static EnumPropertyItem storage_items[] = { {RAS_STORE_AUTO, "AUTO", 0, "Auto Select", "Choose the best supported mode"}, - {RAS_STORE_IMMEDIATE, "IMMEDIATE", 0, "Immediate Mode", "Slowest performance, requires OpenGL (any version)"}, - {RAS_STORE_VA, "VERTEX_ARRAY", 0, "Vertex Arrays", "Better performance, requires at least OpenGL 1.1"}, -#if 0 /* XXX VBOS are currently disabled since they cannot beat vertex array with display lists in performance. */ + {RAS_STORE_VA, "VERTEX_ARRAY", 0, "Vertex Arrays", "Usually the best choice (good performance with display lists)"}, {RAS_STORE_VBO, "VERTEX_BUFFER_OBJECT", 0, "Vertex Buffer Objects", - "Best performance, requires at least OpenGL 1.4"}, -#endif + "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); diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 976590cadaf..0d04ab61919 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -302,12 +302,20 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c canvas->SetSwapInterval((startscene->gm.vsync == VSYNC_ON) ? 1 : 0); RAS_IRasterizer* rasterizer = NULL; + RAS_STORAGE_TYPE raster_storage = RAS_AUTO_STORAGE; + + if (startscene->gm.raster_storage == RAS_STORE_VBO) { + raster_storage = RAS_VBO; + } + else if (startscene->gm.raster_storage == RAS_STORE_VA) { + raster_storage = RAS_VA; + } //Don't use displaylists with VBOs //If auto starts using VBOs, make sure to check for that here - if (displaylists && startscene->gm.raster_storage != RAS_STORE_VBO) - rasterizer = new RAS_ListRasterizer(canvas, true, startscene->gm.raster_storage); + if (displaylists && raster_storage != RAS_VBO) + rasterizer = new RAS_ListRasterizer(canvas, true, raster_storage); else - rasterizer = new RAS_OpenGLRasterizer(canvas, startscene->gm.raster_storage); + rasterizer = new RAS_OpenGLRasterizer(canvas, raster_storage); RAS_IRasterizer::MipmapOption mipmapval = rasterizer->GetMipmapping(); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 2b357f43031..2940e6d07ee 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -607,12 +607,20 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) if (gm->flag & GAME_SHOW_MOUSE) m_canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL); + RAS_STORAGE_TYPE raster_storage = RAS_AUTO_STORAGE; + + if (gm->raster_storage == RAS_STORE_VBO) { + raster_storage = RAS_VBO; + } + else if (gm->raster_storage == RAS_STORE_VA) { + raster_storage = RAS_VA; + } //Don't use displaylists with VBOs //If auto starts using VBOs, make sure to check for that here - if (useLists && gm->raster_storage != RAS_STORE_VBO) - m_rasterizer = new RAS_ListRasterizer(m_canvas, false, gm->raster_storage); + if (useLists && raster_storage != RAS_VBO) + m_rasterizer = new RAS_ListRasterizer(m_canvas, true, raster_storage); else - m_rasterizer = new RAS_OpenGLRasterizer(m_canvas, gm->raster_storage); + m_rasterizer = new RAS_OpenGLRasterizer(m_canvas, raster_storage); /* Stereo parameters - Eye Separation from the UI - stereomode from the command-line/UI */ m_rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) stereoMode); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt index 888a7114f50..168e3fa45a1 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt @@ -53,7 +53,6 @@ set(SRC RAS_ListRasterizer.cpp RAS_OpenGLLight.cpp RAS_OpenGLRasterizer.cpp - RAS_StorageIM.cpp RAS_StorageVA.cpp RAS_StorageVBO.cpp @@ -62,7 +61,6 @@ set(SRC RAS_ListRasterizer.h RAS_OpenGLLight.h RAS_OpenGLRasterizer.h - RAS_StorageIM.h RAS_StorageVA.h RAS_StorageVBO.h ) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp index 275e4b4fc0b..b2d580161ca 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp @@ -122,7 +122,7 @@ bool RAS_ListSlot::End() -RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas, bool lock, int storage) +RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas, bool lock, RAS_STORAGE_TYPE storage) : RAS_OpenGLRasterizer(canvas, storage) { } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h index 420bf5da7a6..e3e6931311b 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h @@ -56,7 +56,7 @@ class RAS_ListRasterizer : public RAS_OpenGLRasterizer public: void RemoveListSlot(RAS_ListSlot* list); - RAS_ListRasterizer(RAS_ICanvas* canvas, bool lock=false, int storage=RAS_AUTO_STORAGE); + RAS_ListRasterizer(RAS_ICanvas* canvas, bool lock, RAS_STORAGE_TYPE storage); virtual ~RAS_ListRasterizer(); virtual void IndexPrimitives(class RAS_MeshSlot& ms); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 4629b91b3e4..8ba4ab715e2 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -47,15 +47,16 @@ #include "RAS_OpenGLLight.h" -#include "RAS_StorageIM.h" #include "RAS_StorageVA.h" #include "RAS_StorageVBO.h" #include "GPU_draw.h" #include "GPU_material.h" +#include "GPU_extensions.h" extern "C"{ #include "BLF_api.h" + #include "BKE_DerivedMesh.h" } @@ -83,7 +84,7 @@ static GLuint right_eye_vinterlace_mask[32]; */ static GLuint hinterlace_mask[33]; -RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, int storage) +RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, RAS_STORAGE_TYPE storage) :RAS_IRasterizer(canvas), m_2DCanvas(canvas), m_fogenabled(false), @@ -122,22 +123,15 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, int storage) m_prevafvalue = GPU_get_anisotropic(); - if (m_storage_type == RAS_VBO /*|| m_storage_type == RAS_AUTO_STORAGE && GLEW_ARB_vertex_buffer_object*/) - { + if (m_storage_type == RAS_VBO /*|| m_storage_type == RAS_AUTO_STORAGE && GLEW_ARB_vertex_buffer_object*/) { m_storage = new RAS_StorageVBO(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer); - m_failsafe_storage = new RAS_StorageIM(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer); - m_storage_type = RAS_VBO; } - else if ((m_storage_type == RAS_VA) || (m_storage_type == RAS_AUTO_STORAGE && GLEW_VERSION_1_1)) - { + else if ((m_storage_type == RAS_VA) || (m_storage_type == RAS_AUTO_STORAGE)) { m_storage = new RAS_StorageVA(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer); - m_failsafe_storage = new RAS_StorageIM(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer); - m_storage_type = RAS_VA; } - else - { - m_storage = m_failsafe_storage = new RAS_StorageIM(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer); - m_storage_type = RAS_IMMEDIATE; + else { + printf("Unknown rasterizer storage type, falling back to vertex arrays\n"); + m_storage = new RAS_StorageVA(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer); } glGetIntegerv(GL_MAX_LIGHTS, (GLint *) &m_numgllights); @@ -151,8 +145,6 @@ RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer() { // Restore the previous AF value GPU_set_anisotropic(m_prevafvalue); - if (m_failsafe_storage && m_failsafe_storage != m_storage) - delete m_failsafe_storage; if (m_storage) delete m_storage; @@ -321,9 +313,6 @@ void RAS_OpenGLRasterizer::SetDrawingMode(int drawingmode) glDisable(GL_CULL_FACE); m_storage->SetDrawingMode(drawingmode); - if (m_failsafe_storage && m_failsafe_storage != m_storage) { - m_failsafe_storage->SetDrawingMode(drawingmode); - } } int RAS_OpenGLRasterizer::GetDrawingMode() @@ -735,11 +724,99 @@ void RAS_OpenGLRasterizer::SetAttrib(TexCoGen coords, int unit, int layer) void RAS_OpenGLRasterizer::IndexPrimitives(RAS_MeshSlot& ms) { if (ms.m_pDerivedMesh) - m_failsafe_storage->IndexPrimitives(ms); + DrawDerivedMesh(ms); else m_storage->IndexPrimitives(ms); } +// Code for hooking into Blender's mesh drawing for derived meshes. +// If/when we use more of Blender's drawing code, we may be able to +// clean this up +static bool current_wireframe; +static RAS_MaterialBucket *current_bucket; +static RAS_IPolyMaterial *current_polymat; +static RAS_MeshSlot *current_ms; +static RAS_MeshObject *current_mesh; +static int current_blmat_nr; +static GPUVertexAttribs current_gpu_attribs; +static Image *current_image; +static int CheckMaterialDM(int matnr, void *attribs) +{ + // only draw the current material + if (matnr != current_blmat_nr) + return 0; + GPUVertexAttribs *gattribs = (GPUVertexAttribs *)attribs; + if (gattribs) + memcpy(gattribs, ¤t_gpu_attribs, sizeof(GPUVertexAttribs)); + return 1; +} + +static DMDrawOption CheckTexDM(MTexPoly *mtexpoly, const bool has_mcol, int matnr) +{ + + // index is the original face index, retrieve the polygon + if (matnr == current_blmat_nr && + (mtexpoly == NULL || mtexpoly->tpage == current_image)) { + // must handle color. + if (current_wireframe) + return DM_DRAW_OPTION_NO_MCOL; + if (current_ms->m_bObjectColor) { + MT_Vector4& rgba = current_ms->m_RGBAcolor; + glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]); + // don't use mcol + return DM_DRAW_OPTION_NO_MCOL; + } + if (!has_mcol) { + // we have to set the color from the material + unsigned char rgba[4]; + current_polymat->GetMaterialRGBAColor(rgba); + glColor4ubv((const GLubyte *)rgba); + return DM_DRAW_OPTION_NO_MCOL; + } + return DM_DRAW_OPTION_NORMAL; + } + return DM_DRAW_OPTION_SKIP; +} + +void RAS_OpenGLRasterizer::DrawDerivedMesh(class RAS_MeshSlot &ms) +{ + // mesh data is in derived mesh, + current_bucket = ms.m_bucket; + current_polymat = current_bucket->GetPolyMaterial(); + current_ms = &ms; + current_mesh = ms.m_mesh; + current_wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME; + // MCol *mcol = (MCol*)ms.m_pDerivedMesh->getFaceDataArray(ms.m_pDerivedMesh, CD_MCOL); /* UNUSED */ + + // handle two-side + if (current_polymat->GetDrawingMode() & RAS_IRasterizer::KX_BACKCULL) + this->SetCullFace(true); + else + this->SetCullFace(false); + + if (current_polymat->GetFlag() & RAS_BLENDERGLSL) { + // GetMaterialIndex return the original mface material index, + // increment by 1 to match what derived mesh is doing + current_blmat_nr = current_polymat->GetMaterialIndex()+1; + // For GLSL we need to retrieve the GPU material attribute + Material* blmat = current_polymat->GetBlenderMaterial(); + Scene* blscene = current_polymat->GetBlenderScene(); + if (!current_wireframe && blscene && blmat) + GPU_material_vertex_attributes(GPU_material_from_blender(blscene, blmat, false), ¤t_gpu_attribs); + else + memset(¤t_gpu_attribs, 0, sizeof(current_gpu_attribs)); + // DM draw can mess up blending mode, restore at the end + int current_blend_mode = GPU_get_material_alpha_blend(); + ms.m_pDerivedMesh->drawFacesGLSL(ms.m_pDerivedMesh, CheckMaterialDM); + GPU_set_material_alpha_blend(current_blend_mode); + } else { + //ms.m_pDerivedMesh->drawMappedFacesTex(ms.m_pDerivedMesh, CheckTexfaceDM, mcol); + current_blmat_nr = current_polymat->GetMaterialIndex(); + current_image = current_polymat->GetBlenderImage(); + ms.m_pDerivedMesh->drawFacesTex(ms.m_pDerivedMesh, CheckTexDM, NULL, NULL, DM_DRAW_USE_ACTIVE_UV); + } +} + void RAS_OpenGLRasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat) { glMatrixMode(GL_PROJECTION); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 10e11bcedfb..39708b382aa 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -56,7 +56,6 @@ class RAS_OpenGLLight; enum RAS_STORAGE_TYPE { RAS_AUTO_STORAGE, - RAS_IMMEDIATE, RAS_VA, RAS_VBO, }; @@ -139,11 +138,10 @@ protected: * Examples of concrete strategies: Vertex Arrays, VBOs, Immediate Mode*/ int m_storage_type; RAS_IStorage *m_storage; - RAS_IStorage *m_failsafe_storage; /* So derived mesh can use immediate mode */ public: double GetTime(); - RAS_OpenGLRasterizer(RAS_ICanvas *canv, int storage=RAS_AUTO_STORAGE); + RAS_OpenGLRasterizer(RAS_ICanvas *canv, RAS_STORAGE_TYPE storage); virtual ~RAS_OpenGLRasterizer(); /*enum DrawType @@ -187,6 +185,7 @@ public: virtual void IndexPrimitives(class RAS_MeshSlot &ms); virtual void IndexPrimitives_3DText(class RAS_MeshSlot &ms, class RAS_IPolyMaterial *polymat); + virtual void DrawDerivedMesh(class RAS_MeshSlot &ms); virtual void SetProjectionMatrix(MT_CmMatrix4x4 &mat); virtual void SetProjectionMatrix(const MT_Matrix4x4 &mat); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp deleted file mode 100644 index 2fd25e47d7f..00000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp +++ /dev/null @@ -1,299 +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_StorageIM.h" -#include "RAS_MaterialBucket.h" -#include "RAS_IPolygonMaterial.h" - -#include "glew-mx.h" -#include "GPU_draw.h" -#include "GPU_extensions.h" -#include "GPU_material.h" - -extern "C"{ - #include "BKE_DerivedMesh.h" -} - -RAS_StorageIM::RAS_StorageIM(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer) : - m_drawingmode(RAS_IRasterizer::KX_TEXTURED), - m_texco_num(texco_num), - m_attrib_num(attrib_num), - m_texco(texco), - m_attrib(attrib), - m_attrib_layer(attrib_layer) -{ -} -RAS_StorageIM::~RAS_StorageIM() -{ -} - -bool RAS_StorageIM::Init() -{ - return true; -} -void RAS_StorageIM::Exit() -{ -} - -void RAS_StorageIM::TexCoord(const RAS_TexVert &tv) -{ - int unit; - - if (GLEW_ARB_multitexture) { - for (unit = 0; unit < *m_texco_num; unit++) { - switch (m_texco[unit]) { - case RAS_IRasterizer::RAS_TEXCO_ORCO: - case RAS_IRasterizer::RAS_TEXCO_GLOB: - glMultiTexCoord3fvARB(GL_TEXTURE0_ARB + unit, tv.getXYZ()); - break; - case RAS_IRasterizer::RAS_TEXCO_UV: - glMultiTexCoord2fvARB(GL_TEXTURE0_ARB + unit, tv.getUV(unit)); - break; - case RAS_IRasterizer::RAS_TEXCO_NORM: - glMultiTexCoord3fvARB(GL_TEXTURE0_ARB + unit, tv.getNormal()); - break; - case RAS_IRasterizer::RAS_TEXTANGENT: - glMultiTexCoord4fvARB(GL_TEXTURE0_ARB + unit, tv.getTangent()); - break; - default: - break; - } - } - } - - if (GLEW_ARB_vertex_program) { - for (unit = 0; unit < *m_attrib_num; unit++) { - switch (m_attrib[unit]) { - case RAS_IRasterizer::RAS_TEXCO_ORCO: - case RAS_IRasterizer::RAS_TEXCO_GLOB: - glVertexAttrib3fvARB(unit, tv.getXYZ()); - break; - case RAS_IRasterizer::RAS_TEXCO_UV: - glVertexAttrib2fvARB(unit, tv.getUV(m_attrib_layer[unit])); - break; - case RAS_IRasterizer::RAS_TEXCO_NORM: - glVertexAttrib3fvARB(unit, tv.getNormal()); - break; - case RAS_IRasterizer::RAS_TEXTANGENT: - glVertexAttrib4fvARB(unit, tv.getTangent()); - break; - case RAS_IRasterizer::RAS_TEXCO_VCOL: - glVertexAttrib4ubvARB(unit, tv.getRGBA()); - break; - default: - break; - } - } - } - -} - -void RAS_StorageIM::SetCullFace(bool enable) -{ - if (enable) - glEnable(GL_CULL_FACE); - else - glDisable(GL_CULL_FACE); -} - -static bool current_wireframe; -static RAS_MaterialBucket *current_bucket; -static RAS_IPolyMaterial *current_polymat; -static RAS_MeshSlot *current_ms; -static RAS_MeshObject *current_mesh; -static int current_blmat_nr; -static GPUVertexAttribs current_gpu_attribs; -static Image *current_image; -static int CheckMaterialDM(int matnr, void *attribs) -{ - // only draw the current material - if (matnr != current_blmat_nr) - return 0; - GPUVertexAttribs *gattribs = (GPUVertexAttribs *)attribs; - if (gattribs) - memcpy(gattribs, ¤t_gpu_attribs, sizeof(GPUVertexAttribs)); - return 1; -} - -/* -static int CheckTexfaceDM(void *mcol, int index) -{ - - // index is the original face index, retrieve the polygon - RAS_Polygon* polygon = (index >= 0 && index < current_mesh->NumPolygons()) ? - current_mesh->GetPolygon(index) : NULL; - if (polygon && polygon->GetMaterial() == current_bucket) { - // must handle color. - if (current_wireframe) - return 2; - if (current_ms->m_bObjectColor) { - MT_Vector4& rgba = current_ms->m_RGBAcolor; - glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]); - // don't use mcol - return 2; - } - if (!mcol) { - // we have to set the color from the material - unsigned char rgba[4]; - current_polymat->GetMaterialRGBAColor(rgba); - glColor4ubv((const GLubyte *)rgba); - return 2; - } - return 1; - } - return 0; -} -*/ - -static DMDrawOption CheckTexDM(MTexPoly *mtexpoly, const bool has_mcol, int matnr) -{ - - // index is the original face index, retrieve the polygon - if (matnr == current_blmat_nr && - (mtexpoly == NULL || mtexpoly->tpage == current_image)) { - // must handle color. - if (current_wireframe) - return DM_DRAW_OPTION_NO_MCOL; - if (current_ms->m_bObjectColor) { - MT_Vector4& rgba = current_ms->m_RGBAcolor; - glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]); - // don't use mcol - return DM_DRAW_OPTION_NO_MCOL; - } - if (!has_mcol) { - // we have to set the color from the material - unsigned char rgba[4]; - current_polymat->GetMaterialRGBAColor(rgba); - glColor4ubv((const GLubyte *)rgba); - return DM_DRAW_OPTION_NO_MCOL; - } - return DM_DRAW_OPTION_NORMAL; - } - return DM_DRAW_OPTION_SKIP; -} - - - -void RAS_StorageIM::IndexPrimitives(RAS_MeshSlot& ms) -{ - bool obcolor = ms.m_bObjectColor; - bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME; - MT_Vector4& rgba = ms.m_RGBAcolor; - RAS_MeshSlot::iterator it; - - if (ms.m_pDerivedMesh) { - // mesh data is in derived mesh, - current_bucket = ms.m_bucket; - current_polymat = current_bucket->GetPolyMaterial(); - current_ms = &ms; - current_mesh = ms.m_mesh; - current_wireframe = wireframe; - // MCol *mcol = (MCol*)ms.m_pDerivedMesh->getFaceDataArray(ms.m_pDerivedMesh, CD_MCOL); /* UNUSED */ - - // handle two-side - if (current_polymat->GetDrawingMode() & RAS_IRasterizer::KX_BACKCULL) - this->SetCullFace(true); - else - this->SetCullFace(false); - - if (current_polymat->GetFlag() & RAS_BLENDERGLSL) { - // GetMaterialIndex return the original mface material index, - // increment by 1 to match what derived mesh is doing - current_blmat_nr = current_polymat->GetMaterialIndex()+1; - // For GLSL we need to retrieve the GPU material attribute - Material* blmat = current_polymat->GetBlenderMaterial(); - Scene* blscene = current_polymat->GetBlenderScene(); - if (!wireframe && blscene && blmat) - GPU_material_vertex_attributes(GPU_material_from_blender(blscene, blmat, false), ¤t_gpu_attribs); - else - memset(¤t_gpu_attribs, 0, sizeof(current_gpu_attribs)); - // DM draw can mess up blending mode, restore at the end - int current_blend_mode = GPU_get_material_alpha_blend(); - ms.m_pDerivedMesh->drawFacesGLSL(ms.m_pDerivedMesh, CheckMaterialDM); - GPU_set_material_alpha_blend(current_blend_mode); - } else { - //ms.m_pDerivedMesh->drawMappedFacesTex(ms.m_pDerivedMesh, CheckTexfaceDM, mcol); - current_blmat_nr = current_polymat->GetMaterialIndex(); - current_image = current_polymat->GetBlenderImage(); - ms.m_pDerivedMesh->drawFacesTex(ms.m_pDerivedMesh, CheckTexDM, NULL, NULL, DM_DRAW_USE_ACTIVE_UV); - } - return; - } - // iterate over display arrays, each containing an index + vertex array - for (ms.begin(it); !ms.end(it); ms.next(it)) { - RAS_TexVert *vertex; - size_t i, j, numvert; - - numvert = it.array->m_type; - - if (it.array->m_type == RAS_DisplayArray::LINE) { - // line drawing - glBegin(GL_LINES); - - for (i = 0; i < it.totindex; i += 2) - { - vertex = &it.vertex[it.index[i]]; - glVertex3fv(vertex->getXYZ()); - - vertex = &it.vertex[it.index[i+1]]; - glVertex3fv(vertex->getXYZ()); - } - - glEnd(); - } - else { - // triangle and quad drawing - if (it.array->m_type == RAS_DisplayArray::TRIANGLE) - glBegin(GL_TRIANGLES); - else - glBegin(GL_QUADS); - - for (i = 0; i < it.totindex; i += numvert) - { - if (obcolor) - glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]); - - for (j = 0; j < numvert; j++) { - vertex = &it.vertex[it.index[i+j]]; - - if (!wireframe) { - if (!obcolor) - glColor4ubv((const GLubyte *)(vertex->getRGBA())); - - glNormal3fv(vertex->getNormal()); - - TexCoord(*vertex); - } - - glVertex3fv(vertex->getXYZ()); - } - } - - glEnd(); - } - } -} diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.h deleted file mode 100644 index e98b3ab7720..00000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.h +++ /dev/null @@ -1,66 +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_IMMEDIATEMODESTORAGE -#define __KX_IMMEDIATEMODESTORAGE - -#include "RAS_IStorage.h" -#include "RAS_IRasterizer.h" - -class RAS_StorageIM : public RAS_IStorage -{ -public: - RAS_StorageIM(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer); - virtual ~RAS_StorageIM(); - - virtual bool Init(); - virtual void Exit(); - - virtual void IndexPrimitives(RAS_MeshSlot& ms); - - virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;}; - -protected: - int m_drawingmode; - int* m_texco_num; - int* m_attrib_num; - RAS_IRasterizer::TexCoGen* m_texco; - RAS_IRasterizer::TexCoGen* m_attrib; - int* m_attrib_layer; - - void TexCoord(const RAS_TexVert &tv); - void SetCullFace(bool enable); - - -#ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_StorageIM"); } - void operator delete( void *mem ) { MEM_freeN(mem); } -#endif -}; - -#endif //__KX_IMMEDIATEMODESTORAGE |