Author Topic: Pulsar2D is still alive ...  (Read 6271 times)

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 574
    • View Profile
    • Home of EGSL
Re: Pulsar2D is still alive ...
« Reply #15 on: 14. October 2015, 20:16:44 »
Anyway, it shouldn't be possible to resize the windows with your mouse, at least it isn't possible on my systems (Linux Mint, Xubuntu, Windows 7 and Windows 10).
I am on Lubuntu 14.04, and it is possible to reduce (minimize in the application bar)  a Pulsar window or to hide it with another one  during an animation. And of course, the Pulsar window does refresh itself thanks to the animation loop.

Quote from: Cybermonkey
It can be if the window isn't refreshed anymore and waiting for a keypress or such that the content isn't visible anymore.
Indeed, but in this case, with EGSL we could recover the window and its content nevertheless, with no need to run the script again.



Concerning the script which runs faster on EGSL than on Pulsar, here is my script (with the results at the end).
It may be that I was mistaken somewhere :
Code: [Select]
local bx,by,bw,bh
bx=0
by=0
bw=256*2
bh=256*2

local sx,sy,sw,sh
sx=-2.2
sy=-1.7
sw=3.4
sh=3.4

local clock = os.clock
local temps, t0, t1
local gx, gy, zx, zy, nzx
local col,r,v,b
local x, y, c

local fen = openwindow("Mandel simple (Pulsar2D)", 50, 50, bw,bh)
setactivewindow(fen)
backcolor(0,0,0,255)
clearwindow()
sync()

t0=clock()

for x=0,bw do
for y=0,bh do
gx=x/bw*sw+sx
gy=y/bh*sh+sy
zx=gx
zy=gy
for c=0,255 do
col = c
nzx=zx*zx - zy*zy + gx
zy=2*zx*zy+gy
zx=nzx
if zx*zx + zy*zy > 4 then
col = c
break
end 
end
r = col     
v = col*32 
b = col*64 
color(r,v,b,255)
dot(x,y)
end
end

t1=clock()
temps = (t1-t0)
text = tostring(temps).." secondes."

color(255,255,0,255)
drawtext(text, 2, 2)
sync()

inkey()
closewindow(fen)
closeapplication()

-- EGSL   : 2.978096 sec.
-- Pulsar : 3.359697 sec.
-- diff.  = 0.381601 sec.


Other information : the problem reported by Rick3137 does not happen on my computer...
Hm, I can put a window in front of a Pulsar window  (finished script, and no sync anymore) and the content is still present. Also if I minimize it to the taskbar and get it back, the content is also present.

Your script is interesting, here the EGSL version is also slightly faster. It practically is the same I used, only that I did a redraw at the end of the second loop. And then Pulsar is faster. Well, actually the Lua part is exactly the same, on Windows it's even the same DLL. So the difference lies between SDL and SDL2, I guess.
Best regards,
Cybermonkey

Rick3137

  • Full Member
  • ***
  • Posts: 108
    • View Profile
    • Rick's Programs
Re: Pulsar2D is still alive ...
« Reply #16 on: 14. October 2015, 22:50:35 »
   My Windows 8.1 has a similar redraw problem. If I minimize a pulsar window to the taskbar, everything is missing when I bring it back. On the other hand, covering the window with another one, does not hurt it.
http://rb23.yolasite.com  Ricks Programs
http://rb27.synthasite.com   Sight and Sound

Bereb

  • Newcomer
  • *
  • Posts: 47
    • View Profile
Re: Pulsar2D is still alive ...
« Reply #17 on: 15. October 2015, 12:19:32 »
Well, actually the Lua part is exactly the same, on Windows it's even the same DLL. So the difference lies between SDL and SDL2, I guess.

It's what I guessed too, but I was not sure (because I'm not really a skilled programmer).
Maybe both problems (speed of script  and “window refreshing”)  are then linked (?)

P.S.: the version of my SDL2 is 2.0.2

adding :
With the loop in this modified script, there is no more problem for displaying the window again (after reducing it or after hiding it) :

Code: [Select]
local bx,by,bw,bh
bx=0
by=0
bw=256*2
bh=256*2

local sx,sy,sw,sh
sx=-2.2
sy=-1.7
sw=3.4
sh=3.4

local clock = os.clock
local temps, t0, t1
local gx, gy, zx, zy, nzx
local col,r,v,b
local x, y, c

