~ubuntu-branches/ubuntu/maverick/blender/maverick

« back to all changes in this revision

Viewing changes to source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Khashayar Naderehvandi, Khashayar Naderehvandi, Alessio Treglia
  • Date: 2009-01-22 16:53:59 UTC
  • mfrom: (14.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090122165359-v0996tn7fbit64ni
Tags: 2.48a+dfsg-1ubuntu1
[ Khashayar Naderehvandi ]
* Merge from debian experimental (LP: #320045), Ubuntu remaining changes:
  - Add patch correcting header file locations.
  - Add libvorbis-dev and libgsm1-dev to Build-Depends.
  - Use avcodec_decode_audio2() in source/blender/src/hddaudio.c

[ Alessio Treglia ]
* Add missing previous changelog entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
#ifdef WIN32
7
7
#include <windows.h>
8
8
#endif // WIN32
9
 
#ifdef __APPLE__
10
 
#define GL_GLEXT_LEGACY 1
11
 
#include <OpenGL/gl.h>
12
 
#else
13
 
#include <GL/gl.h>
14
 
#endif
15
 
 
 
9
 
 
10
#include "GL/glew.h"
 
11
 
 
12
#include "RAS_MaterialBucket.h"
16
13
#include "RAS_TexVert.h"
17
 
#include "RAS_GLExtensionManager.h"
18
14
#include "MT_assert.h"
19
15
 
20
16
//#ifndef NDEBUG
27
23
 
28
24
RAS_ListSlot::RAS_ListSlot(RAS_ListRasterizer* rasty)
29
25
:       KX_ListSlot(),
 
26
        m_list(0),
30
27
        m_flag(LIST_MODIFY|LIST_CREATE),
31
 
        m_list(0),
32
28
        m_rasty(rasty)
33
29
{
34
30
}
130
126
        }
131
127
}
132
128
 
133
 
RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(const vecVertexArray& vertexarrays, KX_ListSlot** slot)
 
