Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/gameengine/Ketsji/BL_BlenderShader.cpp4
-rw-r--r--source/gameengine/Rasterizer/RAS_IRasterizer.h2
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp16
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h3
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp8
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.h3
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp8
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h3
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp17
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h5
10 files changed, 37 insertions, 32 deletions
diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp
index 64e191fe960..f5f9b344b87 100644
--- a/source/gameengine/Ketsji/BL_BlenderShader.cpp
+++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp
@@ -80,7 +80,7 @@ void BL_BlenderShader::SetAttribs(RAS_IRasterizer* ras, const BL_Material *mat)
{
GPUVertexAttribs attribs;
GPUMaterial *gpumat;
- int i, attrib_num;
+ int i, attrib_num, uv = 0;
ras->SetAttribNum(0);
@@ -103,7 +103,7 @@ void BL_BlenderShader::SetAttribs(RAS_IRasterizer* ras, const BL_Material *mat)
continue;
if (attribs.layer[i].type == CD_MTFACE)
- ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV, attribs.layer[i].glindex);
+ ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV, attribs.layer[i].glindex, uv++);
else if (attribs.layer[i].type == CD_TANGENT)
ras->SetAttrib(RAS_IRasterizer::RAS_TEXTANGENT, attribs.layer[i].glindex);
else if (attribs.layer[i].type == CD_ORCO)
diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h
index 99026fa259a..c04b62bc5da 100644
--- a/source/gameengine/Rasterizer/RAS_IRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h
@@ -396,7 +396,7 @@ public:
virtual void SetTexCoordNum(int num) = 0;
virtual void SetAttribNum(int num) = 0;
virtual void SetTexCoord(TexCoGen coords, int unit) = 0;
- virtual void SetAttrib(TexCoGen coords, int unit) = 0;
+ virtual void SetAttrib(TexCoGen coords, int unit, int layer = 0) = 0;
virtual const MT_Matrix4x4& GetViewMatrix() const = 0;
virtual const MT_Matrix4x4& GetViewInvMatrix() const = 0;
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index 0186e99f78a..f995f7ddb3d 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -116,19 +116,19 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, int storage)
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_failsafe_storage = new RAS_StorageIM(&m_texco_num, m_texco, &m_attrib_num, m_attrib);
+ 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))
{
- m_storage = new RAS_StorageVA(&m_texco_num, m_texco, &m_attrib_num, m_attrib);
- m_failsafe_storage = new RAS_StorageIM(&m_texco_num, m_texco, &m_attrib_num, m_attrib);
+ 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_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;
}
}
@@ -740,11 +740,13 @@ void RAS_OpenGLRasterizer::SetTexCoord(TexCoGen coords, int unit)
m_texco[unit] = coords;
}
-void RAS_OpenGLRasterizer::SetAttrib(TexCoGen coords, int unit)
+void RAS_OpenGLRasterizer::SetAttrib(TexCoGen coords, int unit, int layer)
{
// this changes from material to material
- if (unit < RAS_MAX_ATTRIB)
+ if (unit < RAS_MAX_ATTRIB) {
m_attrib[unit] = coords;
+ m_attrib_layer[unit] = layer;
+ }
}
void RAS_OpenGLRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
index 64c07358d95..94589f84197 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
@@ -109,6 +109,7 @@ protected:
int m_drawingmode;
TexCoGen m_texco[RAS_MAX_TEXCO];
TexCoGen m_attrib[RAS_MAX_ATTRIB];
+ int m_attrib_layer[RAS_MAX_ATTRIB];
int m_texco_num;
int m_attrib_num;
//int m_last_alphablend;
@@ -296,7 +297,7 @@ public:
virtual void SetTexCoordNum(int num);
virtual void SetAttribNum(int num);
virtual void SetTexCoord(TexCoGen coords, int unit);
- virtual void SetAttrib(TexCoGen coords, int unit);
+ virtual void SetAttrib(TexCoGen coords, int unit, int layer = 0);
void TexCoord(const RAS_TexVert &tv);
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp
index 7bcc8dc9034..900d6f387ff 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp
@@ -39,11 +39,12 @@ extern "C"{
#include "BKE_DerivedMesh.h"
}
-RAS_StorageIM::RAS_StorageIM(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib) :
+RAS_StorageIM::RAS_StorageIM(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer) :
m_texco_num(texco_num),
m_attrib_num(attrib_num),
m_texco(texco),
- m_attrib(attrib)
+ m_attrib(attrib),
+ m_attrib_layer(attrib_layer)
{
}
RAS_StorageIM::~RAS_StorageIM()
@@ -95,7 +96,6 @@ void RAS_StorageIM::TexCoord(const RAS_TexVert &tv)
}
if (GLEW_ARB_vertex_program) {
- int uv = 0;
for (unit = 0; unit < *m_attrib_num; unit++) {
switch (m_attrib[unit]) {
case RAS_IRasterizer::RAS_TEXCO_ORCO:
@@ -103,7 +103,7 @@ void RAS_StorageIM::TexCoord(const RAS_TexVert &tv)
glVertexAttrib3fvARB(unit, tv.getXYZ());
break;
case RAS_IRasterizer::RAS_TEXCO_UV:
- glVertexAttrib2fvARB(unit, tv.getUV(uv++));
+ glVertexAttrib2fvARB(unit, tv.getUV(m_attrib_layer[unit]));
break;
case RAS_IRasterizer::RAS_TEXCO_NORM:
glVertexAttrib3fvARB(unit, tv.getNormal());
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.h
index de4ff30d394..54ba2a57b61 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.h
@@ -34,7 +34,7 @@
class RAS_StorageIM : public RAS_IStorage
{
public:
- RAS_StorageIM(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib);
+ 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();
@@ -51,6 +51,7 @@ protected:
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);
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp
index 7182525ea71..d45365dde04 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp
@@ -29,13 +29,14 @@
#include "GL/glew.h"
-RAS_StorageVA::RAS_StorageVA(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib) :
+RAS_StorageVA::RAS_StorageVA(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer) :
m_texco_num(texco_num),
m_attrib_num(attrib_num),
m_last_texco_num(0),
m_last_attrib_num(0),
m_texco(texco),
- m_attrib(attrib)
+ m_attrib(attrib),
+ m_attrib_layer(attrib_layer)
{
}
@@ -214,7 +215,6 @@ void RAS_StorageVA::TexCoordPtr(const RAS_TexVert *tv)
}
if (GLEW_ARB_vertex_program) {
- int uv = 0;
for (unit = 0; unit < *m_attrib_num; unit++) {
switch (m_attrib[unit]) {
case RAS_IRasterizer::RAS_TEXCO_ORCO:
@@ -222,7 +222,7 @@ void RAS_StorageVA::TexCoordPtr(const RAS_TexVert *tv)
glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getXYZ());
break;
case RAS_IRasterizer::RAS_TEXCO_UV:
- glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV(uv++));
+ glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV(m_attrib_layer[unit]));
break;
case RAS_IRasterizer::RAS_TEXCO_NORM:
glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getNormal());
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h
index da7766ec5ca..e4d00310a11 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h
@@ -37,7 +37,7 @@ class RAS_StorageVA : public RAS_IStorage
{
public:
- RAS_StorageVA(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib);
+ RAS_StorageVA(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer);
virtual ~RAS_StorageVA();
virtual bool Init();
@@ -59,6 +59,7 @@ protected:
RAS_IRasterizer::TexCoGen* m_texco;
RAS_IRasterizer::TexCoGen* m_attrib;
+ int* m_attrib_layer;
RAS_IRasterizer::TexCoGen m_last_texco[RAS_MAX_TEXCO];
RAS_IRasterizer::TexCoGen m_last_attrib[RAS_MAX_ATTRIB];
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp
index 077dfad80bb..3de77951fa7 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp
@@ -101,10 +101,10 @@ void VBO::UpdateIndices()
glBufferData(GL_ELEMENT_ARRAY_BUFFER, space, &data->m_index[0], GL_STATIC_DRAW);
}
-void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, bool multi)
+void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer, bool multi)
{
int unit;
-
+
// Bind buffers
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, this->ibo);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, this->vbo_id);
@@ -159,7 +159,6 @@ void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num,
if (GLEW_ARB_vertex_program)
{
- int uv = 0;
for (unit = 0; unit < attrib_num; ++unit)
{
switch (attrib[unit]) {
@@ -169,8 +168,7 @@ void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num,
glEnableVertexAttribArrayARB(unit);
break;
case RAS_IRasterizer::RAS_TEXCO_UV:
- glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, this->stride, (void*)((intptr_t)this->uv_offset+uv));
- uv += sizeof(GLfloat)*2;
+ glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, this->stride, (void*)((intptr_t)this->uv_offset+attrib_layer[unit]*sizeof(GLfloat)*2));
glEnableVertexAttribArrayARB(unit);
break;
case RAS_IRasterizer::RAS_TEXCO_NORM:
@@ -204,11 +202,12 @@ void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num,
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
}
-RAS_StorageVBO::RAS_StorageVBO(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib):
+RAS_StorageVBO::RAS_StorageVBO(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer):
m_texco_num(texco_num),
m_attrib_num(attrib_num),
m_texco(texco),
- m_attrib(attrib)
+ m_attrib(attrib),
+ m_attrib_layer(attrib_layer)
{
}
@@ -240,7 +239,7 @@ void RAS_StorageVBO::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
{
RAS_MeshSlot::iterator it;
VBO *vbo;
-
+
for (ms.begin(it); !ms.end(it); ms.next(it))
{
vbo = m_vbo_lookup[it.array];
@@ -254,6 +253,6 @@ void RAS_StorageVBO::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
vbo->UpdateData();
}
- vbo->Draw(*m_texco_num, m_texco, *m_attrib_num, m_attrib, multi);
+ vbo->Draw(*m_texco_num, m_texco, *m_attrib_num, m_attrib, m_attrib_layer, multi);
}
}
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h
index d8d8192e482..2fe0c32f399 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h
@@ -42,7 +42,7 @@ public:
VBO(RAS_DisplayArray *data, unsigned int indices);
~VBO();
- void Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, bool multi);
+ void Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer, bool multi);
void UpdateData();
void UpdateIndices();
@@ -66,7 +66,7 @@ class RAS_StorageVBO : public RAS_IStorage
{
public:
- RAS_StorageVBO(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib);
+ RAS_StorageVBO(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer);
virtual ~RAS_StorageVBO();
virtual bool Init();
@@ -85,6 +85,7 @@ protected:
RAS_IRasterizer::TexCoGen* m_texco;
RAS_IRasterizer::TexCoGen* m_attrib;
+ int* m_attrib_layer;
std::map<RAS_DisplayArray*, class VBO*> m_vbo_lookup;