The render target suggestion is the best way to do what you're
attempting to do (if I read you correctly, you want to put text on a
material and then render it somewhere).
The easiest method would be to re-add baseclientrendertexture.cpp to
the client, and setup a new rendertarget like that (you also need to
add some stuff to rendertargets.cpp)
you then need to expose the interface, which you can do like this:

static CBaseClientRenderTargets g_BaseClientRenderTargets;
IClientRenderTargets *g_pClientRenderTargets = ( IClientRenderTargets
* )&g_BaseClientRenderTargets;
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CBaseClientRenderTargets,
IClientRenderTargets,CLIENTRENDERTARGETS_INTERFACE_VERSION,
g_BaseClientRenderTargets );

at the bottom of baseclientrendertargets.cpp

now note: make sure that you comment out the initialization of the
existing ones in there, ie:
in
void CBaseClientRenderTargets::InitClientRenderTargets(
IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig*
pHardwareConfig )
and
void CBaseClientRenderTargets::ShutdownClientRenderTargets()

comment out the m_WaterReflectionTexture / refraction / camera init()
and shutdown() lines, because they're created in the engine's version
of the render targets.
ie: for mine, i simply removed them as shown here:
void CBaseClientRenderTargets::InitClientRenderTargets(
IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig*
pHardwareConfig )
{
        //Tony; removed the old render targets that are initialized in the
engine and init custom render target only
        m_RadarTexture.Init( CreateRadarTexture( pMaterialSystem ) );
}

void CBaseClientRenderTargets::ShutdownClientRenderTargets()
{
        //Tony; removed old render targets.
        m_RadarTexture.Shutdown();
}
for reference:
m_RadarTexture is setup like:
ITexture* CBaseClientRenderTargets::CreateRadarTexture(
IMaterialSystem* pMaterialSystem )
{
        return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
                "_rt_Radar",
                512, 512, RT_SIZE_DEFAULT,
                pMaterialSystem->GetBackBufferFormat(),
                MATERIAL_RT_DEPTH_SHARED,
                0,
                CREATERENDERTARGETFLAGS_HDR );
}
which is what Init() uses.
rendertexture.cpp has this for ease of use:
static CTextureReference radarRT;
ITexture* GetRadarRT(void)
{
        if ( !radarRT )
        {
                radarRT.Init( materials->FindTexture( "_rt_Radar",
TEXTURE_GROUP_RENDER_TARGET ) );
                Assert( !IsErrorTexture( radarRT ) );
                AddReleaseFunc();
        }
        return radarRT;
}

now .. with the way this works, if you create a new vmt to use the
render target on something, it would look something like this:

"UnlitGeneric"
{
        "$basetexture" "_rt_Radar"
}

using this same scheme you can of course put this on a model, ie:
"VertexLitGeneric"
{
      "$basetexture" "_rt_Radar"
}
and go about your business.

now, continuing with what you want to do, essentially all you have to
do to write vgui out (I actually use this render target that i've
referenced with a hud object)
i push the 2d view and set it to render to the _rt_Radar render target
from within a hud element, paint stuff, and then pop the view back.
it's as simple as that, then whenever the material is rendered it
shows whatever was put on it.

this will in effect be one visual frame behind (if you do it from a
hud element and then render onto a model instead of the hud, that is)
but it's not noticable.
alternatively you could actually force a special vgui panel that
you're going to write with, to render into the render target BEFORE
models are drawn, I'm not going to get into the details on that, but
you should be able to figure that out by poking around the sdk ;)
-Tony



