PDA

View Full Version : Update Canvas Proportions...



Oscar Ugolini
10-05-2012, 19:19
hi all...
i have made a window with a canvas control keep all window space.
i don't want check timer callback to render the canvas,
but only when i do some input, mouse click or keyboard, or when maximize/minimize the window...

When i maximize/restore window and check on select case CbMsg, %WM_SIZE or %WM_SIZING, like this:

...
hCtrl = Control Add Label, hDlg, %gCanvas, "TBGL canvas", 0, 42, 1024, 670

Control Set Resize hDlg, %gCanvas , 1, 1, 1, 1
Dialog Set Minsize hDlg, 1024, 768

TBGL_Render()
TBGL_BindCanvas(hCtrl)

Dialog Show Modal hDlg , Call DlgProc
...
...
Select Case CbMsg
...
Case %WM_SIZE
'''Control Set Focus hDlg, %gCanvas i try also set focus befor render
TBGL_UpdateCanvasProportions(hCtrl)
TBGL_Render()

Case %WM_SIZING
'''Control Set Focus hDlg, %gCanvas i try also set focus befor render
TBGL_UpdateCanvasProportions(hCtrl)
TBGL_Render()
...

The canvas don't keep proportions... and only when i click on it to move an object inside, the canvas show correct proportions...
With check of a "timer callback" like this:
...
Case %WM_TIMER
TBGL_Render()
...
i dont see the problem because always render on timer...
but i dont want use timer check...
How can update correctly the canvas without a timer, but on maximize/restore window?
Thanks all... and sorry for my english not perfect :)

Petr Schreiber
10-05-2012, 22:25
Hi Oscar,

may I ask you for minimal (yet complete) code demonstrating the issue (just with single triangle inside)?

The brute force idea - your TBGL_Render function could look like following:


Function TBGL_Render( hCtrl As DWord )
Static FrameRate As Double

If TBGL_CanvasBound(hCtrl) Then
TBGL_UpdateCanvasProportions(hCtrl)

TBGL_RenderMatrix3D(%TBGL_CLIENTAREA) ' -- Sync proportions with client area
TBGL_ClearFrame

' -- Render code here

TBGL_DrawFrame

End If
End Function


Another way would be not using the TBGL canvas, but TBGL window directly.
You could use asynchronous TBGL functions such as TBGL_MouseGetLButton, TBGL_MouseGetRButton, TBGL_GetWindowKeyState, TBGL_GetWindowKeyOnce and others (please see TBGL help file, Functions list / Input handling for complete set).


Petr

Oscar Ugolini
11-05-2012, 20:58
hi Petr,
thanks for your fast reply :)
I have made a ridicolous error!
in size event, i put some variables for matrix transformation AFTER the render, and not BEFORE!!
sorry for disturb :cry:

bye,
Oscar :)

Petr Schreiber
11-05-2012, 22:41
No problem,

I am happy the problem solution was relatively simple :)


Petr