Lua FBO: Difference between revisions

From Spring
Jump to navigationJump to search
JK (talk | contribs)
New page: == FBO == '''gl.CreateFBO''' ( [ table initialization ] ) -> userdata fbo <font color=darkgreen> initialization table can contain: { depth = luaTex or RBO or nil, ste...
 
Ivand (talk | contribs)
mNo edit summary
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== FBO ==
== FBO ==
== FBO ==
'''gl.CreateFBO'''
'''gl.CreateFBO'''
   ( [ table initialization ] ) -> userdata fbo
   ( [ table initialization ] ) -> userdata [[Lua_FBO#Userdata_FBO|fbo]]
<font color=darkgreen>
<font color=darkgreen>
   initialization table can contain:
   initialization table can contain:
    attachment ::= luaTex or RBO or nil or { luaTex [, num [[Lua_ConstGL#FBO_Targets|target]] [, num level ] ] }
     {
     {
       depth  = luaTex or RBO or nil,
       depth  = attachment,
       stencil = luaTex or RBO or nil,
       stencil = attachment,
       color0  = luaTex or nil,
       color0  = attachment,
       color1  = luaTex or nil,
       color1  = attachment,
       color2  = luaTex or nil,
       color2  = attachment,
       ..
       ..
       color15 = luaTex or nil,
       color15 = attachment,
       drawbuffers = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT3_EXT, ..}
       drawbuffers = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT3_EXT, ..}
     }
     }
</font>
</font>


'''gl.DeleteFBO''' <font color=darkgreen>(this doesn't delete the attacked objects!)</font>
'''gl.DeleteFBO''' <font color=darkgreen>(This doesn't delete the attached objects!)</font>
   ( fbo ) -> nil
   ( fbo ) -> nil


'''gl.IsValidFBO''' <font color=darkgreen>(search the internet for glCheckFramebufferStatusEXT to learn more about the status param)</font>
'''gl.IsValidFBO'''
   ( fbo [, number target ] ) -> boolean valid [, number status ]
   ( fbo [, number [[Lua_ConstGL#FBO_Targets|target]] ] ) -> boolean valid [, number [[Lua_ConstGL#FBO_Status|status]] ]


'''gl.ActiveFBO'''
'''gl.ActiveFBO'''
   ( fbo [, number target] [, boolean loadIdentities ] , lua_function, arg1, arg2, ... ) -> nil
   ( fbo [, number [[Lua_ConstGL#FBO_Targets|target]] ] [, boolean identities ] , lua_function, arg1, arg2, ... ) -> nil


'''gl.UnsafeSetFBO''' <font color=red>(similar to gl.ActiveFBO(). NOTE: don't forget to unbind you FBO!)</font>
'''gl.UnsafeSetFBO''' <font color=darkgreen>(Binds a FBO like gl.ActiveFBO() does, but you have to unbind it yourself!)</font>
   ( nil [, number target = GL_FRAMEBUFFER_EXT ] ) -> nil <font color=darkgreen>(this will load the screenbuffer)</font>
   ( nil [, number [[Lua_ConstGL#FBO_Targets|target]] = GL_FRAMEBUFFER_EXT ] ) -> nil <font color=darkgreen>(Bind default screenbuffer)</font>
   ( fbo [, number target = fbo.target ] ) -> nil
   ( fbo [, number [[Lua_ConstGL#FBO_Targets|target]] = fbo.target ] ) -> nil
 
'''gl.RawBindFBO''' <font color=darkblue> (Replaces UnsafeSetFBO starting from 104.0.1-1003-gb3e02a6 maintenance)</font>
  ( nil [, number [[Lua_ConstGL#FBO_Targets|target]] = GL_FRAMEBUFFER_EXT ] [, number rawFboId = 0] ) -> nil <font color=darkgreen>(Bind default or specified via rawFboId numeric id of FBO)</font>
  ( fbo [, number [[Lua_ConstGL#FBO_Targets|target]] = fbo.target ] ) -> number previouslyBoundRawFboId


'''gl.BlitFBO''' <font color=red>needs GLEW_EXT_framebuffer_blit</font>
'''gl.BlitFBO''' <font color=red>needs GLEW_EXT_framebuffer_blit</font>
   ( int x0Src,y0Src,x1Src,y1Src, int x0Dst,y0Dst,x1Dst,y1Dst
   ( int x0Src,y0Src,x1Src,y1Src,
     [, number mask = GL_COLOR_BUFFER_BIT [, number filter = GL_NEAREST ] ) -> nil
    int x0Dst,y0Dst,x1Dst,y1Dst
   ( <font color=yellow>fboSrc</font>, int x0Src,y0Src,x1Src,y1Src, <font color=yellow>fboDst</font>, int x0Dst,y0Dst,x1Dst,y1Dst
     [, number mask = [[Lua_ConstGL#Clear_Bits|GL_COLOR_BUFFER_BIT]] [, number filter = GL_NEAREST ] ] ) -> nil
     [, number mask = GL_COLOR_BUFFER_BIT [, number filter = GL_NEAREST ] ) -> nil
 
   ( fboSrc , int x0Src,y0Src,x1Src,y1Src,
    fboDst , int x0Dst,y0Dst,x1Dst,y1Dst
     [, number mask = [[Lua_ConstGL#Clear_Bits|GL_COLOR_BUFFER_BIT]] [, number filter = GL_NEAREST ] ] ) -> nil
 
 
===Userdata FBO===
  <font color=darkgreen>attachment ::= luaTex or RBO or nil or { luaTex or RBO [, num [[Lua_ConstGL#FBO_Targets|target]] [, num level ]] }</font>
 
  write-only methods are:
    '''fbo.depth'''  = attachment
    '''fbo.stencil''' = attachment
    '''fbo.color0'''  = attachment
    ..
    '''fbo.color15''' = attachment
    '''fbo.drawbuffers''' = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT3_EXT, ..}
    '''fbo.readbuffer'''  = GL_COLOR_ATTACHMENT0_EXT
 
==RBO==
'''gl.CreateRBO'''
  ( int xsize, int ysize,
    [ {
      target = GL_RENDERBUFFER_EXT,
      format = [[Lua_ConstGL#RBO_Formats|GL_RGBA]],
      [samples = number], <font color=darkblue> any number here will result in creation of multisampled RBO (Added in 104.0.1-1015-g8e36ef2 maintenance)</font>
    } ]) -> userdata [[Lua_FBO#Userdata_RBO|rbo]]
 
'''gl.DeleteRBO'''
  ( rbo ) -> nil
 
===Userdata RBO===
  read-only methods are:
    '''rbo.target'''  = number
    '''rbo.format'''  = [[Lua_ConstGL#RBO_Formats|number]]
    '''rbo.xsize'''  = number
    '''rbo.ysize'''  = number
    '''rbo.valid'''  = boolean
    '''rbo.samples''' = number <font color=darkblue> will return globalRendering->msaaLevel for multisampled RBO or 0 otherwise (Added in 104.0.1-1015-g8e36ef2 maintenance)</font>

Latest revision as of 12:58, 25 February 2019

FBO

FBO

gl.CreateFBO

 ( [ table initialization ] ) -> userdata fbo

 initialization table can contain:
   attachment ::= luaTex or RBO or nil or { luaTex [, num target [, num level ] ] }
   {
     depth   = attachment,
     stencil = attachment,
     color0  = attachment,
     color1  = attachment,
     color2  = attachment,
     ..
     color15 = attachment,
     drawbuffers = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT3_EXT, ..}
   }

gl.DeleteFBO (This doesn't delete the attached objects!)

 ( fbo ) -> nil

gl.IsValidFBO

 ( fbo [, number target ] ) -> boolean valid [, number status ]

gl.ActiveFBO

 ( fbo [, number target ] [, boolean identities ] , lua_function, arg1, arg2, ... ) -> nil

gl.UnsafeSetFBO (Binds a FBO like gl.ActiveFBO() does, but you have to unbind it yourself!)

 ( nil [, number target = GL_FRAMEBUFFER_EXT ] ) -> nil (Bind default screenbuffer)
 ( fbo [, number target = fbo.target ] ) -> nil

gl.RawBindFBO (Replaces UnsafeSetFBO starting from 104.0.1-1003-gb3e02a6 maintenance)

 ( nil [, number target = GL_FRAMEBUFFER_EXT ] [, number rawFboId = 0] ) -> nil (Bind default or specified via rawFboId numeric id of FBO)
 ( fbo [, number target = fbo.target ] ) -> number previouslyBoundRawFboId

gl.BlitFBO needs GLEW_EXT_framebuffer_blit

 ( int x0Src,y0Src,x1Src,y1Src,
   int x0Dst,y0Dst,x1Dst,y1Dst
   [, number mask = GL_COLOR_BUFFER_BIT [, number filter = GL_NEAREST ] ] ) -> nil
 ( fboSrc , int x0Src,y0Src,x1Src,y1Src,
   fboDst , int x0Dst,y0Dst,x1Dst,y1Dst
   [, number mask = GL_COLOR_BUFFER_BIT [, number filter = GL_NEAREST ] ] ) -> nil


Userdata FBO

  attachment ::= luaTex or RBO or nil or { luaTex or RBO [, num target [, num level ]] }
 write-only methods are:
   fbo.depth   = attachment
   fbo.stencil = attachment
   fbo.color0  = attachment
    ..
   fbo.color15 = attachment
   fbo.drawbuffers = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT3_EXT, ..}
   fbo.readbuffer  = GL_COLOR_ATTACHMENT0_EXT

RBO

gl.CreateRBO

 ( int xsize, int ysize,
   [ {
     target = GL_RENDERBUFFER_EXT,
     format = GL_RGBA,
     [samples = number],  any number here will result in creation of multisampled RBO (Added in 104.0.1-1015-g8e36ef2 maintenance)
   } ]) -> userdata rbo

gl.DeleteRBO

 ( rbo ) -> nil

Userdata RBO

 read-only methods are:
   rbo.target  = number
   rbo.format  = number
   rbo.xsize   = number
   rbo.ysize   = number
   rbo.valid   = boolean
   rbo.samples = number  will return globalRendering->msaaLevel for multisampled RBO or 0 otherwise (Added in 104.0.1-1015-g8e36ef2 maintenance)