Jump to content

World point as screen source


SDraw

Recommended Posts

Well, it's really great to render your screen on screen source as provided by example on https://wiki.multitheftauto.com/wiki/DxCreateScreenSource(Xzibit style). But is it possible to render another world point, like render beach with ocean view when you are in city?

I've tried to change player camera position, get his screen, return camera back and update screen source, but it flickers so fast o_O

Even I've thought to create transparent ped, move his camera, get his screen and update screen source for player...But I haven't found function for this...

What do you think?

Link to comment

Well, finally done it :D

local stateCamera = 1 
local screenSource = { new, old } 
local screenSize = { x, y } 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        screenSize.x, screenSize.y = guiGetScreenSize() 
        screenSource.old = dxCreateScreenSource (screenSize.x, screenSize.y) 
        screenSource.new = dxCreateScreenSource ( 640, 480 ) 
        outputChatBox("test.lua loaded") 
                  -- Create a screen source texture which is 640 x 480 pixels 
    end 
) 
  
addEventHandler( "onClientRender", root, 
    function() 
            if(stateCamera == 1) then 
                if(dxUpdateScreenSource(screenSource.old) == false) then 
                    outputChatBox("dxUpdateScreenSource(screenSource.old) == false") 
                else 
                    outputChatBox("dxUpdateScreenSource(screenSource.old) == true") 
                end 
                dxDrawImage(0,0,screenSize.x, screenSize.y,screenSource.old) 
                dxDrawImage( 50,  50,  100, 100, screenSource.new )       -- Now use myScreenSource as a material and draw it lots of times 
                dxDrawImage( 150, 350, 150, 100, screenSource.new ) 
                dxDrawImage( 250, 250, 100, 150, screenSource.new ) 
                dxDrawImage( 350, 30,  150, 150, screenSource.new ) 
                local x,y,z,lx,ly,lz = getCameraMatrix() 
                setCameraMatrix(x,y,z+20,lx,ly,lz+20) 
                stateCamera = 2 
            else                  -- Capture the current screen output from GTA 
                if(dxUpdateScreenSource(screenSource.new) == false) then 
                    outputChatBox("dxUpdateScreenSource(screenSource.new) == false") 
                else 
                    outputChatBox("dxUpdateScreenSource(screenSource.new) == true") 
                end 
                dxDrawImage(0,0,screenSize.x, screenSize.y,screenSource.old) 
                dxDrawImage( 50,  50,  100, 100, screenSource.new )       -- Now use myScreenSource as a material and draw it lots of times 
                dxDrawImage( 150, 350, 150, 100, screenSource.new ) 
                dxDrawImage( 250, 250, 100, 150, screenSource.new ) 
                dxDrawImage( 350, 30,  150, 150, screenSource.new ) 
                local x,y,z,lx,ly,lz = getCameraMatrix() 
                setCameraMatrix(x,y,z-20,lx,ly,lz-20) 
                stateCamera = 1 
            end 
        end 
) 

Used example from link in first post.

But during this code FPS in these screen sources are equal a half of your real FPS. Yeah, just moved camera higher...But it's something! :P

Link to comment

Unfortunately there can't be more than 1 cameras. You can only have 1. You decide where it is and what is rendered. Since you can't render twice the same frame that's why you have to render 1 frame then another frame from different location, that's what causes flickering.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...