|
Post by alexfish on May 14, 2023 22:40:57 GMT 1
NOTE:: there will be upddates to ALL code Ref:: to unref this call is premature and will be sorted soon also think possible promlem with thhe unref sinc on some system will show th image and others will not :: we have a lot of code based on the pixpuf : resent test show that one can only unref once the final transfer stage is completed , at least now I know how it happens Alex
A bit of code to help
Rest is down to the tasks in the Rems + try the TIMEOUT
INCLUDE hug.bac
DECLARE px,py ,z,z2 ,i TYPE double
FUNCTION DRAWcube() ' use points px py z , rotate an size SQUARE("#000000",0,0,600,590,1) INCR px INCR py INCR z LOCAL angle TYPE double angle = 2 * PI * i / 360 px = (100.0/2.0)*COS(angle) z = (100.0/2.0)*COS(angle) z2 = (100.0/2.0)*SIN(angle) 'y = (hug_ysize/2)*SIN(angle) INCR i,5.0 IF i > 360 THEN i = 0 END IF ' Half a Stick & half a Stick = a Whole Stick (the right hand stick LINE("#FF0000",px+300,200, px+300, 200 -(z+100) ) LINE("#FF0000",px+300,200, px+300, 200 +(z+100) ) LINE("#FF0000",-px+300,200, -px+300, 200 +(z2+100) ) LINE("#FF0000",-px+300,200, -px+300, 200 -(z2+100) ) 'TODO REM make a 2 sticks to make top and bottom of the Rotating face of Cube REM Complete the cube REM Tip print the bits RETURN TRUE END FUNCTION
win = WINDOW("cube",606,606) can = CANVAS(600,550) ATTACH(win,can,3,50)
offx = 0 offy = 0
'BACK LINE("#FF0000",offx+ -50,offy+ -50 ,offx+ 50,offy+ -50) LINE("#FF0000",offx+ 50,offy -50 ,offx+ 50,offy+ 50) LINE("#FF0000",offx+ 50,offy+ 50,offx+ -50,offy+ 50) LINE("#FF0000",offx+ -50,offy+ 50,offx+ -50,offy+ -50 )
'JOINS, LINE("#FF0000",offx+ -100,offy+ -100 ,offx+ -50,offy+ -50) LINE("#FF0000",offx+ 100,offy -100,offx+ 50,offy -50 ) LINE("#FF0000",offx+ 100,offy+ 100,offx+ 50,offy+ 50) LINE("#FF0000",offx+ -100,offy+ 100,offx+ -50,offy+ 50)
' FRONT LINE("#FF0000",offx+ -100,offy+ -100 ,offx+ 100,offy -100) LINE("#FF0000",offx+ 100,offy -100,offx+ 100,offy+ 100) LINE("#FF0000",offx+ 100,offy+ 100,offx+ -100,offy+ 100) LINE("#FF0000",offx+ -100,offy+ 100,offx+ -100,offy+ -100)
offx = 250 offy = 250
'BACK LINE("#FF0000",offx+ -50,offy+ -50 ,offx+ 50,offy+ -50) LINE("#FF0000",offx+ 50,offy -50 ,offx+ 50,offy+ 50) LINE("#FF0000",offx+ 50,offy+ 50,offx+ -50,offy+ 50) LINE("#FF0000",offx+ -50,offy+ 50,offx+ -50,offy+ -50 )
'JOINS, LINE("#FF0000",offx+ -100,offy+ -100 ,offx+ -50,offy+ -50) LINE("#FF0000",offx+ 100,offy -100,offx+ 50,offy -50 ) LINE("#FF0000",offx+ 100,offy+ 100,offx+ 50,offy+ 50) LINE("#FF0000",offx+ -100,offy+ 100,offx+ -50,offy+ 50)
' FRONT LINE("#FF0000",offx+ -100,offy+ -100 ,offx+ 100,offy -100) LINE("#FF0000",offx+ 100,offy -100,offx+ 100,offy+ 100) LINE("#FF0000",offx+ 100,offy+ 100,offx+ -100,offy+ 100) LINE("#FF0000",offx+ -100,offy+ 100,offx+ -100,offy+ -100) 'TIMEOUT (100,DRAWcube) DISPLAY Yes I Know one of the lines is not circulating > Imagine your on a road and that is a lamp post and your car is going forward and backwards , so your task it to draw the other sides of the cube or a road sign you know , something not totally SQ , when not head on
Just Had a flashback (3d Joystick)
Have Fun + BR Alex
|
|
|
Post by alexfish on May 15, 2023 22:24:06 GMT 1
How can it be done in Cairo Using hug Imager5.2 imports for hug.bac or hug3.5 series , something to look at
INCLUDE "hug352.bac"
HOME$ = GETENVIRON$("HOME") HUGOPTIONS("CANVASCAIRO") HUGOPTIONS("NOSCALING")
SUB draw() LOCAL pix,ebox,surface pix = hug_gui_properties.canvas ebox = hug_widget_ebox(STR$(pix)) surf = hug_widget_surface( STR$(pix))
cr = cairo_create (surf) cairo_set_source_rgb(cr,1,1,0) cairo_paint(cr) cairo_save (cr) cairo_set_source_rgb(cr,1,0,0)
cairo_new_path(cr) cairo_set_line_width (cr,2)
'CENTER OF CANVAS 800,600 LINE("#FF0000",380,300,420,300) LINE("#FF0000",400,280,400,320) cairo_move_to(cr,400,300) 'start box cairo_rel_move_to(cr,50,50) 'draw around the center cairo_rel_line_to(cr,-100,0) cairo_rel_line_to(cr,0,-100) cairo_rel_line_to(cr,100,0) cairo_close_path (cr) 'cairo_rel_line_to(cr,0,100)
cairo_stroke(cr) cairo_destroy(cr) cairo_surface_flush(surf) gtk_image_set_from_surface (pix,surf) gtk_widget_queue_draw(hug_widget_image(STR$(ebox))) END SUB
win = WINDOW("LINES",806,806) can = CANVAS(800,600)
but = BUTTON("Draw",70,25) CALLBACK(but,draw)
ATTACH(win,but,3,3) ATTACH(win,can,3,50)
DISPLAY
gl example extract bits from SQUARE
glMatrixMode(GL_PROJECTION) glLoadIdentity glOrtho(0, hug_widget_xsize(STR$(ebox)), hug_widget_ysize(STR$(ebox)), 0, 0, 1) glMatrixMode(GL_MODELVIEW) glLoadIdentity glTranslatef(0.375, 0.375, 0)
glBegin(GL_LINE_LOOP) glVertex2i(hug_x, hug_y) glVertex2i(hug_x+hug_xsize, hug_y) glVertex2i(hug_x+hug_xsize, hug_y+hug_ysize) glVertex2i(hug_x, hug_y+hug_ysize) glEnd
although can draw cairo to opengl
like
unsigned char* data = cairo_image_surface_get_data(surface) then do
glTexImage2D(GL_TEXTURE_2D, 0, 4, tex_w,tex_h, 0,GL_BGRA, GL_UNSIGNED_BYTE, data) Demo's of get data are posted in imager thread & imager documentation
how to preset endian(bit) color is in hug.3.5.1
IF ENDIAN THEN cairo_set_source_rgb(cr,b,g,r) ELSE cairo_set_source_rgb(cr,r,g,b) END IF
IF ENDIAN THEN cairo_set_source_rgba(cr,b,g,r,a) ELSE cairo_set_source_rgba(cr,r,g,b,a) END IF
Hug3.5.2 does not require bit change it has
gtk_image_set_from_surface (pix,surf) then get the buffer from the image
gtk_image_get_pixbuf will need to flip the buffer set a pixbuf to get the data use
gdk_pixbuf_flip (const GdkPixbuf* src, gboolean horizontal) get the data back
guchar* gdk_pixbuf_get_pixels (const GdkPixbuf* pixbuf)
for the gdk_pixbuf_flip
CONST GDK_PIXBUF_FLIP_VERTICAL = 0 CONST GDK_GDK_PIXBUF_FLIP_HORIZONTAL = 1 Viola Added Tip Here
buf = gdk_pixbuf_new_from_file(hug_file$, 0)
BR Alex
|
|
|
Post by alexfish on May 16, 2023 7:46:28 GMT 1
Q: how do I get hug gl A: it is built in "CANVASGL" Although the API is Not Complete Complete Examples HEREIf want to use full API then Comment out the following from the gl.bac /*
WARNING: duplicate symbol 'glClearColor' at line 883 in file 'gl.bac'!
WARNING: duplicate symbol 'glClear' at line 884 in file 'gl.bac'!
WARNING: duplicate symbol 'glMatrixMode' at line 930 in file 'gl.bac'!
WARNING: duplicate symbol 'glOrtho' at line 931 in file 'gl.bac'!
WARNING: duplicate symbol 'glLoadIdentity' at line 936 in file 'gl.bac'!
WARNING: duplicate symbol 'glTranslatef' at line 946 in file 'gl.bac'!
WARNING: duplicate symbol 'glBegin' at line 955 in file 'gl.bac'!
WARNING: duplicate symbol 'glEnd' at line 956 in file 'gl.bac'!
WARNING: duplicate symbol 'glVertex2i' at line 959 in file 'gl.bac'!
WARNING: duplicate symbol 'glColor3ub' at line 1006 in file 'gl.bac'!
WARNING: duplicate symbol 'glRasterPos2i' at line 1067 in file 'gl.bac'!
WARNING: duplicate symbol 'glBitmap' at line 1137 in file 'gl.bac'! */ THEN INCLUDE the gl.bac INCLUDE "hug352.bac" INCLUDE "gl.bac" What Works HEREshould work here BR Alex
|
|
|
Post by alexfish on May 17, 2023 12:37:45 GMT 1
Hi All Looking at opengl 'gl bits RE RPI2' , Vovchik and I Worked on way-back :hugrpi with opengl/egl have pulled out 5 bits, Some will recognize the bits : putting them here for a reference for GL TEXTURESPRE-LOADLOADING and BINDING textures[ARRAYS] Of Note No Flipping As pointer to Hug Mark be careful of < > in text the bit in the code is :: IF (t==38) THEN svg2$="&" ELIF (t==60) THEN svg2$="<" ELIF (t==163) THEN svg2$=CURRENCY$ ELSE
svg2$ = CHR$(t) END IF
I need to write that bit into the imager libs, hence an update there yet again but hopeful last update: it took me a while to find that BIT: then will have text like "-> HERE <-" and the currency = $ & £ , depends on keyboard us/uk and key 163 REM ============================================================================ SUB CLEARTEXTURE(int tex) IF (tex >=0 AND tex <256 &Texture[tex]) THEN glDeleteTextures(1,&Texture[tex]) END IF
END SUB REM ============================================================================ SUB BINDTEXTURE(int tex)
glBindTexture(GL_TEXTURE_2D, Texture[tex]) END SUB REM ============================================================================ REM ============================================================================
SUB SvgLoad(STRING svg$,int tex) LOCAL pixloader, pixbuf LOCAL size LOCAL res LOCAL raw_array TYPE unsigned char* LOCAL data TYPE unsigned char* size = LEN(svg$) raw_array = (unsigned char*)svg$ pixloader = gdk_pixbuf_loader_new() res = gdk_pixbuf_loader_write(pixloader, raw_array, size, 0) res = gdk_pixbuf_loader_close(pixloader,0) IF (res) THEN pixbuf = gdk_pixbuf_loader_get_pixbuf(pixloader) data = gdk_pixbuf_get_pixels(pixbuf) glGenTextures(1, & Texture[tex]) glBindTexture(GL_TEXTURE_2D, Texture[tex]) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, gdk_pixbuf_get_width(pixbuf),gdk_pixbuf_get_height(pixbuf), 0, GL_RGBA, GL_UNSIGNED_BYTE, data) g_object_unref(pixbuf) ELSE PRINT "Buffer ERROR" END IF
END SUB
REM ============================================================================ SUB TEXTURE(file$, int tex) LOCAL pixloader, pixbuf LOCAL size LOCAL res LOCAL raw_array TYPE unsigned char* LOCAL data TYPE unsigned char*
pixbuf = gdk_pixbuf_new_from_file(file$,0) IF (pixbuf) THEN data = gdk_pixbuf_get_pixels(pixbuf) glGenTextures(1, &Texture[tex]) glBindTexture(GL_TEXTURE_2D, Texture[tex]) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, gdk_pixbuf_get_width(pixbuf),gdk_pixbuf_get_height(pixbuf), 0, GL_RGBA, GL_UNSIGNED_BYTE, data) g_object_unref(pixbuf) ELSE PRINT " Pixbuff from file failed" END IF END SUB
REM ============================================================================
SUB LoadFont()
LOCAL pixloader TYPE long LOCAL size TYPE int LOCAL res TYPE int LOCAL raw_array TYPE unsigned char* LOCAL svg2$ TYPE char* LOCAL svghead$ TYPE char*
LOCAL data TYPE unsigned char* LOCAL t
FOR t = 0 TO 255 LOCAL pixbuf svghead$="" svghead$ = MkStrs( <svg height="50" width="50" font-size="30" fill="white" stroke="white" text-anchor="middle"><text x="25" y="25" dx="-20">)
IF (t==38) THEN svg2$="&" ELIF (t==60) THEN svg2$="<" ELIF (t==163) THEN svg2$=CURRENCY$ ELSE
svg2$ = CHR$(t) END IF
'PRINT svg2$ svghead$ = svghead$ & svg2$ svghead$ = svghead$ & "</text></svg>" 'PRINT t , " : " , svghead$ size = LEN(svghead$) raw_array = (unsigned char*)svghead$
pixloader = gdk_pixbuf_loader_new() res = gdk_pixbuf_loader_write(pixloader, raw_array, size, 0) res = gdk_pixbuf_loader_close(pixloader,0) IF (res) THEN pixbuf = gdk_pixbuf_loader_get_pixbuf(pixloader) data = gdk_pixbuf_get_pixels(pixbuf) glGenTextures(1, &fonts[t]) glBindTexture(GL_TEXTURE_2D, fonts[t]) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, gdk_pixbuf_get_width(pixbuf),gdk_pixbuf_get_height(pixbuf), 0, GL_RGBA, GL_UNSIGNED_BYTE, data) g_object_unref(pixbuf)
' TODO FIXME 'glDeleteTextures( 1, &texID ) ELSE
END IF
NEXT
END SUB
REM ============================================================================
+ relates what is above this post ADDED What did we cubeize as a texture : see Pick BR Alex Attachments:23.svg (94.45 KB)
|
|
|
Post by alexfish on May 17, 2023 18:22:52 GMT 1
Have downloaded Peter's glglut demo AKA
DECLARE cube_color[] = { 0.1, 0.2, 0.8, 0.5 } TYPE float DECLARE torus_color[] = { 0.8, 0.2, 0.1, 0.5 } TYPE float DECLARE teapot_color[] = { 0.1, 0.7, 0.1, 0.5 } TYPE float DECLARE cone_color[] = { 0.8, 0.7, 0.1, 0.5 } TYPE float DECLARE tetrahedron_color[] = { 0.8, 0.1, 0.8, 0.5 } TYPE float DECLARE isocahedron_color[] = { 0.1, 0.7, 0.7, 0.5 } TYPE float Now this is Where I be At hug.bac = Success
In gtk3 The Bug To Resolve
and where does it emanate from at first glace is it GLUT hug gl includes for the demo are
INCLUDE "hug.bac" INCLUDE "glut.bac" INCLUDE "gl.bac"
in Glut
IMPORT "glutInitWindowPosition(int,int)" FROM glut_LIB$ TYPE void IMPORT "glutInitWindowSize(int,int)" FROM glut_LIB$ TYPE void IMPORT "glutInitDisplayMode(int)" FROM glut_LIB$ TYPE void IMPORT "glutInitDisplayString(char*)" FROM glut_LIB$ TYPE void IMPORT "glutMainLoop(void)" FROM glut_LIB$ TYPE void IMPORT "glutCreateWindow(char*)" FROM glut_LIB$ TYPE int IMPORT "glutCreateSubWindow(int,int,int,int,int)" FROM glut_LIB$ TYPE int IMPORT "glutDestroyWindow(int)" FROM glut_LIB$ TYPE void IMPORT "glutSetWindow(int)" FROM glut_LIB$ TYPE void IMPORT "glutGetWindow(void)" FROM glut_LIB$ TYPE int IMPORT "glutSetWindowTitle(char*)" FROM glut_LIB$ TYPE void IMPORT "glutSetIconTitle(char*)" FROM glut_LIB$ TYPE void IMPORT "glutReshapeWindow(int,int)" FROM glut_LIB$ TYPE void IMPORT "glutPositionWindow(int,int)" FROM glut_LIB$ TYPE void IMPORT "glutShowWindow(void)" FROM glut_LIB$ TYPE void IMPORT "glutHideWindow(void)" FROM glut_LIB$ TYPE void IMPORT "glutIconifyWindow(void)" FROM glut_LIB$ TYPE void IMPORT "glutPushWindow(void)" FROM glut_LIB$ TYPE void IMPORT "glutPopWindow(void)" FROM glut_LIB$ TYPE void IMPORT "glutFullScreen(void)" FROM glut_LIB$ TYPE void IMPORT "glutPostWindowRedisplay(int)" FROM glut_LIB$ TYPE void IMPORT "glutPostRedisplay(void)" FROM glut_LIB$ TYPE void
Now Looks like 3 bits to resolve
Back Soon I hope OK Found its in The DRAW() :: NOT its in the CANVAS GL. I be puzzled . need to double check on the demo that worked
BR Alex
|
|
|
Post by alexfish on May 17, 2023 21:12:14 GMT 1
Not sure on the stance I tried gtk_gl_area_new() Now according to gtk3 docs gtk_gl_area_new is part of gtk3 & not a separate function SINCE gtk 3.16 docs.gtk.org/gtk3/class.GLArea.htmlbut original area exists but fails on gtk_gl_area_new(attibutes) Argh Will change this and see what happens the change = import under GTK3* other part of the stance is GDK ,both are 3* so it can't be glut since that matches 3 OH@ the test was on glarea for render times under SYNC were cairo was fastest + I can create the original but face this container add BUG , the plot thickens there again it will not init as mentioned
|
|
|
Post by alexfish on May 17, 2023 22:13:09 GMT 1
Well only backends of gtk_gl_area_new are in libgtkgl-2.0.so and nothing in as a 3* per say 'libgtkgl-3.0.so.' did a direct call as per the lib docs and that segfaults im = gtk_gl_area_new() and this gtk_gl_init(0, 0) craps out as well Just Found this stackoverflow.com/questions/3815806/gtk-and-opengl-bindings Diary First encounter of GTK3 woes started on Oct 12, 2022 at 2:52amHow are things going ? A: Same as ever and they want to go Vulcan , :: No Comment
|
|
|
Post by alexfish on May 17, 2023 23:01:19 GMT 1
Tip of the Day
|
|
|
Post by alexfish on May 18, 2023 20:15:41 GMT 1
Looks like need a sort out on the original gl/glarea did separate do it like so HUG_MAX_LIB_SEQ = 50 FUNCTION hug_Get_Gtk$ : REM INCLUDE
LOCAL hug_lib$ LOCAL hug_sequence = -1
IF INSTR(OS$, "Darwin") THEN hug_lib$ = "/opt/local/lib/libgtk-x11-2.0.0.dylib" IF NOT(FILEEXISTS(hug_lib$)) THEN hug_lib$ = "/Library/Frameworks/Gtk.framework/Libraries/libgtk-quartz-2.0.0.dylib" END IF ELIF INSTR(OS$, "CYGWIN") THEN hug_lib$ = "cyggtk-x11-2.0-0.dll" END IF
CATCH GOTO Redo_Import
LABEL Redo_Import INCR hug_sequence IF hug_sequence = HUG_MAX_LIB_SEQ THEN GOTO Print_Error IF NOT(INSTR(hug_lib$, "dylib")) AND NOT (INSTR(hug_lib$, "dll")) THEN hug_lib$ = CONCAT$("libgtk-3.so.", STR$(hug_sequence)) IMPORT "gtk_init(int*,void*)" FROM hug_lib$ TYPE void 'HUGLIB.hug_Gtk$ = hug_lib$ RETURN hug_lib$
LABEL Print_Error PRINT "Gtk library not found!" END
END FUNCTION
mylib$ = hug_Get_Gtk$()
PRINT mylib$ IMPORT gtk_gl_area_new() FROM mylib$ TYPE long gtk_init(0,0) gl = gtk_gl_area_new() PRINT gl Hooray Looks like need updates in 3.5.2 it has several functions , in main gtk3 gl area can do what is in first few posts github.com/GNOME/gtk/blob/main/gtk/gtkglarea.csomewhere in there = 'dependency cairo' 'include cairo.h' also noted that TABLE gtk_table = gone some thoughts as in the GTK3 allocation IE certain widgets set_size request fails AKA NOTEBOOK spotted this in the glarea gtk_gl_area_size_allocate (GtkWidget *widget, int width, int height, int baseline) {
think that will be last update on this post Next Up :: a break to take Stock BR Alex
|
|
|
Post by alexfish on May 19, 2023 21:23:36 GMT 1
Well Now got a result GTK3 test code IMPORTED gl_area bits under gtk IMPORTED window bits but not use layer use container add(gl area) IMPORTED g_object & glib USE Peters gl.bac target get the callback to "render" test gl function clear() make the area red INCLUDE gl.bac
FUNCTION render()
gtk_gl_area_make_current(gl_area) 'set to red glClearColor (1, 0, 0, 0) glClear (GL_COLOR_BUFFER_BIT) RETURN TRUE END FUNCTION
gtk_init(0,0) win = WINDOW ("gltest",400,400)
gl_area = gtk_gl_area_new() gtk_container_add(win,gl_area) gtk_widget_show_all(gl_area) g_signal_connect_data (gl_area, "render", render, 0,0,0)
gtk_main() :: will work on the hug gtk3 lib & hopeful of updating next weekend from details this callback should return true : docs suggest testing the bits ' did not see the point, if it fails it fails:: the DIFF GTK3IMPORT gtk_gl_area_new() FROM mylib$ TYPE long GTK2IMPORT "gtk_gl_area_new(long)" FROM hug_lib$ TYPE long BR Alex Picky Attachments:
|
|
|
Post by alexfish on May 20, 2023 17:02:35 GMT 1
hug352The bits are sorted gtk_gl_area() is IMPORTED under GTK$ Have put the initial gtk gl area in as a widget and will update the GLCANVAS , initial setting for both will be to clear the buffer bit to ALPHA 0 but that can be change Q: Why:: see picky Further Updates will be done on the hug IMAGE documentation BR Alex UPDATE :: Just Found out . can't use anything of gtk gl area as list in hug.bac : it will freeze your system switch off and reboot required there are calls to update the buffer ' and guess what gtk have done a dandy with the methods So no swap buffers in there : back to the method = that 'render' in a timeout function you get the area' and call gtk_gl_area_queue_render(area) you can draw what you like in the time out , the thing will not get drawn , only the bits in the 'render' callback that's were I'm standing , in a pile of something that rhymes with , yes you got it Anyway got my first flying saucer the bits INCLUDE hug353.bac HUGOPTIONS("NOSCALING")
FUNCTION GLAREA(hug_xsize,hug_ysize) gl_area = gtk_gl_area_new() gtk_widget_show_all(gl_area) gtk_gl_area_set_has_alpha(gl_area,TRUE) ebox = gtk_event_box_new() gtk_event_box_set_visible_window(ebox,0) gtk_widget_set_events(ebox, GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK) g_signal_connect_data(ebox, "button-press-event", hug_mouse_event, 20, 0, 0) g_signal_connect_data(ebox, "button-release-event", hug_mouse_event, 40, 0, 0) g_signal_connect_data(ebox, "motion-notify-event", hug_mouse_event, 0, 0, 0) g_signal_connect_data(ebox, "scroll-event", hug_mouse_event, 10, 0, G_CONNECT_AFTER) g_signal_connect_data(ebox, "leave-notify-event", hug_mouse_event, 30, 0, 0) gtk_container_add(ebox, gl_area)
IF HUG_WIDGET_SHOW THEN gtk_widget_show_all(ebox) g_signal_connect_data (gl_area, "render", glent_init, 0,0,0)
hug_widget_xsize(STR$(ebox)) = hug_xsize hug_widget_ysize(STR$(ebox)) = hug_ysize hug_widget_signal(STR$(ebox)) = 4 hug_widget_s_widget(STR$(ebox)) = ebox
hug_widget_type$(STR$(ebox)) = "canvasgl" hug_widget_font(STR$(ebox)) = gl_area hug_widget_focus(STR$(ebox)) = gl_area WIDGET = ebox RETURN ebox END FUNCTION
win = WINDOW("GL dem " ,600,400) but = BUTTON("Hello gl",100,25) ATTACH(win,but,0,0) can = GLAREA(600,400) ATTACH(win,can,0,0) DISPLAY
Last ditch : ignored the docs callback used old faithful gtk_widget_queue_draw(area) And Viola Attachments:
|
|
|
Post by alexfish on May 27, 2023 16:23:54 GMT 1
Hi All Have done the re-wright of gl_area :: now in as Widget + Canvas + Cleaned up the code The lib will be posted as 3.5.3 in first off need to find my bearings again have got the first side of a cube done , I thinks says He The lib will be updated on Monday , all been well BR Alex And the Picky and then Two Attachments:
|
|
|
Post by alexfish on May 27, 2023 19:28:14 GMT 1
Its All Go For Monday Attachments:
|
|
|
Post by alexfish on May 31, 2023 11:28:03 GMT 1
Hi All From last post :: tested gl texture Findings :: the textures did not work Fixes:: 1: gl.bac TEXTURE* in progress , + looking for possible others to (OPEN GL API) 2: depth needs to be applied to Z buffer the original paint method works fine Updated gl.bac : expect Friday 2nd June Updated demo's * 2: posting Next day For now after some testy debugging ... BaCon Eyes Picky cube demo , constrained by use of glViewport at the time I felt What a relieve to find the bits And BR Alex Attachments:
|
|
|
Post by alexfish on May 31, 2023 14:52:38 GMT 1
Now got everything into scope , I think says He Preview of 3dcube function SUB DrawGL_Cube() LOCAL ouy = 0.5 TYPE float LOCAL xrot=0, yrot = 0, zrot=0 TYPE static int LOCAL pix, ebox
REM Get the associated canvas pix = hug_gui_properties.canvas ebox = hug_widget_ebox(STR$(pix))
gtk_gl_area_make_current(hug_gui_properties.canvas)
glEnable(GL_CULL_FACE) glEnable(GL_DEPTH_TEST) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glMatrixMode(GL_PROJECTION)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glLoadIdentity()
glRotatef(xrot,1.0f,0.0f,0.0f) glRotatef(yrot,0.0f,1.0f,0.0f) glRotatef(yrot,0.0f,0.0f,1.0f) 'glScalef(0.5,0.5,0.5) glBindTexture(GL_TEXTURE_2D, texture)
glBegin(GL_QUADS) 'Front face glTexCoord2f(0.0f, 0.0f); glVertex3f(-ouy, -ouy, ouy) glTexCoord2f(1.0f, 0.0f); glVertex3f( ouy, -ouy, ouy) glTexCoord2f(1.0f, 1.0f); glVertex3f( ouy, ouy, ouy) glTexCoord2f(0.0f, 1.0f); glVertex3f(-ouy, ouy, ouy)
' Back Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-ouy, -ouy, -ouy) glTexCoord2f(1.0f, 0.0f); glVertex3f(-ouy, ouy, -ouy) glTexCoord2f(1.0f, 1.0f); glVertex3f( ouy, ouy, -ouy) glTexCoord2f(0.0f, 1.0f); glVertex3f( ouy, -ouy, -ouy)
' Top Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-ouy, ouy, -ouy) glTexCoord2f(1.0f, 0.0f); glVertex3f(-ouy, ouy, ouy) glTexCoord2f(1.0f, 1.0f); glVertex3f( ouy, ouy, ouy) glTexCoord2f(0.0f, 1.0f); glVertex3f( ouy, ouy, -ouy)
' Bottom Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-ouy, -ouy, -ouy) glTexCoord2f(1.0f, 0.0f); glVertex3f( ouy, -ouy, -ouy) glTexCoord2f(1.0f, 1.0f); glVertex3f( ouy, -ouy, ouy) glTexCoord2f(0.0f, 1.0f); glVertex3f(-ouy, -ouy, ouy)
' Right face glTexCoord2f(0.0f, 0.0f); glVertex3f( ouy, -ouy, -ouy) glTexCoord2f(1.0f, 0.0f); glVertex3f( ouy, ouy, -ouy) glTexCoord2f(1.0f, 1.0f); glVertex3f( ouy, ouy, ouy) glTexCoord2f(0.0f, 1.0f); glVertex3f( ouy, -ouy, ouy)
' Left Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-ouy, -ouy, -ouy) glTexCoord2f(1.0f, 0.0f); glVertex3f(-ouy, -ouy, ouy) glTexCoord2f(1.0f, 1.0f); glVertex3f(-ouy, ouy, ouy) glTexCoord2f(0.0f, 1.0f); glVertex3f(-ouy, ouy, -ouy)
glEnd()
INCR xrot ,2 INCR yrot ,3 INCR zrot ,4 '=UPDATE THE SCREEN ====================== gtk_widget_queue_draw(hug_widget_image(STR$(ebox)) ) '===================================== END SUB BR Alex And the Picky Attachments:
|
|