diff options
author | Jacek Antonelli | 2009-04-30 13:04:20 -0500 |
---|---|---|
committer | Jacek Antonelli | 2009-04-30 13:07:16 -0500 |
commit | ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch) | |
tree | 8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/llrender/llvertexbuffer.cpp | |
parent | Second Life viewer sources 1.22.11 (diff) | |
download | meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2 meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz |
Second Life viewer sources 1.23.0-RC
Diffstat (limited to 'linden/indra/llrender/llvertexbuffer.cpp')
-rw-r--r-- | linden/indra/llrender/llvertexbuffer.cpp | 109 |
1 files changed, 80 insertions, 29 deletions
diff --git a/linden/indra/llrender/llvertexbuffer.cpp b/linden/indra/llrender/llvertexbuffer.cpp index cb7f352..461edbe 100644 --- a/linden/indra/llrender/llvertexbuffer.cpp +++ b/linden/indra/llrender/llvertexbuffer.cpp | |||
@@ -17,7 +17,8 @@ | |||
17 | * There are special exceptions to the terms and conditions of the GPL as | 17 | * There are special exceptions to the terms and conditions of the GPL as |
18 | * it is applied to this Source Code. View the full text of the exception | 18 | * it is applied to this Source Code. View the full text of the exception |
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | 20 | * online at |
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | 22 | * |
22 | * By copying, modifying or distributing this software, you acknowledge | 23 | * By copying, modifying or distributing this software, you acknowledge |
23 | * that you have read and understood your obligations described above, | 24 | * that you have read and understood your obligations described above, |
@@ -68,8 +69,10 @@ S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] = | |||
68 | { | 69 | { |
69 | sizeof(LLVector3), // TYPE_VERTEX, | 70 | sizeof(LLVector3), // TYPE_VERTEX, |
70 | sizeof(LLVector3), // TYPE_NORMAL, | 71 | sizeof(LLVector3), // TYPE_NORMAL, |
71 | sizeof(LLVector2), // TYPE_TEXCOORD, | 72 | sizeof(LLVector2), // TYPE_TEXCOORD0, |
73 | sizeof(LLVector2), // TYPE_TEXCOORD1, | ||
72 | sizeof(LLVector2), // TYPE_TEXCOORD2, | 74 | sizeof(LLVector2), // TYPE_TEXCOORD2, |
75 | sizeof(LLVector2), // TYPE_TEXCOORD3, | ||
73 | sizeof(LLColor4U), // TYPE_COLOR, | 76 | sizeof(LLColor4U), // TYPE_COLOR, |
74 | sizeof(LLVector3), // TYPE_BINORMAL, | 77 | sizeof(LLVector3), // TYPE_BINORMAL, |
75 | sizeof(F32), // TYPE_WEIGHT, | 78 | sizeof(F32), // TYPE_WEIGHT, |
@@ -102,8 +105,8 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) | |||
102 | { | 105 | { |
103 | MAP_VERTEX, | 106 | MAP_VERTEX, |
104 | MAP_NORMAL, | 107 | MAP_NORMAL, |
105 | MAP_TEXCOORD, | 108 | MAP_TEXCOORD0, |
106 | MAP_COLOR | 109 | MAP_COLOR, |
107 | }; | 110 | }; |
108 | 111 | ||
109 | GLenum array[] = | 112 | GLenum array[] = |
@@ -111,7 +114,7 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) | |||
111 | GL_VERTEX_ARRAY, | 114 | GL_VERTEX_ARRAY, |
112 | GL_NORMAL_ARRAY, | 115 | GL_NORMAL_ARRAY, |
113 | GL_TEXTURE_COORD_ARRAY, | 116 | GL_TEXTURE_COORD_ARRAY, |
114 | GL_COLOR_ARRAY | 117 | GL_COLOR_ARRAY, |
115 | }; | 118 | }; |
116 | 119 | ||
117 | for (U32 i = 0; i < 4; ++i) | 120 | for (U32 i = 0; i < 4; ++i) |
@@ -122,7 +125,7 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) | |||
122 | { //needs to be disabled | 125 | { //needs to be disabled |
123 | glDisableClientState(array[i]); | 126 | glDisableClientState(array[i]); |
124 | } | 127 | } |
125 | else | 128 | else if (gDebugGL) |
126 | { //needs to be enabled, make sure it was (DEBUG TEMPORARY) | 129 | { //needs to be enabled, make sure it was (DEBUG TEMPORARY) |
127 | if (i > 0 && !glIsEnabled(array[i])) | 130 | if (i > 0 && !glIsEnabled(array[i])) |
128 | { | 131 | { |
@@ -136,29 +139,55 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) | |||
136 | { //needs to be enabled | 139 | { //needs to be enabled |
137 | glEnableClientState(array[i]); | 140 | glEnableClientState(array[i]); |
138 | } | 141 | } |
139 | else if (glIsEnabled(array[i])) | 142 | else if (gDebugGL && glIsEnabled(array[i])) |
140 | { //needs to be disabled, make sure it was (DEBUG TEMPORARY) | 143 | { //needs to be disabled, make sure it was (DEBUG TEMPORARY) |
141 | llerrs << "Bad client state! " << array[i] << " enabled." << llendl; | 144 | llerrs << "Bad client state! " << array[i] << " enabled." << llendl; |
142 | } | 145 | } |
143 | } | 146 | } |
144 | } | 147 | } |
145 | 148 | ||
146 | if (sLastMask & MAP_TEXCOORD2) | 149 | U32 map_tc[] = |
147 | { | 150 | { |
148 | if (!(data_mask & MAP_TEXCOORD2)) | 151 | MAP_TEXCOORD1, |
152 | MAP_TEXCOORD2, | ||
153 | MAP_TEXCOORD3 | ||
154 | }; | ||
155 | |||
156 | for (U32 i = 0; i < 3; i++) | ||
157 | { | ||
158 | if (sLastMask & map_tc[i]) | ||
149 | { | 159 | { |
150 | glClientActiveTextureARB(GL_TEXTURE1_ARB); | 160 | if (!(data_mask & map_tc[i])) |
161 | { | ||
162 | glClientActiveTextureARB(GL_TEXTURE1_ARB+i); | ||
163 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | ||
164 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | ||
165 | } | ||
166 | } | ||
167 | else if (data_mask & map_tc[i]) | ||
168 | { | ||
169 | glClientActiveTextureARB(GL_TEXTURE1_ARB+i); | ||
170 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | ||
171 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | ||
172 | } | ||
173 | } | ||
174 | |||
175 | if (sLastMask & MAP_BINORMAL) | ||
176 | { | ||
177 | if (!(data_mask & MAP_BINORMAL)) | ||
178 | { | ||
179 | glClientActiveTextureARB(GL_TEXTURE2_ARB); | ||
151 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | 180 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
152 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | 181 | glClientActiveTextureARB(GL_TEXTURE0_ARB); |
153 | } | 182 | } |
154 | } | 183 | } |
155 | else if (data_mask & MAP_TEXCOORD2) | 184 | else if (data_mask & MAP_BINORMAL) |
156 | { | 185 | { |
157 | glClientActiveTextureARB(GL_TEXTURE1_ARB); | 186 | glClientActiveTextureARB(GL_TEXTURE2_ARB); |
158 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 187 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
159 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | 188 | glClientActiveTextureARB(GL_TEXTURE0_ARB); |
160 | } | 189 | } |
161 | 190 | ||
162 | sLastMask = data_mask; | 191 | sLastMask = data_mask; |
163 | } | 192 | } |
164 | } | 193 | } |
@@ -193,6 +222,7 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi | |||
193 | return; | 222 | return; |
194 | } | 223 | } |
195 | 224 | ||
225 | stop_glerror(); | ||
196 | glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, | 226 | glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, |
197 | ((U16*) getIndicesPointer()) + indices_offset); | 227 | ((U16*) getIndicesPointer()) + indices_offset); |
198 | stop_glerror(); | 228 | stop_glerror(); |
@@ -222,13 +252,14 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const | |||
222 | return; | 252 | return; |
223 | } | 253 | } |
224 | 254 | ||
255 | stop_glerror(); | ||
225 | glDrawElements(sGLMode[mode], count, GL_UNSIGNED_SHORT, | 256 | glDrawElements(sGLMode[mode], count, GL_UNSIGNED_SHORT, |
226 | ((U16*) getIndicesPointer()) + indices_offset); | 257 | ((U16*) getIndicesPointer()) + indices_offset); |
258 | stop_glerror(); | ||
227 | } | 259 | } |
228 | 260 | ||
229 | void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const | 261 | void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const |
230 | { | 262 | { |
231 | |||
232 | if (first >= (U32) mRequestedNumVerts || | 263 | if (first >= (U32) mRequestedNumVerts || |
233 | first + count > (U32) mRequestedNumVerts) | 264 | first + count > (U32) mRequestedNumVerts) |
234 | { | 265 | { |
@@ -246,6 +277,7 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const | |||
246 | return; | 277 | return; |
247 | } | 278 | } |
248 | 279 | ||
280 | stop_glerror(); | ||
249 | glDrawArrays(sGLMode[mode], first, count); | 281 | glDrawArrays(sGLMode[mode], first, count); |
250 | stop_glerror(); | 282 | stop_glerror(); |
251 | } | 283 | } |
@@ -766,11 +798,7 @@ U8* LLVertexBuffer::mapBuffer(S32 access) | |||
766 | stop_glerror(); | 798 | stop_glerror(); |
767 | mMappedIndexData = (U8*) glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); | 799 | mMappedIndexData = (U8*) glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); |
768 | stop_glerror(); | 800 | stop_glerror(); |
769 | /*if (sMapped) | 801 | |
770 | { | ||
771 | llerrs << "Mapped two VBOs at the same time!" << llendl; | ||
772 | } | ||
773 | sMapped = TRUE;*/ | ||
774 | if (!mMappedData) | 802 | if (!mMappedData) |
775 | { | 803 | { |
776 | //-------------------- | 804 | //-------------------- |
@@ -895,14 +923,22 @@ bool LLVertexBuffer::getIndexStrider(LLStrider<U16>& strider, S32 index) | |||
895 | { | 923 | { |
896 | return VertexBufferStrider<U16,TYPE_INDEX>::get(*this, strider, index); | 924 | return VertexBufferStrider<U16,TYPE_INDEX>::get(*this, strider, index); |
897 | } | 925 | } |
898 | bool LLVertexBuffer::getTexCoordStrider(LLStrider<LLVector2>& strider, S32 index) | 926 | bool LLVertexBuffer::getTexCoord0Strider(LLStrider<LLVector2>& strider, S32 index) |
927 | { | ||
928 | return VertexBufferStrider<LLVector2,TYPE_TEXCOORD0>::get(*this, strider, index); | ||
929 | } | ||
930 | bool LLVertexBuffer::getTexCoord1Strider(LLStrider<LLVector2>& strider, S32 index) | ||
899 | { | 931 | { |
900 | return VertexBufferStrider<LLVector2,TYPE_TEXCOORD>::get(*this, strider, index); | 932 | return VertexBufferStrider<LLVector2,TYPE_TEXCOORD1>::get(*this, strider, index); |
901 | } | 933 | } |
902 | bool LLVertexBuffer::getTexCoord2Strider(LLStrider<LLVector2>& strider, S32 index) | 934 | /*bool LLVertexBuffer::getTexCoord2Strider(LLStrider<LLVector2>& strider, S32 index) |
903 | { | 935 | { |
904 | return VertexBufferStrider<LLVector2,TYPE_TEXCOORD2>::get(*this, strider, index); | 936 | return VertexBufferStrider<LLVector2,TYPE_TEXCOORD2>::get(*this, strider, index); |
905 | } | 937 | } |
938 | bool LLVertexBuffer::getTexCoord3Strider(LLStrider<LLVector2>& strider, S32 index) | ||
939 | { | ||
940 | return VertexBufferStrider<LLVector2,TYPE_TEXCOORD3>::get(*this, strider, index); | ||
941 | }*/ | ||
906 | bool LLVertexBuffer::getNormalStrider(LLStrider<LLVector3>& strider, S32 index) | 942 | bool LLVertexBuffer::getNormalStrider(LLStrider<LLVector3>& strider, S32 index) |
907 | { | 943 | { |
908 | return VertexBufferStrider<LLVector3,TYPE_NORMAL>::get(*this, strider, index); | 944 | return VertexBufferStrider<LLVector3,TYPE_NORMAL>::get(*this, strider, index); |
@@ -1100,24 +1136,39 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const | |||
1100 | { | 1136 | { |
1101 | glNormalPointer(GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_NORMAL])); | 1137 | glNormalPointer(GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_NORMAL])); |
1102 | } | 1138 | } |
1139 | if (data_mask & MAP_TEXCOORD3) | ||
1140 | { | ||
1141 | glClientActiveTextureARB(GL_TEXTURE3_ARB); | ||
1142 | glTexCoordPointer(2,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_TEXCOORD3])); | ||
1143 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | ||
1144 | } | ||
1103 | if (data_mask & MAP_TEXCOORD2) | 1145 | if (data_mask & MAP_TEXCOORD2) |
1104 | { | 1146 | { |
1105 | glClientActiveTextureARB(GL_TEXTURE1_ARB); | 1147 | glClientActiveTextureARB(GL_TEXTURE2_ARB); |
1106 | glTexCoordPointer(2,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_TEXCOORD2])); | 1148 | glTexCoordPointer(2,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_TEXCOORD2])); |
1107 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | 1149 | glClientActiveTextureARB(GL_TEXTURE0_ARB); |
1108 | } | 1150 | } |
1109 | if (data_mask & MAP_TEXCOORD) | 1151 | if (data_mask & MAP_TEXCOORD1) |
1110 | { | 1152 | { |
1111 | glTexCoordPointer(2,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_TEXCOORD])); | 1153 | glClientActiveTextureARB(GL_TEXTURE1_ARB); |
1154 | glTexCoordPointer(2,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_TEXCOORD1])); | ||
1155 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | ||
1112 | } | 1156 | } |
1113 | if (data_mask & MAP_COLOR) | 1157 | if (data_mask & MAP_BINORMAL) |
1114 | { | 1158 | { |
1115 | glColorPointer(4, GL_UNSIGNED_BYTE, stride, (void*)(base + mOffsets[TYPE_COLOR])); | 1159 | glClientActiveTextureARB(GL_TEXTURE2_ARB); |
1160 | glTexCoordPointer(3,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_BINORMAL])); | ||
1161 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | ||
1116 | } | 1162 | } |
1117 | if (data_mask & MAP_BINORMAL) | 1163 | if (data_mask & MAP_TEXCOORD0) |
1118 | { | 1164 | { |
1119 | glVertexAttribPointerARB(6, 3, GL_FLOAT, FALSE, stride, (void*)(base + mOffsets[TYPE_BINORMAL])); | 1165 | glTexCoordPointer(2,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_TEXCOORD0])); |
1120 | } | 1166 | } |
1167 | if (data_mask & MAP_COLOR) | ||
1168 | { | ||
1169 | glColorPointer(4, GL_UNSIGNED_BYTE, stride, (void*)(base + mOffsets[TYPE_COLOR])); | ||
1170 | } | ||
1171 | |||
1121 | if (data_mask & MAP_WEIGHT) | 1172 | if (data_mask & MAP_WEIGHT) |
1122 | { | 1173 | { |
1123 | glVertexAttribPointerARB(1, 1, GL_FLOAT, FALSE, stride, (void*)(base + mOffsets[TYPE_WEIGHT])); | 1174 | glVertexAttribPointerARB(1, 1, GL_FLOAT, FALSE, stride, (void*)(base + mOffsets[TYPE_WEIGHT])); |