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

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: Pulsar2D is still alive ...
« Reply #15 on: October 14, 2015, 06:16:44 PM »
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.

Rick3137

  • Guest
Re: Pulsar2D is still alive ...
« Reply #16 on: October 14, 2015, 08:50:35 PM »
   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.

Bereb

  • Guest
Re: Pulsar2D is still alive ...
« Reply #17 on: October 15, 2015, 10:19:32 AM »
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: October 15, 2015, 06:04:01 PM by Bereb »

Rick3137

  • Guest
local variables
« Reply #18 on: October 15, 2015, 03:46:45 PM »
  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.

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: Pulsar2D is still alive ...
« Reply #19 on: October 15, 2015, 06:02:59 PM »
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().

Bereb

  • Guest
Re: Pulsar2D is still alive ...
« Reply #20 on: October 16, 2015, 09:47:48 AM »
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  :)

Rick3137

  • Guest
Re: Pulsar2D is still alive ...
« Reply #21 on: October 16, 2015, 01:41:15 PM »
   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.

Rick3137

  • Guest
Re: Pulsar2D is still alive ...
« Reply #22 on: October 16, 2015, 03:14:37 PM »
   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.

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: Pulsar2D is still alive ...
« Reply #23 on: October 16, 2015, 03:25:07 PM »
   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.  ;)

Rick3137

  • Guest
Re: Pulsar2D is still alive ...
« Reply #24 on: October 26, 2015, 06:17:32 PM »
 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: October 26, 2015, 06:21:44 PM by Rick3137 »

Roland Chastain

  • Guest
Re: Pulsar2D is still alive ...
« Reply #25 on: December 28, 2015, 08:58:35 AM »
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: December 28, 2015, 09:02:26 AM by Roland Chastain »

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: Pulsar2D is still alive ...
« Reply #26 on: December 28, 2015, 07:05:40 PM »
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

Roland Chastain

  • Guest
Re: Pulsar2D is still alive ...
« Reply #27 on: December 28, 2015, 09:59:47 PM »
Works perfectly. Thank you.  :)

Roland Chastain

  • Guest
Re: Pulsar2D is still alive ...
« Reply #28 on: December 29, 2015, 11:03:15 AM »
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: December 29, 2015, 11:05:58 AM by Roland Chastain »

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: Pulsar2D is still alive ...
« Reply #29 on: December 29, 2015, 06:00:44 PM »
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).