fen1 = openwindow("Mandel simple (Pulsar2D)", -1, -1, bw,bh)
setactivewindow(fen1)
backcolor(0,0,0,255)
clearwindow()
redraw()

t0=clock()

for x=0,bw do
for y=0,bh do
gx=x/bw*sw+sx
gy=y/bh*sh+sy
zx=gx
zy=gy
for c=0,255 do
col = c
nzx=zx*zx - zy*zy + gx
zy=2*zx*zy+gy
zx=nzx
if zx*zx + zy*zy > 4 then
col = c
break
end 
end
r = col     
v = col*32 
b = col*64 
color(r,v,b,255)
dot(x,y)
end
end

t1=clock()
temps = (t1-t0)
text = tostring(temps).." secondes."

color(255,255,0,255)
drawtext(text, 2, 2)
--redraw()

--LOOP----------------------
repeat
    redraw()
until getkey() == 41 --> <esc>
----------------------------

closewindow(fen1)
closeapplication()
« Last Edit: 15. October 2015, 20:04:01 by Bereb »
Regards, Bertrand :)
** Lubuntu 14.04 (Intel Celeron CPU 2.66GHz - 1280MiB) **

Rick3137

  • Full Member
  • ***
  • Posts: 108
    • View Profile
    • Rick's Programs
local variables
« Reply #18 on: 15. October 2015, 17:46:45 »
  I have been using several dialects of Basic and forgot all about the "local" command found in functions.
  My programs do really strange things if I forget to declare variables local.
  Not really a bug, but it can sure look like one.
http://rb23.yolasite.com  Ricks Programs
http://rb27.synthasite.com   Sight and Sound

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 574
    • View Profile
    • Home of EGSL
Re: Pulsar2D is still alive ...
« Reply #19 on: 15. October 2015, 20:02:59 »
Erm, instead of
Code: [Select]
--LOOP----------------------
repeat
    redraw()
until getkey() == 41
----------------------------
better use
Code: [Select]
--LOOP----------------------
repeat
    sync()
until getkey() == 41
----------------------------
otherwise your CPU will go up on 100% while the loop runs. Actually you could even add a wait(20) behind sync().
Best regards,
Cybermonkey

Bereb

  • Newcomer
  • *
  • Posts: 47
    • View Profile
Re: Pulsar2D is still alive ...
« Reply #20 on: 16. October 2015, 11:47:48 »
Erm, instead of
Code: [Select]
--LOOP----------------------
repeat
    redraw()
until getkey() == 41
----------------------------
better use
Code: [Select]
--LOOP----------------------
repeat
    sync()
until getkey() == 41
----------------------------
otherwise your CPU will go up on 100% while the loop runs. Actually you could even add a wait(20) behind sync().

Yes, I've just realized it now (before I read your post).
Thank you  :)
Regards, Bertrand :)
** Lubuntu 14.04 (Intel Celeron CPU 2.66GHz - 1280MiB) **

Rick3137

  • Full Member
  • ***
  • Posts: 108
    • View Profile
    • Rick's Programs
Re: Pulsar2D is still alive ...
« Reply #21 on: 16. October 2015, 15:41:15 »
   This last fix makes my Windows 8.1 flicker badly.
 I must have my computer set up different than everyone else.
 Maybe someday, I'll upgrade to Windows10 or Ubuntu and fix this stuff.
http://rb23.yolasite.com  Ricks Programs
http://rb27.synthasite.com   Sight and Sound

Rick3137

  • Full Member
  • ***
  • Posts: 108
    • View Profile
    • Rick's Programs
Re: Pulsar2D is still alive ...
« Reply #22 on: 16. October 2015, 17:14:37 »
   This combination of commands actually make my screen stable, but I still can't push it to the task bar:
   sync()
repeat
        redraw()
        wait(0)
        sync()
        wait(100)
until getkey() == 41
closewindow(win)           
closeapplication()

 Changing the numbers will cause the flicker to return.
 Big mystery to me.
http://rb23.yolasite.com  Ricks Programs
http://rb27.synthasite.com   Sight and Sound

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 574
    • View Profile
    • Home of EGSL
Re: Pulsar2D is still alive ...
« Reply #23 on: 16. October 2015, 17:25:07 »
   This combination of commands actually make my screen stable, but I still can't push it to the task bar:
   sync()
repeat
        redraw()
        wait(0)
        sync()
        wait(100)
