Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


CE Lua d3d.createTexture. How to speed up?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
rettyov
How do I cheat?
Reputation: 0

Joined: 22 Jul 2020
Posts: 1

PostPosted: Thu Jul 23, 2020 3:03 am    Post subject: CE Lua d3d.createTexture. How to speed up? Reply with quote

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 Smile 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. Neutral

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? Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites