aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lldynamictexture.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lldynamictexture.cpp45
1 files changed, 34 insertions, 11 deletions
diff --git a/linden/indra/newview/lldynamictexture.cpp b/linden/indra/newview/lldynamictexture.cpp
index 6111e36..90ebd74 100644
--- a/linden/indra/newview/lldynamictexture.cpp
+++ b/linden/indra/newview/lldynamictexture.cpp
@@ -35,6 +35,8 @@
35#include "llviewercamera.h" 35#include "llviewercamera.h"
36#include "llviewercontrol.h" 36#include "llviewercontrol.h"
37#include "llviewerimage.h" 37#include "llviewerimage.h"
38#include "llvertexbuffer.h"
39
38 40
39// static 41// static
40LLLinkedList<LLDynamicTexture> LLDynamicTexture::sInstances[ LLDynamicTexture::ORDER_COUNT ]; 42LLLinkedList<LLDynamicTexture> LLDynamicTexture::sInstances[ LLDynamicTexture::ORDER_COUNT ];
@@ -64,6 +66,7 @@ LLDynamicTexture::LLDynamicTexture(S32 width, S32 height, S32 components, EOrder
64//----------------------------------------------------------------------------- 66//-----------------------------------------------------------------------------
65LLDynamicTexture::~LLDynamicTexture() 67LLDynamicTexture::~LLDynamicTexture()
66{ 68{
69 releaseGLTexture();
67 for( S32 order = 0; order < ORDER_COUNT; order++ ) 70 for( S32 order = 0; order < ORDER_COUNT; order++ )
68 { 71 {
69 LLDynamicTexture::sInstances[order].removeData(this); // will fail in all but one case. 72 LLDynamicTexture::sInstances[order].removeData(this); // will fail in all but one case.
@@ -71,19 +74,23 @@ LLDynamicTexture::~LLDynamicTexture()
71} 74}
72 75
73//----------------------------------------------------------------------------- 76//-----------------------------------------------------------------------------
74// generateGLTexture() 77// releaseGLTexture()
75//----------------------------------------------------------------------------- 78//-----------------------------------------------------------------------------
76void LLDynamicTexture::generateGLTexture() 79void LLDynamicTexture::releaseGLTexture()
77{ 80{
78 if (mComponents < 1 || mComponents > 4) 81 if (mTexture.notNull())
79 { 82 {
80 llerrs << "Bad number of components in dynamic texture: " << mComponents << llendl; 83// llinfos << "RELEASING " << (mWidth*mHeight*mComponents)/1024 << "K" << llendl;
84 mTexture = NULL;
81 } 85 }
86}
82 87
83 LLPointer<LLImageRaw> raw_image = new LLImageRaw(mWidth, mHeight, mComponents); 88//-----------------------------------------------------------------------------
84 mTexture = new LLImageGL(mWidth, mHeight, mComponents, FALSE); 89// generateGLTexture()
85 mTexture->createGLTexture(0, raw_image); 90//-----------------------------------------------------------------------------
86 mTexture->setClamp(mClamp, mClamp); 91void LLDynamicTexture::generateGLTexture()
92{
93 generateGLTexture(-1, 0, 0, FALSE);
87} 94}
88 95
89void LLDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes) 96void LLDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes)
@@ -92,10 +99,14 @@ void LLDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum prima
92 { 99 {
93 llerrs << "Bad number of components in dynamic texture: " << mComponents << llendl; 100 llerrs << "Bad number of components in dynamic texture: " << mComponents << llendl;
94 } 101 }
95 102 releaseGLTexture();
96 LLPointer<LLImageRaw> raw_image = new LLImageRaw(mWidth, mHeight, mComponents); 103 LLPointer<LLImageRaw> raw_image = new LLImageRaw(mWidth, mHeight, mComponents);
97 mTexture = new LLImageGL(mWidth, mHeight, mComponents, FALSE); 104 mTexture = new LLImageGL(mWidth, mHeight, mComponents, FALSE);
98 mTexture->setExplicitFormat(internal_format, primary_format, type_format, swap_bytes); 105 if (internal_format >= 0)
106 {
107 mTexture->setExplicitFormat(internal_format, primary_format, type_format, swap_bytes);
108 }
109// llinfos << "ALLOCATING " << (mWidth*mHeight*mComponents)/1024 << "K" << llendl;
99 mTexture->createGLTexture(0, raw_image); 110 mTexture->createGLTexture(0, raw_image);
100 mTexture->setClamp(mClamp, mClamp); 111 mTexture->setClamp(mClamp, mClamp);
101} 112}
@@ -193,6 +204,8 @@ BOOL LLDynamicTexture::updateAllInstances()
193 return TRUE; 204 return TRUE;
194 } 205 }
195 206
207 BOOL started = FALSE;
208
196 BOOL result = FALSE; 209 BOOL result = FALSE;
197 for( S32 order = 0; order < ORDER_COUNT; order++ ) 210 for( S32 order = 0; order < ORDER_COUNT; order++ )
198 { 211 {
@@ -202,11 +215,16 @@ BOOL LLDynamicTexture::updateAllInstances()
202 { 215 {
203 if (dynamicTexture->needsRender()) 216 if (dynamicTexture->needsRender())
204 { 217 {
218 if (!started)
219 {
220 started = TRUE;
221 LLVertexBuffer::startRender();
222 }
223
205 dynamicTexture->preRender(); 224 dynamicTexture->preRender();
206 if (dynamicTexture->render()) 225 if (dynamicTexture->render())
207 { 226 {
208 result = TRUE; 227 result = TRUE;
209 gViewerWindow->finishFastFrame();
210 sNumRenders++; 228 sNumRenders++;
211 } 229 }
212 dynamicTexture->postRender(result); 230 dynamicTexture->postRender(result);
@@ -214,6 +232,11 @@ BOOL LLDynamicTexture::updateAllInstances()
214 } 232 }
215 } 233 }
216 234
235 if (started)
236 {
237 LLVertexBuffer::stopRender();
238 }
239
217 return result; 240 return result;
218} 241}
219 242