PDA

View Full Version : canvas, mix canvas draw routines on top of tbgl_ opengl commands



kryton9
13-06-2010, 08:03
In a canvas that is assigned to tbgl, can I use a canvas draw function after I did some tbgl opengl drawing?

Petr Schreiber
13-06-2010, 09:44
Hi Kent,

if you mean casting Canvas_* functions on TBGL render surface, than that is not possible. Some people combined GDI with OpenGL in the past, but with Vista/7 this is prohibied approach by MS.
But what you can do, is to render image using TBGL, get the bitmap using TBGL_GetWindowBMP, save it to temporary file and load to UI canvas using Canvas_BitmapLoad.

Or even simpler - as TBGL_GetWindowBMP returns BMP as string, just cut off the BMP header:


s = TBGL_GetWindowBMP(hWnd, %TBGL_CLIENTAREA, width, height)
(which is:
s =
)
=> is internally

s = [Header][b][RGBXSeries]

=> cut off the header which is located on the beginning

s = [RGBXSeries]

=> use Canvas_BitmapSet to UI canvas of same size

Canvas_BitmapSet(s, width, height)


I will provide example Kent, but I have something very important to perform tomorrow and need to prepare well today, so example will be posted most probably by tommorow evening.


Petr

P.S. Also do not forget TBGL has 2D primitives as well now, thanks to Mike, so it might be not necessary to use UI canvas

kryton9
13-06-2010, 09:51
Thanks Petr, work on your stuff. I was just wondering if it was doable.

zak
13-06-2010, 15:07
Hi kent, Petr
i like the example TBGL_2D_primitives in the TBGL\Basic folder by Mike, it contains several good functions, point, line ,rect ,TBGL_NGon, the last one is interesting: in the doc: "With the vertex count of 3 you can draw triangles, with 4 squares, with 6 hexagons", 20 or more approximately circles, change the vertexCount to 6 and we will see a beautifull hexagon
i think this example can be used as a basis for teaching geometry basics.
for those who havn't tried it look at its picture with a moving heptagon (tbgl_ngon(x,y,60,7)):
http://img43.imageshack.us/img43/2015/tbgl2dprimitives.png

kryton9
13-06-2010, 20:54
Thanks for the link, I never saw that one or even that these new commands were in place. Nice additions to tbgl, thanks Mike and Petr.

Petr Schreiber
15-06-2010, 09:25
Hi Kent,

did you have a look at the 2D functions? Are they what you need or do you want to investigate the TBGL->Canvas hack further?


Petr

kryton9
16-06-2010, 06:40
Just looking around Petr at what all has been going on, no detailed hacking at the moment :good: