|
Post by alexfish on Feb 10, 2016 17:05:52 GMT 1
Hi Vovchik
can get one image showing , as in the bg , the others fail. weird. need to go back through the bits , like U say.
in the mean time , the CallBacks..here is an example of another method
BR Alex
CONST canvas_w = 600 CONST canvas_h = 400
GLOBAL SELECTED_WIDGET TYPE long
'make array same size of canvas GLOBAL CallEvents[canvas_w][canvas_h] TYPE long
FUNCTION CallBack(int mouse_x,int mouse_y)
SELECTED_WIDGET= CallEvents[mouse_x][mouse_y] RETURN ( CallEvents[mouse_x][mouse_y]) END FUNCTION
LOCAL but_event =1 TYPE long LOCAL but_event2 =2 TYPE long 'widget size 95x41 at 5,5 FOR t = 5 TO 100 FOR s = 5 TO 46 CallEvents[t][s] = but_event NEXT NEXT ' widget size 90x41 at 110,5 FOR t = 110 TO 200 FOR s = 5 TO 46 CallEvents[t][s] = but_event2 NEXT NEXT
PRINT "widget but_event ID : " , but_event PRINT "widget but_event2 ID : " ,but_event2
LET s = CallBack(0,0) PRINT "-----------------------------" PRINT "event ID : " , s PRINT "SELECTED_WIDGET ID : " , SELECTED_WIDGET
LET s = CallBack(90,46)
PRINT "-----------------------------" PRINT "widget event ID : " , s PRINT "SELECTED_WIDGET ID : " , SELECTED_WIDGET
LET s = CallBack(110,46)
PRINT "-----------------------------" PRINT "widget event ID : " , s PRINT "SELECTED_WIDGET ID : " , SELECTED_WIDGET
|
|
|
Post by vovchik on Feb 10, 2016 17:14:18 GMT 1
Dear Alex, Looked at the widget callback scheme just now. Looks good and entierey workable, and simple. Nowe have to test it in a real environment. With kind regards, vovchik
|
|
|
Post by alexfish on Feb 10, 2016 17:28:58 GMT 1
Dear Alex, Looked at the widget callback scheme just now. Looks good and entierey workable, and simple. Nowe have to test it in a real environment. With kind regards, vovchik Hi vovchik it worked in the radtool , and it works on the Raspberry PI , SDC canvas. can use own id or if memory type , images/widgets etc then can use that id as well , BR Alex
|
|
|
Post by basica on Feb 10, 2016 19:26:36 GMT 1
vovchik, Latest "memvar_img" works for me. Very nice concept. And as you mentioned, the last row is blank. Is this the makings of a "stamp" routine for images It's great that "domestic duties" have such a good effect on your creative juices Thanks, basica
|
|
|
Post by vovchik on Feb 10, 2016 22:21:03 GMT 1
Dear basica, I am glad it worked for you, and I hope Alex can get it working. You are right about the "stamp" being within reach, but I am not so sure domestic duties are the best stimulus. We need to use glReadPixels to grab the area for clipping and use glDrawPixels for stamping, I think. Will brood on this. With kind regards, vovchik
|
|
|
Post by alexfish on Feb 10, 2016 22:53:07 GMT 1
Hi Vovchik & all
Vovchik i was busy with this .... will look at the bits later
Looking to extend the screenArray callback feature
here is prototype callback , bit of a dummy , yet it works
need to use a header , can rename the function if wish..
void CALLBACK(long widget , void callback(),void* data) { // can do things with this callback(<b,i,t,s>) callback(widget); }
a bit of code for testing
PRAGMA INCLUDE callback.h
OPTION PARSE FALSE
SUB Test1(long widget)
PRINT "widget 1 result " , widget
END SUB
' see if works withou args SUB Test2()
PRINT "Test 2"
END SUB
Mywiget = 1
CALLBACK(Mywiget,Test1,NULL)
CALLBACK(Mywiget,Test2,NULL)
MARK 1.1 , here added some actions
void CALLBACK(long widget ,char * action, void callback(),void* data) // receive widget and address function { if(action=="button_click") { puts(" action button_click"); }
if(action=="resize_event") { puts(" action resize_event"); } // can do things with this callback(<b,i,t,s>) callback(widget); }
test code
PRAGMA INCLUDE callback.h
OPTION PARSE FALSE
SUB Test1(long widget)
PRINT "widget 1 result " , widget
END SUB
' see if works withou args SUB Test2()
PRINT "Test 2"
END SUB
Mywiget = 1
CALLBACK(Mywiget,"button_click",Test1,NULL)
CALLBACK(Mywiget,"resize_event",Test2,NULL)
BR Alex
|
|
|
Post by vovchik on Feb 10, 2016 23:37:33 GMT 1
Dear Alex,
That's wonderful! We can now make widget callbacks easily. Great! And thanks!
With kind regards, vovchik
|
|
|
Post by alexfish on Feb 11, 2016 16:25:50 GMT 1
Hi Vovchik
some code for testing . here passing the func calls to our widgets ,
at present using direct in main
the CALLBACK function therefore needs to encompass , the likes where it is on screen IE the array method I posted.
IE the CALLBACK is the method to register the bits. then say if the screen is click and that widget is there.
then can make the callback to IT's functions, in other words it is Alive..
BR Alex
Does it work. Some demo code.. Something Like This
GLOBAL WidgetCount
RECORD TheBoss[1] LOCAL what_is_the_boss TYPE long LOCAL childs[201] TYPE long END RECORD
'200 childs RECORD WidgetID[201] LOCAL TheBossID LOCAL ID LOCAL TYPEOF LOCAL ASSOCID TYPE long LOCAL XPOS LOCAL YPOS LOCAL WIDTH LOCAL HEIGHT ' 10 callbacks LOCAL CALLS[11] TYPE STRING LOCAL CALLBACKS[11] TYPE void * LOCAL HASCALLBACK
END RECORD
OPTION PARSE FALSE
SUB CALLBACK(long widget ,char * action, void callback(),void* data)
IF (action=="button_click") THEN
PRINT "action button_click" END IF
IF (action=="resize_event") THEN PRINT " action resize_event" END IF
' can do things with this callback(<b,i,t,s>) callback(widget) END SUB
SUB Test1(long widget)
PRINT "widget 1 result " , widget
END SUB
' see if works without args SUB Test2()
PRINT "Test 2"
END SUB
LOCAL THEBOSS = 0 WidgetID[0].ID = THEBOSS Mywiget = 1 WidgetID[1].ID = Mywiget
' BLAGH BLAGH
' these should be registered in the CALLBACK , hence need to add the method as in code ' hence should not be here / but testing if can store the function/sub WidgetID[1].CALLS[0] = "button_click" ' store the widget callback WidgetID[1].CALLBACKS[0] = (void*)(Test1) WidgetID[1].HASCALLBACK = TRUE
WidgetID[1].CALLS[1] = "resize_event" ' store the widget callback WidgetID[1].CALLBACKS[1] = (void*)(Test2)
' TODO map the array id as suggest in the callback.h ; when clicked, test the callbacks CALLS[x]/CALLBACK[x] '------------------------------------------------
CALLBACK(Mywiget,"button_click",WidgetID[1].CALLBACKS[0],NULL)
CALLBACK(Mywiget,"resize_event",WidgetID[1].CALLBACKS[1],NULL)
|
|
|
Post by vovchik on Feb 11, 2016 19:25:35 GMT 1
Dear Alex,
Thanks! Testing and thinking. Looks very good so far.
With kind regards, vovchik
|
|
|
Post by alexfish on Feb 11, 2016 19:55:22 GMT 1
Hi Vovchik have tested with the screen array , but think from here on in. be a matter to , code the bits that work here as in Desktop Glut. as said what be posted are Ideas. IE someone to put the bits into place.not naming names now to get the bits into action . from the screen array callback need to make an execute function As here but calling this CALLBACK 2.. ADDED if U need to change stance of the callback , as in can it use a function OK in CALLBACK2 ,, or prior to , then note <void callback()> this is for a void function So , if build into the code a method , as in , is a void or function , type = 0 , type = 1 where 0 be void callback() and say 1 = int callback() . IE FUNCTION blagh(...) TYPE int .. and so on Dry Run Demo , most bits are hard coded. 'make array same size of canvas
GLOBAL WidgetCount CONST canvas_w = 600 CONST canvas_h = 400 OPTION PARSE FALSE GLOBAL SELECTED_WIDGET TYPE long GLOBAL CallEvents[canvas_w][canvas_h] TYPE long
RECORD TheBoss[1] LOCAL what_is_the_boss TYPE long LOCAL childs[201] TYPE long END RECORD
'200 childs RECORD WidgetID[201] LOCAL TheBossID LOCAL ID LOCAL TYPEOF LOCAL ASSOCID TYPE long LOCAL XPOS LOCAL YPOS LOCAL WIDTH LOCAL HEIGHT ' 10 callbacks LOCAL CALLS[11] TYPE STRING LOCAL CALLBACKS[11] TYPE void * LOCAL HASCALLBACK
END RECORD
SUB CALLBACK2(long widget, void callback(),void* data)
PRINT "CALLBACK2" ' send some data callback(123456789) END SUB
FUNCTION CallBack(int mouse_x,int mouse_y) LOCAL widget TYPE long
SELECTED_WIDGET= CallEvents[mouse_x][mouse_y] CALLBACK2(1,WidgetID[1].CALLBACKS[0],NULL) RETURN ( CallEvents[mouse_x][mouse_y]) END FUNCTION
SUB CALLBACK(long widget ,char * action, void callback(),void* data)
IF (action=="button_click") THEN
PRINT "action button_click" END IF
IF (action=="resize_event") THEN PRINT " action resize_event" END IF
' can do things with this callback(<b,i,t,s>) callback(widget) END SUB
SUB Test1(long widget)
PRINT "TEST 1 result " , widget
END SUB
' see if works without args SUB Test2()
PRINT "Test 2"
END SUB
LOCAL THEBOSS = 0 WidgetID[0].ID = THEBOSS Mywiget = 1 WidgetID[1].ID = Mywiget
' BLAGH BLAGH
' these should be registered in the CALLBACK , hence need to add the method as in code ' hence should not be here / but testing if can store the function/sub WidgetID[1].CALLS[0] = "button_click" ' store the widget callback WidgetID[1].CALLBACKS[0] = (void*)(Test1) WidgetID[1].HASCALLBACK = TRUE
WidgetID[1].CALLS[1] = "resize_event" ' store the widget callback WidgetID[1].CALLBACKS[1] = (void*)(Test2) ' CALLBACK(Mywiget,"button_click",WidgetID[1].CALLBACKS[0],NULL)
LOCAL but_event =1 TYPE long LOCAL but_event2 =2 TYPE long
FOR t = 5 TO 100 FOR s = 5 TO 46 CallEvents[t][s] = but_event NEXT NEXT
FOR t = 110 TO 200 FOR s = 5 TO 46 CallEvents[t][s] = but_event2 NEXT NEXT
PRINT "widget but_event ID : " , but_event PRINT "widget but_event2 ID : " ,but_event2
LET s = CallBack(0,0) PRINT "-----------------------------" PRINT "event ID : " , s PRINT "SELECTED_WIDGET ID : " , SELECTED_WIDGET
LET s = CallBack(90,46)
PRINT "-----------------------------" PRINT "widget event ID : " , s PRINT "SELECTED_WIDGET ID : " , SELECTED_WIDGET
LET s = CallBack(110,46)
PRINT "-----------------------------" PRINT "widget event ID : " , s PRINT "SELECTED_WIDGET ID : " , SELECTED_WIDGET
|
|
|
Post by alexfish on Feb 11, 2016 20:59:16 GMT 1
Hi All
I will be back to the Raspberry bits
So as a signing off note..
Anyone Calling BaCon (Cbasic) to CB as in Crippled Basic . Assume they have Lost Their Marbles..
BR Alex
|
|
|
Post by alexfish on Feb 12, 2016 20:44:44 GMT 1
Hi Vovchik
Have gone back and tested pixbux for the image methods , these work bacon3.3 is working fine as well ,
conclusion here , stb or the plugin is the culp , as in not working as should , tested that on with basica's demo with glfw. this uses stb direct. = ok
that seems to leave the plugin . so will look further.
just had to look at your code again .. so comment = plugin and or this
' ------------------ SUB IMAGE_MEM(unsigned char img_memvar[], int len, xpos, ypos, float scale) ' ------------------ ' xpos and ypos start at upper right LOCAL width, height, framew, n, x_1, y_1 TYPE int LOCAL data, data1 TYPE unsigned char* LOCAL w2, h2 TYPE int data = stbi_load_from_memory(img_memvar, len, &width, &height, &n, STB_CHANNELS) x_1 = width * scale y_1 = height * scale data1 = malloc(x_1 * y_1 * 4) stbir_resize_uint8(data, width, height, 0, data1, x_1, y_1, 0, 4) framew = x_1 CALL Draw_Prepare : ' Setup 2D canvas with (0,0) top left glRasterPos2f(xpos, ypos + y_1 - 1) glPixelStorei(GL_UNPACK_ROW_LENGTH, x_1) : ' Set the row length of the data array glDrawPixels(framew, y_1, GL_RGBA, \ GL_UNSIGNED_BYTE, data1+framew*STB_CHANNELS) : ' Draw the actual data to the canvas END SUB
BR Alex
|
|
|
Post by alexfish on Feb 12, 2016 21:17:34 GMT 1
Hi Vovchik well , well , none of the above , yet you mis' MISS an important Ingredient SYNC , why does it work on your system without the SYNC your code WINDOW("Memvar Images Resized & Repositioned", 600, 600) ' tiny 3x3 png stretched to fill canvas (interpolated gradient) IMAGE_MEM(bg_png, bg_png_len, 0, 0, 200.0) ' old Hanoi poster resized and partially off canvas IMAGE_MEM(hanoi_png, hanoi_png_len, 100, 100, 0.5) IMAGE_MEM(hanoi_png, hanoi_png_len, 350, 300, 0.6) IMAGE_MEM(hanoi_png, hanoi_png_len, 10, 300, 0.4) IMAGE_MEM(hanoi_png, hanoi_png_len, 500, 20, 0.6) ' bacon logo with transparency IMAGE_MEM(bacon_png, bacon_png_len, 200, 400, 0.8) WAITKEY now it works WINDOW("Memvar Images Resized & Repositioned", 800, 800)
SYNC ' tiny 3x3 png stretched to fill canvas (interpolated gradient) IMAGE_MEM(bg_png, bg_png_len, 0, 0, 200.0) ' old Hanoi poster resized and partially off canvas IMAGE_MEM(hanoi_png, hanoi_png_len, 100, 100, 0.5) IMAGE_MEM(hanoi_png, hanoi_png_len, 350, 300, 0.6) IMAGE_MEM(hanoi_png, hanoi_png_len, 10, 300, 0.4) IMAGE_MEM(hanoi_png, hanoi_png_len, 500, 20, 0.6) ' bacon logo with transparency IMAGE_MEM(bacon_png, bacon_png_len, 200, 400, 0.8) SYNC WAITKEY BR Alex
|
|
|
Post by vovchik on Feb 12, 2016 21:30:42 GMT 1
Dear Alex, Thanks for figuring that one out for PI. I don't need those syncs, and neither does basica, so OPEN-GL is implemented with subtle differences, I gather, depending on platform and GPU. We still have a little problem in that I am one row off somewhere in that routine. with kind regards, vovchik
|
|
|
Post by alexfish on Feb 12, 2016 21:50:46 GMT 1
Hi Vovchik
one thing I be thinking is the rendering IE is your system working single buffer..
as regards the pixel offset , can you explain in further detail what we are looking for , they are U'r images .
BR Alex
|
|