Ywa Posted October 7, 2014 Share Posted October 7, 2014 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. Quote Link to comment Share on other sites More sharing options...
Roland Posted October 7, 2014 Share Posted October 7, 2014 Why not just a pivot for that as a holder for your GUI code. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Ywa Posted October 7, 2014 Author Share Posted October 7, 2014 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 Quote Link to comment Share on other sites More sharing options...
macklebee Posted October 7, 2014 Share Posted October 7, 2014 you are clearing the context which will remove the world render from it... Quote 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 More sharing options...
Ywa Posted October 7, 2014 Author Share Posted October 7, 2014 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) Quote Link to comment Share on other sites More sharing options...
macklebee Posted October 7, 2014 Share Posted October 7, 2014 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. Quote 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 More sharing options...
Roland Posted October 7, 2014 Share Posted October 7, 2014 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 Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Recommended Posts
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.