Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#515 closed enhancement (fixed)

A simple gadget request

Reported by: beherith Owned by: Bluestone
Priority: minor Milestone:
Component: BAR Version:
Keywords: Cc:

Description (last modified by beherith)

I would like to request a gadget that does three things: It gets called init it gets called on viewresize And it has a single function that can be called from any unsynced gadget and any widget which returns a string.

I totally fail at the gadget interoperability, and have wasted a day and gotten nowhere with it :(

Any favor barter offers are welcome.

Change History (16)

comment:1 by beherith, 7 years ago

Description: modified (diff)

comment:2 by Bluestone, 7 years ago

Owner: set to Bluestone

I'll do it.

What string do you want it to return? And what do you mean by 'called' on view resize and init - where should it return to in these cases?

Last edited 7 years ago by Bluestone (previous) (diff)

comment:3 by beherith, 7 years ago

It will return a string that is a handle to a lua texture. It should just return to itself when called in resize and init, like a normal gadget.

comment:4 by beherith, 7 years ago

Aparrently, its ok if this is just a widget, too: http://springrts.com/phpbb/viewtopic.php?f=23&t=31243

comment:5 by Bluestone, 7 years ago

I am lost here - the texture (and its 'string' identifier) is only valid within the lua state that it's created in, so it wouldn't help to know what that identifier was in another lua state unless you'd also sent the entire texture over.

I guess jKs Script.LuaUI solution works (didn't test it) and the fact that jK didn't use _G suggests that my _G solution won't, I guess because of the amount of data involved.

Do you have code that creates + binds the texture you're interested in? And then I can play with it and try and send it somewhere.

comment:6 by beherith, 7 years ago

function widget:GetInfo()
  return {
    name      = "Screencopy Manager",
    desc      = "Makes a copy of the screen to a texture to share to bloom, los and distortionfbo",
    author    = "Beherith",
    date      = "Nov 2013",
    license   = "GNU GPL, v2 or later",
    layer     = -1000000000,
    enabled   = true  --  loaded by default?
  }
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local screenTexture = nil
local vsx =0 
local vsy =0
local lastupdate = 0


local glCopyToTexture = gl.CopyToTexture
local glCreateTexture = gl.CreateTexture
local glDeleteTexture = gl.DeleteTexture
local spGetDrawFrame  = Spring.GetDrawFrame


function widget:Initialize()
	Spring.Echo('Welcome to the fx_screencopy_manager!')
	if glCopyToTexture == nil then
		Spring.Echo('Sorry you are screwed with no glCopyToTexture support')
		return
	end
	screenTexture = gl.CreateTexture(vsx,vsy, {
		min_filter = GL.LINEAR,
		mag_filter = GL.LINEAR,
		wrap_s   = GL.CLAMP_TO_EDGE,
		wrap_t   = GL.CLAMP_TO_EDGE,
		})
end

function widget:ViewResize(viewSizeX, viewSizeY)
	Spring.Echo('fx_screencopy_manager:viewresize')
	vsx = viewSizeX
	vsy = viewSizeY
	if screenTexture then
		glDeleteTexture(screenTexture)
	end
	screenTexture = gl.CreateTexture(vsx,vsy, {
		min_filter = GL.LINEAR,
		mag_filter = GL.LINEAR,
		wrap_s   = GL.CLAMP_TO_EDGE,
		wrap_t   = GL.CLAMP_TO_EDGE,
		})
end

function widget:GameFrame(n)
	if n>lastupdate+30 and screenTexture then
		glDeleteTexture(screenTexture)
	end
end

function GetScreenCopy()
	if screenTexture == nil then
		Spring.Echo('Creating new screenTexture')
		widget:ViewResize(vsx,vsy)
	end
	if lastupdate < spGetDrawFrame() then
		lastupdate=spGetDrawFrame() 
		glCopyToTexture(screenTexture, 0, 0, 0, 0, vsx, vsy, nil,0)
	end
	return screenTexture
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

comment:7 by Bluestone, 7 years ago

We can close this now, right?

comment:8 by Bluestone, 7 years ago

Resolution: fixed
Status: newclosed

fixed by [1910]

comment:10 by NormanMouff, 4 years ago

bb1964 eb8208 [url=http://tadalafil.party]Cialis Pricesurl sy7103 sn2729rl106 <a href=" http://online-pharmacy.review ">pharmacy from canada</a> jd4444sr1515fw5341 ed6692 nb3693 [url=http://online-pharmacy.review]canada pharmacyurl hl3577

comment:11 by Jameshup, 4 years ago

fj9572 http://canpharm.win price of viagra <a href=" http://canpharm.win ">pharmacy from canada</a> zg5395 I am not my body. My body is nothing without me

comment:12 by Jameshup, 4 years ago

gz6271 http://zithromax.party information buy zithromax hf2841 [url=http://zithromax.party]Zithromax[/url] zithromax cheap for aa2361 <a href=" http://zithromax.party ">buy Zithromax</a> azithromycin offers br7202 What drains your pungency drains your body. What fuels your bent fuels your essence

comment:13 by Jameshup, 4 years ago

fa7997 http://levtrust.men levitra online purchase propecia <a href=" http://levtrust.men/ ">read more</a> ou6426 Before choosing healthy over half-starved you are choosing self-love to self-judgment. You are beautiful

comment:14 by eulane18, 4 years ago

Study my altered devise

mobogenie android games free download live wallpaper sexy girls download market application m market apk igo for android

http://sex.games.android.porndairy.in/?profile.eliza

live wallpaper adult erstes android smartphone app making my google play games download play market apk

comment:15 by shawnlk4, 4 years ago

Every day gay photos military talents

http://teen.gay.sexy.blogporn.in/?entry-geoffrey

comment:16 by Brianswins, 4 years ago

xq8396 http://generic-viagra.click viagra online discount <a href=" http://generic-viagra.click/#generic-viagra ">generic viagra</a> qo5657 Via choosing salubrious as a remainder pinched you are choosing self-love over self-judgment. You are incomparable gh8637 http://generic-cialis.review buying cialis online <a href=" http://generic-cialis.review/#poppers-and-cialis-20mg ">generic cialis</a> ke517 An over-indulgence of anything, all the same something as mere as unsound, can electrify

Note: See TracTickets for help on using tickets.