Jump to content

Context::SetScale breaks some drawing commands


 Share

Recommended Posts

http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/contextsetscale-r728

 

I wanted to scale my GUI using the setscale command and found some of the drawing commands do not function correctly.

 

The drawrect command works properly.

 

The plot command does not scale at all.

 

The line command does not work properly in straight lines horizontally or vertically, but it does diagonally.

 

Hear is code to test and explain:

 

--This function will be called once when the program starts
function App:Start()

--Initialize Steamworks (optional)
--Steamworks:Initialize()

--Set the application title
self.title="MyGame"

--Create a window
local windowstyle = window.Titlebar
if System:GetProperty("fullscreen")=="1" then windowstyle=windowstyle+window.FullScreen end
self.window=Window:Create(self.title,0,0,System:GetProperty("screenwidth","1024"),System:GetProperty("screenheight","768"),windowstyle)

--Create the graphics context
self.context=Context:Create(self.window,0)
if self.context==nil then return false end

return true
end

--This is our main program loop and will be called continuously until the program ends
function App:Loop()

--If window has been closed, end the program
if self.window:Closed() or self.window:KeyDown(Key.Escape) then return false end


--Update the app timing
Time:Update()


self.context:SetScale(2,2) -- everything should be twice as big

self.context:SetColor(self:rgbatovec4scalar({255,255,255},255))
self.context:DrawRect(0,0,200,200) -- This is the size the line squares should be at


self.context:SetColor(self:rgbatovec4scalar({100,100,100},255))
for y = 1 , 200 do -- this should make a solid square, not rectangle
self.context:DrawLine(5, y , 205, y ) -- draw square at an offset so you can see its dimensions in a relative manner
end

self.context:SetColor(self:rgbatovec4scalar({80,100,100},10))

for x = 5 , 205 do -- this should make a solid square also
self.context:DrawLine(x, 5 , x, 205 ) -- draw square at an offset so you can see its dimensions in a relative manner
end

self.context:SetColor(self:rgbatovec4scalar({255,0,0},255))
self.context:DrawLine(0,0,200,200) -- the line is off from actuall 0,0 by a few pixels but it is the size

self.context:SetColor(self:rgbatovec4scalar({0,255,0},255))
self.context:Plot(200,200) -- this should actually be at the edge of the white box but its at real cordinates 100,100

--Refresh the screen
self.context:Sync(true)

--Returning true tells the main program to keep looping
return true
end

function App:rgbatovec4scalar(rgb,a)
return Vec4(rgb[1]/256,rgb[2]/256,rgb[3]/256,a/256)
end

 

As long as this is does not function as intended, my gui will have to be put on the backburner.

Link to comment
Share on other sites

  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...