Re: Phix While Loop Inside pGUI Main Loop
- Posted by irv May 15, 2019
- 3145 views
I've spent the morning searching the web, and it appears that the best approach to doing this would be by wrapping GLFW3. It's current (most are really old) and has pre-compiled dlls for windows and excellent documentation.
https://www.glfw.org/docs/latest/index.html
OpenGL itself is awfully complex, and there are several Euphoria wrappers for openGL in the archives, if someone wants to use (modify?) those. At any rate, EuGTK just allows you to create a GLArea and obtain an openGL "context". The setup should be simple, see below. As is, this opens a window with a blank black area for drawing. The hard part is writing the openGL code, and about this, like Sergeant Schultz, "I Know Nothing. Nothing!".
include GtkEngine.e constant win = create(GtkWindow,"size=300x300;border=10;$destroy=Quit"), gla = create(GtkGLArea), glx = get(gla,"context"), clk = create(GIdle,"DoStuff"), --* calls DoStuff repeatedly, as fast as possible; tik = create(GTimeout,250,"Tock") --* calls your "Tock" function 4 times per second; --* = optional, use one or both, as appropriate for the game; add(win,gla) show_all(win) connect(gla,"render","Render") -- do whenever needed; main() global function DoStuff() -- fast as possible; -- you compute the collisions and moves here, -- (and, presumably, call openGL draw function) return 1 end function global function Render(atom area, atom context) -- redraw the stuff that needs redrawing; -- here's where the fun starts (And I Get Lost Totally!) return 1 end function global function Tock() -- do something every x milliseconds; return 1 -- returning 0 will shut off the tik timer; end function