wiremod-svn-archive/wire/lua/entities/gmod_wire_oscilloscope/cl_init.lua

119 lines
3.0 KiB
Lua
Raw Permalink Normal View History

2008-06-14 00:55:20 +00:00
include('shared.lua')
ENT.Spawnable = false
ENT.AdminSpawnable = false
ENT.RenderGroup = RENDERGROUP_BOTH
function ENT:Initialize()
Quality update time! If something breaks, let me know. Some of things in this update may really break stuff, but I'll be present for next few days to fix them. [ADDED] GPU [FIXED] Console screen caching, now should work fine [ADDED] New oscilloscope based on GPULib engine. Look in its sourcecode for how to use GPULib (it gives you rendertarget and coordinates for as many screens as you want). Sorry bobsy, your fix is no longer needed. [FIXED] PORT's problem in ZASM that corrupted program code [FIXED] DATA&CODE macros corrupting program code [FIXED] Whitespaces ignored in several places in ZASM [ADDED] Support for "\n" "\r" "\\" "\0" in ZASM DB macro [ADDED] "STRING" macro (string <name>,'<string>';) [FIXED] Some stuff in function macro (may not work still) [FIXED] Possibly fixed local variables. Didn't test yet [FIXED] ZCPU now outputs interrupt parameter in fraction of error code (e.g. 5.1 for read error, 5.2 for decode error) [FIXED] Several typos [FIXED] Effective address not returning proper address for LEA ...,PORTx [FIXED] Render target system was rewritten. No more rendertarget loss (Some of console screen bugs got fixed by that) [CHANGED] Render target count is now 16 on start. Will be changed to 32 later. [FIXED] Re-added and square pulse gate, and saw pulse gate (which were broken by flux who updated SVN properties with previous svn version) [ADDED] Shared lua with all monitor coordinates and descriptions. Look at oscilloscope for example of how to use GPULib and all the coordinates
2008-10-05 14:43:12 +00:00
self.RTTexture = WireGPU_NeedRenderTarget(self:EntIndex())
end
function ENT:OnRemove()
WireGPU_ReturnRenderTarget(self:EntIndex())
2008-06-14 00:55:20 +00:00
end
function ENT:Draw()
self.Entity:DrawModel()
Quality update time! If something breaks, let me know. Some of things in this update may really break stuff, but I'll be present for next few days to fix them. [ADDED] GPU [FIXED] Console screen caching, now should work fine [ADDED] New oscilloscope based on GPULib engine. Look in its sourcecode for how to use GPULib (it gives you rendertarget and coordinates for as many screens as you want). Sorry bobsy, your fix is no longer needed. [FIXED] PORT's problem in ZASM that corrupted program code [FIXED] DATA&CODE macros corrupting program code [FIXED] Whitespaces ignored in several places in ZASM [ADDED] Support for "\n" "\r" "\\" "\0" in ZASM DB macro [ADDED] "STRING" macro (string <name>,'<string>';) [FIXED] Some stuff in function macro (may not work still) [FIXED] Possibly fixed local variables. Didn't test yet [FIXED] ZCPU now outputs interrupt parameter in fraction of error code (e.g. 5.1 for read error, 5.2 for decode error) [FIXED] Several typos [FIXED] Effective address not returning proper address for LEA ...,PORTx [FIXED] Render target system was rewritten. No more rendertarget loss (Some of console screen bugs got fixed by that) [CHANGED] Render target count is now 16 on start. Will be changed to 32 later. [FIXED] Re-added and square pulse gate, and saw pulse gate (which were broken by flux who updated SVN properties with previous svn version) [ADDED] Shared lua with all monitor coordinates and descriptions. Look at oscilloscope for example of how to use GPULib and all the coordinates
2008-10-05 14:43:12 +00:00
self.RTTexture = WireGPU_GetMyRenderTarget(self:EntIndex())
local NewRT = self.RTTexture
local OldRT = render.GetRenderTarget()
local OldTex = WireGPU_matScreen:GetMaterialTexture("$basetexture")
WireGPU_matScreen:SetMaterialTexture("$basetexture",self.RTTexture)
if (true) then
local oldw = ScrW()
local oldh = ScrH()
render.SetRenderTarget(NewRT)
render.SetViewPort(0,0,512,512)
cam.Start2D()
surface.SetDrawColor(10,20,5,255)
surface.DrawRect(0,0,512,512)
local nodes = self:GetNodeList()
for i=1,39 do
local i_next = i+1
local nx1 = nodes[i].X*256+256
local ny1 = -nodes[i].Y*256+256
local nx2 = nodes[i_next].X*256+256
local ny2 = -nodes[i_next].Y*256+256
if ((nx1-nx2)*(nx1-nx2) + (ny1-ny2)*(ny1-ny2) < 256*256) then
local b = math.max(0, math.min(i*i*0.16, 255))
for i=-3,3 do
surface.SetDrawColor(b/8, b/2, b/8, 255)
surface.DrawLine(nx1, ny1+i, nx2, ny2+i)
surface.SetDrawColor(b/8, b/2, b/8, 255)
surface.DrawLine(nx1+i, ny1, nx2+i, ny2)
end
surface.SetDrawColor(b/4, b, b/4, 255)
surface.DrawLine(nx1, ny1, nx2, ny2)
end
end
surface.SetDrawColor(30, 120, 10, 255)
surface.DrawLine(0, 128, 512, 128)
surface.DrawLine(0, 384, 512, 384)
surface.DrawLine(128, 0, 128, 512)
surface.DrawLine(384, 0, 384, 512)
surface.SetDrawColor(180, 200, 10, 255)
surface.DrawLine(0, 256, 512, 256)
surface.DrawLine(256, 0, 256, 512)
cam.End2D()
render.SetViewPort(0,0,oldw,oldh)
render.SetRenderTarget(OldRT)
end
if (WireGPU_Monitors[self.Entity:GetModel()]) && (WireGPU_Monitors[self.Entity:GetModel()].OF) then
OF = WireGPU_Monitors[self.Entity:GetModel()].OF
OU = WireGPU_Monitors[self.Entity:GetModel()].OU
OR = WireGPU_Monitors[self.Entity:GetModel()].OR
Res = WireGPU_Monitors[self.Entity:GetModel()].RS
RatioX = WireGPU_Monitors[self.Entity:GetModel()].RatioX
else
OF = 0
2008-06-14 00:55:20 +00:00
OU = 0
OR = 0
Quality update time! If something breaks, let me know. Some of things in this update may really break stuff, but I'll be present for next few days to fix them. [ADDED] GPU [FIXED] Console screen caching, now should work fine [ADDED] New oscilloscope based on GPULib engine. Look in its sourcecode for how to use GPULib (it gives you rendertarget and coordinates for as many screens as you want). Sorry bobsy, your fix is no longer needed. [FIXED] PORT's problem in ZASM that corrupted program code [FIXED] DATA&CODE macros corrupting program code [FIXED] Whitespaces ignored in several places in ZASM [ADDED] Support for "\n" "\r" "\\" "\0" in ZASM DB macro [ADDED] "STRING" macro (string <name>,'<string>';) [FIXED] Some stuff in function macro (may not work still) [FIXED] Possibly fixed local variables. Didn't test yet [FIXED] ZCPU now outputs interrupt parameter in fraction of error code (e.g. 5.1 for read error, 5.2 for decode error) [FIXED] Several typos [FIXED] Effective address not returning proper address for LEA ...,PORTx [FIXED] Render target system was rewritten. No more rendertarget loss (Some of console screen bugs got fixed by that) [CHANGED] Render target count is now 16 on start. Will be changed to 32 later. [FIXED] Re-added and square pulse gate, and saw pulse gate (which were broken by flux who updated SVN properties with previous svn version) [ADDED] Shared lua with all monitor coordinates and descriptions. Look at oscilloscope for example of how to use GPULib and all the coordinates
2008-10-05 14:43:12 +00:00
Res = 1
RatioX = 1
2008-06-14 00:55:20 +00:00
end
local ang = self.Entity:GetAngles()
local rot = Vector(-90,90,0)
ang:RotateAroundAxis(ang:Right(), rot.x)
ang:RotateAroundAxis(ang:Up(), rot.y)
Quality update time! If something breaks, let me know. Some of things in this update may really break stuff, but I'll be present for next few days to fix them. [ADDED] GPU [FIXED] Console screen caching, now should work fine [ADDED] New oscilloscope based on GPULib engine. Look in its sourcecode for how to use GPULib (it gives you rendertarget and coordinates for as many screens as you want). Sorry bobsy, your fix is no longer needed. [FIXED] PORT's problem in ZASM that corrupted program code [FIXED] DATA&CODE macros corrupting program code [FIXED] Whitespaces ignored in several places in ZASM [ADDED] Support for "\n" "\r" "\\" "\0" in ZASM DB macro [ADDED] "STRING" macro (string <name>,'<string>';) [FIXED] Some stuff in function macro (may not work still) [FIXED] Possibly fixed local variables. Didn't test yet [FIXED] ZCPU now outputs interrupt parameter in fraction of error code (e.g. 5.1 for read error, 5.2 for decode error) [FIXED] Several typos [FIXED] Effective address not returning proper address for LEA ...,PORTx [FIXED] Render target system was rewritten. No more rendertarget loss (Some of console screen bugs got fixed by that) [CHANGED] Render target count is now 16 on start. Will be changed to 32 later. [FIXED] Re-added and square pulse gate, and saw pulse gate (which were broken by flux who updated SVN properties with previous svn version) [ADDED] Shared lua with all monitor coordinates and descriptions. Look at oscilloscope for example of how to use GPULib and all the coordinates
2008-10-05 14:43:12 +00:00
ang:RotateAroundAxis(ang:Forward(), rot.z)
2008-06-14 00:55:20 +00:00
local pos = self.Entity:GetPos() + (self.Entity:GetForward() * OF) + (self.Entity:GetUp() * OU) + (self.Entity:GetRight() * OR)
cam.Start3D2D(pos,ang,Res)
Quality update time! If something breaks, let me know. Some of things in this update may really break stuff, but I'll be present for next few days to fix them. [ADDED] GPU [FIXED] Console screen caching, now should work fine [ADDED] New oscilloscope based on GPULib engine. Look in its sourcecode for how to use GPULib (it gives you rendertarget and coordinates for as many screens as you want). Sorry bobsy, your fix is no longer needed. [FIXED] PORT's problem in ZASM that corrupted program code [FIXED] DATA&CODE macros corrupting program code [FIXED] Whitespaces ignored in several places in ZASM [ADDED] Support for "\n" "\r" "\\" "\0" in ZASM DB macro [ADDED] "STRING" macro (string <name>,'<string>';) [FIXED] Some stuff in function macro (may not work still) [FIXED] Possibly fixed local variables. Didn't test yet [FIXED] ZCPU now outputs interrupt parameter in fraction of error code (e.g. 5.1 for read error, 5.2 for decode error) [FIXED] Several typos [FIXED] Effective address not returning proper address for LEA ...,PORTx [FIXED] Render target system was rewritten. No more rendertarget loss (Some of console screen bugs got fixed by that) [CHANGED] Render target count is now 16 on start. Will be changed to 32 later. [FIXED] Re-added and square pulse gate, and saw pulse gate (which were broken by flux who updated SVN properties with previous svn version) [ADDED] Shared lua with all monitor coordinates and descriptions. Look at oscilloscope for example of how to use GPULib and all the coordinates
2008-10-05 14:43:12 +00:00
local w = 512
local h = 512
local x = -w/2
local y = -h/2
surface.SetDrawColor(0,0,0,255)
surface.DrawRect(-256,-256,512/RatioX,512)
surface.SetDrawColor(255,255,255,255)
surface.SetTexture(WireGPU_texScreen)
WireGPU_DrawScreen(x,y,w/RatioX,h,0,0)
2008-06-14 00:55:20 +00:00
cam.End3D2D()
Wire_Render(self.Entity)
end
function ENT:IsTranslucent()
return true
end