wiremod-svn-archive/wire/lua/autorun/client/cl_gpulib.lua

132 lines
2.9 KiB
Lua
Raw Permalink Normal View History

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 RT_CACHE_SIZE = 16
//
// Create rendertarget cache
//
if (!RenderTargetCache) then
RenderTargetCache = {}
for i=1,RT_CACHE_SIZE do
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
RenderTargetCache[i] = {}
RenderTargetCache[i].Target = GetRenderTarget("WireGPU_RT_"..i, 512, 512)
RenderTargetCache[i].Used = nil
end
end
//
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
// Create basic fonts
//
surface.CreateFont("lucida console", 20, 800, true, false, "WireGPU_ConsoleFont")
//
// Create screen textures and materials
//
WireGPU_matScreen = Material("models\duckeh\buttons\0")
WireGPU_texScreen = surface.GetTextureID("models\duckeh\buttons\0")
//
// Rendertarget cache management
//
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
function WireGPU_NeedRenderTarget(entindex)
for i=1,#RenderTargetCache do
if (not RenderTargetCache[i].Used) then
RenderTargetCache[i].Used = entindex
return RenderTargetCache[i].Target
end
end
//Need to create new. PANIC?!
//print("RENDER TARGET PANIC. RENDER TARGET PANIC!")
return RenderTargetCache[1].Target
end
function WireGPU_GetMyRenderTarget(entindex)
for i=1,#RenderTargetCache do
if ((RenderTargetCache[i].Used) and
(RenderTargetCache[i].Used == entindex)) then
return RenderTargetCache[i].Target
end
end
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
return WireGPU_NeedRenderTarget(entindex)
end
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
function WireGPU_ReturnRenderTarget(entindex)
for i=1,#RenderTargetCache do
if ((RenderTargetCache[i].Used) and
(RenderTargetCache[i].Used == entindex)) then
RenderTargetCache[i].Used = nil
end
end
end
//
// Misc helper functions
//
function WireGPU_DrawScreen(x,y,w,h,rotation,scale)
vertex = {}
//Generate vertex data
vertex[1] = {}
vertex[1]["x"] = x
vertex[1]["y"] = y
vertex[2] = {}
vertex[2]["x"] = x+w
vertex[2]["y"] = y
vertex[3] = {}
vertex[3]["x"] = x+w
vertex[3]["y"] = y+h
vertex[4] = {}
vertex[4]["x"] = x
vertex[4]["y"] = y+h
//Rotation
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
if (rotation == 0) then
vertex[4]["u"] = 0-scale
vertex[4]["v"] = 1+scale
vertex[3]["u"] = 1+scale
vertex[3]["v"] = 1+scale
vertex[2]["u"] = 1+scale
vertex[2]["v"] = 0-scale
vertex[1]["u"] = 0-scale
vertex[1]["v"] = 0-scale
end
if (rotation == 1) then
vertex[2]["u"] = 0-scale
vertex[2]["v"] = 0-scale
vertex[3]["u"] = 1+scale
vertex[3]["v"] = 0-scale
vertex[4]["u"] = 1+scale
vertex[4]["v"] = 1+scale
vertex[1]["u"] = 0-scale
vertex[1]["v"] = 1+scale
end
if (rotation == 2) then
vertex[3]["u"] = 0-scale
vertex[3]["v"] = 0-scale
vertex[4]["u"] = 1+scale
vertex[4]["v"] = 0-scale
vertex[1]["u"] = 1+scale
vertex[1]["v"] = 1+scale
vertex[2]["u"] = 0-scale
vertex[2]["v"] = 1+scale
end
if (rotation == 3) then
vertex[4]["u"] = 0-scale
vertex[4]["v"] = 0-scale
vertex[1]["u"] = 1+scale
vertex[1]["v"] = 0-scale
vertex[2]["u"] = 1+scale
vertex[2]["v"] = 1+scale
vertex[3]["u"] = 0-scale
vertex[3]["v"] = 1+scale
end
surface.DrawPoly(vertex)
end