rettyov How do I cheat?
Reputation: 0
Joined: 22 Jul 2020 Posts: 1
|
Posted: Thu Jul 23, 2020 3:03 am Post subject: CE Lua d3d.createTexture. How to speed up? |
|
|
hi everyone!
I'm trying to write my first trainer on CE and I have achieved some success.
I'm using D3D Hook for my dark goal and trying to draw some lines on the screen.
When I inject my code with timer event game and CE has freeze a bit. After interval of the timer all repeat.
Look at this code:
| Code: |
if (isEnabledMapPoints and isEnabledD3D) then
local t1,t2,t3,t4,t5
t1 = os.clock()
--create picture
local x1,x2,y1,y2
local picMap = createPicture()
picMap.Bitmap.Width = 1920
picMap.Bitmap.Height = 1080 - 171
picMap.Bitmap.setTransparent(true)
picMap.Bitmap.setTransparentColor(0x0)
picMap.Bitmap.Canvas.Pen.Color = 0xFF
t2 = os.clock()
--calculate points
for i=-200,-1 do
x1 = math.floor((i+200)/200*1919 + 0.5)
y1 = 1079 - (math.floor(mapPointsBitmap[i+200]*1079 +0.5) + 172)
x2 = math.floor((i+201)/200*1919 + 0.5)
y2 = 1079 - (math.floor(mapPointsBitmap[i+201]*1079 +0.5) + 172)
picMap.Bitmap.Canvas.line(x1, y1, x2, y2)
end
--create texture
t3 = os.clock()
local texture = d3d.createTexture(picMap, 0x0)
t4 = os.clock()
--update screen
d3dhook_beginUpdate()
d3dhook_sprite_setTexture(sprite,texture)
d3dhook_endUpdate()
t5 = os.clock()
print(t3-t2, t4-t3)
end
|
I include t1,t2,t3,t4,t5 variables for tracking how many secs waste on this code.
In Lua Engine output I get:
0.024 and 0.177 respectively.
I found out that this line can be speed up in 2 times if I exclude transparentColor (0x0)
| Code: |
local texture = d3d.createTexture(picMap, 0x0)
|
but after this I lost transparent background for my lines.
Also If I comment this line freeze will go.
I tried to use new thread and use a lot of small sprites instead of one.
In first case, thread didn't solve my problem.
In second case, I got a lot of artifacts on the screen and then game crashed, CE crashed too.
any ideas, masters?
|
|