[Release] Generic DUI 2d/3d renderer

,

What

Combine the power of DUI and Scaleform together. Long story short:

Gimme gimme

generic_texture_renderer_gfx.zip (4.7 KB)

How

Unpack it in your resources folder. Add this line to your server config:

start generic_texture_renderer_gfx

That was the easiest part. As it is just a tool and not a standalone kind of resource you gotta add something else, something that will use this renderer.

Example JS code that backs pic above
async function loadScaleform(scaleform) {
  let scaleformHandle = RequestScaleformMovie(scaleform);

  return new Promise(resolve => {
    const interval = setInterval(() => {
      if (HasScaleformMovieLoaded(scaleformHandle)) {
        clearInterval(interval);
        resolve(scaleformHandle);
      } else {
        scaleformHandle = RequestScaleformMovie(scaleform);
      }
    }, 0);
  });
}

const url = 'https://w.soundcloud.com/player/?url=' +
  'https%3A//api.soundcloud.com/tracks/467725488&color=%23ff5500&auto_play=true' +
  '&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true';
const scale = 0.1;
const sfName = 'generic_texture_renderer';

const width = 1280;
const height = 720;

let sfHandle = null;
let txdHasBeenSet = false;
let duiObj = null;

setTick(() => {
  const ped = PlayerPedId();
  const pos = GetEntityCoords(ped);

  if (sfHandle !== null && !txdHasBeenSet) {
    PushScaleformMovieFunction(sfHandle, 'SET_TEXTURE');

    PushScaleformMovieMethodParameterString('meows'); // txd
    PushScaleformMovieMethodParameterString('woof'); // txn

    PushScaleformMovieFunctionParameterInt(0); // x
    PushScaleformMovieFunctionParameterInt(0); // y
    PushScaleformMovieFunctionParameterInt(width);
    PushScaleformMovieFunctionParameterInt(height);

    PopScaleformMovieFunctionVoid();

    txdHasBeenSet = true;
  }

  if (sfHandle !== null && HasScaleformMovieLoaded(sfHandle)) {
    DrawScaleformMovie_3dNonAdditive(
      sfHandle,
      pos[0] - 1, pos[1], pos[2] + 2,
      0, 0, 0,
      2, 2, 2,
      scale * 1, scale * (9/16), 1,
      2,
    );
  }
});

on('onClientResourceStart', async (resName) => {
  if (resName === GetCurrentResourceName()) {
    sfHandle = await loadScaleform(sfName);

    runtimeTxd = 'meows';

    const txd = CreateRuntimeTxd('meows');
    const duiObj = CreateDui(url, width, height);
    const dui = GetDuiHandle(duiObj);
    const tx = CreateRuntimeTextureFromDuiHandle(txd, 'woof', dui);
  }
})

on('onResourceStop', (resName) => {
  if (resName === GetCurrentResourceName()) {
    DestroyDui(duiObj);
    SetScaleformMovieAsNoLongerNeeded(sfName)
  }
})

I want a many of them on muh screen

There’re two .gfx in the stream folder of this res, as you may have noticed, this is to demonstrate the need for a separate file for each instance of scaleform in-game, if you need many of floating DUI’s on the screen you just clone .gfx with a new name and use it by it’s name.

F.A.Q.

Can you please make a Lua version of it?

No, it’s not bound to any language runtime at.

I don’t get how to use it?

Well, simple answer is that then you should not, sorry.

How do I run example?

Seriously, if you don’t know how then you most likely should not be doing it.

An excuse to all above

This is not a resource for server builders or persons like that, this is a resource for developers who make their own resources, you see, this is a meta resource! So please, please, PLEASE, if you don’t get it or don’t know where to see it in game then don’t use it, it is not for you.

31 Likes

I seen this the other day in various chats but had not have the time to ask does this also have audio?

Aw yeah, it does, a dot.

1 Like

i was hoping something like this could be implemented on the screen in Tivoli cinema interior

It could be. But it is not a topic of this particular resource.

1 Like

How to create screen? and edit the .gfx?

OMG, this is going to be sooo awesome @thers <3
Soo awesome


3 Likes

gimme gimme ! :mascot:

Hows this different to the normal DUI stuff? Is it like being able to just draw it in 3d space?

Yeah, ive done that before (not on the cinema screen though, the resolution on it is awful)

1 Like

This isn’t different to the normal DUI stuff. It is a normal DUI stuff. But this particular resource provides you with a gfx that is able to render texture and be rendered and 3d space.

1 Like

Ah, nice.

in addition there’s no extra downscaling

Can I use this with LUA? I am not ablte to find anything about dui in natives/fivem docs.

Thats because its undocumented

Will it be added to documents soon? Really top omg mlg 1337 elite ultra spec feature :open_mouth:

Look in natives_universal.lua in your fivem files, it tells you what they do in there

2 Likes

Thanks a lot. And is there are any way to support youtube ebmed? It says error parsing header x-xss-protection

Ingore that, it will still work

1 Like

Wow really. Last question. How can I stop sound of this? Because when I am destroying DUI the sound is still playing. It also has extremely low fps when I am trying to watch youtube video. I also determined that low fps happens when I am recreating screen with video.