Lionheart008
23-02-2009, 17:28
secondo input for today:
have done a little bit more than a 'sinus' function of the sinus rendering example by petr/zak :) don't found the example at the board, sorry ;) placed it here... I like the canvas UI/TBGL modus...
more will also come...
best regards, Lionheart, have a cold... ;( and heavy head full of virus elements...
ps: it's possible to rotate canvas_box or canvas_ellipse with the usual 'rotate' command for canvas_box 45, 0,0,0???
Petr Schreiber
23-02-2009, 18:58
Hi Frank,
very nice script, very ellegant visualization.
Regarding transformations - UI Canvas is bitmap buffer, not vector graphics processor.
It would be possible to handle custom geometry buffer which would work like TBGL ... but I think that is not UI Canvas purpose.
Petr
Lionheart008
23-02-2009, 20:05
hi petr:)
Regarding transformations - UI Canvas is bitmap buffer, not vector graphics processor.
:D, you are right, I see it... so I will concentrate myself again to tbgl and ui features... :)
nice evening, Lionheart
Lionheart008
22-03-2009, 14:07
hi :)
perhaps anybody can help... I would like to draw three different colours as pointline... but I have got only a blue line driving slowly up... ;) and how can I type the colours after the R=(255..., G=(255..., B=(255... ??? hmh... no idea...
TBGL_Color 55,250,250
TBGL_BEGINPOLY %GL_Points
FOR x = rangeFrom to upperBoundary step drawStep
R = (255 + ((TAN(X/1024) + COS(Y/768)) * 255))/2
G = (0 + ((SIN(Y/768) + TAN(X/1024)) * 255))/2
B = (255 + ((COS(X/1024) + SIN(Y/768)) * 255))/2
tbgl_Vertex x,y
NEXT
TBGL_ENDPOLY
FOR y = rangeFrom to upperBoundary step drawStep
R = (255 + ((TAN(X/1024) + COS(Y/768)) * 255))/2
G = (0 + ((SIN(Y/768) + TAN(X/1024)) * 255))/2
B = (255 + ((COS(X/1024) + SIN(Y/768)) * 255))/2
tbgl_Vertex x,y
NEXT
TBGL_ENDPOLY
I attach my example...
best regards, now I am off... walking with doggy... ciao... Lionheart
Petr Schreiber
22-03-2009, 15:36
Hi Frank,
you forgot again about your little helper - TBGL_GetLastGLError :unguee:
You had one TBGL_EndPoly without TBGL_BeginPoly there, the rest is correct:
'
' Sinus function rendering, based on Zak's code
' Petr Schreiber, started on 01-30-2009
' follows with new log input by lionheart
USES "UI", "TBGL"
DIM i AS DOUBLE
DIM X AS DOUBLE
DIM Y AS DOUBLE
DIM XS AS DOUBLE
DIM YS AS DOUBLE
DIM R AS INTEGER
DIM G AS INTEGER
DIM B AS INTEGER
' -- ID numbers of controls
BEGIN CONST
%lblCanvas = 1000
%btnClose
%myTimer
%timeOut = 20 ' -- Determines graphics refresh rate in milliseconds
END CONST
GLOBAL hDlg AS DWORD
FUNCTION TBMAIN( )
DIALOG NEW 0, "Sinus, Cosinus, Log functions", - 1, - 1, 320, 230, _
%WS_POPUP OR %WS_VISIBLE OR _
%WS_CLIPCHILDREN OR %WS_CAPTION OR _
%WS_SYSMENU OR %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR %WS_THICKFRAME, 0 TO hDlg
' -- Place controls here
CONTROL ADD LABEL, hDlg, %lblCanvas, "", 5, 5, 310, 200
CONTROL SET COLOR hDlg, %lblCanvas, %BLACK, %BLACK
CONTROL SET RESIZE hDlg, %lblCanvas, 1, 1, 1, 1
CONTROL ADD BUTTON, hDlg, %btnClose, "Close", 255, 210, 60, 14
CONTROL SET RESIZE hDlg, %btnClose, 0, 1, 0, 1
DIALOG SET MINSIZE hDlg, 320, 230
DIALOG SHOW MODAL hDlg, CALL dlgCallback
END FUNCTION
CALLBACK FUNCTION dlgCallback( )
STATIC hCtrl AS DWORD
SELECT CASE CBMSG
CASE %WM_INITDIALOG
DIALOG SET TIMER CBHNDL, %myTimer, %timeOut, %NULL
CONTROL HANDLE CBHNDL, %lblCanvas TO hCtrl
' -- Init OpenGL
TBGL_BINDCANVAS( hCtrl )
CASE %WM_SIZE, %WM_SIZING
TBGL_UPDATECANVASPROPORTIONS( hCtrl )
RenderMyImage( hCtrl )
CASE %WM_TIMER
RenderMyImage( hCtrl )
CASE %WM_CLOSE
TBGL_RELEASECANVAS( hCtrl )
DIALOG KILL TIMER CBHNDL, %myTimer
CASE %WM_COMMAND
SELECT CASE CBCTL
CASE %btnClose
IF CBCTLMSG = %BN_CLICKED THEN DIALOG END CBHNDL
END SELECT
END SELECT
END FUNCTION
SUB RenderMyImage( hCtrl AS DWORD )
STATIC FrameRate AS DOUBLE
LOCAL x, y AS DOUBLE
LOCAL rangeFrom AS DOUBLE = - 5
LOCAL rangeTo AS DOUBLE = 5
STATIC upperBoundary AS DOUBLE = - 5
LOCAL drawStep AS DOUBLE = 0.2
LOCAL cx, cy AS LONG
CONTROL GET CLIENT hDlg, %lblCanvas TO cx, cy
drawStep = ( rangeTo - rangeFrom ) / cx / 2
IF TBGL_CANVASBOUND( hCtrl ) THEN
FrameRate = TBGL_GETFRAMERATE
IF upperBoundary < rangeTo THEN
upperBoundary += 2 / FrameRate
END IF
TBGL_CLEARFRAME
' -- Custom coordinate system
TBGL_RENDERMATRIX2D( rangeFrom, rangeFrom * cy / cx, rangeTo, rangeTo * cy / cx )
' ' -- Setting up constant properties before drawing
TBGL_POINTSIZE 2
TBGL_COLOR 255, 0, 0
TBGL_BEGINPOLY %GL_POINTS
FOR x = rangeFrom TO upperBoundary STEP drawStep
y = SIN( x )
' -- 2D vertex can use just 2 parameters
TBGL_VERTEX x, y
NEXT
TBGL_ENDPOLY
TBGL_COLOR 25, 250, 0
TBGL_BEGINPOLY %GL_POINTS
FOR y = rangeFrom TO upperBoundary STEP drawStep
x = COS( y )
' -- 2D vertex can use just 2 parameters
TBGL_VERTEX x, y
NEXT
TBGL_ENDPOLY
TBGL_COLOR 255, 250, 0
TBGL_BEGINPOLY %GL_POINTS
FOR x = rangeFrom TO upperBoundary STEP drawStep
y = LOG( x )
' -- 2D vertex can use just 2 parameters
TBGL_VERTEX x, y
NEXT
TBGL_ENDPOLY
TBGL_COLOR 25, 0, 250
TBGL_BEGINPOLY %GL_POINTS
FOR y = rangeFrom TO upperBoundary STEP drawStep
x = LOG( y )
' -- 2D vertex can use just 2 parameters
TBGL_VERTEX x, y
NEXT
TBGL_ENDPOLY
'-----------------------------------------------------------???
TBGL_COLOR 55, 250, 250
TBGL_BEGINPOLY %GL_Points
FOR x = rangeFrom TO upperBoundary STEP drawStep
R = ( 255 + (( TAN( X / 1024 ) + COS( Y / 768 )) * 255 )) / 2
G = ( 0 + (( SIN( Y / 768 ) + TAN( X / 1024 )) * 255 )) / 2
B = ( 255 + (( COS( X / 1024 ) + SIN( Y / 768 )) * 255 )) / 2
TBGL_VERTEX x, y
NEXT
FOR y = rangeFrom TO upperBoundary STEP drawStep
R = ( 255 + (( TAN( X / 1024 ) + COS( Y / 768 )) * 255 )) / 2
G = ( 0 + (( SIN( Y / 768 ) + TAN( X / 1024 )) * 255 )) / 2
B = ( 255 + (( COS( X / 1024 ) + SIN( Y / 768 )) * 255 )) / 2
TBGL_VERTEX x, y
NEXT
TBGL_ENDPOLY
'----------------------------------------------------------- ???
TBGL_LINEWIDTH 1
TBGL_BEGINPOLY %GL_LINES
TBGL_COLOR 250, 200, 250
' -- X axis
TBGL_VERTEX - 5, 0
TBGL_VERTEX 5, 0
' -- Y axis
TBGL_VERTEX 0, 5
TBGL_VERTEX 0, - 5
' -- Marks on axes
FOR i = - 5 TO 5
TBGL_VERTEX i, - 0.1
TBGL_VERTEX i, 0.1
TBGL_VERTEX - 0.1, i
TBGL_VERTEX 0.1, i
NEXT
TBGL_ENDPOLY
'-------------------------------
TBGL_DRAWFRAME
END IF
END SUB
Lionheart008
23-03-2009, 12:23
thanks petr:) hi all...
have fixed it and it was the beer or wine I have drunken last night with friends at a birthday party that I have forgotten begin poly, must laugh! :D
add new functions and a very interesting calculation for new tan curve with math. unclear regiones for the results, you can see in the script :)
have a nice day all of you, best regards, Lionheart
ps: "TBGL_GetLastGLError" :lol: