RenderSystem.CreateRenderTexture() naming problem


26-10-2007 19:04:01

Hi all,

I've been having a strange problem with textures created using RenderSystem.CreateRenderTexture().

What happens is that I create a texture with a given name, say "Tex1", and the resulting texture doesn't have the same name, rather it displays an obscure name like "rtt/77813888".

Obviously this raises issues for material scripts, since they can't reference the correct texture.

Anyone has a clue about what's going on?

Best regards,



26-10-2007 22:14:36


First of all, are you sure you want to create a render texture ? These texture are used for off-screen rendering. They are like a RenderWindow, but invisible. These are not you normal material textures. The strange name you see is the internal name of the render target (rtt = Render-To-Texture).

Secondly, I believe RenderSystem.CreateRenderTexture is deprecated. You have to create a texture with TextureManager.CreateManual with usage TU_RENDERTARGET.



29-10-2007 10:13:29

Thanks for the update,

I do want to create a Render-To-Texture, but I was unaware that the function was deprecated, thanks for the heads-up.

[edit] On a related topic, can the texture created by CreateManual with usage TU_RENDERTARGET be obtained by calling RenderSystem.GetRenderTarget()? How can I assign viewports to it? In sum, what is the role of RenderTexture and how can I create an instance and use it?

Anyway, why isn't the TextureUsage enumeration used in the header of the CreateManual function?

Best regards,



30-10-2007 00:01:54

Hi, again, I dont have a lot of time to help you, but here I just pasted a piece of code I wrote some time ago. I creates a node with 4 cameras/viewports attached to it which all renders to the same textures (one in each quadrant). You can probably figure out what the variables are. You can simplify it for a single camera/viewport setup.


m_texture = TextureManager.Singleton.CreateManual("Vis", "", TextureType.TEX_TYPE_2D, 1024, 1024, 0, PixelFormat.PF_BYTE_BGRA, (int)Mogre.TextureUsage.TU_RENDERTARGET);
m_rt = m_texture.GetBuffer().GetRenderTarget();

Quaternion[] orients = new Quaternion[] {
new Quaternion( 1, 0, 0, 0), // Face
new Quaternion( SQRT_12, 0, SQRT_12, 0), // Gauche
new Quaternion( 0, 0, 1, 0), // Arriere
new Quaternion( SQRT_12, 0, -SQRT_12, 0), // Droite
new Quaternion( SQRT_12, SQRT_12, 0, 0), // Haut
new Quaternion( SQRT_12, -SQRT_12, 0, 0) }; // Bas

float[,] pos = new float[4, 2] { { 0.0f, 0.0f },
{ 0.5f, 0.0f },
{ 0.0f, 0.5f },
{ 0.5f, 0.5f } };

m_cameraNode = m_sm.RootSceneNode.CreateChildSceneNode("VisCameraNode");

m_cameras = new Camera[4];
m_viewports = new Viewport[4];

for (int i = 0; i < 4; i++)
m_cameras[i] = m_sm.CreateCamera("Vis" + i);
m_cameras[i].AspectRatio = 1.0f;
m_cameras[i].NearClipDistance = 1;
m_cameras[i].FarClipDistance = 1000;
m_cameras[i].FOVy = new Degree(90.0f);
m_cameras[i].Orientation = orients[i];

m_viewports[i] = m_rt.AddViewport(m_cameras[i], i, pos[i, 0], pos[i, 1], 0.5f, 0.5f);
m_viewports[i].OverlaysEnabled = false;




31-10-2007 00:02:03

Hi again,

Thanks for the example code. I think that I'm having a hard-time explaining myself, here as well as in the main Ogre forums. What I was after was not a way of doing it in code, but a way to script the assignment of viewports to cameras and render targets.

Basically what I wanted was something similar to this XML excerpt:

<viewport renderTargetName="Target1" cameraName="Camera2">

In the parser I was hoping that I could then access a renderTarget named "Target1", regardless of whether it was a RenderWindow or a RenderTexture or even a MultiRenderTarget.

I was just arguing that previous Ogre versions had this abstracted in the RenderSystem, but now apparently there is no way for me to create an instance of RenderTexture with a specific name. I can indeed create the dynamic Texture with a specific name, but not the RenderTexture instance, as this is always created with an internally generated name.

However, now at least I'm clarified as to Ogre can and cannot do in this regard, and I will try to work around it as best I can.

Thanks for all your honest help.

Best regards,



31-10-2007 05:19:45

Oh i see. Its more of a name thing... Sorry I didnt get that.

Well, you could keep come kind of lookup table or hashtable to access the render targets with your own name. Anyway, you will figure it out! Good luck!