Jump to content

How to access the default buffer?


macklebee
 Share

Recommended Posts

I am trying to grab the various components from the default buffer that is created but for some reason those components come back 'nil'. When I create my own buffer, the commands seem to work. What am I missing to be able to grab the default buffer's components?

 

function App:Start()
       self.window = Window:Create()
    self.context = Context:Create(self.window)
       local width = self.context:GetWidth()
       local height = self.context:GetHeight()
    self.world = World:Create()
       self.cam = Camera:Create()

       self.buffer = Buffer:GetCurrent()
       if self.buffer==nil then System:Print("buffer is nil") end
       if self.buffer:GetDepthTexture()==nil then System:Print("depth is nil") end
       if self.buffer:GetColorTexture(0)==nil then System:Print("color0 is nil") end
       if self.buffer:GetColorTexture(1)==nil then System:Print("color1 is nil") end
       if self.buffer:GetColorTexture(2)==nil then System:Print("color2 is nil") end

       local buffer = Buffer:Create(width, height, 1+2,1)
       Buffer:SetCurrent(buffer)
       local mybuffer = Buffer:GetCurrent()
       if mybuffer==nil then System:Print("my buffer is nil") end
       if mybuffer:GetDepthTexture()==nil then System:Print("my depth is nil") end
       if mybuffer:GetColorTexture(0)==nil then System:Print("my color0 is nil") end
       if mybuffer:GetColorTexture(1)==nil then System:Print("my color1 is nil") end
       if mybuffer:GetColorTexture(2)==nil then System:Print("my color2 is nil") end
       Buffer:SetCurrent(self.buffer)

       return true
end

function App:Loop()
    if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end

       Time:Update()
    self.world:Update()
    self.world:Render()
       self.context:SetBlendMode(Blend.Alpha)
       self.context:DrawText("FPS: "..Time:UPS(),20,20)
       self.context:Sync()

       return true
end

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Try using the context instead of Buffer:GetCurrent(). As far, as I remember, Context is inherited from Buffer (at least in C++) and your current buffer should usually be the context (as far, as you don't change it). It might be, that the current buffer only gets set somewhere in between App:Start() und App:Loop().

Link to comment
Share on other sites

If the default isn't getting created until the App:Loop() I would say something is wrong since I can create my own buffer and immediately access it in the App:Start() as shown above. In any case, checking for those components in the Start or Loop still returns nil as well as checking for those components via the context. I suspect this is a question that Josh will need to chime in on as he is the only one that knows for sure what is going on in the background since the documentation does not exist.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Well at least lua is showing the same results - which it should since its built off of the c++ implementation. Thanks for checking. What would be ideal is for Josh to give us maybe a direct variable like we had in LE2 like 'gbuffer'. I suspect that maybe the GetCurrent() is grabbing the BackBuffer?

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Ok - well the good news is that there has been an answer to this; the bad news is that apparently there isn't a default buffer per say... even though Buffer:GetCurrent() above is grabbing something and the docs mention buffers in several places with one actual script function having a buffer parameter. But in any case, unless you make your own buffer, there is only a context which is bound to a window for renderable space. And the context can only be written to without a possibility to actually grab from - at least as far as depth/color components go. So big changes from LE2 vs now in LE3.

 

So no grabbing the depth or color or normal.of a main render window. And off hand there doesn't appear to be a way to grab the normal component of a buffer like we used to do in LE2- still waiting for an answer to that one actually

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...