|
Post by Pjot on Jun 14, 2011 21:07:02 GMT 1
Thanks, the tutorial and your examples were very insightful! As far as I understand the Clutter library now, it seems it can be used as an OpenGL backend for the CANVAS widget, similarly as GtkGlArea and GtkGlExt. However, it has a separate API to perform OpenGL drawing and animations.
So I will study how it can be added to HUG as optional GL canvas...
Thanks again, Peter
|
|
ffweb
New Member
Posts: 20
|
Post by ffweb on Jun 16, 2011 10:36:16 GMT 1
I’m happy to have triggered some evolutions of Bacon and HUC, much beyond my programming skills. I only further encourage you to point to the maximum possible simplicity of use. Regards
|
|
|
Post by Pjot on Jun 18, 2011 20:53:33 GMT 1
So I still felt unhappy with the situation where the GL drawing is just as slow as the GTK drawing. Again, this is caused by the fact that after each tiny drawing action the complete GL buffer is swapped. Inspired by the previous demo program in this post, I made another HUGOPTION to freeze a GL canvas. That way, a full OpenGL drawing can be completed without all the intermediate buffer swaps which slows down the process. The below program is a re-implementation of the "Plasma" GL demo, now using HUG. Just for fun, you can try to comment the line which defines the OpenGL canvas and then compile/run again. The difference in performance will blow you from your chair Of course use the latest H.U.G. ' Use HUG by selective INCLUDE'ing the functions we need INCLUDE "hug.bac", INIT, HUGOPTIONS, WINDOW, CANVAS, ATTACH, TIMEOUT, DISPLAY, PIXEL, DRAW, SYNC
' Initialize HUG INIT
' Set OpenGL canvas HUGOPTIONS("CANVAS GL") HUGOPTIONS("GL_FREEZE 1")
' No scaling of the window HUGOPTIONS("NOSCALING")
' Window size CONST x_size = 400 CONST y_size = 400
' Array to calculate colors DECLARE cols[3][256]
' Create the actual drawing FUNCTION Draw_Plasma
LOCAL x, y, r, g, b TYPE float LOCAL c
' As GL FREEZE option is enabled, we must prepare the canvas explicitly DRAW(canvas)
FOR y = 1 TO y_size FOR x = 1 TO x_size
c = FLOOR(SIN(x/35)*128 + SIN(y/28)*32 + SIN((x+y)/16)*64) & 255
r = cols[0][c] & 255 g = cols[1][c] & 255 b = cols[2][c] & 255
IF r < 16 THEN red$ = CONCAT$("0", HEX$(r)) ELSE red$ = HEX$(r)
IF g < 16 THEN green$ = CONCAT$("0", HEX$(g)) ELSE green$ = HEX$(g)
IF b < 16 THEN blue$ = CONCAT$("0", HEX$(b)) ELSE blue$ = HEX$(b)
PIXEL(CONCAT$("#", red$, green$, blue$), x, y) NEXT NEXT
' As GL FREEZE option is enabled, we must SYNC explicitly SYNC
RETURN FALSE
END FUNCTION
' Initialize colors FOR i = 0 TO 255 cols[0][i] = ABS(128 - 127 * SIN(i * PI / 32)) cols[1][i] = ABS(128 - 127 * SIN(i * PI/ 64)) cols[2][i] = ABS(128 - 127 * SIN(i * PI / 128)) NEXT
' Define GUI win = WINDOW("Plasma Demo with HUG", x_size, y_size) canvas = CANVAS(x_size, y_size) ATTACH(win, canvas, 0, 0)
' Make sure to call the drawing function *after* the Window is displayed TIMEOUT(50, Draw_Plasma)
' Display window DISPLAY
Attachments:
|
|
ffweb
New Member
Posts: 20
|
Post by ffweb on Jun 21, 2011 20:59:20 GMT 1
Neat!
|
|
|
Post by Pjot on Jun 22, 2011 15:00:01 GMT 1
So, now the Final Verdict on the Clutter Library: it is not going to work. The Clutter library tries to reversely open the executed program to setup a GLX context. As BaCon always is dynamically opening external libraries, the compile flag "-export-dynamic" must be added to the compile options (in case of the GCC compiler). Nevertheless the compiled program sometimes crashes... Regards Peter
|
|
2lss
Full Member
Posts: 140
|
Post by 2lss on Jul 27, 2011 5:49:30 GMT 1
So, now the Final Verdict on the Clutter Library: it is not going to work. The Clutter library tries to reversely open the executed program to setup a GLX context. As BaCon always is dynamically opening external libraries, the compile flag "-export-dynamic" must be added to the compile options (in case of the GCC compiler). Nevertheless the compiled program sometimes crashes... Regards Peter That is a shame, but I'm sure HUG's GL drawing functions will work fine without it The issue with clutter reversely opening the program seems pretty hard to comprehend. Thanks for taking the time to investigate it! I may play around with the clutter library in a C program just for fun. People are doing some pretty cool things with it.
|
|