RetroBASIC

Retrogamecoding(.org) => EGSL => Topic started by: Cybermonkey on October 26, 2013, 08:29:01 PM

Title: EGSL 2
Post by: Cybermonkey on October 26, 2013, 08:29:01 PM
I thought I'll keep you informed that the planning process of the creation of EGSL2 has just started. Nothing is programmed, yet. At the moment I take a closer look at SDL2 which will be the core library of EGSL2 (actually, EGSL2 will have another name but it will not be revealed, yet). I will try to keep the result as compatible as possible to EGSL but some things will change due to the change from SDL to SDL2. You can expect a preview version in a few weeks which won't be full featured but will show you the direction in which EGLS2 will go.
The first and maybe most important change is that EGSL2 will support multiple windows (since SDL2 does it now). So a window creation will look like
Code: [Select]
mywindow = openwindow (640,480,32,"First Window")Of course all drawing operations must have a window target, e.g.
Code: [Select]
putimage (mywindow, x, y, myimage)Because of the multiple windows support I am planning to implement a complete GUI, so maybe the next editor will be done with EGSL2. Yeah, the lack of input possibilities will probably vanish since SDL2 provides a text input API.
An even more attractive feature will be hardware accelerated 2D graphics but this doesn't change any functions. Ok, one thing will change but I think it's positive: with the actual EGSL one has to make a copy of an image if it's e.g. displayed rotated. So far as I have dived into SDL2 this isn't necessary anymore. SDL2 uses textures instead of the old "surfaces" and they can be displayed rotated, stretched or in another colour.
There is a drop of bitterness, though: a Haiku version of EGSL2 is rather unlikely.
Title: Re: EGSL 2
Post by: GEEK on October 26, 2013, 11:20:17 PM
Nice :D and multiple windows!
i can't wait!
Title: Re: EGSL 2
Post by: Tomaaz on October 27, 2013, 11:10:50 AM
Sounds cool.  8) I have one suggestion. Could you do a version with Lua5.1 as well? This way people could use EGSL with a set of libraries written for this version of Lua. You know, with Lua5.2 and Lua5.1 is like with Python3 and Python2 - former is the future and latter is the one that everybody uses. ;)
Title: Re: EGSL 2
Post by: Cybermonkey on October 28, 2013, 09:30:16 PM
Hm, I think if SDL2 is in the repositories, Lua 5.2 should also be. And the difference between 5.2 and 5.1 is not that much as with Python 2 and Python 3.
Anyway, I wanted to let you know that I am making progress. The first thing I want to implement is a working windowing system. There is one thing to consider: a render context (and texture, what I call sprite) is always bound to a window. So one has to adress the target window in every function. Well, that seemed a bit too much of typing for me:
Code: [Select]
mywindow = openwindow (640,480,20,20,"First test")
myimage = loadimage ("test.png")
mysprite = createsprite (myimage, mywindow)
drawsprite (mysprite, mywindow, 320, 240,1,1,45)
(Yes, you don't draw images anymore onto the screen, because we want to have hardware acceleration.)
So instead I came up with the following (actually working Pascal code!):
Code: [Select]
win1:=openwindow ('Hello World',SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480);
win2:=openwindow ('Hello World2',10, 10 , 320, 240);

bmp := loadimage ('media/fighter1.png');

setactivewindow (win1);
tex := createsprite (bmp);

//We no longer need the surface
freeimage(bmp);

bmp := loadimage ('media/laser.png');
setactivewindow (win2);
tex2:=createsprite (bmp);
freeimage (bmp);

setactivewindow (win1);
backcolor (155,10,10,255);
clearwindow;
setactivewindow (win2);
backcolor (55,110,10,255);
for i:= 0 to 360 do begin
setactivewindow (win2);
clearwindow;
drawsprite (tex2,160,100,1,1,i);
redraw;
setactivewindow (win1);
clearwindow;
drawsprite (tex,320,200,1,1,i);
redraw;
wait (5);
end;
SDL_ShowSimpleMessageBox (SDL_MESSAGEBOX_INFORMATION, 'Beware', 'That''s all folks.', nil);
closewindow(win1);
closewindow (win2);
SDL_Quit();
The messagebox will be wrapped up, too and of course on does not have to add SDL_Quit.
This is how drawsprite will work:
Code: [Select]
drawsprite (spritetexture,x,y,xzoom,yzoom,angle)
Title: Re: EGSL 2
Post by: Tomaaz on October 28, 2013, 09:54:12 PM
Code: [Select]
[quote author=Cybermonkey link=topic=227.msg1590#msg1590 date=1382995816]
Hm, I think if SDL2 is in the repositories, Lua 5.2 should also be.

I wasn't talking about liblua5.2. I was talking about Lua libraries like luasocket, luafilesystem etc., but probably no one else needs them to work with EGSL, so... forget it. ;)
Title: Re: EGSL 2
Post by: Cybermonkey on October 29, 2013, 09:39:47 AM
Ah, okay. Maybe you don't need luasocket anymore since I am planning to implement a socket API via SDL2_Net. Yeah, multiplayer games will become true with EGSL2. But bear in mind that everything is intented for 2D games.
Title: Re: EGSL 2
Post by: GEEK on October 29, 2013, 07:26:18 PM
is egsl going to stay portable? or do you need some framework like .NET ?
Title: Re: EGSL 2
Post by: Cybermonkey on October 29, 2013, 08:31:59 PM
is egsl going to stay portable? or do you need some framework like .NET ?
No, no frameworks. Main platforms will be Linux and Windows. If possible MacOS X. Maybe Haiku. Eventually in the future iOS and Android.
Title: Re: EGSL 2
Post by: Cybermonkey on October 31, 2013, 12:27:32 PM
Just implemented circle and fillcircle. Yes, we don't need SDL_gfx anymore. EGSL needs about 1200 ms for drawing 500 filled and outlined (above) circles on this computer. EGSL2 needs for the same task about 650 ms. ;D
BTW, the screen was redrawn after each circle!


Oh, I should have tested after the complete task was redrawn ... SDL1.2 -> 6(!) ms, SDL2 ->500ms  :o
Title: Re: EGSL 2
Post by: Mopz on November 01, 2013, 05:42:10 PM
I don't know anything about the new sdl. Have they perhaps let go of all software rendering and replaced it with hardware stuff? Doesn't function well with intermediate drawing unless you cache every drawing command and sort them by texture usage until the screen update (I will never go hardware, it's useless for retro games).
Title: Re: EGSL 2
Post by: Cybermonkey on November 01, 2013, 09:04:39 PM
Yes, I am using hardware accelerated features. I had solved the filled circle problem by using a better algorithm. EGSL2 is not for retro games only (I hope).
So far I have implemented mouse and keyboard support, multple windows, loading images and using them as sprites and graphics primitives (except triangle). A lot of things will change but I like it very much for now.
Attached screenshot shows the built in font which size can be changed with
Code: [Select]
textsize (x)
Title: Re: EGSL 2
Post by: Cybermonkey on November 03, 2013, 09:52:00 PM
So I really like SDL2. Things are really fast.
Here is the first example as an attachment (win32). But beware: you'll need a 1920 x 1080 (aka FullHD) resolution monitor.
Framerate is limited to 100! (With EGSL2 framerates above 1500 are possible - if a hardware accelerated gpu is available).
For anyone who's interested in the source (in Freepascal for now - no Lua bindings made, yet):
Code: [Select]
      begin
        textsize (5);
randomize;
setframetimer (100);
win:=openwindow ('S T A R S',-1,-1,1920,1080);
setactivewindow (win);
setvirtualsize (1920,1080);
  togglefullscreen;
setcolorkey (0,0,255);
image:=loadimage  ('media/phoenix.png');
phoenix:=createsprite (image);
freeimage (image);
spritecolor (phoenix,255,255,255,255);
backcolor (0,0,0,255);
clearwindow;
for i:=0 to 500 do begin
x[i]:=random (windowwidth());
y[i]:=random (windowheight());
z[i]:=random (8)+1
end;

accel:= 0.25;
phy:=360;
phx:=50;
phdy:=0;
phdx:=0;
flip:=false;
hidemouse;

repeat
clearwindow;
ch:=getkey;
for i:=0 to 500 do begin
     x[i]:=x[i]-z[i];
    if x[i]<0 then begin
      x[i]:=x[i]+windowwidth();
    end;
    color (255,255,255,255);
      dot (x[i],y[i]);
end;                         

if keystate (SDL_SCANCODE_RIGHT) then begin
phdx:=phdx + accel;
flip:=false;
if phdx >= 3.0 then begin
phdx:=3.0;

end;
end;

if keystate (SDL_SCANCODE_LEFT) then begin
phdx := phdx - accel;
flip:=true;
if phdx  <= -3.0 then begin
phdx := -3.0;

end;             
end;

if keystate (SDL_SCANCODE_DOWN) then begin
phdy:=phdy + accel;
if phdy >= 3.0 then begin
phdy:=3.0;
end;
end;

if keystate (SDL_SCANCODE_UP) then begin
   phdy := phdy - accel;
if phdy  <= -3.0 then begin
phdy := -3.0;
end;                   
end;
   
   phx:=phx+phdx;
   phy:=phy+phdy;

   if phx <= 0 then begin
      phx:=0;
   end;
   if phy <= 0 then begin
      phy:=0;
   end;
   if phx >= (windowwidth() - spritewidth (phoenix)) then begin
    phx := (windowwidth() - spritewidth (phoenix));
   end;
   if phy >= (windowheight() - spriteheight (phoenix)) then begin
    phy := (windowheight() - spriteheight (phoenix));
   end;
   if phdx > 0.05 then begin
      phdx:=phdx- 0.05;
   end;
   if phdx < -0.05 then begin
      phdx:=phdx + 0.05;
   end;
   if phdy > 0.05 then begin
      phdy:=phdy - 0.05;
   end;
   if phdy < -0.05 then begin
      phdy:=phdy + 0.05;
   end;                                                             

drawsprite (phoenix, round(phx), round(phy), 1,1,0,false,flip);
color (255,255,0,200);
position:=round((windowwidth()-textwidth('The Phoenix'))/2);

drawtext (position,textheight()*2,'The Phoenix');

sync;

   
    until ch=SDL_SCANCODE_ESCAPE;


freesprite (phoenix);
closewindow (win);
closeapplication;
END.
Title: Re: EGSL 2
Post by: Osgeld on November 03, 2013, 10:00:08 PM
yea I wouldnt say hardware is useless for retro games, as it sits right now, it really doesn't take much to choke up EGSL
Title: Re: EGSL 2
Post by: Cybermonkey on November 04, 2013, 09:04:13 AM
Just tried Phoenix on an old computer with 1024 x 768 resolution and it works! Seems that SDL2 chooses the correct resolution. Awesome!
Title: Re: EGSL 2
Post by: Cybermonkey on November 05, 2013, 09:54:17 PM
Now a new test for y'all. Some of you may remember the physics test from EGSL. I now ported it to EGSL2 and - with an even higher resolution of 1024 x 768 - it runs more fluently. Enjoy!
Title: Re: EGSL 2
Post by: GEEK on November 06, 2013, 07:19:23 PM
is there a possibility that you can make a function or something in EGSL2
for seeing when a sound is stopped playing?
you can do nice things with a function like that (:

grts, Tom!
Title: Re: EGSL 2
Post by: Cybermonkey on November 06, 2013, 08:32:42 PM
Can't say for now. I am not implementing sound, yet. I will have a look intoto that then.
Title: Re: EGSL 2
Post by: Cybermonkey on November 09, 2013, 10:32:57 PM
Just playing a bit with the new particles engine. It's still rather simple but more advanced than the old one. (Did I mention that PNGs keep their transparency?  ;))
So this weekend I hope to implement bitmap fonts, sprite animations and the particle system. Then the Lua bindings will start.
Title: Re: EGSL 2
Post by: GEEK on November 09, 2013, 10:59:22 PM
very nice! (;
Title: Re: EGSL 2
Post by: Cybermonkey on November 10, 2013, 12:04:13 PM
Acutually one can do this:
(Will be part of Astrorocks HD  8))
Title: Re: EGSL 2
Post by: Cybermonkey on November 10, 2013, 03:43:48 PM
Okay, here are the bitmap fonts. Did I mention that I actually love SDL2?
Title: Re: EGSL 2
Post by: Cybermonkey on November 11, 2013, 01:40:33 PM
Now try that parallax demo. It goes fullscreen with a 1024 x 768 virtual size whether your desktop has greater resolution or not.
All files are taken from: http://smartmobilestudio.com/Smartdemo/Spartacus/index.html
(I tried to imitate as equal as possible).
Title: Re: EGSL 2
Post by: Cybermonkey on November 12, 2013, 08:59:57 PM
Okay, I just detected something weird. I installed for testing and compiling a 32bit Xubuntu 13.10. One thing what is pleasant is that the SDL2 libs are now in the repository. One not so pleasant thing is that fullscreen mode does not work as expected. Starting a program in windowed mode and going to fullscreen results in a crash. The only thing that works is this (an example):
Code: [Select]
win:=openwindow ('Parallax',-1,-1,0,0);
setvirtualsize (1920,1080);
togglefullscreen;
This sets the width and height to 0 and toggles to the fullscreen with the current desktop resolution. You can set however the virtual resolution like you want (e.g. 1024 x 768). But it is not possible to toggle to windowed mode because the window is set to 0 x 0. A work around could be to use two windows and if the user wants to leave the fullscreen mode to show the second window.
I have to check this with other 32bit Linux distros (or is it because of XFCE?) On my 64bit Kubuntu everything works as expected ...
Anyone willing to test Linux binaries?
Title: Re: EGSL 2
Post by: Osgeld on November 14, 2013, 12:42:25 AM
yea I can do a little testing
Title: Re: EGSL 2
Post by: Cybermonkey on November 14, 2013, 09:08:27 AM
yea I can do a little testing
Thanks. What system (32 or 64 bit)? What is your native desktop resolution?
Title: Re: EGSL 2
Post by: Tomaaz on November 14, 2013, 12:57:12 PM
I can help, too. Mint 13 (based on Ubuntu 12.04 LTS) 32bit with LXDE and Mate. I was also using EGSL 1.6 on Puppy Linux, so I can try with a new version, as well. Desktop resolutions: 1366x768 and 1024x768.
Title: Re: EGSL 2
Post by: Cybermonkey on November 14, 2013, 09:19:43 PM
Okay, then please install SDL 2.0.0 or SDL 2.0.1 and SDL2_image. All binaries are included into the attachment. They are named with the resolution. Having a _0x0 added means that the resolution of the window starts with 0x0 otherwise with the appr. resolution. All binaries are 32 bit and compiled on Xubuntu 13.10.
Title: Re: EGSL 2
Post by: Osgeld on November 15, 2013, 01:09:06 AM
yea I can do a little testing
Thanks. What system (32 or 64 bit)? What is your native desktop resolution?

I have xubuntu 12 x32 at 1024x768 and fedora x64 at 1280x1024, I could also boot a cd on my work laptop wihch is 1366x768
Title: Re: EGSL 2
Post by: Tomaaz on November 15, 2013, 01:12:16 PM
Sorry, can't do this. I have problem with SDL2_image. To many dependencies are missing on 12.04. At the moment this is the most recent LTS version (with support lasting till 2017), so probably it is a bit to early for EGSL2 for Linux (or is it Mint issue only?).
Title: Re: EGSL 2
Post by: Cybermonkey on November 15, 2013, 02:02:35 PM
Why not compiling from source? I compiled all SDL2 libs on Kubuntu 12.10 from source. (If it works on 12.10 it might work on 12.04, too). The 13.10 comes with SDL2 in repository. I know it's not a LTS but gamers are adviced to use the newest distro because of the graphics cards drivers. And EGSL2 needs hardware accelerated graphics. If you have an Intel based graphics card, 12.04 might not be recommended because for e.g. Steam:
Quote
For Ubuntu 12.04 LTS, you'll need to update your mesa stack using the x-updates PPA.
Title: Re: EGSL 2
Post by: Tomaaz on November 15, 2013, 09:08:57 PM
Why not compiling from source?

Well, I'm happy to test a new version of EGSL but compiling libraries for it is a slightly different story. And I'm not entirely sure that compiling from source would be that much easier and less time consuming than chasing dependencies foe a .deb package I can download from PKGS. But it looks like testing on 12.04 wouldn't be useful anyway, so I give up.
Title: Re: EGSL 2
Post by: Osgeld on November 16, 2013, 02:36:43 AM
I have spent most the evening trying to get it running on 12.04 with no luck at all  :(
Title: Re: EGSL 2
Post by: Cybermonkey on November 16, 2013, 08:29:51 AM
Oh, that's a pitty. So minimum system requirements will be Ubuntu 13.10 or similar.