129
RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(RAS_MeshSlot& ms)
134
130
{
135
131
        /*
136
132
         Keep a copy of constant lists submitted for rendering,
137
133
                this guards against (replicated)new...delete every frame,
138
134
                and we can reuse lists!
139
 
                :: sorted by vertex array
 
135
                :: sorted by mesh slot
140
136
        */
141
 
        RAS_ListSlot* localSlot = (RAS_ListSlot*)*slot;
 
137
        RAS_ListSlot* localSlot = (RAS_ListSlot*)ms.m_DisplayList;
142
138
        if(!localSlot) {
143
 
                RAS_Lists::iterator it = mLists.find(vertexarrays);
 
139
                RAS_Lists::iterator it = mLists.find(&ms);
144
140
                if(it == mLists.end()) {
145
141
                        localSlot = new RAS_ListSlot(this);
146
 
                        mLists.insert(std::pair<vecVertexArray, RAS_ListSlot*>(vertexarrays, localSlot));
 
142
                        mLists.insert(std::pair<RAS_MeshSlot*, RAS_ListSlot*>(&ms, localSlot));
147
143
                } else {
148
144
                        localSlot = static_cast<RAS_ListSlot*>(it->second->AddRef());
149
145
                }
162
158
        mLists.clear();
163
159
}
164
160
 
165
 
 
166
 
void RAS_ListRasterizer::IndexPrimitives(
167
 
        const vecVertexArray & vertexarrays,
168
 
        const vecIndexArrays & indexarrays,
169
 
        int mode,
170
 
        class RAS_IPolyMaterial* polymat,
171
 
        class RAS_IRenderTools* rendertools,
172
 
        bool useObjectColor,
173
 
        const MT_Vector4& rgbacolor,
174
 
        class KX_ListSlot** slot)
 
161
void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
175
162
{
176
163
        RAS_ListSlot* localSlot =0;
177
164
 
178
 
        // useObjectColor(are we updating every frame?)
179
 
        if(!useObjectColor) {
180
 
                localSlot = FindOrAdd(vertexarrays, slot);
 
165
        if(ms.m_bDisplayList) {
 
166
                localSlot = FindOrAdd(ms);
181
167
                localSlot->DrawList();
182
168
                if(localSlot->End()) {
183
169
                        // save slot here too, needed for replicas and object using same mesh
184
170
                        // => they have the same vertexarray but different mesh slot
185
 
                        *slot = localSlot;
 
171
                        ms.m_DisplayList = localSlot;
186
172
                        return;
187
173
                }
188
174
        }
189
175
        
190
 
        if (mUseVertexArrays) {
191
 
                RAS_VAOpenGLRasterizer::IndexPrimitives(
192
 
                                vertexarrays, indexarrays,
193
 
                                mode, polymat,
194
 
                                rendertools, useObjectColor,
195
 
                                rgbacolor,slot
196
 
                );
197
 
        } else {
198
 
                RAS_OpenGLRasterizer::IndexPrimitives(
199
 
                                vertexarrays, indexarrays,
200
 
                                mode, polymat,
201
 
                                rendertools, useObjectColor,
202
 
                                rgbacolor,slot
203
 
                );
204
 
        }
 
176
        if (mUseVertexArrays)
 
177
                RAS_VAOpenGLRasterizer::IndexPrimitives(ms);
 
178
        else
 
179
                RAS_OpenGLRasterizer::IndexPrimitives(ms);
205
180
 
206
 
        if(!useObjectColor) {
 
181
        if(ms.m_bDisplayList) {
207
182
                localSlot->EndList();
208
 
                *slot = localSlot;
 
183
                ms.m_DisplayList = localSlot;
209
184
        }
210
185
}
211
186
 
212
187
 
213
 
void RAS_ListRasterizer::IndexPrimitivesMulti(
214
 
                const vecVertexArray& vertexarrays,
215
 
                const vecIndexArrays & indexarrays,
216
 
                int mode,
217
 
                class RAS_IPolyMaterial* polymat,
218
 
                class RAS_IRenderTools* rendertools,
219
 
                bool useObjectColor,
220
 
                const MT_Vector4& rgbacolor,
221
 
                class KX_ListSlot** slot)
 
188
void RAS_ListRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
222
189
{
223
190
        RAS_ListSlot* localSlot =0;
224
191
 
225
 
        // useObjectColor(are we updating every frame?)
226
 
        if(!useObjectColor) {
227
 
                localSlot = FindOrAdd(vertexarrays, slot);
 
192
        if(ms.m_bDisplayList) {
 
193
                localSlot = FindOrAdd(ms);
228
194
                localSlot->DrawList();
229
195
 
230
196
                if(localSlot->End()) {
231
197
                        // save slot here too, needed for replicas and object using same mesh
232
198
                        // => they have the same vertexarray but different mesh slot
233
 
                        *slot = localSlot;
 
199
                        ms.m_DisplayList = localSlot;
234
200
                        return;
235
201
                }
236
202
        }
237
203
 
238
 
        if (mUseVertexArrays) {
239
 
                RAS_VAOpenGLRasterizer::IndexPrimitivesMulti(
240
 
                                vertexarrays, indexarrays,
241
 
                                mode, polymat,
242
 
                                rendertools, useObjectColor,
243
 
                                rgbacolor,slot
244
 
                );
245
 
        } else {
246
 
                RAS_OpenGLRasterizer::IndexPrimitivesMulti(
247
 
                                vertexarrays, indexarrays,
248
 
                                mode, polymat,
249
 
                                rendertools, useObjectColor,
250
 
                                rgbacolor,slot
251
 
                );
252
 
        }
 
204
        // workaround: note how we do not use vertex arrays for making display
 
205
        // lists, since glVertexAttribPointerARB doesn't seem to work correct
 
206
        // in display lists on ATI? either a bug in the driver or in Blender ..
 
207
        if (mUseVertexArrays && !localSlot)
 
208
                RAS_VAOpenGLRasterizer::IndexPrimitivesMulti(ms);
 
209
        else
 
210
                RAS_OpenGLRasterizer::IndexPrimitivesMulti(ms);
253
211
 
254
 
        if(!useObjectColor) {
 
212
        if(ms.m_bDisplayList) {
255
213
                localSlot->EndList();
256
 
                *slot = localSlot;
 
214
                ms.m_DisplayList = localSlot;
257
215
        }
258
216
}
259
217