Game Development Community

Release 1.4 DynamicTexture help

by Bill Vee · in Torque Game Engine · 11/26/2005 (10:01 am) · 23 replies

Ok first off I am not an expert programmer or I could fiqure this out but this is the first function I simply can't figure out how to impliment.

What I am trying to do is take the fxGuiSnooper resource and the fxRenderObject resource and by using the DynamicTexture bind the fxGuiSnooper texture to the fxRenderObject texture.

This is what I thought would work

void fxGuiSnooper::renderWorld(const RectI & updateRect)
{
[b]	DynamicTexture *textfx1 = new DynamicTexture( updateRect); [/b]

[b]textfx1->setUpdateRect(updateRect); [/b]
[b]textfx1->storePixels(); [/b]
	// Set-up OpenGL for a scene render.
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	glClear(GL_DEPTH_BUFFER_BIT);
	glDisable(GL_CULL_FACE);
	glMatrixMode(GL_MODELVIEW);
	dglSetCanonicalState();

	// Render Client Scene Graph.
	gClientSceneGraph->renderScene();

	// Disable Depth Test.
	glDisable(GL_DEPTH_TEST);
[b]textfx1->restorePixels(); [/b]
[b]textfx1->update(); [/b]
[b]fxRenderObject* fxRenderOb = static_cast<fxRenderObject*>(mAttachedObject); [/b]
[b]TextureHandle tex1;// = fxRenderOb->mTextureHandle; [/b]
[b]tex1  = fxRenderOb->mTextureHandle; [/b]
[b]fxRenderOb->mTextureHandle = tex1; [/b]
}

While it compiles fine it won't map the texture to the fxRenderObject.
Page«First 1 2 Next»
#21
12/24/2005 (9:35 am)
I added
mDynamicTexture = new DynamicTexture();
as part of the fxGuiSnooper constuctor. Which I think is probably wrong.

But when called there are 4 steps to use the dynamictexture according to the header.

mDynamicTexture ->setUpdateRect(updateRect);
mDynamicTexture ->storePixels();
//render code
mDynamicTexture ->update();
mDynamicTexture ->restorePixels();

setUpdateRect(updateRect); passes ok
mDynamicTexture ->storePixels(); passes ok
the object renders ok
then mDynamicTexture ->update(); fails with the this as expression cannot be evaluated.

Like I said I am not an expert. I think the problem is on my end. I just don't know what it is.
It's got to be the allocating of the DynamicTexture .
#22
12/24/2005 (7:56 pm)
Your alloc call will result in a valid pointer.

Are you sure that the this for the object which is calling the mDynamicTexture is valid? If it's wrong then you'll get a garbage mDynamicTexture too.
#23
12/24/2005 (8:20 pm)
According to VC7's debug it's 0xcececece ..... if thats what you mean.
Did you see the screenshot I posted a couple of posts back of the debug when it fails.

If I comment out the mDynamicTexture stuff in the render it runs ok and displays the GUI.
Page«First 1 2 Next»