Josh Posted December 15, 2017 Share Posted December 15, 2017 Some people have asked me how to do this. Here is an example: local window=Window:Create("Draw to texture") --Create the graphics context context=Context:Create(window,0) if context==nil then return end --Create a world world=World:Create() local camera = Camera:Create() camera:Move(0,0,-2) local buffer = Buffer:Create(512,512,1,0) local box = Model:Box() local mtl = Material:Create() mtl:SetTexture(buffer:GetColorTexture()) mtl:SetShader("Shaders/Model/diffuse.shader") --local surf = box:GetSurface(0) box:SetMaterial(mtl) mtl:Release() local font = Font:Load("Fonts/Arial.ttf",42) context:SetFont(font) font:Release() world:SetAmbientLight(1,1,1) while window:Closed()==false do box:Turn(0,0.2,0) Time:Update() world:Update() --Render to texture buffer:Enable() buffer:SetColor(0,0,1) buffer:Clear() buffer:SetColor(1,0,0) context:DrawRect(0,0,256,256) context:DrawRect(256,256,256,256) context:SetColor(1,1,1) context:SetBlendMode(Blend.Alpha) context:DrawText("Draw to texture! ;)",0,0,512,512,Text.Center+Text.VCenter) context:SetBlendMode(Blend.Solid) --Render world context:Enable() world:Render() context:Sync() end Quote 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 More sharing options...
Josh Posted December 15, 2017 Author Share Posted December 15, 2017 You could call Texture:BuildMipmaps() to improve the appearance of the texture after drawing. Quote 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 More sharing options...
macklebee Posted December 15, 2017 Share Posted December 15, 2017 Similar examples from over the years: 1 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...
macklebee Posted December 16, 2017 Share Posted December 16, 2017 1 hour ago, jen said: Useful for minimaps! yep - same concept: 1 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...
mdgunn Posted December 17, 2017 Share Posted December 17, 2017 16 hours ago, jen said: Useful for minimaps! Never got round to mini maps yet so out of interest is the mechanism presented here the most obvious choice to go with or what are 1 or 2 other ways that might be considered? I imagine it depends on your game of course (as always) so I suppose I mean in most cases what methods might have been used? Quote 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.