On Nov 16, 2007 12:35 PM, Janek <[EMAIL PROTECTED]> wrote:
> --
> [ Picked text/plain from multipart/alternative ]
> Thank you for this link and feedback. I didn't succeed to do what I want
> till now but I'm working on :-D
>
> 2007/11/16, Nate Nichols <[EMAIL PROTECTED]>:
>
> >
> > The old version of News at Seven used procedural materials (512x512
> > IIRC) to play movies, and that seemed to run ok.  It was a small map
> > with not much going on, but it was also just running on my non-beefy
> > laptop, and I definitely did not know what I was doing.    Here's a
> > link to the Wiki with code we used for playing movies:
> > http://developer.valvesoftware.com/wiki/Avi_materials
> >
> > Nate
> >
> > On 16/11/2007, Christopher Harris <[EMAIL PROTECTED]> wrote:
> > > In my experience of trying a procedural material is it is slow unless
> > you
> > > really know what you are doing. Trying to brute force change every pixel
> > > every call to the regenerator met with bad results unless the texture
> > was
> > > 256x256 or smaller.
> > > ----- Original Message -----
> > > From: "Janek" <[EMAIL PROTECTED]>
> > > To: <[email protected]>
> > > Sent: Friday, November 16, 2007 3:57 AM
> > > Subject: Re: [hlcoders] Dynamically creating material including text
> > >
> > >
> > > > --
> > > > [ Picked text/plain from multipart/alternative ]
> > > > Thx Paul and Mike for your suggestions. I think I will try both of
> > them.
> > > > Paul's solution seems easier as we can use standard vgui functions
> > > > (surface->Draw*) but I don't know if render target will be updated at
> > the
> > > > correct framerate.
> > > > Mike's solution sounds more complex (I don't know which command I can
> > use
> > > > to
> > > > select a font, a color and to draw text) but it is a real material.
> > > >
> > > > I'll work on that. Ty very much for your help mates.
> > > >
> > > > 2007/11/16, Paul Peloski <[EMAIL PROTECTED]>:
> > > >>
> > > >> --
> > > >> [ Picked text/plain from multipart/alternative ]
> > > >> Another, easier way is with a render target.
> > > >>
> > > >> Initializing:
> > > >>
> > > >> - Create a render target texture of the size you need (derive
> > > >> CBaseClientRenderTargets, you have to init a render target at the
> > right
> > > >> time), call it something like _my_rt0
> > > >>
> > > >> Drawing:
> > > >>
> > > >> - Use SetRenderTargetAndViewPort to set the render target and view
> > area
> > > >> - Clear the render target
> > > >> - Paint a vgui control or several vgui controls (call
> > Paint/PaintTraverse
> > > >> or
> > > >> something manually) or, use surface->Draw*
> > > >> - The render target now contains whatever vgui painted, and you can
> > > >> reference it in a .vmt using $basetexture "_my_rt0".
> > > >>
> > > >> The way Mike suggested hasn't really worked for me, I had problems
> > trying
> > > >> to
> > > >> get the procedural texture to work. This way is somewhat easier if
> > you
> > > >> just
> > > >> want to draw text the way vgui does. If you need to upload text where
> > you
> > > >> already have the raw image data then use the procedural texture.
> > Likewise
> > > >> if
> > > >> you wanted to read image data from a video decoder or unsupported
> > image
> > > >> format.
> > > >>
> > > >> Regards,
> > > >>
> > > >> Paul
> > > >>
> > > >> On Nov 15, 2007 1:19 PM, Janek <[EMAIL PROTECTED]> wrote:
> > > >>
> > > >> > --
> > > >> > [ Picked text/plain from multipart/alternative ]
> > > >> > Thx Mike. I'll read that again and again. At the moment I don't
> > > >> understand
> > > >> > everything. I hope I can write text using this method but I'm not
> > sure.
> > > >> >
> > > >> > 2007/11/15, Mike Durand <[EMAIL PROTECTED]>:
> > > >> > >
> > > >> > > Try this:
> > > >> > >
> > > >> > > http://developer.valvesoftware.com/wiki/Procedural_Materials
> > > >> > >
> > > >> > > -----Original Message-----
> > > >> > > From: [EMAIL PROTECTED]
> > > >> > > [mailto:[EMAIL PROTECTED] On Behalf Of Janek
> > > >> > > Sent: Thursday, November 15, 2007 7:45 AM
> > > >> > > To: [email protected]
> > > >> > > Subject: [hlcoders] Dynamically creating material including text
> > > >> > >
> > > >> > > --
> > > >> > > [ Picked text/plain from multipart/alternative ]
> > > >> > > Hi all,
> > > >> > >
> > > >> > > I would like to know if it is possible to dynamically create a
> > > >> > > clean IMaterial (client side only) in which I write some texts
> > which
> > > >> can
> > > >> > > be
> > > >> > > an argument like "My text" or whatever.
> > > >> > > I know the materials->FindMaterial( name, group ) which is using
> > an
> > > >> > > exisiting material. What I want is to create my own one
> > dynamically
> > > >> coz
> > > >> > > I
> > > >> > > don't know what text will be in this material.
> > > >> > >
> > > >> > > Any idea ?
> > > >> > > --
> > > >> > >
> > > >> > > _______________________________________________
> > > >> > > To unsubscribe, edit your list preferences, or view the list
> > > >> > > archives,
> > > >> > > please visit:
> > > >> > > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > > >> > >
> > > >> > >
> > > >> > > _______________________________________________
> > > >> > > To unsubscribe, edit your list preferences, or view the list
> > > >> > > archives,
> > > >> > > please visit:
> > > >> > > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > > >> > >
> > > >> > >
> > > >> >
> > > >> >
> > > >> > --
> > > >> > -------------------
> > > >> > [EMAIL PROTECTED]
> > > >> > --
> > > >> >
> > > >> > _______________________________________________
> > > >> > To unsubscribe, edit your list preferences, or view the list
> > archives,
> > > >> > please visit:
> > > >> > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > > >> >
> > > >> >
> > > >> --
> > > >>
> > > >> _______________________________________________
> > > >> To unsubscribe, edit your list preferences, or view the list
> > archives,
> > > >> please visit:
> > > >> http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > > >>
> > > >>
> > > >
> > > >
> > > > --
> > > > -------------------
> > > > [EMAIL PROTECTED]
> > > > --
> > > >
> > > > _______________________________________________
> > > > To unsubscribe, edit your list preferences, or view the list archives,
> > > > please visit:
> > > > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > > >
> > >
> > >
> > > _______________________________________________
> > > To unsubscribe, edit your list preferences, or view the list archives,
> > please visit:
> > > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > >
> > >
> >
> > _______________________________________________
> > To unsubscribe, edit your list preferences, or view the list archives,
> > please visit:
> > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >
> >
>
>
> --
> -------------------
> [EMAIL PROTECTED]
> --
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives, please 
> visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>



--
-omega

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to