Re: SFML2 Demo Dilema
- Posted by jimcbrown (admin) May 09, 2015
- 2592 views
Icy_Viking said...
Ok I got the window to stay open with this code. Now I just need to code the events so you can properly close the window, without it locking up the computer.
You have a bit of code in the wrong place. Try this.
without warning include std/machine.e include EuSys2.ew include EuGfx2.ew include sfFlags.e atom win = sfRenderWindow_create(800,600,32,"My Window",sfClose,0) if win = -1 then puts(1,"Could not create render window!\n") abort(0) end if constant event = allocate(4 * 6) -- This is wrong. these shouldn't be here. No data is in event yet. -- These will be no more than random numbers. --integer eventType = peek4s(event) --integer code = peek4s(event+4) --integer alt = peek4s(event+8) --integer control = peek4s(event+12) --integer shift = peek4s(event+16) --integer system = peek4s(event+20) while sfRenderWindow_isOpen(win) do while sfRenderWindow_pollEvent(win,event) do -- they belong down here instead integer eventType = peek4s(event) integer code = peek4s(event+4) integer alt = peek4s(event+8) integer control = peek4s(event+12) integer shift = peek4s(event+16) integer system = peek4s(event+20) -- where did sfeventType come from? what is it's value? -- it doesn't seem to be declared anywhere, let alone initialized --if sfeventType = sfEvtClosed then if eventType = sfEvtClosed then sfRenderWindow_close(win) end if end while sfRenderWindow_clear(win,sfBlack) sfRenderWindow_display(win) end while sfRenderWindow_destroy(win)
Note that I had the correct order in my original post:
jimcbrown said...
constant event = allocate(4*6) ... while(sfRenderWindow_pollEvent(win,event) ... integer eventType = peek4s(event) integer code = peek4s(event+4) integer alt = peek4s(event+8) integer control = peek4s(event+12) integer shift = peek4s(event+16) integer system = peek4s(event+20)