Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 2 3 4 5 6 … 18 Next »
render.drawBeam() and textures
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode
render.drawBeam() and textures
22-08-2020, 09:42 PM,
#1
The17thDoctor Offline
TSCM Average Enjoyer
****
Posts: 1,100
Threads: 249
Joined: Oct 2015
render.drawBeam() and textures
When drawing any textured element ( either Wireframe Box or Textured Rect ) the beam takes the last registered texture. But if nothing is drawn and we just use render.setTexture(),
the beam isnt affected at all.
Perhaps could drawBeam() be used alongside setTexture() without having to do some hacky rectangle drawing ?

Example of code :
--@name
--@author

Keeper_Beam = render.getTextureID("tscm/beam_keeper2.png")

hook("render", "draw it nao", function()
local plys = find.allPlayers()
render.clear()
render.setColor(255,255,255)
render.setTexture(Keeper_Beam)
render.drawTexturedRect(0,0,100,100) --Comment me !

render.start3D()
for i = 1,#plys do
local ply = plys[i]
render.drawBeam(ents.self():pos(), ply:pos(), 2, 1, 0,Color(255,255,255))
end
render.end3D()
end)

The17thDoctor: Server take me to the most handsome person
srcds_linux: I cant send people to themselves...
Website Find
Reply
23-08-2020, 10:07 AM,
#2
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: render.drawBeam() and textures
3D operations take their material from calls to render.setMaterial(), which requires a Material instance. I'm guessing that the engine is setting the 3D material somewhere inside the textured rectangle draw which is why you see it ending up on the beam.

There was a bug in the material validation in render.setMaterial() that was making it reject PNGs and other materials which will be fixed after the next restart. Here's how I changed your code to work properly:
Keeper_Beam = Material("tscm/beam_keeper2.png")

hook("render", "draw it nao", function()
local plys = find.allPlayers()
render.clear()
render.setColor(255,255,255)
-- Set the 2D rendering material.
render.setTexture(Keeper_Beam)
render.drawTexturedRect(0,0,100,100)

render.start3D()
-- Set the 3D rendering material.
render.setMaterial(Keeper_Beam)
for i = 1,#plys do
local ply = plys[i]
render.drawBeam(ents.self():pos(), ply:pos(), 2, 1, 0,Color(255,255,255))
end
render.end3D()
end)
Find
Reply
23-08-2020, 02:20 PM,
#3
The17thDoctor Offline
TSCM Average Enjoyer
****
Posts: 1,100
Threads: 249
Joined: Oct 2015
RE: render.drawBeam() and textures
The rect was purely to apply the material on the beam itself so I dont need it. Thanks though.

The17thDoctor: Server take me to the most handsome person
srcds_linux: I cant send people to themselves...
Website Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
Forum Jump:


Users browsing this thread:
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.