Jump to content

Buffer confusion


ChrisMAN
 Share

Recommended Posts

I posted a gist describing the effect. download as start.lua and run engine.

 

https://gist.github.com/3971641

 

I am switching buffers and issuing drawing commands. The output drastically changes based upon whether or not I am drawing on the current frame. When there is no drawing on the current frame it renders more how i would expect it.

 

I am lacking intuition on how buffers work so any help is welcome.

 

Thanks

Chris

Link to comment
Share on other sites

Hi Chris,

 

This is ripped from my code in C++ I changed the variable names more genereic names. I have no idea how to do it in lua, but this may help.

 

 

 

TTexture bufferTexture;
TBuffer buf;

if(flags & flagsUpdateBuffer)
{

flags &= ~flagsUpdateBuffer;
if(bufferTexture)FreeTexture(bufferTexture);
bufferTexture = 0;
bufferTexture = CreateTexture(20, 20, TEXTURE_RGBA);

SetColorBuffer(buf, bufferTexture, 0, 0);

SetBuffer(buf);
//Do the buffer drawing here
SetBlend(BLEND_ALPHA);
//Draw red a rectangle in the buffer
SetColor(1.0F, 0.0F, 0.0F, 1.0F);
DrawRect(0, 0, 10, 10);
SetColor(1.0F, 1.0F,1.0F, 1.0F);
SetBuffer(BackBuffer());
}
//Draw the rectangle
DrawImage(bufferTexture, 0, 0, 20, 20);

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
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...