SDraw Posted August 13, 2013 Share Posted August 13, 2013 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
SDraw Posted August 13, 2013 Author Share Posted August 13, 2013 Well, finally done it 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! Link to comment
50p Posted August 14, 2013 Share Posted August 14, 2013 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now