Author Topic: EGSL 2  (Read 6096 times)

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 680
    • View Profile
    • Home of EGSL
EGSL 2
« on: 26. October 2013, 22:29:01 »
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.
Best regards,
Cybermonkey

GEEK

  • Jr. Member
  • **
  • Posts: 83
  • want to learn c++, if you want to teach me, pm me!
    • View Profile
Re: EGSL 2
« Reply #1 on: 27. October 2013, 01:20:17 »
Nice :D and multiple windows!
i can't wait!

Tomaaz

  • Guest
Re: EGSL 2
« Reply #2 on: 27. October 2013, 12:10:50 »
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. ;)

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 680
    • View Profile
    • Home of EGSL
Re: EGSL 2
« Reply #3 on: 28. October 2013, 22:30:16 »
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)
Best regards,
Cybermonkey

Tomaaz

  • Guest
Re: EGSL 2
« Reply #4 on: 28. October 2013, 22:54:12 »
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. ;)

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 680
    • View Profile
    • Home of EGSL
Re: EGSL 2
« Reply #5 on: 29. October 2013, 10:39:47 »
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.
Best regards,
Cybermonkey

GEEK

  • Jr. Member
  • **
  • Posts: 83
  • want to learn c++, if you want to teach me, pm me!
    • View Profile
Re: EGSL 2
« Reply #6 on: 29. October 2013, 20:26:18 »
is egsl going to stay portable? or do you need some framework like .NET ?

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 680
    • View Profile
    • Home of EGSL
Re: EGSL 2
« Reply #7 on: 29. October 2013, 21:31:59 »
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.
Best regards,
Cybermonkey

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 680
    • View Profile
    • Home of EGSL
Re: EGSL 2
« Reply #8 on: 31. October 2013, 13:27:32 »
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
« Last Edit: 31. October 2013, 13:33:53 by Cybermonkey »
Best regards,
Cybermonkey

Mopz

  • Guest
Re: EGSL 2
« Reply #9 on: 01. November 2013, 18:42:10 »
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).
« Last Edit: 01. November 2013, 18:44:30 by Mopz »

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 680
    • View Profile
    • Home of EGSL
Re: EGSL 2
« Reply #10 on: 01. November 2013, 22:04:39 »
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)
Best regards,
Cybermonkey

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 680
    • View Profile
    • Home of EGSL
Re: EGSL 2
« Reply #11 on: 03. November 2013, 22:52:00 »
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.
« Last Edit: 03. November 2013, 22:54:32 by Cybermonkey »
Best regards,
Cybermonkey

Osgeld

  • Newcomer
  • *
  • Posts: 33
    • View Profile
Re: EGSL 2
« Reply #12 on: 03. November 2013, 23:00:08 »
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

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 680
    • View Profile
    • Home of EGSL
Re: EGSL 2
« Reply #13 on: 04. November 2013, 10:04:13 »
Just tried Phoenix on an old computer with 1024 x 768 resolution and it works! Seems that SDL2 chooses the correct resolution. Awesome!
Best regards,
Cybermonkey

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 680
    • View Profile
    • Home of EGSL
Re: EGSL 2
« Reply #14 on: 05. November 2013, 22:54:17 »
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!
Best regards,
Cybermonkey