Hello, as most of you may know gmod came out with a new update. This update is the reason why one of my most useful addons broke... screengrab.. Gmod did this to help protect peoples privacy which is understandable since we could view steam overlay
Gmod broke this by removing render.Capture which is how the addon functions.
The only way there is to fix this seems to be by avoiding render.Capture completely. If anyone can help me out with this that would be great!
Link to the code of this addon - https://github.com/cobalt77/Screengrab
It's not removed, render.Capture
Since the pixel buffer clears itself every frame, this will return a black screen outside of render hooks. To capture the user's final view, use GM:PostRender.
Yea, ive tried using that but it didnt seem to work.
Could you show me?
-- new "StartScreengrab" callback
net.Receive("StartScreengrab", function()
shouldScreengrab = true
end)
hook.Add("PostRender", "Screengrab", function()
if shouldScreengrab then
-- old "StartScreengrab" callback call
shouldScreengrab = false
end
end)
Added as an example on the wiki under GM/PostRender
Havnt tried this yet, ill try once i get home. Also ,
I think it was taken down.
render.Capture
The example is here the whole time.
Sorry for bothering you, but could you tell me if this is correct at all?
net.Receive("StartScreengrab", function()
shouldScreengrab = true
end )
hook.Add("PostRender", "Screengrab", function()
if shouldScreengrab then
net.Receive( "StartScreengrab", function()
shouldScreengrab = false
end
end)
local quality = net.ReadUInt( 32 )
local _ply = net.ReadEntity()
cl_rtxappend2( sg.green, "Initializing", _ply )
local function capture( q )
local tab = {
format = "jpeg",
h = ScrH(),
w = ScrW(),
quality = q,
x = 0,
y = 0
}
local split = 20000
local _data = util.Base64Encode( render.Capture( tab ) )
local data = util.Compress( _data )
local len = string.len( data )
cl_rtxappend2( color_white, "Captured " .. len .. " bytes", _ply )
local parts = math.ceil( len / split )
cl_rtxappend2( color_white, parts .. " parts", _ply )
local partstab = {}
for i = 1, parts do
local min
local max
if i == 1 then
min = i
max = split
elseif i > 1 and i ~= parts then
min = ( i - 1 ) * split + 1
max = min + split - 1
elseif i > 1 and i == parts then
min = ( i - 1 ) * split + 1
max = len
end
No, use this. It replaces lines 195-256 in your original file:
local shouldScreengrab = false
net.Receive( "StartScreengrab", function()
shouldScreengrab = true
end)
hook.Add("PostRender", "Screengrab", function()
if (!shouldScreengrab) then return end
shouldScreengrab = false
local quality = net.ReadUInt( 32 )
local _ply = net.ReadEntity()
cl_rtxappend2( sg.green, "Initializing", _ply )
local function capture( q )
local tab = {
format = "jpeg",
h = ScrH(),
w = ScrW(),
quality = q,
x = 0,
y = 0
}
local split = 20000
local _data = util.Base64Encode( render.Capture( tab ) )
local data = util.Compress( _data )
local len = string.len( data )
cl_rtxappend2( color_white, "Captured " .. len .. " bytes", _ply )
local parts = math.ceil( len / split )
cl_rtxappend2( color_white, parts .. " parts", _ply )
local partstab = {}
for i = 1, parts do
local min
local max
if i == 1 then
min = i
max = split
elseif i > 1 and i ~= parts then
min = ( i - 1 ) * split + 1
max = min + split - 1
elseif i > 1 and i == parts then
min = ( i - 1 ) * split + 1
max = len
end
local str = string.sub( data, min, max )
partstab[ i ] = str
end
local amt = table.getn( partstab )
net.Start( "ScreengrabInitCallback" )
net.WriteEntity( _ply )
net.WriteUInt( amt, 32 )
net.WriteUInt( len, 32 )
net.WriteFloat( CurTime(), 32 )
net.SendToServer()
cl_rtxappend2( Color( 0, 255, 0 ), "Preparing to send data", _ply )
local i = 1
timer.Create( "ScreengrabSendParts", 0.1, amt, function()
net.Start( "ScreengrabSendPart" )
local l = partstab[ i ]:len()
net.WriteUInt( l, 32 )
net.WriteData( partstab[ i ], l )
net.SendToServer()
cl_rtxappend2( Color( 255, 255, 0 ), "Sent " .. i .. STNDRD( i ) .. " part", _ply )
net.Start( "Progress" )
net.WriteEntity( _ply )
net.WriteFloat( ( i / amt ) / 2 )
net.SendToServer()
i = i + 1
end )
end
capture( quality )
end )
Thanks to all of you. Problem has been solved.
Sorry, you need to Log In to post a reply to this thread.