Jump to content

Buffer commands exposed to lua with documentation


macklebee
 Share

Recommended Posts

Looking over some postprocessing code that I believe shadmar did, it appears there are some Buffer commands exposed in lua but there is no documentation on this.

 

Would like to have access to all the available commands and documentation for each please.

 

I assume in the very least LE3 would have the same commands or similar as what was in LE2:

http://www.leadwerks.com/wiki/index.php/Buffers

  • Upvote 1

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

The lua exposed ones are these with //lua at the end. But no docs.

 

   	 virtual void SetMask(const bool red, const bool green, const bool blue, const bool alpha)=0;//lua
       virtual void SetColor(const Vec4& color);//lua
    virtual void SetColor(const float r, const float g, const float B);//lua
       virtual void SetColor(const float r, const float g, const float b, const float a);//lua
       virtual std::string GetClassName();
       virtual void GetPixels(const char* buf, const int component)=0;
       virtual int CountColorTextures();//lua
       virtual void Clear(const int mode=Depth|Color)=0;//lua
       virtual void Enable();//lua
       virtual void Disable();//lua
       virtual int GetWidth()=0;//lua
       virtual int GetHeight()=0;//lua
       virtual bool SetColorTexture(Texture* texture, const int i=0, const int cubeface=0)=0;//lua
       virtual bool SetDepthTexture(Texture* texture, const int cubeface=0)=0;//lua
       virtual Texture* GetColorTexture(const int index=0);//lua
       virtual Texture* GetDepthTexture();//lua
       //virtual Clear(const int flags)=0;
       virtual void Blit(Buffer* dst, const int components)=0;//lua

       static const int Depth;//lua
       static const int Color;//lua
       static const int Color0;//lua
       static const int Color1;//lua
       static const int Color2;//lua
       static const int Color3;//lua
       static const int Color4;//lua
       static const int Color5;//lua
       static const int Color6;//lua
       static const int Color7;//lua

       static std::list<Buffer*> list;
       static void SetCurrent(Buffer* buffer);//lua
       static Buffer* GetCurrent();//lua
       static Buffer* Create(const int width, const int height, const int colorcomponents=1, const int depthbuffer=1, const int multisamplemode=0);//lua

  • Upvote 4

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Link to comment
Share on other sites

  • 11 months later...
  • 1 month later...

The post-process stack and render target setting eliminate the need for any direct use of Leadwerks buffers. Buffers are a low-level class that don't really need to be accessed directly.

 

In Leadwerks 2, originally this was the only way to apply a post-processing effect, but no one knew how to use it, so the "Framework" class was created, which was a hack. In Leadwerks 3, the post-processing stack provides more flexibility and ease of use.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Well, I understand and approve the idea to go for the simplicity and the most common use cases (the post-processing, here).

 

However, I like LE precisely because it manages to couple simplicity with generality. A vertex manipulation (normals, uvs), for example, gives us a low level access to the mesh and empowers us to do wonderful things with a procedural geometry. And yet, it's very simple to use.

 

Likewise, I use buffers for procedural textures. I generate a texture directly in a custom shader (insted of using Context's Plot function) and render it to the buffer. For example:

 

-- Save the ref to the current shader & buffer.
local context = Context:GetCurrent()
local defaultShader = context:GetShader()
local defaultBuffer = Buffer:GetCurrent()

-- Specify a TEXTURE size.
local textureSize = 128

-- Although we can use Context::Plot,
-- we rather use the custom SHADER to draw a texture in the GPU.
local customShader = Shader:Load("Scripts/Custom/drawimage.shader")

-- Create a custom BUFFER to draw a texture to.
-- static Buffer* Create(const int width, const int height, const int colorcomponents=1,
-- const int depthbuffer=1, const int multisamplemode=0);//lua
local customBuffer = Buffer:Create(textureSize, textureSize, 1, 1)
Buffer:SetCurrent(customBuffer)

-- must be called after Buffer:SetCurrent()
context:SetShader(customShader)

-- DRAW the texture and store it in the local variable.
--context:SetBlendMode(Blend.Alpha)
local texture = customBuffer:GetColorTexture(0)
context:DrawImage(texture, 0, 0)

-- Restore previous buffer and shader.
Buffer:SetCurrent(defaultBuffer)
context:SetShader(defaultShader)

 

I would be very disappointed to see the possibility to do something like this removed, only because the use of buffers was meant as a hack to enable post-processing.

 

For me, the possiblity to directly manipulate buffers is as essential as a possiblity to directly manipulate vertices.

  • Upvote 1
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...