Petr Schreiber
12-01-2019, 18:52
Hi,
as DirectuX suggested, it might be handy to have TBGL_MouseGetPosX & TBGL_MouseGetPosY aware of the RenderMatrix2D coordinates.
I attach version which should achieve the following:
- preserve backward compatibility for TBGL_MouseGetPosX & TBGL_MouseGetPosY
- add ability to specify %TBGL_2D or %TBGL_CLIENTAREA as parameters for these functions, controling their behaviour
- add TBGL_MouseInClient function to check whether mouse is in window client area
Just copy the DLL from the attachement to the Lib directory & try different scenarios.
Example:
uses "tbgl"
function tbmain()
dword hWin = tbgl_createWindowEx ("201x201 - ESC to quit", 201, 201, 32, %TBGL_WS_WINDOWED or %TBGL_WS_DONTSIZE)
tbgl_showWindow
tbgl_useDepth false
tbgl_resetKeyState()
while tbgl_isWindow(hWin)
tbgl_clearFrame
tbgl_renderMatrix2D(-100, 100, 100, -100, %TBGL_PIXEL_PERFECT_2D)
tbgl_polygonlook %GL_LINE
tbgl_color 255, 0, 0
tbgl_rect(-100, -100, 100, 100)
tbgl_drawFrame
if tbgl_getWindowKeyState(hWin, %VK_ESCAPE) then
exit while
end if
if tbgl_mouseInClient then
tbgl_setwindowtitle(hWin, tbgl_mousegetposx(%TBGL_2D) + " " + tbgl_mousegetposy(%TBGL_2D))
else
tbgl_setwindowtitle(hWin, "Mouse is out of the client area")
end if
wend
tbgl_destroyWindow
end function
Thank you for your help,
Petr
as DirectuX suggested, it might be handy to have TBGL_MouseGetPosX & TBGL_MouseGetPosY aware of the RenderMatrix2D coordinates.
I attach version which should achieve the following:
- preserve backward compatibility for TBGL_MouseGetPosX & TBGL_MouseGetPosY
- add ability to specify %TBGL_2D or %TBGL_CLIENTAREA as parameters for these functions, controling their behaviour
- add TBGL_MouseInClient function to check whether mouse is in window client area
Just copy the DLL from the attachement to the Lib directory & try different scenarios.
Example:
uses "tbgl"
function tbmain()
dword hWin = tbgl_createWindowEx ("201x201 - ESC to quit", 201, 201, 32, %TBGL_WS_WINDOWED or %TBGL_WS_DONTSIZE)
tbgl_showWindow
tbgl_useDepth false
tbgl_resetKeyState()
while tbgl_isWindow(hWin)
tbgl_clearFrame
tbgl_renderMatrix2D(-100, 100, 100, -100, %TBGL_PIXEL_PERFECT_2D)
tbgl_polygonlook %GL_LINE
tbgl_color 255, 0, 0
tbgl_rect(-100, -100, 100, 100)
tbgl_drawFrame
if tbgl_getWindowKeyState(hWin, %VK_ESCAPE) then
exit while
end if
if tbgl_mouseInClient then
tbgl_setwindowtitle(hWin, tbgl_mousegetposx(%TBGL_2D) + " " + tbgl_mousegetposy(%TBGL_2D))
else
tbgl_setwindowtitle(hWin, "Mouse is out of the client area")
end if
wend
tbgl_destroyWindow
end function
Thank you for your help,
Petr