Jump to content

Recommended Posts

Posted

Hi folks,

 

I'm trying to draw some text on top of my 3D world. I have my rendering code after my world update & render, but it still only shows my 2D stuff with a black background. I've read about PostRender hooks, but it only seems to be available to entities. How can I fix this to work with my normal game logic? Because adding a chat via an entity doesn't seem to make much sense to me.

 

Thanks in advance.

Posted

Well I did that to test if it made any difference, but it doesn't. Still a red box with a black background. Removing the 3 lines of code renders my 3D world just fine.

 

This is my pivot code. Pivot is created after creating a world and before loading a map.

function Script:PostRender(Context)
--local Context = App.Context
Context:Clear()
Context:SetColor(1,0,0)
Context:DrawRect(20,20,100,100)
end

Posted

That fixed it. Thanks!

 

Wish the documentation was more clear on this matter. All examples include the clearing.

Do I need to clear the context on every new frame/render? (before rendering the world)

Posted

No - world rendering does not need that. The examples where they were clearing the context was just a simple way to clear the screen to prevent smearing of variable or moving 2D items like text or rectangles but those same examples do not have a world being rendered. When the world is rendered it will overwrite every pixel in its context/buffer - effectively "clearing" the last render or 2D item drawn.

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

LE / 3DWS / BMX / Hexagon

macklebee's channel

Posted

This will draw a red rectangle when attached to a pivot.

 

function Script:PostRender(context)

  context:SetBlendMode(Blend.Alpha)

  context:SetColor(1,0,0,1)
  context:DrawRect( 100, 100, 200, 200)

  context:SetBlendMode(Blend.Solid)

end

 

You should not call Clear.. that's done in the App:Loop already

Roland Strålberg
Website: https://rstralberg.com

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.

×
×
  • Create New...