until getkey() == 41
closewindow(win)           
closeapplication()

 Changing the numbers will cause the flicker to return.
 Big mystery to me.
That's a mystery to me, too. Do you have hardware accelerated graphics?
On the other hand, if one minimizes a program to the taskbar it's probably a running game. No one has a window with a static content opened longer than a few seconds/minutes. Pulsar2D is intended for games, i.e for "the action", not for static content.  ;)
Best regards,
Cybermonkey

Rick3137

  • Full Member
  • ***
  • Posts: 108
    • View Profile
    • Rick's Programs
Re: Pulsar2D is still alive ...
« Reply #24 on: 26. October 2015, 19:17:32 »
 The fix to my problem, is to always have a loop running. then I can always put it on the taskbar and bring it back.

 The following code does the trick:

require "scancodes"
win = openwindow ("Start",-1,-1,1200,700)
setactivewindow (win)
backcolor (0,0,0,255)
repeat
  cls()
  key = getkey()
  t1 = timerticks()
        -- x,y,radius
   color (255,0,250,255)
   circle(500,350,300)
   a = 0 ; x = 250 ; y = 200
   while( a < 100200)
     do
        dot(x,y)
        a = a + 1
        x = x + 1
        if  x > 750 then
           y = y + 1 ; x = 250
        end
       
     end
    t2 = timerticks()   
    t3 = t2-t1
    color (255,255,0,255)
    textsize (2)
    drawtext ("Press Escape to exit ..",0,0)
    drawtext ( t3,0,20)

    sync()
    --key=inkey()
until key == SCANCODE_ESCAPE
closewindow(win)
closeapplication()
« Last Edit: 26. October 2015, 19:21:44 by Rick3137 »
http://rb23.yolasite.com  Ricks Programs
http://rb27.synthasite.com   Sight and Sound

Roland Chastain

  • Newcomer
  • *
  • Posts: 14
    • View Profile
    • Eschecs
Re: Pulsar2D is still alive ...
« Reply #25 on: 28. December 2015, 09:58:35 »
Hello!

@Cybermonkey

Congratulations for your work. I love this project! I tested successfully (under Windows 10) the FreeBASIC and the Lua examples. For the Free Pascal examples, I need SDL2 unit and don't know where to find it. I tried one that I have found somewhere but it seems it wasn't the good one. Anyway, I will follow the development of the project with interest and will certainly use it.

What is exactly the difference between "Pulsar2D" and "PulsarLua"? I would say that Pulsar2D is a library, usable with different compilers, and PulsarLua is an interpreter based on Pulsar2D. Is it correct?

Good continuation!  ;)

« Last Edit: 28. December 2015, 10:02:26 by Roland Chastain »

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 574
    • View Profile
    • Home of EGSL
Re: Pulsar2D is still alive ...
« Reply #26 on: 28. December 2015, 20:05:40 »
Thanks, and yes, Pulsar2D is the name for the framework, whereas PulsarLua is the Lua interpreter which uses Pulsar2D.  ;)
With the next release (coming soon  - with the new built-in font) I will add a readme for Pascal, how to compile and where to find the SDL2 headers.
Here is the link to the github project: https://github.com/ev1313/Pascal-SDL-2-Headers
Compile PulsarLua or any example like this:
Code: [Select]
fpc example.pas -Sd
Best regards,
Cybermonkey

Roland Chastain

  • Newcomer
  • *
  • Posts: 14
    • View Profile
    • Eschecs
Re: Pulsar2D is still alive ...
« Reply #27 on: 28. December 2015, 22:59:47 »
Works perfectly. Thank you.  :)

Roland Chastain

  • Newcomer
  • *
  • Posts: 14
    • View Profile
    • Eschecs
Re: Pulsar2D is still alive ...
« Reply #28 on: 29. December 2015, 12:03:15 »
Not very important, but here the PulsarLua window has no icon. It's the Win32 binary downloaded on this page:

http://pulsar2d.org/

In Windows Explorer no problem.
« Last Edit: 29. December 2015, 12:05:58 by Roland Chastain »

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 574
    • View Profile
    • Home of EGSL
Re: Pulsar2D is still alive ...
« Reply #29 on: 29. December 2015, 19:00:44 »
Oh, this is because you have to/can set it yourself within the script/program. Load an image with image=loadimage("blabla.png") and use seticon (image).
Best regards,
Cybermonkey