PDA

View Full Version : Writing a better 2D engine. (Phoenix 2D Game Engine)



Pages : [1] 2

Andreaz
12-06-2006, 03:39 PM
Hi

As many of you may know, i'm the developer of GLXTreem and a huge fan of DelphiX. Even through i havn't been that visible either here or on my own page of late due to alot of things happening in real life i still have been lurking on these forums and done some thinking :)

My engine started out as a 2D rendering engine that worked similar to DelphiX but it has evolved to be more or less a 3D only engine, even if it support some 2D stuff, but thats mostly to be used as gui stuff and so forth.

There's been alot of talk latly about 2D and opengl rendering, both here and on the GLXTreem site, and DelphiX is, frankly outdated, with poor hardware support and not as fast as it could be.

This combined with that i have for a time been considering writing a 2D only, highly optimized engine using OpenGL with all the new hardware features (VBO's Multitexturing, Pixeshalders and 32 textures) has made me considering starting this project up.

So, i thought, what about posting a public wish-list on theese forums, to see what features the coders here likes about, for example DelphiX and whats their shortcommings.

I have a few idea's myself, mostly conserning how the engine will work and some features

Thread based timer, (or standard app.idle depending on further testing)
Higly optimized image list using VBO's (fallback to simple glBegin / end), support for tiles and automatic animations. (Freeimage probably)
Tile engine. Using view port optimizations. Possibly lightmaps, isometric etc
Sprite engine, quite straightforward. Per-pixel colisions etc.
Per pixel lighting via GLSL for 2D light effects.
Font renderer, with support for styled text, wordwrap etc.
Xml based gui engine (probably a clone of the GLXTreem one)
Scripting engine using lua ( to interact with the spriteengine + tileengine + gui engine)
Package support for all components, for single file distributions.


That is what i have thought of so far. But i really would like to hear what you people would want from an engine like this.

Robert Kosek
12-06-2006, 04:50 PM
I must say that I'm interested, very interested.

Firstly, what I'd want from such an engine is that it wouldn't turn into something like the A5/6 engine. IE, something clunky, overscripted and has no source access.

Personally the feature list you've put together appeals to me and really contains all I'd want for 2D work. My only suggestion would be instead of coding your own fileformat for the packages, why not use Abbrevia instead? It's zipfile archiving and has directories and can encrypt as well.

Other than those two points I must say you've got me intrigued. If you can get most, if not all, the points on your feature list into an OpenGL 2D engine DelphiX replacement, you will probably get me as a user right off the bat.

WILL
12-06-2006, 05:25 PM
Hey Andreas!

Sounds like a great project idea. There aren't too many OpenGL based 2D libraries for Pascal compilers these days, if any really. So I hope this one takes off! :)

From a support side of things, I'd be quite happy to see this thing support Free Pascal(and/or Lazarus) aswell as Delphi. FPC and Lazarus are very quickly becoming the flagship pair of the Pascal development world, but Delphi is not gone by far either. So I think to maximize your target userbase you'd want to offer good support for both compilers and/or component models. (Refering, of course to both VCL and LCL should you make a [non-]visual component version of this new 2D library.)

With reguards to the modeling and structure of your library, I find that if you keep the functionality very modular and simple where we can pick and choose our level of graphics engine 'hand off' then we as developers will be moe pleased than not in it's usage. It's of course a balancing game, right? Hold our hands too much and it becomes a beginners crutch and they'll all eventually move onto something they can use with a bit more of an intuative understanding. You leave too much to the developer to do himself, he feels a bit overwealmed and moves onto something else that is more within his realm of understanding of OpenGL and graphics in general.

As for packaging. I like simple, but I also like (LOVE actually! ;)) options. So why not just write an interface for yours aswell as this Abbrevia I've been hearing about so much?

Oh and graphics formats... Must have PNG and BMP! I was a little shocked to find out that SDL did not support it by default. It's an open format for crying out loud! :o *sigh* oh well. :p

Traveler
12-06-2006, 07:38 PM
Hi Andreaz,

Welcome back!
I like your idea a lot. I've been doing some 2d opengl programming myself, the last few months. At first it was a bit of getting used to, but it's actually fairly easy to learn, once you get 'it'.

Some things I'd like to see is a solid 2d particle generator, and some good sound support, preferably openAL.
Another thing might be netwerk support, but that should be a very low priority thing.


Oh and graphics formats... Must have PNG and BMP! I was a little shocked to find out that SDL did not support it by default. It's an open format for crying out loud! Surprised *sigh* oh well. :p

I doubt bmp is a format you'll want to invest time into. IMO, if you want alpha support its either tga or png, for all the rest its jpg.

cairnswm
13-06-2006, 05:30 AM
Some things for Sprites
:arrow: Transparency
:arrow: Rotation
:arrow: Scaling
are musts

Why use Lua for the scripting engine. I'm a Pascal programmer and would rather write my scripting in Pascal as well. There are many pascal scripting projects out there - DWS, paxScript etc etc - why not integrate one of them into the 2D libraries.

One reason I stopped using GLXtreem (Still have it installed though) is that I found it inconsistent accross different computers. This is something that must be made more stable in the new Libraries.

Are you considering doing this as a Andreaz only project or are you considering opening it up as an open source collaboration project? I would certainly like to be involved if you did do somethign like this.

Andreaz
13-06-2006, 09:29 AM
I must say that I'm interested, very interested.

Firstly, what I'd want from such an engine is that it wouldn't turn into something like the A5/6 engine. IE, something clunky, overscripted and has no source access.

Personally the feature list you've put together appeals to me and really contains all I'd want for 2D work. My only suggestion would be instead of coding your own fileformat for the packages, why not use Abbrevia instead? It's zipfile archiving and has directories and can encrypt as well.

Other than those two points I must say you've got me intrigued. If you can get most, if not all, the points on your feature list into an OpenGL 2D engine DelphiX replacement, you will probably get me as a user right off the bat.

It will be open source for shure, and my intention is to make it very modular, atleast without limiting the speed and ease of use.

As a package format i was planning on using the format me and Tokter wrote for glxtreem, (was only avaible for the v1.0 via cvs). But shure, a external lib is doable aswell.


Hey Andreas!

Sounds like a great project idea. There aren't too many OpenGL based 2D libraries for Pascal compilers these days, if any really. So I hope this one takes off! :)

From a support side of things, I'd be quite happy to see this thing support Free Pascal(and/or Lazarus) aswell as Delphi. FPC and Lazarus are very quickly becoming the flagship pair of the Pascal development world, but Delphi is not gone by far either. So I think to maximize your target userbase you'd want to offer good support for both compilers and/or component models. (Refering, of course to both VCL and LCL should you make a [non-]visual component version of this new 2D library.)

With reguards to the modeling and structure of your library, I find that if you keep the functionality very modular and simple where we can pick and choose our level of graphics engine 'hand off' then we as developers will be moe pleased than not in it's usage. It's of course a balancing game, right? Hold our hands too much and it becomes a beginners crutch and they'll all eventually move onto something they can use with a bit more of an intuative understanding. You leave too much to the developer to do himself, he feels a bit overwealmed and moves onto something else that is more within his realm of understanding of OpenGL and graphics in general.

As for packaging. I like simple, but I also like (LOVE actually! ;)) options. So why not just write an interface for yours aswell as this Abbrevia I've been hearing about so much?

Oh and graphics formats... Must have PNG and BMP! I was a little shocked to find out that SDL did not support it by default. It's an open format for crying out loud! :o *sigh* oh well. :p

Yeah, support for other platforms then delphi would be nice, i have quite limited experience with lazarus and the likes myself, especially regarding the design ide, wich is a big part of making a accessable package :). But this should be doable for shure :)

My intention is to make it as modular as possible, so you easilly can mix parts from the package with custom components and raw opengl code. But to get the design editors to work in a easy and accessable way will requre to interconnect certain parts, package routines comes in mind.

I feel you should be quite pleased with the format that freeimage (http://freeimage.sourceforge.net) supports:


BMP files [reading, writing]
DDS files [reading]
Dr. Halo files [reading] *
GIF files [reading, writing] **
ICO files [reading, writing]
IFF files [reading]
JBIG [reading, writing] ***
JNG files [reading]
JPEG/JIF files [reading, writing]
KOALA files [reading]
LBM files [reading]
Kodak PhotoCD files [reading]
MNG files [reading]
PCX files [reading]
PBM files [reading, writing]
PGM files [reading, writing]
PNG files [reading, writing]
PPM files [reading, writing]
PhotoShop files [reading]
Sun RAS files [reading]
TARGA files [reading, writing]
TIFF files [reading, writing]
WBMP files [reading, writing]
XBM files [reading]
XPM files [reading, writing]


However the freeimage version i'm using is distributed as a dll so will be some platform issues there that will require some kind of fallback i suppose.



Hi Andreaz,

Welcome back!
I like your idea a lot. I've been doing some 2d opengl programming myself, the last few months. At first it was a bit of getting used to, but it's actually fairly easy to learn, once you get 'it'.

Some things I'd like to see is a solid 2d particle generator, and some good sound support, preferably openAL.
Another thing might be netwerk support, but that should be a very low priority thing.


Oh and graphics formats... Must have PNG and BMP! I was a little shocked to find out that SDL did not support it by default. It's an open format for crying out loud! Surprised *sigh* oh well. :p

I doubt bmp is a format you'll want to invest time into. IMO, if you want alpha support its either tga or png, for all the rest its jpg.

Thanks :)

Yeah, i've noticed, been visiting your page quite regulary :)

With 2d particle generator i suppose you mean a particle system ? In that case there will propbably be one down the line, maybe not as advanced as the later versions of the glxtreem ones but nontheless.

Sound is also a thing on the todo list, only been working with fmod myself, but nothing says it cant support multiple sound libs.



Some things for Sprites
:arrow: Transparency
:arrow: Rotation
:arrow: Scaling
are musts

Why use Lua for the scripting engine. I'm a Pascal programmer and would rather write my scripting in Pascal as well. There are many pascal scripting projects out there - DWS, paxScript etc etc - why not integrate one of them into the 2D libraries.

One reason I stopped using GLXtreem (Still have it installed though) is that I found it inconsistent accross different computers. This is something that must be made more stable in the new Libraries.

Are you considering doing this as a Andreaz only project or are you considering opening it up as an open source collaboration project? I would certainly like to be involved if you did do somethign like this.

Yeah, scaling and all those stuff for sprites will ofc be supported, mosy likly via texture transformations to limit the need to modify the vertex buffers to much.

Well my idea of to use lua is mostly because of its speed and the ability to precompile scripts, shure it's c style code so that may not be optimum, but it should be possible to make this pluggable to use different languages i guess.

The computer inconsistency in glxtreem is mosly because there's limited fallback functions for the more advanced opengl calls, ie its targeted on somwhat top of the line gpus. Another limiting thing is the testing platforms i have avaiable, wich basicly is only my own computer :)

To be honest, glxtreem has mostly been my test platform for different graphical technologies that i have put together in a library that people could use of their liking. Thats why when someone has asked if they may use and modify any of the code from a component in the package for their own use I have given a all go :)

Actually, the idea of making it a community project appeals me, there's alot of compentent coders here with great ideas so I think this would only be good for the project.

cairnswm
13-06-2006, 09:49 AM
Well with this idea and the Game Networking idea we can surely get a PGD game project going. (Whos doing the Sound project :) )

jdarling
13-06-2006, 01:01 PM
Tisk tisk tisk, a better graphics library would definately be GraphicEx: http://www.delphi-gems.com/GraphicEx.php. Free and written in Delphi. Plus it supports the more graphics types.

As far as the Lua scripting goes, I'm in. I've been spending alot of my spare time working on integration of Lua into many of my projects, and have come along way from the posts on pas2lua. Soon as I get it stable again I'll be posting it. The current version still works quite well though :).

Would be nice if it were in FPC and not in Delphi, but I'd live either way. FPC would just make it more open to the world.

On a final though, why not seperate the rendering engine from the game engine. Thus you could easily offer cross-platform and support for graphics engines that haven't even been thought up yet.

Andreaz
13-06-2006, 01:33 PM
Tisk tisk tisk, a better graphics library would definately be GraphicEx: http://www.delphi-gems.com/GraphicEx.php. Free and written in Delphi. Plus it supports the more graphics types.

I actually used it before i switched to freeimage, but its built as a TGraphic desendence with all the inherit problems. Freeimage is alot faster when loading images, so it will still be the one libary i prefer, however graphicex is a good candidate for a fallback loader.



As far as the Lua scripting goes, I'm in. I've been spending alot of my spare time working on integration of Lua into many of my projects, and have come along way from the posts on pas2lua. Soon as I get it stable again I'll be posting it. The current version still works quite well though :).

Would love to see that one :)



Would be nice if it were in FPC and not in Delphi, but I'd live either way. FPC would just make it more open to the world.

On a final though, why not seperate the rendering engine from the game engine. Thus you could easily offer cross-platform and support for graphics engines that haven't even been thought up yet.
Hopefully it will work in both FPC and delphi :). Well as i have imagined its not as much of a game engine then a rendering engine, much like the way DelphiX is, but this may change, who knows :)

jdarling
13-06-2006, 02:52 PM
You can download Pas2Lua from: http://www.eonclash.com/pas2lua/pas2lua.zip and the source from: http://www.eonclash.com/pas2lua/pas2lua_src.zip. As I said, its not ready for main stream yet (hence why the url isn't exactly published on my site). Basicly right now you still have to tweak its output, but when complete it will have full wrapper building capibilities. No timeline on completion at this time.

Andreaz
16-06-2006, 01:18 PM
I have started writing some code on the project now.

After some testing I found that it wasn't that easy to get rendering in panels working in lazarus so i decided to use GLFW (http://glfw.sourceforge.net/) for the window management instead.

Thiss will mean that it should be able to use the engine on any freepascal compiler and delphi as well as almost any platform, but we can't use any gui components (exept the planned opengl ones that is). Fair trade if you ask me, there's some speed gain this way aswell.

What needs to be done now is finishing the wrapper for the window management and then the image loading functions (GLFW has a built in tga loader so that can be used if you don't want to use freeimage)

After that i'll guess i'll release a alpha version to let you look at :)

Edit: And GLFW has quite nice support for input handling aswell, so this could end up quite nice :)

jdarling
16-06-2006, 03:08 PM
Can't wait to see an Alpha release. As I said before, when you get to the scripting interface (and if you want help) let me know. I'm more then interested, as my current pet project (JumpStart) has been quite the learning experience on Lua (and other languages) integration.

On that note, the sooner that you can get it to a point that you feel comfortable with others aiding the better off :). I know that there is a really good thread on GameDev about a new isometric engine that is being worked on. Can't get to GameDev right now, but soon as I can I'll post some of the things I thought were good ideas :).

cairnswm
19-06-2006, 12:03 PM
Will you make the new 2D library VCL/LCL based or just classes?

I'd prefer just having classes - and then to make it easier to learn, wrap those classes as LCL and VCL components.

jdarling
19-06-2006, 01:01 PM
Will you make the new 2D library VCL/LCL based or just classes?

I'd prefer just having classes - and then to make it easier to learn, wrap those classes as LCL and VCL components.

I vote for simple classes as well, the LCL and VCL have way too much bloat for standard game applications. Here are the controls I've been working on for my DirectX projects:

A panel
An Image Panel - Uses an image instead of the default panel look
A label
A button
An Edit Box
A List Box
A memo type thing

Those are what I came up with for all of the UI's that I would need/use. I have code in place for most, just missing the List Box and Memo. Though the way I'm handeling them is mostly due to the limits of UnDelphiX, so I don't know that it would be of any use.

Andreaz
19-06-2006, 03:29 PM
Will you make the new 2D library VCL/LCL based or just classes?

I'd prefer just having classes - and then to make it easier to learn, wrap those classes as LCL and VCL components.

Well, as GLFW creates and handles all the windowmanagement its not possible to make that many VCL/LCL components, maybe based around DataModules if anything.

As a progress update, the window funktions is all but done, need some polishing and documentation. Texture loading is more or less completed aswell, some work left on imagelists and such.

After that the base is done and then its timer + font that is the next project.

cairnswm
20-06-2006, 05:59 AM
Can we start playing with what you have done so far? Where can we download a small delphi demo to compile and try out?

I would love to give feedback right from the start.

Andreaz
20-06-2006, 08:29 AM
Shure thing :) Note that its quite jittered with openGL calls atm as not all thats needed is supported yet (perspective calculations and such).

However the window management class is quite complete, the doc isn't 100% yet (and not compiled for that matter :P). And the image loading is there, the image rendering functions is not completed however.

You can download the current version at:

http://www.glxtreem.net/Phoenix2006-06-20.rar

There's a small demo in the demo folder.

cairnswm
20-06-2006, 09:29 AM
Nice so far :)

Why not another phxWindow constructor that includes left, top, width, height
and another for full screen and dimensions - makes it easier than having to set them afterwards. :)


phxImage
One thing I found useful in the past is a Draw that draws the complete image.

My S2DL libraries (Basically what you are trying to do but using SDL and OpenGL instead) includes an image class as follows (private declarations removed):

TS2DLImage = Class
public
Name : String;
ImageSurface: PSDL_Surface;
Texture : TTexture;
SrcRect, DestRect: TSDL_Rect;
PatternWidthFrac, PatternHeightFrac : Single;
Transparent : Boolean;
Property Width : Integer read GetWidth;
Property Height : Integer read GetHeight;
Property PatternWidth : Integer read FPatternWidth write SetPatternWidth;
Property PatternHeight : Integer read FPatternHeight write SetPatternHeight;
Constructor Create;
Constructor CreateSizedSurface(Width,Height,ColorDepth : Integer);
Destructor Destroy; Override;
Procedure LoadFromFile(FileName : PChar); Overload;
Procedure LoadFromFile(FileName : String); Overload;
Procedure LoadFromFile(FileName : String; IsTransparent : Boolean); Overload;
Procedure DrawStretch(X,Y,W,H : Integer); Overload;
Procedure DrawStretch(X,Y,W,H, Pattern : Integer); Overload;
Procedure DrawStretchRotate(X,Y,W,H, Pattern,Degrees : Integer); Overload;
Procedure DrawStretchAlpha(X,Y,W,H, Pattern : Integer; Alpha : Single); Overload;
Procedure Draw(X,Y : Integer); Overload;
Procedure Draw(X,Y : Integer; Pattern : Integer); Overload;
Procedure DrawRotate(X,Y : Integer; Angle : Single); Overload;
Procedure DrawRotate(X,Y : Integer; Pattern : Integer; Angle : Single); Overload;
Procedure DrawAlpha(X,Y : Integer; Alpha : Single); Overload;
Procedure DrawAlpha(X,Y : Integer; Pattern : Integer; Alpha : Single); Overload;
Procedure DrawTiled(X,Y,W,H : Integer); Overload;
Procedure DrawTiled(X,Y,W,H,Pattern : Integer); Overload;
Procedure DrawArea(X,Y : Integer; IX, IY, IW, IH : Integer);
Procedure SetPixel(X,Y : Integer; Color : UInt32);
Procedure BindImage;
End;

Just as an idea.[/pascal]

Andreaz
20-06-2006, 09:48 AM
Nice so far :)

Why not another phxWindow constructor that includes left, top, width, height
and another for full screen and dimensions - makes it easier than having to set them afterwards. :)

Good idea, consider it done :)



phxImage
One thing I found useful in the past is a Draw that draws the complete image.

My S2DL libraries (Basically what you are trying to do but using SDL and OpenGL instead) includes an image class as follows (private declarations removed):

TS2DLImage = Class
public
Name : String;
ImageSurface: PSDL_Surface;
Texture : TTexture;
SrcRect, DestRect: TSDL_Rect;
PatternWidthFrac, PatternHeightFrac : Single;
Transparent : Boolean;
Property Width : Integer read GetWidth;
Property Height : Integer read GetHeight;
Property PatternWidth : Integer read FPatternWidth write SetPatternWidth;
Property PatternHeight : Integer read FPatternHeight write SetPatternHeight;
Constructor Create;
Constructor CreateSizedSurface(Width,Height,ColorDepth : Integer);
Destructor Destroy; Override;
Procedure LoadFromFile(FileName : PChar); Overload;
Procedure LoadFromFile(FileName : String); Overload;
Procedure LoadFromFile(FileName : String; IsTransparent : Boolean); Overload;
Procedure DrawStretch(X,Y,W,H : Integer); Overload;
Procedure DrawStretch(X,Y,W,H, Pattern : Integer); Overload;
Procedure DrawStretchRotate(X,Y,W,H, Pattern,Degrees : Integer); Overload;
Procedure DrawStretchAlpha(X,Y,W,H, Pattern : Integer; Alpha : Single); Overload;
Procedure Draw(X,Y : Integer); Overload;
Procedure Draw(X,Y : Integer; Pattern : Integer); Overload;
Procedure DrawRotate(X,Y : Integer; Angle : Single); Overload;
Procedure DrawRotate(X,Y : Integer; Pattern : Integer; Angle : Single); Overload;
Procedure DrawAlpha(X,Y : Integer; Alpha : Single); Overload;
Procedure DrawAlpha(X,Y : Integer; Pattern : Integer; Alpha : Single); Overload;
Procedure DrawTiled(X,Y,W,H : Integer); Overload;
Procedure DrawTiled(X,Y,W,H,Pattern : Integer); Overload;
Procedure DrawArea(X,Y : Integer; IX, IY, IW, IH : Integer);
Procedure SetPixel(X,Y : Integer; Color : UInt32);
Procedure BindImage;
End;

Just as an idea
You mean, basicly what the current TPHXImage.Draw does ?( havn't started on the pattern stuff yet :P)

Any yes, will add a bunch of draw methods, probably using displaylists for the pattern management.

Will add support for the special functions thats in the texture loading class aswell, such as color key transparency and such. Btw what do you think of the approach for the texture loading, should be quite moddable imo.

cairnswm
20-06-2006, 10:39 AM
You mean, basicly what the current TPHXImage.Draw does ?


Correct - except you already have a Pattern Index as a paramenter :)


Btw what do you think of the approach for the texture loading, should be quite moddable imo.

Ummm, well , aahhh, you see ummm.....

Actually this is the level of coding I use other peoples stuff :) - Its sort of too level for me to understand properly - lol :)

Which is also why I'm so willing to help you get this working :)

If you are interested in stealing some of the image code from my S2DL library (And improving it I hope) - it is all available here: http://www.cairnsgames.co.za/files/S2DLv1-10.zip

Andreaz
20-06-2006, 11:26 AM
Correct - except you already have a Pattern Index as a paramenter :)

Hehe, very true. Havn't really started on thoose functions so :)



Ummm, well , aahhh, you see ummm.....

Actually this is the level of coding I use other peoples stuff :) - Its sort of too level for me to understand properly - lol :)

Haha, hopefully you understand how to use it atleast, I will write a small demo showing off how to write a custom texture loader when I got the time, could be used for loading fractals for example.



Which is also why I'm so willing to help you get this working :)

If you are interested in stealing some of the image code from my S2DL library (And improving it I hope) - it is all available here: http://www.cairnsgames.co.za/files/S2DLv1-10.zip

Hehe, stealing is good :P

Well, the next project, after the imageList class with all the simple Draw functions in place (Draw, StrechDraw, TileDraw, DrawRotate, DrawAlpha etc) is done is the font renderer.

What i have in mind is creating an abstractation between a font and a text renderer, ie the THPXFont class only contains the bitmap texture as well as glyph information (width, heigt, offset etc) and the loading functions and display lists.

Then the text renderer(s ?) handles all the rendering routines, could be TPHXTextRendererPlain, TPGXTextRendererHtml and whatever you want. Ie something like this:



Font = FontList.LoadFont('Arial.png');

TextRenderer = TPHXTextRendererPlain.Create();
TextRenderer.TextOut(Font, 10, 10, 'My little text');

TextRenderer.WrapText(Font, 10, 10, 200, 200, 'My very very very long text, it will not fit in one row :)';

TextRenderer2 := TPHXTextRendererHtml.Create();
TextRenderer2.addFont(fsItalic, Font);
TextRenderer2.addFont(fsBold, Font2);
TextRenderer2.addFont('p', ParagraphFont);
TextRenderer2.TextOut(Font, 10, 10, 'SomeHtml text<br>with <p>Styles</p>)';

Something like that, ofc it wont be a full html renderer, but could still be usefull :)
Edit:
Or rather the creation of a font renderer would be more like this:


Renderer := TPHXTextRenderer.getRenderer("html");


This way you could register your own renderers quite easy:


TPHXTextRenderer.registerRenderer('rtf', TMyRTFRenderer);


Any ideas or suggestions ?

cairnswm
20-06-2006, 11:34 AM
Yeah I know how to use others peoples stuff :) Its called Copy paste or just reuse the library :)

If you like I'll add all the procedures etc to the TPhxImage class - this leaves you to carry on with the other items. I at least know enough on how to do this now :)

I will use the logic as in S2DL (Probably mostly copy and paste). Once I'm done I'll give it back to you and you can optimise it.

cairnswm
20-06-2006, 11:37 AM
Oh, another thing

I built in a nice fading effect in S2DL - basically I use an S2DLDraw class, it has functions to fade in and out, as well as some scene control methods (Start Scene and EndScene) - when Images are drawn they use the S2DLImage fade colors to define the glColor3f parameters.

It would be nice to have something like this as well.

Andreaz
20-06-2006, 12:54 PM
Yeah I know how to use others peoples stuff :) Its called Copy paste or just reuse the library :)

If you like I'll add all the procedures etc to the TPhxImage class - this leaves you to carry on with the other items. I at least know enough on how to do this now :)

I will use the logic as in S2DL (Probably mostly copy and paste). Once I'm done I'll give it back to you and you can optimise it.

Yeah, that would be sweet indeed. However there's still the issue of wich rendering method to use, there's basically 4 ways:

1, glBegin / glEnd - The wy you've done in your lib aswell as I did in GLXTreem, potentally slow.

2. Display list, one for every pattern. Abit more advanced, but "should" be faster then the prefious method. Drawback of needing to modify the modelview matrix for each render (position, stretch).

3. glVertexPointer + glTexCoordPointer, Should be faster then both of the previous versions, requires quite a bit of coding however, but no need to modify the modelvirew matrix and only one opengl call per draw.

4. glBindBuffer (Vertex Buffer Objects), Should improve of the last variant even more due to the texturecoordinates being static on the gpu memory, only vertex data needs to be shuffled to the gfx card on each draw. And still no modelview matrix modifixations.

The first 2 methods is quite straigth forward, infact they are already implemented to some degree, however there may be some performance issues with em.

Then there's the Vertex Array and Vertex Buffer Object versions, shure they will bring some performence gain, but the question is if the performance gain is big enough to justify the extra work :P

cairnswm
20-06-2006, 01:21 PM
I'll do method one :) I dont know enough about OpenGL coding to try any of the others :P

Will send it to you tomorrow :)

Andreaz
20-06-2006, 02:16 PM
Yeah, works for starters, its always possible to change that for a later version :)

cairnswm
20-06-2006, 02:20 PM
I'd also like to do some changes on the phxWindow class. But I would rather you get it into some sort of final state before I make the changes. (I want to add the fading and scene management as in S2DL)

Andreaz
20-06-2006, 02:43 PM
Wouldnt Scene Management be better of as a new class and file, ie phxScene, TPHXScene, TPHXSceneManager ?

And it could be extended abit from your version, ie have support for multiple scenes, and nextScene, previousScene methods and such

Andreaz
20-06-2006, 02:50 PM
Checked your scene fade funktion, it's not 100% as you're using glColor for fading, what if some funktion sets it own color ? Then you fading is nullified. A better approach is to disable deapth test and render a alpha blended quad that fills the whole window :)

cairnswm
20-06-2006, 03:11 PM
Maybe we have different meanings for Scene.

My scene is the current state of the drawing screen. Ie what level of fading is being used etc. (Basically manipulation of glColor3f).

Your scene seems to map my idea of a game state.

cairnswm
20-06-2006, 03:13 PM
I have two methods of setting color - the S2DLDraw sets a global color that applies to everytihg. There is a SetTempColor (or something like that) that changes the colors for a single drawing action.

Worked OK for me.

Ignore my suggestion then for fading etc until later :)

jdarling
20-06-2006, 03:27 PM
I'll download the source tonight when I get home and start looking into the scripting aspects (that is if your comfortable with this). So far what I've seen looks really good.

jdarling
20-06-2006, 04:00 PM
PS: Can you post up links for all of the libraries that your making use of? Since I'll be installing Lazarus from scratch (again) I won't have any of the libs, and want to make sure its a smooth process :)

cairnswm
20-06-2006, 04:02 PM
I think everything is included already. There are no extras that need to be installed for lazarus.

Andreaz
20-06-2006, 04:19 PM
Yeah, please do so.

And yes, all required librarys is included in the zip file (Atleast the Win32 versions)

jdarling
20-06-2006, 04:25 PM
hmm... The RAR I found didn't have everything in it. Was missing s2dl, glxtreme, and glfw. I've put together a zip file that once extracted only requires lazarus to be installed. I've put all libraries into the package and fixed the LPI file to use relative paths instead of absolute paths.

In case anyone else has problems, you can download from: http://www.eonclash.com/phoenix/ProjectPhoenixFull.zip

Andreaz
20-06-2006, 04:46 PM
Hmm, the library doesnt require eiter GLXTreem, SDL2 and glfw.pas is included in the lib folder and the dll in demo\compiled

jdarling
20-06-2006, 05:58 PM
Hmm, the library doesnt require eiter GLXTreem, SDL2 and glfw.pas is included in the lib folder and the dll in demo\compiled

That is odd... You might take a look at the package I uploaded and see if you can figure out why its requiring me to have those files present.

I've updated the package (and the compiled exe) to now use Lua scripting. I haven't done much except make the "Background" move, but its all working properly.

Basically I got ambitious during my lunch hour instead of waiting till I got home :).

Still ALOT to do from the scripting side of things (obviously) but you can make the background move :).

As an aside: Please keep method overloading to a minimum. Lua doesn't support it at all, so all overloaded methods will have to be renamed in the scripting engine, or extreme code will have to be put in place to test witch version of the method to call. If anyone knows how to use type info inside of Lazarus exe's I'd love to hear it, as it would save time in the conversions of the actual objects.

Andreaz
20-06-2006, 06:42 PM
Oh, it seems some glxtreem files are included in the project file, probably due to that i have had them opened to copy some code, just open the project file and remove all items that referenses glx / SD2L

jdarling
20-06-2006, 07:46 PM
Oh, it seems some glxtreem files are included in the project file, probably due to that i have had them opened to copy some code, just open the project file and remove all items that referenses glx / SD2L

I've made the changes to the package, and setup a post build clean.bat to execute. Now the compiled folder only contains the files that are required for a re-dist.

Just to re-itterate: http://www.eonclash.com/phoenix/ProjectPhoenixFull.zip ~3.3MB

cairnswm
21-06-2006, 09:46 AM
I've made the changes to phxImage.

Avaialble from here: http://www.cairnsgames.co.za/files\phx-2d.zip

Currently LOTS of overloading as it just makes coding so much easier. We could remove the overloading and then write another S2DL layer over the others with the relevant overloaded names.

I'm not happy with the rotation stuff in phxImage as it seems to be putting the image in the wrong place.

I will try do a conversion of my Flies game (included with the S2DL download) to use this engine instead.

Andreaz
21-06-2006, 10:07 AM
Looks quite good, could use some optimisations through :) (Sel GLXImageList for some of em). And then some documentation ;)

We should change the pushAttrib aswell, there's no need to restore colors and blending to some semi- standard value as youve done now:

glColor4f( 1.0, 1.0, 1.0, 1.0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

instead we push theese 2 bits:

GL_COLOR_BUFFER_BIT: for glColor etc
GL_CURRENT_BIT : for glBlendFunc

glPushAttrib(GL_ENABLE_BIT or GL_COLOR_BUFFER_BIT or GL_CURRENT_BIT );
glBlendFunc (GL_SRC_ALPHA, GL_ONE);
glColor4f(1,1,1, Alpha);
Draw();
glPopAttrib();

For a full spec of glPushAttrib, see:
http://pyopengl.sourceforge.net/documentation/manual/glPushAttrib.3G.html

Andreaz
21-06-2006, 10:09 AM
Oh, and btw use the texture matrix for Tile draw instead :O, ie:


glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex2i(X , Y);
glTexCoord2f(W,0); glVertex2i(X+FWidth, Y);
glTexCoord2f(W,H); glVertex2i(X+FWidth, Y+FHeight);
glTexCoord2f(0,H); glVertex2i(X , Y+FHeight);
glEnd();


Saves alot of OpenGL calls :O

Andreaz
21-06-2006, 11:11 AM
I made the code needed for using display lists for image rendering instead

The needed changes is the following. Note the difference between the 2 draw methods


TPHXImage = class(TObject)
private
FName : String;
FWidth : Integer;
FHeight : Integer;

FTexture: glUint;

// Display list for patterns
FDisplayList : glUint;

FPatternWidth : Integer;
FPatternHeight: Integer;
FPatternCount : Integer;

procedure setPatternHeight(const Value: Integer);
procedure setPatternWidth (const Value: Integer);
public

{ Load the texture from a file. }
Procedure LoadImage(FileName: String ); overload;
procedure LoadImage(FileName: String; Stream: TStream); overload;

// Rendering functions
procedure Draw(X, Y: Integer; PatternIndex: Cardinal); overload;

procedure Draw(X, Y: Integer ); overload;

{ Update the patterns<br>Need to be called after changed <code>PatternWidth</code> or <code>PatternHeight</code> is changed. }
Procedure UpdatePatterns();

Procedure Bind;

{ The name of the image, used to search for textures in the imagelist. }
property Name : String read FName write FName;
{ The width of the image. }
property Width : Integer read FWidth;
{ The height of the image. }
property Height : Integer read FHeight;
{ The OpenGL texture ID. }
property Texture : glUint read FTexture;
{ The OpenGL displaylist ID, contains <code>PatternCount+1</code> lists, where 0 is the full image. }
property DisplayList: glUint read FDisplayList;

{ The pattern width. }
property PatternWidth : Integer read FPatternWidth write setPatternWidth;
{ The pattern height. }
property PatternHeight : Integer read FPatternHeight write setPatternHeight;
{ The number of patterns, same as <code>PatternWidth * PatternHeight</code>. }
property PatternCount : Integer read FPatternCount;
end;





and




//------------------------------------------------------------------------------
procedure TPHXImage.LoadImage(FileName: String);
var TextureLoader: TPHXTextureLoader;
var TextureData : TTextureData;
begin
TextureLoader:= TPHXTextureLoader.getDefaultLoader();

TextureData:= TextureLoader.LoadTexture(FileName);

FName := ExtractFileName(FileName);
FTexture:= TextureData.Texture;
FWidth := TextureData.Width;
FHeight := TextureData.Height;

TextureLoader.FreeData(TextureData);

FPatternWidth := FWidth;
FPatternHeight:= FHeight;
UpdatePatterns();
end;

//------------------------------------------------------------------------------
procedure TPHXImage.LoadImage(FileName: String; Stream: TStream);
var TextureLoader: TPHXTextureLoader;
var TextureData : TTextureData;
begin
TextureLoader:= TPHXTextureLoader.getDefaultLoader();

TextureData:= TextureLoader.LoadTexture(FileName, Stream);

FName := ExtractFileName(FileName);
FTexture:= TextureData.Texture;
FWidth := TextureData.Width;
FHeight := TextureData.Height;

TextureLoader.FreeData(TextureData);

FPatternWidth := FWidth;
FPatternHeight:= FHeight;
UpdatePatterns();
end;


//------------------------------------------------------------------------------
Procedure TPHXImage.UpdatePatterns();
var numX: Integer;
var numY: Integer;
var X,Y : Integer;
var Index : glUint;
var cx, dx: glFloat;
var cy, dy: glFloat;
begin
// Delete the old displaylist
if FDisplayList <> 0 then glDeleteLists(FDisplayList, FPatternCount + 1);

if((FWidth = 0) or (FHeight = 0)) then Exit;

if(FWidth mod FPatternWidth <> 0) then
raise Exception.Create('PatternWidth doesnt match the width.');

if(FHeight mod FPatternHeight <> 0) then
raise Exception.Create('PatternHeight doesnt match the height.');

// Calculate the number of patterns
numX:= FWidth div FPatternWidth;
numY:= FHeight div FPatternHeight;
// Calculate the number of patterns
FPatternCount:= numX * numY;

// Generate the displaylist and leave the 0 position for the full image
FDisplayList:= glGenLists(FDisplayListSize + 1);

glNewList(FDisplayList, GL_COMPILE);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 1.0); glVertex2i(0 , FHeight);
glTexCoord2f(1.0, 1.0); glVertex2i(FWidth,FHeight);
glTexCoord2f(1.0, 0.0); glVertex2i(FWidth,0);
glTexCoord2f(0.0, 0.0); glVertex2i(0 , 0);
glEnd();
glEndList();

dx:= glFloat(FPatternWidth ) / glFloat(FWidth );
dy:= glFloat(FPatternHeight) / glFloat(FHeight);
cx:=0;
cy:=0;

Index:=1;
For y:= 1 to numY do begin
For x:= 1 to numX do begin
glNewList(FDisplayList + Index, GL_COMPILE);
glBegin(GL_QUADS);
glTexCoord2f(cx , cy+dy); glVertex2i(0 , FPatternHeight);
glTexCoord2f(cx+dx, cy+dy); glVertex2i(FPatternWidth, FPatternHeight);
glTexCoord2f(cx+dx, cy ); glVertex2i(FPatternWidth, 0);
glTexCoord2f(cx , cy ); glVertex2i(0 , 0);
glEnd();
glEndList();
inc(Index);

cx:= cx + dx;
end;
cy:=cy + dy;
end;
end;


//------------------------------------------------------------------------------
procedure TPHXImage.Bind;
begin
glBindTexture(GL_TEXTURE_2D, FTexture);
end;






//------------------------------------------------------------------------------
procedure TPHXImage.SetPatternWidth(const Value: Integer);
begin
IF Value = 0 then
FPatternWidth:=Width
else
FPatternWidth:= Value;

end;

//------------------------------------------------------------------------------
procedure TPHXImage.SetPatternHeight(const Value: Integer);
begin
IF Value = 0 then
FPatternHeight:=Height
else
FPatternHeight:= Value;
end;




//------------------------------------------------------------------------------
procedure TPHXImage.Draw(X, Y: Integer; PatternIndex: Cardinal);
begin
glPushAttrib(GL_ENABLE_BIT or GL_COLOR_BUFFER_BIT or GL_CURRENT_BIT );
glEnable (GL_TEXTURE_2D);
glEnable (GL_BLEND);
glDisable (GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, FTexture);

glCallList(FDisplayList + PatternIndex + 1);

glPopAttrib();
end;



//------------------------------------------------------------------------------
procedure TPHXImage.Draw(X, Y: Integer);
begin
glPushAttrib(GL_ENABLE_BIT or GL_COLOR_BUFFER_BIT or GL_CURRENT_BIT );
glEnable (GL_TEXTURE_2D);
glEnable (GL_BLEND);
glDisable (GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, FTexture);

glCallList(FDisplayList);

glPopAttrib();
end;



Shouldnt be that hard to adapt to the other rendering functions :P

cairnswm
21-06-2006, 11:49 AM
Dont like this bit:

if(FWidth mod FPatternWidth <> 0) then
raise Exception.Create('PatternWidth doesnt match the width.');

if(FHeight mod FPatternHeight <> 0) then
raise Exception.Create('PatternHeight doesnt match the height.');


Because I often use sub images that do not tile exactly.

Busy trying to understand what you did :) - Will try and adapt the other methods.

Comments were started but then I ran out of time :P

Tile image will be better to actually adapt the drawing to draw multiple quads with the same texture. But It should work as is - these are the only ones I didn;t test.

Andreaz
21-06-2006, 12:20 PM
Hehe, the pattern modula thing is not really neded actually, no code that depends on the pattern size being a even multiplicator of the image size.

hehe, blame lack of time, please do :P

With displaylist looping for tiledraws is not that big of an issue, but dont use the Draw method for doing it, Function overhead in pascal is large enough as it is :P

Oh, as a font renderer, what do you think of using
http://www.angelcode.com/products/bmfont/
to generate the fonts.

And make a converter to convert the font files into a binary format instead, will save some loading time.

cairnswm
21-06-2006, 12:34 PM
Cool - so we remove the modula thing :) - However also notice that I've included code to just draw a subsection of the main texture anyway.

Any BMP font builder is cool. If you do want to convert to some binary format consider these two things:
1: Only one external resource for one font (ie include the image and the sizing info in one file)
2: keep the facility to use normal image files also - I typically generate a font and infclude it in my games - my artist then uses his tool to modify the raw image and test it in game - this is done remotely so having to continually binarize the file info would add a lot of overhead.

I promise to do more comments :)

jdarling
21-06-2006, 12:50 PM
As a side thought, something that has always annoied the hell out of me about packages with image collections is that they don't let you have different image sizes throughout the image lib.

Could we put a flag in that lets you either setup a pattern width/height or setup the pattern rectangles yourself? I've hacked this into just about every library that I've used. Some of the graphic files I've found in the past had all of the game graphics in one file. To re-build the game you either had to re-cut the graphics (painful) or setup your engine to allow for patterns at different points.

Just my two cents again :).

Still working on the Lua integration, FPC has some searious issues when it comes to C library integration. The debugger freaks out a bit, and some times you have to pull a few tricks to get the methods to appear properly.

Andreaz
21-06-2006, 01:04 PM
Any BMP font builder is cool. If you do want to convert to some binary format consider these two things:
1: Only one external resource for one font (ie include the image and the sizing info in one file)
2: keep the facility to use normal image files also - I typically generate a font and infclude it in my games - my artist then uses his tool to modify the raw image and test it in game - this is done remotely so having to continually binarize the file info would add a lot of overhead.

1. Yeah, that is the general idea of making the binary format, to merge the .fnt and the .tga file BMFont generates. And speed up loading as the .fnt file is a text file containing the character widhts, spacings etc.
2. Loading font as normal images should be no problems, but the issue is the .fnt files, without it the engine wont know where to place the characters as the font generator doesn't place them in a normal grid. However, why not sending him the binary font compiler to (will basicly just be a program with an opendialog for the .fnt and the .tga file that them generates the binary font file.


As a side thought, something that has always annoied the hell out of me about packages with image collections is that they don't let you have different image sizes throughout the image lib.

Could we put a flag in that lets you either setup a pattern width/height or setup the pattern rectangles yourself? I've hacked this into just about every library that I've used. Some of the graphic files I've found in the past had all of the game graphics in one file. To re-build the game you either had to re-cut the graphics (painful) or setup your engine to allow for patterns at different points.

Just my two cents again :).

Dont worry, the image library will for certain support different size images in the resource files, whatever the format will be. (GLXTreem supports this already).

PatternWidth + PatternHeight is already supported, but making different sized patterns for each image is not supported, probably wont be either (not saying its not possible to do this yourself without modifying the image code as the displaylist is exposed just that it won't be built-in)

cairnswm
21-06-2006, 01:19 PM
The phxImage already allows the drawing of any part of the drawing of any size - however these are not seen as patterns but are identified by X,Y widht and height properies - currently this also only allows normal drawing, no stretching, alpha or rotation.

I Prefer image files that my artist can modify directly rather than having to send him extra tools. He takes the standard font file and adds effects, so it used the same chanacter sizing information.

My prefered bitmap font builder is from www.LMNOPc.com (I currently use Bitmap Font Builder c1.8.2) - this also confiorms to creating fonts in the nehe bitmap font style (2 fonts in the same bitmap)

jdarling
21-06-2006, 06:25 PM
I've updated some of the scripting stuff. The updates are:
1) Integrated the console window into the Lua environment, so you can type Lua Script into the console window and execute it. For example focus the console window and type: require "test"<ENTER>
2) Started including some of the glfw stuff into the Lua Environment (more to come)
3) Fixed some issues and added in the basic types; Rect and Point (more to come)

Same download as before. If anyone has Lazarus on Linux please try and build to make sure I didn't screw something up. I believe that I have it setup to load the .so (though I may not have it with the package, you will need Lua 5.0.2) and I'm making use of crt so I'm not sure it will work :(. If not I'll have to start looking into libs for console control.

jdarling
21-06-2006, 08:59 PM
I just uploaded a version that can supposidly load and display TPHXImage's. It seems to load them just fine, problem is it won't display them even though the proper methods are being called. Can someone take a look at this.

Download from source above
Build and run
Select console window
Type: require "test"<ENTER>

It should be displaying a test image (copy of the same) at 100, 100. It doesn't :(. Maybe this has something to do with the image being loaded up during the frame process, I don't know :).

It does show though that the basic object import will work, still needs work on pas2lua to get it fully working for the engine (but it will work).

jdarling
21-06-2006, 11:01 PM
Ok, I've fixed a few problems. Actually quite a few, now loading images from the script works. So does displaying them. I've also implemented the new version of the drawing routines (and made them actually work, had to use Matrix's to pull it off so it may be wrong but it works :)).

Give it a download and let me know what you think: http://www.eonclash.com/phoenix/ProjectPhoenixFull.zip

cairnswm
23-06-2006, 01:52 PM
Have you looked at the list of features available in Torque Game Builder? They are available here: http://www.garagegames.com/products/62#features

Nice defintion of requirements for the new engine.

Andreaz
26-06-2006, 10:28 AM
Yeah, quite a nice list there :)

A small screenshot of the font renderer. Quite nice TrueType font that looks very nice.

http://glxtreem.net/Fonts.jpg

cairnswm
26-06-2006, 10:54 AM
The fonts look nice.

I haven't had more time to spend on the phxImages. Will do it as soon as I can.

Andreaz
27-06-2006, 08:25 AM
Ok, I've fixed a few problems. Actually quite a few, now loading images from the script works. So does displaying them. I've also implemented the new version of the drawing routines (and made them actually work, had to use Matrix's to pull it off so it may be wrong but it works :)).

Give it a download and let me know what you think: http://www.eonclash.com/phoenix/ProjectPhoenixFull.zip

Good work, one thought, do you have any plans on writing a true wrapper for Lua ? I'm feeling thats really what's needed to let the users to have a easy way of adding their own scripts. Ie an abstractation layer of the VM, Scripts, functions etc ?

Andreaz
27-06-2006, 08:36 AM
Most importly some easy way to add functions into lua for the user, ie in some similar way as dws2 does it:



Type TLuaVM = class
procedure registerMethod&#40;Name&#58; String; FunctionClass&#58; class of TLuaFunction &#41;;
end;

Type TLuaInfo = class
Property Parameter&#91;Name&#58; String&#93;&#58; TVariant... default;
end;

Type TLuaFunction = class
procedure exec&#40;Info&#58; TLuaInfo&#41;;
end;

...

LuaVm.registerMethod&#40;'getPlayerX', TgetPlayerX&#41;;

Procedure TgetPlayerX.exec&#40;Info&#58; TLuaInfo&#41;;
begin
Info&#91;"Result"&#93;&#58;= Player.X;
end;



Or something in that range

jdarling
27-06-2006, 01:17 PM
Good work, one thought, do you have any plans on writing a true wrapper for Lua ? I'm feeling thats really what's needed to let the users to have a easy way of adding their own scripts. Ie an abstractation layer of the VM, Scripts, functions etc ?

Even with your sample I'm a bit confused as to what you mean by a true wrapper for Lua? In the end I'll surface anything and everything that we need for the scripting environment to be useful. If the user wants to add functionality to the engine and wrap up there own objects and/or methods then they will either be able to use the conversion software (getting closer to accpetable) or do it by hand.

If you mean completely porting Lua to Pascal so that it can be incorperated into the engine seamlessly, nope. That would require way too much work, and I'm not sure, but I think it would break some license restrictions.

Something like what you posted already exists. Take a look at TLua in LuaWrapper.pas. You can't overwrap the PLua_State (unfortunately) but the user can use it to extend.

My focus right now is to get the rest of the converter working properly with FPC and Delphi, build a few more templates for it and get method overloading working. That should make importing all of the engine very simple. Course that mutch wrapping will mean that people won't necessarly have to compile in FPC to write a game, they could pull off simply downloading the compiled version, writting a few scripts, adding some graphics and modles, and running a complete game. Thats my goal with the scripting environment.

If they then want to make it faster, cleaner, better (or whatever) then they can start migrating the scripts into native code.

BTW: Has anyone thougth about licensing and etc???

Andreaz
29-06-2006, 08:13 AM
My point is that lua is quite complex for a user that never used it before with all the table and stack manipulation one have to use to get something to work.

But if you take for DWS2 they have a very nice abstractation layer between the core scripting engine and the user, to add a new funtion to the engine all you need to do is inherit a special class that represents a function, i'll post a small demo that creates glVertex3f in DWS2:


const // type constants to make sure strings get reused by the compiler
cSingle = 'Float';
cInteger = 'Integer';
cString = 'String';
cBoolean = 'Boolean';


Type TVertex3fFunc = class(TInternalFunction)
procedure Execute; override;
end;

procedure TVertex3fFunc.Execute;
var x, y, z: Single;
begin
x := Info['x'];
y := Info['y'];
z := Info['z'];

glVertex3f(x,y,z);
end;


initialization
//------------------------------------------------------------------------------
RegisterInternalFunction(TVertex3fFunc, 'glVertex3f', ['x', cSingle, 'y', cSingle, 'z', cSingle], '');

end.

DWS can register either internal functions thats common to every instance of the vm or specific for every wm function.

The idea is to seperate the user from the lua calls wich for a beginner seems very strange. You have created one part of that functionallity that i have seen so far, this is where you assign global variables:

ScriptEngine.Value['Time'] := Time;

Easy and innutive, even through the name maybe should be ScriptEngine.Globals :)



There's alot of support for registering classes and the like to, dws2 is quite nice in that aspect even through its not as fast as lua (as the core is written in pascal) and as far as i know doesn't support precompiled scripts.

One comment more i have is that your TLUA class contains both the wm and the script source in one class, would love to se an seperation there, meaning that you can run multiple scripts in the same wm, thus you have a shared vm where you can run a list of precompiled scripts or functions in thoose scripts.

Ie you have a wm with a TList of loaded scripts, where each script has a own name and a easy way to execute it in the parent wm, this way it will be easy to write events that calls a script, for example in the upcomming gui engine..

I'm not a expert of lua myself but as far as i have understod yuu can have many instances of the luaVM actictive and every instance of it has its own set of global variables that can be shared between many scripts, wich would be a nice thing to have easy access to.

The whole idea behind this is that the user shouldnt need to call any core lua functions if he doesn't wants to, ie he dont need to know anything about the lua interface to be able to include his scripts and functions in a easy way.

Puh long one :)

And now to a TPHXFont update:

The font rendering is almost complete, its not exactly as i wrote before as it ended up in a more basic form, ie you have one THPXFont class that uses a binary format, with the option to load the texture from an external image or embedded in the font file, and a tool to convert external formats to the internal font format (only supports BMFFont atm, if anyone feel like adding more formats to it i can supply the current souce code :) ). The font class has basic font rendering capabilities, TextOut, textWidth, textHeight and the ability to compile a displaylist for a specified text.

I will add special functions for word wrapping and text formatting to seperate classes later, for example TPHXStaticText that contains a list of static texts with colors and positions thats compiled into one displaylist to render large texts quickly.

The next part of the engine is probably to convert the glxtreeem gui engine, (have prewritten gui editor so will save alot of time) but with some changes, if you have any suggestions for it please post em here.

Then we have to deside how to work with game loops and timers, anyone has any good ideas on good solutions ?

cairnswm
29-06-2006, 08:50 AM
I prefer being in control of my own gameloop and timing. I'd suggest finding a nice way of managing user input is more important :)

I havn't spent time on this for a while but I will do so again soon. I just have a few deadline for the end of the month I'm trying to get done - and for once playing games is taking tooo much time away from development (I'm playing Zeus and DiabloII a lot at the moment).

jdarling
29-06-2006, 01:27 PM
One comment more i have is that your TLUA class contains both the wm and the script source in one class, would love to se an seperation there, meaning that you can run multiple scripts in the same wm, thus you have a shared vm where you can run a list of precompiled scripts or functions in thoose scripts.
What does WM stand for?


I'm not a expert of lua myself but as far as i have understod yuu can have many instances of the luaVM actictive and every instance of it has its own set of global variables that can be shared between many scripts, wich would be a nice thing to have easy access to.
Well, I'm no expert, but I'm quickly becomming one. Very quickly in fact :).


The whole idea behind this is that the user shouldnt need to call any core lua functions if he doesn't wants to, ie he dont need to know anything about the lua interface to be able to include his scripts and functions in a easy way.
Completely agree, see the rest of my comments below :)


I will add special functions for word wrapping and text formatting

The next part of the engine is probably to convert the glxtreeem gui engine, (have prewritten gui editor so will save alot of time) but with some changes, if you have any suggestions for it please post em here.

I have sample code for both of these that I use in JumpStart. Its written to work on a generic TCanvas so it should be easily ported. I'll admit though that it isn't pretty nor perfect, and not even close to optimized :). But it works :)


Then we have to deside how to work with game loops and timers, anyone has any good ideas on good solutions ?
Two thoughts; One we distro a compiled version that basically requires the user to write scripts to build there game. Most of what I've written up for JumpStart is completely portable (editors for game worlds and etc...). Two we also have the source available so that more advanced persons can download and build there own wrapper exe as they see fit. Many people won't agree on how game timers and control loops should be implemented. I like state machines for primary control and up front loading for speed. Others will say I'm nuts.

On the subjects about the scripting wrappers. Since DWS, Pascal Script for Delphi, and all of the others are written in Delphi for Delphi they can have some very nice features. Lua is not, and thus some of the nice features just simply can't be implemented without loss of speed or ALOT of effort. I'm not willing to give up speed, and I don't have alot of time.

So my solution is the pas2gen application. Basically it reads a given pascal file and generates a wrapper for your scripting engine. First engine out the door will be Lua (and this is almost complete, god willing and the creeks don't rise, by July 5th). I've spent alot of time on making the application as easy to use as possiable, but it still has its difficulties.

I think that you will find that if we do a good enough job, more Lua people will use the engine then Pascal/Delphi users. Simply put; more people know and use Lua right now then Pascal/Delphi. Its in most of the big games, and people love to mod. At least I'm surprised at the numbers using JumpStart (and its not even alpha release ready).

The largest problem we are going to have (as I see it) with the scripting engine right now is events. They arn't going to be easy. In fact they are going to be quite the pain. I've been working on this problem for quite some time. Hopefully soon I'll have a good working solution (instead of a poor working one, witch I currently have).

On the subject of multiple VM's. Yes you can have multiple VM's loaded at the same time. They do not play well together. They don't know about each other, they don't share process space, and forcing them to do so causes bad things to happen. JumpStart initially had all of these problems. Now I'm moving up to using Co-routines, basically VM based threading. This works quite well. We can run scripts seperately that don't need to know aobut each other. For example the debug console control script will be completley seperate from the game script. Unfortunately the actuall processing of the commands must be in the game script :(.

Course all of this is once we get to an multithreaded environment. First it will all be single threaded, I have to walk before I can run, and personally I'd rather see the entire engine stable in single thread mode then migrated to multi-threaded.

Andreaz
03-07-2006, 01:10 PM
I prefer being in control of my own gameloop and timing. I'd suggest finding a nice way of managing user input is more important :)

Yeah, controll is good, gonna try some different approaches, maybe a wait based timer instead of callbacks... Regaring inputs, soon done, will look much like DXInput but with some added functionability to use for the gui engine and such.



I havn't spent time on this for a while but I will do so again soon. I just have a few deadline for the end of the month I'm trying to get done - and for once playing games is taking tooo much time away from development (I'm playing Zeus and DiabloII a lot at the moment).
hehe, fun to do some other stuff from time to time aswell :O

Andreaz
03-07-2006, 01:20 PM
One comment more i have is that your TLUA class contains both the wm and the script source in one class, would love to se an seperation there, meaning that you can run multiple scripts in the same wm, thus you have a shared vm where you can run a list of precompiled scripts or functions in thoose scripts.
What does WM stand for?


I'm not a expert of lua myself but as far as i have understod yuu can have many instances of the luaVM actictive and every instance of it has its own set of global variables that can be shared between many scripts, wich would be a nice thing to have easy access to.
Well, I'm no expert, but I'm quickly becomming one. Very quickly in fact :).


The whole idea behind this is that the user shouldnt need to call any core lua functions if he doesn't wants to, ie he dont need to know anything about the lua interface to be able to include his scripts and functions in a easy way.
Completely agree, see the rest of my comments below :)


I will add special functions for word wrapping and text formatting

The next part of the engine is probably to convert the glxtreeem gui engine, (have prewritten gui editor so will save alot of time) but with some changes, if you have any suggestions for it please post em here.

I have sample code for both of these that I use in JumpStart. Its written to work on a generic TCanvas so it should be easily ported. I'll admit though that it isn't pretty nor perfect, and not even close to optimized :). But it works :)


Then we have to deside how to work with game loops and timers, anyone has any good ideas on good solutions ?
Two thoughts; One we distro a compiled version that basically requires the user to write scripts to build there game. Most of what I've written up for JumpStart is completely portable (editors for game worlds and etc...). Two we also have the source available so that more advanced persons can download and build there own wrapper exe as they see fit. Many people won't agree on how game timers and control loops should be implemented. I like state machines for primary control and up front loading for speed. Others will say I'm nuts.

On the subjects about the scripting wrappers. Since DWS, Pascal Script for Delphi, and all of the others are written in Delphi for Delphi they can have some very nice features. Lua is not, and thus some of the nice features just simply can't be implemented without loss of speed or ALOT of effort. I'm not willing to give up speed, and I don't have alot of time.

So my solution is the pas2gen application. Basically it reads a given pascal file and generates a wrapper for your scripting engine. First engine out the door will be Lua (and this is almost complete, god willing and the creeks don't rise, by July 5th). I've spent alot of time on making the application as easy to use as possiable, but it still has its difficulties.

I think that you will find that if we do a good enough job, more Lua people will use the engine then Pascal/Delphi users. Simply put; more people know and use Lua right now then Pascal/Delphi. Its in most of the big games, and people love to mod. At least I'm surprised at the numbers using JumpStart (and its not even alpha release ready).

The largest problem we are going to have (as I see it) with the scripting engine right now is events. They arn't going to be easy. In fact they are going to be quite the pain. I've been working on this problem for quite some time. Hopefully soon I'll have a good working solution (instead of a poor working one, witch I currently have).

On the subject of multiple VM's. Yes you can have multiple VM's loaded at the same time. They do not play well together. They don't know about each other, they don't share process space, and forcing them to do so causes bad things to happen. JumpStart initially had all of these problems. Now I'm moving up to using Co-routines, basically VM based threading. This works quite well. We can run scripts seperately that don't need to know aobut each other. For example the debug console control script will be completley seperate from the game script. Unfortunately the actuall processing of the commands must be in the game script :(.

Course all of this is once we get to an multithreaded environment. First it will all be single threaded, I have to walk before I can run, and personally I'd rather see the entire engine stable in single thread mode then migrated to multi-threaded.

Well i intended to write VM, not WM (virtual machine).

The event thing really should be quite simple, as long as you keep it as one event = one script. Ie button1.onClick='button1click.lua', and you have a list of loaded scripts in the script engine, kindof like the imagelist works.

And the idea of the framework for lua is not to make the lua coding easier but to make it easier to write own functions to be able to call from lua without needing to go trough all the hazzle with the lua api.

wagenheimer
04-07-2006, 04:01 PM
How is the progress going? I´m very interested in doing multiplataform games!

Asphyre Engine (www.afterwarp.net) is a MPL OpenSource Direct3D 2D engine, with a lot of things already implemented, there are a excellent Particle Engine, a SpriteEngine very well made, and lot of more things. Maybe, some of the authors there, could help with some things in this new engine. I think the ParticleEngine and the SpriteEngine is very well, and could be upgraded and getting better for use with this new engine.

What do you think?

Sorry the bad english!
Cezar Wagenheimer

Robert Kosek
04-07-2006, 04:19 PM
Wagenheimer, Yuriy had a private beta GL only version of Asphyre but wasn't impressed with it enough to use it. He has since stuck to DirectX and I doubt you'll pull him away.

It still has an excellent component base you might want to check out though.

wagenheimer
05-07-2006, 03:14 AM
Humm.. Very nice... I would like to give a look! What was missing in the version that did you saw?

But, who is Yuriy? I did search here in the forum and in the afterwarp forum and did not find any Yuriu.

Thanks!

Robert Kosek
05-07-2006, 03:36 AM
Lifepower := Yuriy; :D

And I didn't see it, it was an internal release that he did as a test. We talked about it awhile ago, not sure if you were using Asphyre then or not, but it should be somewhere in his blog I think.

But anyway, back to the topic. ;)

Andreaz
05-07-2006, 07:33 AM
Progress is going forward, having somewhat of a heatwave here in sountern sweden atm, the motivation sitting down and writing 2k rows of code after work when it's 30C in the apartment isnt that great from time to time :)

I'm currently wrapping up the final parts of the input management, some documentation and then a demo and public release :)

And cairnswm is currently working on extending the image class with additional rendering functions (unless he's playing D2 all the time :P ) so that's comming along quite nice.

I havn't really decided where to go next my current plan is to include the following components (not saying i will write all myself, if you feel like "wow i realy want to do that one" please reply here):


Animation, pattern animation, multiple states (ie run, walk etc)
Gui engine, xml based gui engine, probably texture based building of the GLXTreem gui engine.
Sprite engine, quite straigtforward, per-pixel collisions, collision groups, a sprite format + editor
Tile engine, higly optimized tile engine, multi layer support with different tilesize of each layer, probably 1 texture per layer for speed increase. + Editor
Some kind of primitive renderer, lines pixels etc.
Particle engine, xml based ? (see http://glxtreem.net/Newparticles.rar for the draft of the latest glxtreem version, alot of features)
Sound engine, OpenAL / FMOD ?
Resource loader, to load textures/fonts and other resources from single file resources.

But this is just a preview list, if there's anything missing or lacking please give your oppinion so this Library will own all others :P

cairnswm
05-07-2006, 09:02 AM
Dont forget some method to do graphic transitions between game states/scenes.

When you do the Sprite engine please ensure that the X,Y coordinates work on a single/double rather than an integer to get better smoother movement.

jdarling
05-07-2006, 01:05 PM
Well, I have the importer code working almost seamlessly, now I just have to clean it up and we are good to go on most of the wrappers. There are a few minor things that can throw it for a loop, but I should get those worked out easily enough (the context unit of GLScene is one of these :( ). Did you still want the GUI stuff that I was working on for JumpStart? As I said, it isn't complete but its a start.

Andreaz
06-07-2006, 07:19 AM
Well, I have the importer code working almost seamlessly, now I just have to clean it up and we are good to go on most of the wrappers. There are a few minor things that can throw it for a loop, but I should get those worked out easily enough (the context unit of GLScene is one of these :( ). Did you still want the GUI stuff that I was working on for JumpStart? As I said, it isn't complete but its a start.

Why not, always nice to see different solutions to a problem :)

Andreaz
06-07-2006, 05:46 PM
phxFont + phxInput preview:

http://www.glxtreem.net/Phoenix2006-07-06.rar

remember they're still wip so they probably will change some :)

wagenheimer
07-07-2006, 12:24 AM
Hummm.. Very Nice!

The Image/Fonts/Input engines is going very well! =)

Somebody already did started the Timer and SpriteEngine engines?

Keep on the good work! =)

Andreaz
07-07-2006, 07:03 AM
There's some code for the timer done, so it wont be to long before that one is complete.

The spriteengine however isnt started, there's a lot of questions about what features it shall have, how to approach collisions/fustrum culling (in a 2d manner) and other optimizations, if you have any (bright) ideas, please let's brainstorm abit !

Andreaz
07-07-2006, 10:13 AM
I have been checking around abit on the sprite engine, and i'm not shure per pixel collisions is the best way to do it (althrough the easiests) I'm instead considering implementing a quadtree bases algoruthm using AABB and the "Separation of Axis Theorem" for the colisions using convex polygions. Will be alot faster then then the per pixel approach.

Andreaz
07-07-2006, 11:50 AM
If you wanna se what i have in mind check out the examples + tutorial found here:

http://uk.geocities.com/olivier_rebellion/Polycolly.zip

And heres a small quite from the doc on the advantages using polygon collisions:


Sprite based detection performs check on pixels of a overlapping pixels of sprites, and detects collisions that way. Polygons use vector maths to accurately calculate the point, time and direction of impact. While the polygon is only an approximation of the sprite itself, it has advantages over sprite systems.

* Allows to perform good looking physics simply and accurately, like bouncing, friction, deals with slopes in an automated fashion.
* The collision detection is more accurate for high-speed sprites. In a sprite-based system, the objects can potentially jump past each other in a time frame if they move too fast.
* It is based on vector maths, so can be extended to 3D, while a sprite collision system is strictly limited to 2D.

cairnswm
07-07-2006, 01:54 PM
Sounds good.

jdarling
07-07-2006, 03:00 PM
I have been checking around abit on the sprite engine, and i'm not shure per pixel collisions is the best way to do it (althrough the easiests) I'm instead considering implementing a quadtree bases algoruthm using AABB and the "Separation of Axis Theorem" for the colisions using convex polygions. Will be alot faster then then the per pixel approach.

The largest problem I have with Per-pixel colision is the fact that you don't always want to collide the entire sprite. Actually I hardly ever want to test the entire sprite :). For example a character in an RPG will only collide on his feet for the most part. I have been able to get away with minimal bounding box aproaches for everything I've done, but I must admit that it shows.

jdarling
07-07-2006, 04:12 PM
As I was reading through some of the posts on GameDev I saw another one of those common questions "How can I automate converting my 3D models into 2D sprites". This one has always struck me as rather odd that no tools really seem to exist. So... What does everyone think of including a support app (along with a seperate download) that lets you load in model files, apply translations, movements, animations, etc... cap them and build out sprite images from them.

Looking at GLScene for Lazarus I think this could be done easily, and if we utilized the scripting engine thats already in the works we could allow for a great bit of flexability. Of course a standard UI would be needed for those that arn't scripting savy.

Just a thought that I figured might gain some interest.

WILL
07-07-2006, 09:40 PM
What about an option to choose a level of collision detection? ie. instead of just being stuck to per-pixel or #-point collision, instead you enable it to do polygon, circular(my personal fav. since it's just a distance from a 'collision point' and is super quick), per-pixel and simple #-point collision algos then give them the option or the toggle to use whichever ones they want.

Shouldn't be too hard to impliment if you ar going through the task of making a whole 2D collision object engine, right? :)

At any rate, you can do one or two type(s) of collision detection method(s) then leave it open to do the other ones when you get around to it... or if a friendly volunteer comes along... ;)

WILL
07-07-2006, 09:44 PM
As I was reading through some of the posts on GameDev I saw another one of those common questions "How can I automate converting my 3D models into 2D sprites". This one has always struck me as rather odd that no tools really seem to exist. So... What does everyone think of including a support app (along with a seperate download) that lets you load in model files, apply translations, movements, animations, etc... cap them and build out sprite images from them.

:lol: I think I'd use your whole package just for that one thing for my Cyber-Crisis game... what a cool tool! :D

Andreaz
08-07-2006, 02:46 PM
The largest problem I have with Per-pixel colision is the fact that you don't always want to collide the entire sprite. Actually I hardly ever want to test the entire sprite :). For example a character in an RPG will only collide on his feet for the most part. I have been able to get away with minimal bounding box aproaches for everything I've done, but I must admit that it shows.

Well, that's why i have implemented a polygonal colission detection system, this means that the colision area can be any size and shape as you like, as long as they are convex that is :)


What about an option to choose a level of collision detection? ie. instead of just being stuck to per-pixel or #-point collision, instead you enable it to do polygon, circular(my personal fav. since it's just a distance from a 'collision point' and is super quick), per-pixel and simple #-point collision algos then give them the option or the toggle to use whichever ones they want.

Shouldn't be too hard to impliment if you ar going through the task of making a whole 2D collision object engine, right? :)

At any rate, you can do one or two type(s) of collision detection method(s) then leave it open to do the other ones when you get around to it... or if a friendly volunteer comes along... ;)

Well i see one problem with having different ways of dealing with the colissions, will be hardly impossible to have some kinds of optimizations in place.

Another problem well as collisions between different types of colission engines, for example bouding circle vs polygon tests. Unless you have some smart way of doing this ?

I have a fealing that my current approach will be sufficient, it will use Axis Aligned Bounding Rectangles for precolissoon detection, as well as a quadtree for the colission segmentation.

Did a small test did 1000 polygon collisions where every single one colided and still had around 180 fps, that is with no AAAB's or quadtrees.

And the 3D mesh -> 2D sprite idea sounds very usefull indeed :)

WILL
08-07-2006, 05:42 PM
What about an option to choose a level of collision detection? ie. instead of just being stuck to per-pixel or #-point collision, instead you enable it to do polygon, circular(my personal fav. since it's just a distance from a 'collision point' and is super quick), per-pixel and simple #-point collision algos then give them the option or the toggle to use whichever ones they want.

Shouldn't be too hard to impliment if you ar going through the task of making a whole 2D collision object engine, right? :)

At any rate, you can do one or two type(s) of collision detection method(s) then leave it open to do the other ones when you get around to it... or if a friendly volunteer comes along... ;)

Well i see one problem with having different ways of dealing with the colissions, will be hardly impossible to have some kinds of optimizations in place.

Another problem well as collisions between different types of colission engines, for example bouding circle vs polygon tests. Unless you have some smart way of doing this ?

I have a fealing that my current approach will be sufficient, it will use Axis Aligned Bounding Rectangles for precolissoon detection, as well as a quadtree for the colission segmentation.

Did a small test did 1000 polygon collisions where every single one colided and still had around 180 fps, that is with no AAAB's or quadtrees.

Hmm... well I think HOW to impliment multiple collision schemes is an issue with my idea. However, I think it could be easily solved by having several systems in place and you just set the whole engine to use one or another, not mix them. It would allow for the developer to pick and choose at what level and weight on the CPU the collision detection will take for their game. Plus it provides more options.

ie.
GameEngine.CollisionMode := Polygon;
or
GameEngine.CollisionMode := Circle;
or
GameEngine.CollisionMode := Point;
or
GameEngine.CollisionMode := PerPixel;
or
GameEngine.CollisionMode := Square;
etc...

This will allow for only a simple case statement to occure extra when the engine actually does the collision. Plus, it keeps your code easy to modify and add/remove collision systems. Because what if someone is looking for a 2D engine with a different collsision system than you are offering? (considering that you stay with only one kind) it doesn't help them and they have to choose something else.

This at least gives that freedom to create new schemes and takes less time away form your own implimentations. ie. jst write the one you have now and/or that per-pixel one and others like myself can write and add the other ones for you. ;)

This engine is going to be opensource, right?

AthenaOfDelphi
08-07-2006, 07:10 PM
Another solution for allowing choice, without too much impact on performance is the eventing mechanism.




type
TCollisionFunction = function&#40;spriteA,spriteB&#58;TSpriteClass&#41;&#58;boolean of object;
....
TEngine = class&#40;TEngineParentClass&#41;
protected
fCollision &#58; TCollisionFunction;
public
function collisionPerPixel&#40;a,b&#58;TSpriteClass&#41;&#58;boolean;
function collisionSquare&#40;a,b&#58;TSpriteClass&#41;&#58;boolean;
function collisionCircle&#40;a,b&#58;TSpriteClass&#41;&#58;boolean;
published
property collision&#58;TCollisionFunction read fCollision write fCollision;
end;


You then set the handler:-



myEngine.collision=myEngine.collisionPerPixel;


And use it in your code:-



if myEngine.collision&#40;a,b&#41; then


I've used this method to great effect quite a few times, including as an example optimisation in my article on basic optimisation.

WILL
08-07-2006, 07:52 PM
Ah well thats probably a much nicer implimentation of my idea.

And you could take that even further if you wanted to make a drag and drop non-visual component for Delphi/Laz that had a simple property that you can choose from.

Or delve into the code and set it manually...

Plus your library gains the bonus of being pro-choice in collision detection methods.

Andreaz
09-07-2006, 07:43 AM
Yeah, should probably be doable, but i think you're stuck with the quadtree as if you want it fast you need to have alot of cross references

The whole colission algorithm for the quadtree + polygon approach will need the following steps: (This is atleast what i have figured out so far).


TSprite = object
Static: Boolean; // If the object is moving, used for colission seperation aswell as if the sprite will ever update the quadtree.
CollisionMesh: Array[0..32] of TVector2f; // The colissiondata
BoundingRect: TRect; // The AABB rectangle for the sprite
ListNode: PLinkedListNode; // The node of the linkedlist in the tree that this sprite is a child of
TreeNode: PQuadTreeNode; // The quadtree node this sprite is a member of
Procedure Moved; // need to be called by the user when the node has moved and needs to be moved to another quandrant in the quadtree
end


This will make removing nodes from the quadtree O(1) and adding nodes O(N) where N is the deapth of the tree

Then for each frame:
1. call Move for each sprite
2. if the sprite is marked with Moved update the quadtree
3. For each sprite that is moved, get a array of objects that this may have collided. (Iterate trough the list objects of each sibling and parent tree node)
5: Do a simple intesect rect collision of the bounding rectangles for the sprites.
4: Do the collision(a,b:TSpriteClass):
5: Do the seperation of each sprite (Ie if they are intersecting we need to move them apart.) If the sprite is static it won't be moved here.
6: Call the sprite callback for each collison

So changing the colission type probably isnt that hard, but you'll get some unesery data in the sprite (planning on writing a sprite editor where you simply can edit the colission polygon, center point of the sprite etc).

So in essence changing the collission function isnt that hard but i think you're kindof stuck with the QuadTree approach.

Secondly, been doing some thinking about how we should design the sprite class tree and how to deal with the collisions for each type, my current idea is basicly to have 3 types of sprites, a imagesprite, a background sprite and a particle sprite where only imagesprites or descendants of that will be able to collide with eachoter. But i'm not really shur this is the best way of doing it, any ideas ?

WILL
09-07-2006, 08:19 AM
Hmm... some particle effects might need collision detection aswell. Just when it hits x,y,z it knows to go away or do something else like bounce off, etc.

Andreaz
09-07-2006, 09:42 AM
Hmm, you have a point there, do you have any good idea on how to approach this ? Ie with sprites that can collide and sprites that can't. Moving and adding sprites that doesnt want to collide with anything in the QuadTree is a waste of processing power...

WILL
09-07-2006, 10:31 AM
I'd say just have a since Boolean value it checks.

if (Particle[A].doDetection) and (Particle[B].doDetection) then
// do detection algo...


Then it simply ignores the algo if you don't have two objects that will actually collide.

However if you want to get more sophisticated where some particles will detect collision with anything and others with only other collidale types then, perhaps make it a byte or an integer where you check the values.

You have some values setup for it's use like so: (forgive the bad name conventions it's late here ;))
conts
CollisionCondition_None = 0;
CollisionCondition_Any = 1;
CollisionCondition_ActiveOnly = 2;
CollisionCondition_NonActiveOnly = 3;

Then it would handle the detection conditions like so...
case (Particle.CollisionCondition) of
CollisionCondition_None : ; // Skip Collision Detection altogether!
CollisionCondition_Any : ; // Do detection, but with any other particle (or sprite?)
CollisionCondition_ActiveOnly : ; // Same as last, but only with particles/sprites that are > 1
CollisionCondition_NonActiveOnly : ; // does collision, but only detects those that are non detectable...
end;

I think you get the point. :) You can add in sprite and particle collisiondetection conditions into the whole mix... case statement was to just illustrate my point, I doubt you'll want to do it exactly like that.

Andreaz
24-07-2006, 02:37 PM
Time for a small status update :)

I have got the basics of the sprite engine working, some work left on optimizations and colissions through. I have converted the basic parts of the GLXTreem gui engine aswell and it works nice.

One pending project atm is the font compiler, it should really need some more work (support for symmetrical grid fonts for instance, maybe nehe's font format (yes the font renderer will cope with that quite easilly ) ) If someone feels like ending up on the credit list the source for the font compiler is included in the last release.

jdarling
24-07-2006, 02:46 PM
Andreaz, can you post up the DL link again. I'd like to make sure that the wrapper stuff is still on target and wrap up the things that you have added. As well as integrate the XML stuff I finally completed.

Andreaz
24-07-2006, 03:16 PM
Shure, here's the latest soruce:

http://www.glxtreem.net/Phoenix2006-07-24.rar

Oh, and there's already a xml parser included (written by myself and is a modified version of the one used in GLXTreem) that the component engine uses.

wagenheimer
24-07-2006, 08:52 PM
Hi...

A suggestion, about the Particle Engine, you could give a look o XParticles for Asphyre. It´s a very good particle engine with editor already ready, and i think it will be not hard to convert. I think the author will allow the conversion if asked.

http://www.afterwarp.net/forum/showthread.php?t=414&highlight=particle

[]´s
Cezar

wagenheimer
25-07-2006, 01:20 PM
Hi Andreaz...

I can´t compile the Sprite Example. It´s missing the phxSpriteEngine.pas file.

[]´s
Cezar

Andreaz
25-07-2006, 02:14 PM
Seems i forgot to add that one to the rar file, you can get it from here:

http://www.glxtreem.net/phxSpriteEngine.pas

jdarling
25-07-2006, 02:58 PM
Seems i forgot to add that one to the rar file, you can get it from here:

http://www.glxtreem.net/phxSpriteEngine.pas

I just figured that it wasn't complete yet :)

Andreaz
26-07-2006, 06:55 AM
I just figured that it wasn't complete yet :)

Quite correct, yesterday i've reworked the collision groubs a bit so now you have very goood control on wich sprites can collide with eachoter (by making smart seperations you can get very good speeds with no fancy optimisations). I also extended the animated sprite class so it really supports animated sprites. Still some work on the collision detection and responce left.

Andreaz
01-08-2006, 09:49 AM
Yet another status update:

The sprite engine is now working very good, currently working on wrapping up a small demo showing off some of the functionality, there will be a much larger demo/game aswell but i'll leave that as a surprise.

Have started writing a SoundEngine using OpenAL aswell and it's progressing well, nothing fancy yet.

Cairn, hows the image list going, i came up with a nice idea to improve the pattern animaton, to add 2 new variables: PatternSkipX and patternSkipY, wich does just as it sounds, skips a few pixels for each pattern, could be usefull for nonpower of two textures and the gui engine for instance.

Gonna try getting a new version up tonight

Edit: And btw, if there's anything you feel that could be improved or is working badly dont be afraid to say so. Feedback is much welcome !

cairnswm
01-08-2006, 10:29 AM
A status update from me :)

I started adding the other Pattern based drawing functions last night. Unfortunatly it doesn;t worked with scaled images. I am still busy making the changes.

I want to add methods to allow custom patterns to be defined (ie define sections of the image as new sprites that then use the normal drawing functions) - however this wont then work with the stretch draw functions.

I am starting a set of articles for a local free game dev magazine (Gameforce - http://gamedev.co.za) on making 2D game with FreePascal and Phoenix. I will include all the aricles I write for inclusion in the Phoenix download. (It will be a 6 part series).

Andreaz
01-08-2006, 11:00 AM
Dont see why your strechdraw functions don't work, should only be as simple as this:


procedure TPHXImage.StrechDraw(X, Y, W, H: Integer);
begin
glPushAttrib(GL_ENABLE_BIT or GL_COLOR_BUFFER_BIT or GL_CURRENT_BIT );
glEnable (GL_TEXTURE_2D);
glEnable (GL_BLEND);
glDisable (GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, FTexture);

glPushMatrix();
glScalef(W / Width, H / Height, 1);
glTranslated(X,Y,0);
glCallList(FDisplayList);
glPopMatrix();


glPopAttrib();
end;

procedure TPHXImage.StrechDraw(X, Y, W, H: Integer; PatternIndex: Cardinal);
begin
glPushAttrib(GL_ENABLE_BIT or GL_COLOR_BUFFER_BIT or GL_CURRENT_BIT );
glEnable (GL_TEXTURE_2D);
glEnable (GL_BLEND);
glDisable (GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, FTexture);

glPushMatrix();
glScalef(W / PatternWidth, H / PatternHeight, 1);
glTranslated(X,Y,0);
glCallList(FDisplayList+PatternIndex+1);
glPopMatrix();


glPopAttrib();
end;


And yeah, custom frame support would be good, probably just need to look something like this ?


TPHXFrame = class
DisplayList: glUint;
Image : TPHXImage
PatternX : Integer;
PatternY: Integer
PatternWidth : Integer;
PatternHeight: Integer
end


And btw, dont mess with the DisplayList property of the image class, you will break alot of code if you do so :P

Nice to hear about the tuts

cairnswm
03-08-2006, 05:26 AM
The stretch draw is working fine now. Rotate still has some problems - I dont think its really rotating properly.

I have made all the changes I wanted onto the phxImage class.

I started trying to make a small game last night. I could not get FullScreen working properly - are there any issues with it?

Andreaz
03-08-2006, 10:40 AM
The stretch draw is working fine now. Rotate still has some problems - I dont think its really rotating properly.

I have made all the changes I wanted onto the phxImage class.

I started trying to make a small game last night. I could not get FullScreen working properly - are there any issues with it?

Sounds good !

There's no fullscreen issues that i'm aware of, just set fullscreen to true in the window constructor.

A few days late but here's the latest release:

http://www.glxtreem.net/Phoenix2006-08-03.rar

The sprite engine is included, as well as a early version of the sound engine, no need to initialize OpenGL yourself anymore and setOrthoMode is done by default. And some fixes and tweaks as usuall!

jdarling
03-08-2006, 12:53 PM
Well, as you can see from the front page, I finally got the importer working properly. Once I get Indexed Property code generation working I'm going to start wraping up all of the classes in the game and engine. Once thats complete full scripting support should be availalble.

I have ran the wrapper generator on everything thus far, and with the exception of the indexed properties, everything generated properly. Also have to fix Records, but those don't seem to be in use right now :).

I can even wrap the OpenGL calls so that you can make use of them inside of the scripts :)

paul_nicholls
03-08-2006, 10:36 PM
Well, as you can see from the front page, I finally got the importer working properly. Once I get Indexed Property code generation working I'm going to start wraping up all of the classes in the game and engine. Once thats complete full scripting support should be availalble.

I have ran the wrapper generator on everything thus far, and with the exception of the indexed properties, everything generated properly. Also have to fix Records, but those don't seem to be in use right now :).

I can even wrap the OpenGL calls so that you can make use of them inside of the scripts :)

Cool! nice work chief! :)

Especially the OpenGL calls bit :)

cheers,
Paul.

cairnswm
08-08-2006, 06:41 PM
Why does it automatically set VSync on?

Do you want the image drawing functions I've done - I notice they are not included.

I am starting to work on my tutorial set - can we have a release 1 sometime soon. My deadline is actually friday. In addition I want to start using this for a project of mine - I need some stability.

I have started creating a state manager. Needs a bit more work - making it more extendible - will release soon.

Andreaz
09-08-2006, 05:59 AM
Why does it automatically set VSync on?

Because i noticed some screen flickering with vsync off, so i opted for having it on by default


Do you want the image drawing functions I've done - I notice they are not included.
Maybe you also noticed that you sent me the file after the last release :P I gonna include it with some modifications, for example speeding up the tiledraw and such. Need to fix the state changes as we discussed before aswell (ie no glColor4f( 1.0, 1.0, 1.0, 1.0);).


I am starting to work on my tutorial set - can we have a release 1 sometime soon. My deadline is actually friday. In addition I want to start using this for a project of mine - I need some stability.
A release 1 wont make it more stable :P But if you experience stability problems we just have to fix em, simple as that :) I have caught a nasty cold so it will probably not be that much coding done over the next few days.

cairnswm
09-08-2006, 04:44 PM
A release 1 wont make it more stable

But it will fix the unit and class names :) Each version so far has had unit name chnage - and class name changes.

I just want something to start working with :)

WILL
09-08-2006, 10:17 PM
Wow, this project is coming along quite a bit, no? :)

How many people have been working on it and/or contributing?

jdarling
10-08-2006, 02:52 AM
Well, I've been working on it, but haven't yet put my stuff up as a contribution due to issues that are almost completely resolved. Soon, very soon, my precious... Err... Soon, the scripting wrappers will be complete. I have a running version now that lets you create, load, and display all just fine. Overloaded methods and events arn't working (and it will be quite some time till the events work) but other then that I'm just awaiting the next build so I can make sure that the wrappers all still work. If they do, I'll post them to be included in the package.

cairnswm
10-08-2006, 05:38 AM
Well I call myself a contributor - but I've done less than 1% of the work :)

When my tuts are done then I can say I'm a real contributor :)

cairnswm
10-08-2006, 05:43 AM
Oh yes - I tried compiling some of the examples in Delphi and had a number of problems - can we please try and get this compatible for Delphi and FreePascal please.

jdarling
10-08-2006, 12:57 PM
Oh yes - I tried compiling some of the examples in Delphi and had a number of problems - can we please try and get this compatible for Delphi and FreePascal please.

What problems? I just had to change a few register things with IfDefs and all went well. I'm sure that once a code locked version is released it can be setup to compile in both IDE's. At least I know that the scripting engine compiles in both right now :)

Andreaz
11-08-2006, 07:48 AM
But it will fix the unit and class names :) Each version so far has had unit name chnage - and class name changes.

I just want something to start working with :)
Only class that has changed name so far is the phxWindow -> phxFrame because the Window class in the gui engine. I have no plans on changing any other names :)


Oh yes - I tried compiling some of the examples in Delphi and had a number of problems - can we please try and get this compatible for Delphi and FreePascal please.

Yeah, i know this, one compiler directive delphi doesn't like and a helper function in the sprite engine that currently uses overloaded operators.

No big stuff but havent had time to test it out in delphi yet.

I'm currently working on the paricle engine, it will be a hybrid between the GLX particle engine and the XParticle of apshyre. I felt the apshyre engine a bit limited in my own taste so i wrote a new one from scratch :)

cairnswm
11-08-2006, 08:13 AM
I am away from home for most of this weekend. So I will start on the tutorials on Monday.

phxWindow -> phxMainWindow -> phxFrame

Wht not phxDraw - then its similar to GLX and DelphiX names?

Andreaz
11-08-2006, 08:32 AM
Okey you got me, had a temporary name in the middle there :)

I've considered using the draw name, but dont know if it makes any sense, but it could be advantageous with the same name even trhough mosth functions is window management related... what do you think

cairnswm
11-08-2006, 10:47 AM
I think the best name would be to call it screen: phxScreen because it does actually refer to the full screen as opposed to a GUI window that gets created.

(In fact when I did DelphiX stuff I used to Create a Screen class for interaction with the DXDraw components)

Andreaz
11-08-2006, 11:24 AM
Screen, good idea, i'll change to that :)

Andreaz
13-08-2006, 11:48 AM
I'm wrapping up the final changes and additions to the latest version, here's a preview of what will be included.

Upcomming additions and changes:


TPHXFrame renamed to TPHXScreen for better description.
Particle System, powerfull and fast. Editor is wip
Package System, distribute all you game files in one big package, including edtior
The updated version of the image list


Expect it in the newt few days. (If nothing unexpected happends ofc)

Andreaz
15-08-2006, 01:15 PM
Here's the next release, have made a overhaul of all code so now everything is named correctly and should be compilable in both delphi and fpc.

Now every classname and unit name is final, so can in some way consider this as the first official release, please download it and give it a good testing so we can get rid of all bugs and errors.

What to note through is that the compression / repackaging (removing the defragmentation from deleting files) of the package routines is not addded yet, but this is just nice-to-have features and not required so not highest priority just now.

http://www.glxtreem.net/Phoenix2006-08-15.rar

I have started on the html documentation using fpdoc (altrhough i needed to rebuild it to get it working :P ), alot better then pasdoc i've used before, this means i propably remove all documentation comments from the source code in a future release.

Included in the release is a new Font converter for converting BMFonts to the phx font format. ( Interesting in writing a full fledged editor anyone ?) A package editor as well as the basics of a particle effect editor that needs alot more work. :P

I have some plans on making some small changes to the TPHXImage class aswell to make the pixel data of the images exposed to the end user but this is nohing that will change how the image class works through.

I have also added alot more rendering functions, some of cairnswm's and some of my own, highly optimised of course.

What is on the future is a TileMap with multiple layers and TileMap -> Sprite collision support.

Have Fun !

cairnswm
16-08-2006, 05:34 AM
Sounds good :)

Last week I had a few problems on one PC where a FullScreen window made everything green. I have not tested it much yet though.

Andreaz
18-08-2006, 07:08 AM
Please test it, but i have bad experience of OpenGL on laptops, the gpu's are often some odd variant of the normal cards with lacking driver support.

Found a small bug in the imageclass, for some reason i have switched place of the parameters in some functions, ie drawAdd:

Procedure DrawAdd(X,Y,Alpha);
Procedure DrawAdd(X,Y,PatternIndex, Alpha);

Should really be

Procedure DrawAdd(X,Y,Alpha);
Procedure DrawAdd(X,Y, Alpha, PatternIndex);

for consistency across the board.

jdarling
21-08-2006, 04:55 PM
I finally might have a bit more time to start converting the classes and creating test cases for the scripting engine. Was curious to see what you felt were the most important classes and units to convert. I'm thinking:

phxImage
phxSprites
phxSpriteEngine
phxTexture
phxFont

I'm sure that there are more, so let me know. I'll post something once I have some demo's working with the headers. I figure that will be the easiest way to find what I'm missing :)

Andreaz
21-08-2006, 08:30 PM
Yeah, something like that, the functions and classes in phxTexture is rewritten from scratch through.

Here's a link to the latest version of the documention, something like 20h work behind that so far:

http://glxtreem.net/phoenix/docs.rar

Image, Texture, Screen, Font, Input is covered so far.

jdarling
21-08-2006, 08:39 PM
Well, interestingly enough I've ran into some problems. I've successfully wrapped everything up, but when trying to run I get errors somewhere deep in the bowles of the system.

You can download the source from: http://www.eonclash.com/phoenix/Phoenix2006-08-15.zip

It would be nice if someone would take a look at the demo\Scripting\Scripting.lpr project. In the bin folder you will find a file called Game.lua. Run the Scripting.exe and everything is fine. Open Game.lua and change:

--&#91;&#91;
Images&#58;LoadImagePattern&#40;'Sprites.png', 32, 32&#41;;
Images&#58;LoadImage&#40;'Rectangle.png'&#41;;
Images&#58;LoadImage&#40;'Octagon.png'&#41;;
--&#93;&#93;
to


Images&#58;LoadImagePattern&#40;'Sprites.png', 32, 32&#41;;
Images&#58;LoadImage&#40;'Rectangle.png'&#41;;
Images&#58;LoadImage&#40;'Octagon.png'&#41;;
--&#93;&#93;

Now it will blow up when it tries to load the images. Looking at the code didn't help me any :( neither did the stack dump :(. Any ideas? Until I figure this out, fonts, Image collections, and sprites won't work :(. Once I figure it out, I'll make a clean build and we should have scripting support.

jdarling
21-08-2006, 08:46 PM
BTW, Here is the dump that I get while running:

&#91;FORMS.PP&#93; ExceptionOccurred
Sender=EAccessViolation
Exception=Access violation
Stack trace&#58;
$004FBC75 REMOVE_FROM_LIST_VAR, line 562 of C&#58;/lazarus/source/fpc/fpcbuild-2.0.2/fpcsrc/rtl/inc/heap.inc
$004FB1B1 SYSGETMEM_VAR, line 966 of C&#58;/lazarus/source/fpc/fpcbuild-2.0.2/fpcsrc/rtl/inc/heap.inc
$004F9838 SYSGETMEM, line 1002 of C&#58;/lazarus/source/fpc/fpcbuild-2.0.2/fpcsrc/rtl/inc/heap.inc
$004F4389 GETMEM, line 229 of C&#58;/lazarus/source/fpc/fpcbuild-2.0.2/fpcsrc/rtl/inc/heap.inc
$004F32F2 fpc_dynarray_setlength, line 185 of C&#58;/lazarus/source/fpc/fpcbuild-2.0.2/fpcsrc/rtl/inc/dynarr.inc
$004EED75 TPHXTEXTURELOADER_FREEIMAGE__LOADBITMAP, line 498 of C&#58;/Documents and Settings/jdarling/Desktop/Phoenix2006-08-15/src/phxTexture.pas
$004EF259 TPHXTEXTURELOADER_FREEIMAGE__LOADIMAGEDATA, line 591 of C&#58;/Documents and Settings/jdarling/Desktop/Phoenix2006-08-15/src/phxTexture.pas
$004EE9A2 TPHXTEXTURELOADER__LOADTEXTURE, line 432 of C&#58;/Documents and Settings/jdarling/Desktop/Phoenix2006-08-15/src/phxTexture.pas
$004EF8EB TPHXIMAGE__LOADIMAGE, line 205 of C&#58;/Documents and Settings/jdarling/Desktop/Phoenix2006-08-15/src/phxImages.pas
$004F0BF3 TPHXIMAGELIST__LOADIMAGE, line 675 of C&#58;/Documents and Settings/jdarling/Desktop/Phoenix2006-08-15/src/phxImages.pas
$004DF91A LUATPHXIMAGELISTLOADIMAGEPATTERN, line 784 of C&#58;/Documents and Settings/jdarling/Desktop/Phoenix2006-08-15/src/lua/lua_phxImages.pas
$002648B6
$0026BA4E
$002649F8
$00261E76
$002642E3
$00264C8A
TApplication.HandleException Access violation
Stack trace&#58;
$004FBC75 REMOVE_FROM_LIST_VAR, line 562 of C&#58;/lazarus/source/fpc/fpcbuild-2.0.2/fpcsrc/rtl/inc/heap.inc
$004FB1B1 SYSGETMEM_VAR, line 966 of C&#58;/lazarus/source/fpc/fpcbuild-2.0.2/fpcsrc/rtl/inc/heap.inc
$004F9838 SYSGETMEM, line 1002 of C&#58;/lazarus/source/fpc/fpcbuild-2.0.2/fpcsrc/rtl/inc/heap.inc
$004F4389 GETMEM, line 229 of C&#58;/lazarus/source/fpc/fpcbuild-2.0.2/fpcsrc/rtl/inc/heap.inc
$004F32F2 fpc_dynarray_setlength, line 185 of C&#58;/lazarus/source/fpc/fpcbuild-2.0.2/fpcsrc/rtl/inc/dynarr.inc
$004EED75 TPHXTEXTURELOADER_FREEIMAGE__LOADBITMAP, line 498 of C&#58;/Documents and Settings/jdarling/Desktop/Phoenix2006-08-15/src/phxTexture.pas
$004EF259 TPHXTEXTURELOADER_FREEIMAGE__LOADIMAGEDATA, line 591 of C&#58;/Documents and Settings/jdarling/Desktop/Phoenix2006-08-15/src/phxTexture.pas
$004EE9A2 TPHXTEXTURELOADER__LOADTEXTURE, line 432 of C&#58;/Documents and Settings/jdarling/Desktop/Phoenix2006-08-15/src/phxTexture.pas
$004EF8EB TPHXIMAGE__LOADIMAGE, line 205 of C&#58;/Documents and Settings/jdarling/Desktop/Phoenix2006-08-15/src/phxImages.pas
$004F0BF3 TPHXIMAGELIST__LOADIMAGE, line 675 of C&#58;/Documents and Settings/jdarling/Desktop/Phoenix2006-08-15/src/phxImages.pas
$004DF91A LUATPHXIMAGELISTLOADIMAGEPATTERN, line 784 of C&#58;/Documents and Settings/jdarling/Desktop/Phoenix2006-08-15/src/lua/lua_phxImages.pas
$002648B6
$0026BA4E
$002649F8
$00261E76
$002642E3
$00264C8A
&#91;FORMS.PP&#93; ExceptionOccurred

The same thing will happen if you try to use the font:
Font = TPHXFont&#58;new&#40;&#41;
Font&#58;LoadFont&#40;'Arial16.phfnt'&#41;

WILL
22-08-2006, 01:01 AM
Wow docs already huh?

So, does this project have a public website yet? Or is PGD it? :P

Can't wait to see the first Phoenix Engine demos! ;)

cairnswm
22-08-2006, 05:20 AM
Hi Andreaz

Bad news. My PC at home that gave me a funny color full screen version previously doesn;t display anything using the new version :(

I was using specifically the Input demo, and also took my previous version of the demo and ran it. Both just give me blank screens.

Its an AMD 64x2 4400, X1600 card and 1GM RAM.

What sort of tests can I do to try work out what the problem is.

Andreaz
22-08-2006, 10:42 AM
Wow docs already huh?

So, does this project have a public website yet? Or is PGD it? :P

Can't wait to see the first Phoenix Engine demos! ;)

Yeah, i've started writing documentation for the completed components. Mor fun then to write everything at once :P

Well only pgd for now, there's just a blank page att http://phoenix.glxtreem.net/ so far. :) We could use some sweet logo through :P

Me neither :P

Andreaz
22-08-2006, 10:44 AM
Hi Andreaz

Bad news. My PC at home that gave me a funny color full screen version previously doesn;t display anything using the new version :(

I was using specifically the Input demo, and also took my previous version of the demo and ran it. Both just give me blank screens.

Its an AMD 64x2 4400, X1600 card and 1GM RAM.

What sort of tests can I do to try work out what the problem is.

Try changing the resolution, deaphtbits, vsync and so in TPHXScreen.Open and see if that helps.

Robert Kosek
22-08-2006, 02:28 PM
Andreaz, try Jupiter CMS (http://www.jupiterportal.com/). ;) You might find it handy and saves you time so you don't have to code one.

Keep up the good work, I look forward to fooling around with a release. :D

Andreaz
22-08-2006, 03:54 PM
Andreaz, try Jupiter CMS (http://www.jupiterportal.com/). ;) You might find it handy and saves you time so you don't have to code one.

Keep up the good work, I look forward to fooling around with a release. :D
Good idea, here it is, not that much content through :P

http://phoenix.glxtreem.net/index.php

Robert Kosek
22-08-2006, 04:13 PM
Bingo, looks good to me. ;) And since it has a built in forum, it's pretty handy I thought. (Too bad my sites are established, and so cannot migrate without... difficulty to say the least.)

jdarling
22-08-2006, 06:41 PM
I started playing with some Phoenix images I had on my system and came up with the following:

http://www.eonclash.com/phoenix/Phoenix.png

WILL
22-08-2006, 09:53 PM
Cool. :) Kinda reminds me of the FireFox/Thunderbird logos though. ;)

jdarling
23-08-2006, 01:23 PM
Actually its a modification of http://phoenix.lpl.arizona.edu/multimedia/images_page/index.php?category_id=2&image_id=2 removing Mars from the background and modifying the saturation points a bit. Now that you mention it, it does look like the fox on the globe :).

What I think would look really good for this project is something like; A phoenixish broad line on a compass (think shape, not full image) with the four corners pointed out. The head of the phoenix could makeup the top point, with the other 3 comming from the compass wheel.

Now if I could only figure out what is going on with the frigging texture loader and why it won't work at all. I can't get it to work with any project that I build, with our without the scripting stuff. So I'm obviously doing something wrong as the Sprites demo works fine when I compile it :(.

jdarling
23-08-2006, 01:58 PM
Ok, so now I've figured out how to re-produce the problem EVERY time. Create a project from the template, or copy paste the code below. If you create an image before you create the font the system will die, if you create the font then the image everything works fine. I don't know enough about the loading code to say what the problem is, but I know its a problem :)

{
Phoenix Demo
}
program Texture;

{$mode objfpc}{$H+}

uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes,
{ add your units here }
dglOpenGL,

sysutils,

phxClasses, phxFonts,
phxImages,

phxScreen;

var
Screen: TPHXScreen;
Img : TPHXImage;
Font : TPHXFont;
begin
// Create the window
Screen:= TPHXScreen.Create('Phoenix Texture', 100, 100, 800, 600);

// Open the window
if not Screen.Open then Exit;
// Doesn't work if the image code is here
//{
img := TPHXImage.Create;
img.LoadImage('test.bmp');
//}
Font:=TPHXFont.Create;
Font.LoadFont(ExtractFilePath(ParamStr(0)) + 'Arial16.phfnt');
// Works if the image code is here
{
img := TPHXImage.Create;
img.LoadImage('test.bmp');
//}

repeat
// Clear the window
Screen.Clear();

// ... do the rendering here ...
img.Draw(0, 0);
Font.TextOut(5, 5, 'Testing the font engine', clrWhite);

// Flip the buffers
Screen.Flip();

until (Screen.Visible = False);
Screen.Free;
Font.Free;
img.Free;
end.

Robert Kosek
23-08-2006, 02:48 PM
Uh, Jeremy? That's because if you don't create the object you're loading something into nothing... hence the problem. You always ought to create/initialize the object prior to loading data into it. Hehe. :lol:

jdarling
23-08-2006, 03:22 PM
Actually, the highlighter is screwed up for pascal. Take a look at the comment blocking system, its being created. The code works fine in one instance and not in the other. By taking advantage of the pascal comment types you can use things like //{ //} to optionally comment out code. Course an IFDEF would be more appropriate, but I started doing this so long ago and just have never changed when its only testing :)

Andreaz
23-08-2006, 03:35 PM
Works both ways for me, but then i have a new version of the texture loader so it may be because of that...

jdarling
23-08-2006, 05:03 PM
LOL we need an SVN to keep up with the updates :). I've almost got all of the basic stuff wrapped up. Once I get the basics done I'll start adding in support for the event handlers. Only problem is that once I add them it will be very time consuming to change them, so I want to make sure that the basics are completely locked down.

PS: There was a post on GD.net about some guy making logos to help build is online portfolio. I asked for one for the project, if he comes through I'll cover the expense ($10) if you want to use it.

Also, put up the new loader code and I'll see if it makes a difference. Just the one unit would do ;)

Andreaz
23-08-2006, 05:41 PM
The new texture loader is uploaded to the homepage, not tested it fully yet through, you have to change the loading functions in the font to:


//------------------------------------------------------------------------------
Function LoadFontTexture(FileName: String): glUint; overload;
var Manager: TPHXTextureManager;
var W, H : Integer;
begin
Manager:= TPHXTextureManager.getInstance();
Manager.setMipmaps(True);
Manager.setFilter(tfLinear, tfLinear);

Result:= Manager.LoadTexture(FileName, W, H);
end;

//------------------------------------------------------------------------------
Function LoadFontTexture(FileName: String; Stream: TStream): glUint; overload;
var Manager: TPHXTextureManager;
var W, H : Integer;
begin
Manager:= TPHXTextureManager.getInstance();
Manager.setMipmaps(True);
Manager.setFilter(tfLinear, tfLinear);


Result:= Manager.LoadTexture(FileName, Stream, W, H);
end;


And similar for the image class

Andreaz
24-08-2006, 08:23 AM
Any changes with the new texture loader ? And the part about the logo is just great, much appriciated :)

I'm currently working on the gui engine + editor. Have converted it to a binary format though, much easier to work with and faster aswell. The editor's powerfull enough to not being able to change the gui components manually :)

jdarling
24-08-2006, 01:35 PM
Well, the new code helped me track down a little further into the problem. Seems there is something about MS Paint that the loader doesn't like. I save the image off in paint and when I try and load it, the system blows up. Re-Save it in ArtWeaver still blows up. Create a new image in ArtWeaver and everything works fine, so its something to do with the format that MS Paint uses :(

I now have quite a bit of the scripting engine working, soon as I get the input stuff done I'll post up a new snapshot of the code and the demo.

jdarling
24-08-2006, 02:09 PM
And more information, its actually a power of two thing. If I make the bmp file from MS Paint 256x256 instead of 143x107 everything works fine. So, now there needs to be some image scaling done to get everything to work properly :(

Andreaz
24-08-2006, 02:38 PM
Yeah, non power of two texture is not supported by most hardware and if it are it will be without mipmaps and so forth.

So that's really not that much to do about, could use some kind of scaling function when loading the textures, but that will only result in streched textures and longer loading times. It's better to let the users scale the textures beforehand (For example setting the rest of the image to transparent).

This is the main reason to why alpha blending is enabled by default in all rendering functions :)

jdarling
24-08-2006, 03:47 PM
Well, the scripting stuff is wrapped up enough that I feel comfortable letting everyone see it :). In fact you can do quite a bit with the scripting engine and whats available through the game engine already. I'd go as far as to say that you could write an entire game :).

Download: http://www.eonclash.com/phoenix/Phoenix2006-08-15.zip

The only known issues:
Using Mouse:Hide() causes problems when in windowed mode, Andreaz can you look into this?

I've kept the exe's in place in case people want to download and simply run it (or play with the Lua script, game.lua). The scripting sample is in \Phoenix2006-08-15\demo\Scripting\bin

jdarling
24-08-2006, 07:30 PM
Well, I said you could build a game in Phoenix with the Lua scripting support and now I'm backing it up. Granted that the collision detection works horridly (I'm lazy and haven't worked it out proper yet), the game is still playable. You can win or loose. Use the arrow keys to move your dragon, the space bar to shoot. One shot, one kill, one life. You can die, kill all the archers to "Win".

Basically I've utilized the resources from Dragon Flight and created a VERY simple game with them just to prove it could be done.

Download here: http://www.eonclash.com/phoenix/PDF.zip

EXE and Resources included along with all script source.

PS: Cairnswm thanks for a simple enough implementation of a game that I could copy it crappy as I did :). Next comes some of the more difficult tasks to wrap up such as the built in collision detection and a few other things.

Andreaz
25-08-2006, 08:04 AM
Looks nice indeed :)

The collision problems is due to that the actual visible pixels of the images is less then the patterns size, you'll have to overide the

// Get the bounds of the sprite, used for rectangular collisions and Optimisations. }
TPHXSprite.Procedure getBounds(var Rect: TRectf); virtual;
// Get the circle for the sprite, used for circular collisions.
TPHXSprite.Procedure getCircle(var Circle: TCirclef); virtual;
// Get the convex polygon for this sprite, used for polygon collisions.
TPHXSprite.Procedure getPolygon(var Polygon: TPolygon); virtual;

functions to specify better colision rectangles. I'm considering changing how this works as there's some overhead in the current version to the following:


TPHXCollisionInfo = record
Bounds : TRectf;
Radius : Single;
Polygon: TPolygon;
end;

TPHXSprite
property CollisionInfo: TPHXCollisionInfo read FCollisionInfo write FCollisionInfo ;


Will make it faster and more easy to use. And will make all 3 of the current collision algorims equal (atm Bounds and circle uses the absolute position of the sprites, Polygon the relative postion). Considering changing the collision engine selection to the following aswell:


TPHXCollisionMethod = (
cmRectangle,
cmCircle,
cmPolygon
);

Type TPHXSpriteEngine
Property CollisionMethod: TPHXCollisionMethod read FCollisionMethod write setCollisionMethod;


This will make the collision selection much easier for the user and it opens up for some additional optimizations aswell.

Probably going to add a 4th collision method, cmPixel using the new TPHXBitmap class for the pixel data.

jdarling
25-08-2006, 01:10 PM
Andres, the problem with the way that collision (and many other things) are implemented right now is that it doesn't incorporate well into the scripting environment without me subclassing the existing top levels. Something that I will be doing in a future version.

As an example, I can't override the getRectangle method inside of a script. If instead, Collision.Rectangle were availalble as a property I could change it :). Instead I'm not even using the built in collision, and doing it all by hand inside the Lua script itself.

Another thing that this showed me is that we need a collision list available to the scripting engine. Something that says I collided with these other items. Again this will all come from the sub-classing once you get the objects to a completely stable state (code locking the interface is what is necessary).

How long until we get pixel perfect collision working?

Andreaz
26-08-2006, 07:13 AM
Yeah, seems the truly oop way of doing stuff not always is the best there is :)

I'm going to be away this weekend so perhaps sometime the next week, There's some issues handling patterns and so that needs a solution :P

Andreaz
27-08-2006, 05:28 PM
My registration of glxtreem.net expired yesterday, working on getting it extended, hopefully i will be able to so so soon

Robert Kosek
27-08-2006, 09:03 PM
If you need project space, IE have trouble renewing yours, just let me know. I've plenty to lend a hand with.

jdarling
28-08-2006, 12:49 PM
Andrez I have more space then I know what to do with on our servers. Should be easy enough to set you up with a sub-domain or domain space (if you have the name already). Last time I checked I have something like 20 Gb of space but it may be a bit more or less :).

EDIT: Actually just check your PM queue you have a message with all the info in it.

Andreaz
04-09-2006, 05:54 AM
Yeah, it seems the domain is beyond hope, the registator doesn't reply to the emails i sent regarding the renewal. So guess i'll have to register a new one. Kindof dull if you ask me :O

Traveler
04-09-2006, 09:28 AM
Yeah, you lost it :(
It seems some add site has claimed it now.

Not too long ago there was a discussion whether or not delphigamer.com should be renewed. Your (ex)domain makes the perfect example of what happens when it wont be renewed.

Andreaz
04-09-2006, 10:13 AM
Yepp, i even tried to get in hold of em thin january but they didnt want to answer at that time either. Really annoying

Andreaz
07-09-2006, 08:58 AM
The page is now up and running at jdarlings site:

http://phoenix.eonclash.com/

Seems to be something bugged with loggin in through, just keeps complaining on invalid passwords, dunno way throught.


Have anyone had a look on the sprite engine, any suggestions on it at its a central part of the engine ?

I have some thoughts on going away from the current rendering method of glVertex to have some kind of render context where the sprites are rendered to if marked as moved, but dont know how big performance gain it will be, probably guite large i suppose.

Pixel collison is put on hold, i have no good way of exposing the pixel data atm, it creates alot of memory overhead to need to store each texture both in the gpu memory for opengl and in the ram for collisions.

Andreaz
25-10-2006, 01:24 PM
Time for a small status update !

Have made a quite nice list of changes and tweeks over the last few days, added a whole new logging system so its much easier to track what is happening and if any errors are encountered.

Also made some changes to the screen class, it's now instanced automatically so the user doesnt need to create it every time, now its's simple:


Screen:= TPHXScreen.getInstance;

// Open the screen
Screen.Open('Phoenix Component Demo', 100, 100, 800, 600);


I've also reworked all the callbacks both for the screen and input so they support removing aswell.

Lastly i've improved the gui engine quite extensivly, added support for hint rendering and cleaned stuff up, it's possible to have multiple font and imagelists assigned to the engine for instance.

As a final note Mario Russo is creating the official logo for Phoenix and i must say it looks really good :)

The whole project is reaching a state where it's stable enought for a first official release :)

Hope the news that the project isnt abandoned is good news :)

savage
25-10-2006, 01:52 PM
Hope the news that the project isnt abandoned is good news :)

Some people say that "no news is good news", but I'm not so sure of that. My grand father was last seen walking into a crocodile infested river in Australia ( when I was 4 ), and we have not heard from him since. Would you consider that lack of news good?

I'm all for news, the more news the better! Where are the screenies??

Andreaz
08-11-2006, 07:22 PM
Finally the phoenix homepage is up again, not much content there yet, but you can check out the new logo and download the latest beta release :)

There's been alot going on latly, not much new stuff but plenty of fixes and tweeks of the current components and tools.

Check it out and post you'r comments here :)

http://www.phoenixlib.net/

savage
08-11-2006, 09:32 PM
Wow, cool logo!

tanffn
08-11-2006, 10:15 PM
I'll second that!

FNX
09-11-2006, 11:53 AM
IT - IS - AWESOME!! :shock: So must be the lib then ;)

jasonf
09-11-2006, 12:46 PM
I'm loving that logo. Nice bright colours. The Blue goes well too.

jdarling
09-11-2006, 01:33 PM
The logo does look good. Now you just have to come up with a smaller version that can be easily displayed on web pages to let people know something was done with Phoenix.

WILL
09-11-2006, 02:50 PM
Well since the Phoenix Engine has sort of been released as a packaged product, it might be worth making a new thread in My Projects called 'Phoneix Engine' to be posted on the front page, no? :)

Andreaz
09-11-2006, 10:08 PM
Yeah, very soon, going to wrap up the new image and animation editors first and then a overhaul of the sprite engine. Then it's fit for a official release :)

WILL
09-11-2006, 10:50 PM
Nice. :) Well till then, baited breath for many, I'm sure. ;)

bigsofty
13-11-2006, 01:46 AM
There is a 24meg mp3 file in the sound demo, this bloats the package, is it a mistake?

Andreaz
13-11-2006, 06:10 AM
No, the huge wav file is not a mistake, but it won't be in the official releases.

Having some problems with the collision part of the sprite engine, the collision detection works as it should, but there's something wrong with the collision responces. Other then that I think everything is ready for the 1.0 release :)

tanffn
13-11-2006, 09:05 AM
Do you think you can include the demos precompiled for the lazy programmers among us? (obviously my self included)

Andreaz
13-11-2006, 10:41 AM
Yeah, i'll make a binary release aswell, it tends to get alot bigger so there will be a source only release to, but not until 1.0 :)

Seems to be some bug or something I've overlooked in the collision algoritmh that makes some polygon's collision responce data not correct. Somewhat annoying because the collision detection is working like a charm.

Andreaz
17-11-2006, 05:47 PM
I've uploaded what i'm hoping for the latest beta version of the engine on the homepage and we need some help testing it out.

All the demos are avaiable in binary format aswell.

If you feel like it, please download the library and try it out. And please post any results here, everything from it works nice to bugs is welcome. And please post you'r system speccs aswell.

tanffn
17-11-2006, 10:49 PM
Very nice Andreaz!

Don’t get this the wrong but I you are still far away from reaching version 1.. maybe I should not post this as I didn’t follow the entire thread but I feel there are many components lacking for it to become a game engine/lib. (let me know if you need more info)

Particles FPS: 450-500;
Sprites: 970;
Spec: AMD 3500+, GeForce 6600, 1GB RAM, XP sp2;

Now with Sounds.exe I had a problem, it did work but the kernel used 90%+ of the CPU.
00:40 TPHXSoundEngine.Init: Opening OpenAL device.
00:40 TPHXSoundEngine.Init: OpenAL version : OpenAL version 1.0
00:40 TPHXSoundEngine.Init: OpenAL renderer : SB Audigy 2 Audio [9000]
00:40 TPHXSoundEngine.Init: OpenAL vendor : Creative Labs Inc.
00:40 TPHXSoundEngine.Init: OpenAL extensions: EAX
EAX1.0
EAX2.0
EAX3.0
EAX4.0

00:40 TPHXSoundEngine.Init: Initialized 63 sources .
00:40 TPHXSoundEngine.getDevices:
00:40 TPHXSoundBuffer.LoadBuffer: Loading sound: ins.wav
00:40 TPHXSoundBuffer.LoadBuffer: Loading sound: smb3_jump.wav
00:40 TPHXSoundBuffer.LoadBuffer: Loading sound: ding.wav
00:40 TPHXSoundBuffer.LoadBuffer: Not a valid wave file.
00:40 TPHXTextureManager.LoadTexture: Loading texture from stream: Arial16_00.tga

Andreaz
18-11-2006, 08:54 AM
The 100% cpu utilization is normal, all demos uses a simple repeat.. until window.visible = false as a main loop.

You have to specify more what you feel is lacking, the framework (really engine is the wrong word and not what's intended) already got all the components DelphiX has and a few more.

Andreaz
18-11-2006, 09:00 AM
Oh, and I seemed to missed to include the ding.wav in the release, that's why you get that message, i've uploded it to the homepage, wich btw is a placeholder, i'm working on a new one!

tanffn
18-11-2006, 09:41 AM
The 100% cpu utilization is normal, all demos uses a simple repeat.. until window.visible = false as a main loop
100% utilization is fine, but there are two kinds kernel usage and application usage. Kernel usage (which appears in red, unlike normal process which appear in green) should NOT be high, if its in 90% it means that *all* apps are sharing/using only 10% of the CPU.

When I run the other demos cpu utilization is still 100%, 97% green and only some red. windows operation is still fine (Everything runs smooth) unlike the sound demo that freezes windows.

Andreaz
18-11-2006, 10:40 AM
Oh, i see, what things can cause such a thing, might it be OpenAL related ?

tanffn
18-11-2006, 11:52 AM
Probably, maybe I need to update my drivers.. I’ll give it a try. And lets here some feedback from other testers, maybe its localized to my configuration?

Andreaz
18-11-2006, 12:34 PM
Yeah, sounds good, what other features is it that you feel is needed before the 1.0 release ?

tanffn
18-11-2006, 07:39 PM
GUI - More controls (TList, TcheckBox, TRadioBnt, TMemo, more?) and finish the existing one (i.e text scroll for the edit box, resizable and skinable (windows style) form)
Sprites engine - easily create and control sprites and their events. (maybe you have that, didn’t look at the code *)
Physics - would be nice :) collations transfer of energy, friction, gravitation/force points.
Collision - make it vector based not rect based (each object can have n collideable lines), add pixel test collision.
3D features - allow loading and rendering of models (instead of pre rendering the animation), and generally allow/integrate all of the possibilities you have in a modern 3D card.
Alimentary drawing routines - draw line, circle, polygon, etc.

* More examples that easily demonstrate the operation.

There are many more things that you can add but I think the above is the elementary features that is needed to be added (apart from Physics, 3D features).
Sadly the current semester don’t leave me any of free time.. but I will try to help you in any of the above topics.

XTRiZ
18-11-2006, 10:29 PM
Hi,

i might be wrong here but the collisiontests availible in the sprite demo is rectangle, polygon and circle. Not only rectangle.

I think it looks great, keep up the good work, every single demo works for me..

system:
AMD X2 3800+, 2GB Ram, 2x GF 6800 256MB. Integrated 7.1 Channel Sound (On the Ati Fatal1ty MB) ..

Rgrds,
Peter

tanffn
18-11-2006, 10:36 PM
i might be wrong here but the collisiontests availible in the sprite demo is rectangle, polygon and circle. Not only rectangle.


:oops: You're right, I missed that. Collision works great.

I'll test the sounds demo tomorrow at work, I'll have plenty of computers to test it on.

Andreaz
20-11-2006, 08:47 AM
GUI - More controls (TList, TcheckBox, TRadioBnt, TMemo, more?) and finish the existing one (i.e text scroll for the edit box, resizable and skinable (windows style) form)

Checkbox and radio button is already there, ListBox is wip (even included in the component palette in the editor). I'll readd the scrolling of the edit aswell (was in the glx version, but never got around to copy it over)

I'm not shure what you mean with skinnable as each component is rendered as a image, this makes resizing components somewhat difficult to handle (stretched gui controls don't look good, trust me)

There's also a progress and a table included already. The current rendering method makes more advanced controls, such as a scrollbar quite tendersome to implement, the texture coordinates for each part of the component is static, wich makes for alot of work when there's many faces, (a button is 4, a scrollbar is atleast 12 or so).

This is the drawback of the image based approach of the gui, the positive thing is that you can have the gui look just like you want.



Sprites engine - easily create and control sprites and their events. (maybe you have that, didn’t look at the code *)

Tried to make it as easy as possible, have a look at the code and say what you thinhk :twisted:



Physics - would be nice :) collations transfer of energy, friction, gravitation/force points.

I feel this is somewhat of a two sided issue, the current engine is very easy to handle, no need to mess with vectors and forces and such if you dont want to, but it's still possible to add it yourself. The goal of the engine is to have it very easy yet powerfull and this might clash.



Collision - make it vector based not rect based (each object can have n collideable lines), add pixel test collision.

Allready ansvered, pixel collisions is not so straight forward as the pixel data of the images (read texures) is never saved (to save memory) and there's really no way of extracting it from OpenGL. This is still something i want to do but I can't really come up with a good way of doing it.



3D features - allow loading and rendering of models (instead of pre rendering the animation), and generally allow/integrate all of the possibilities you have in a modern 3D card.

There wont be any 3D routines in Phoenix, atleast not until all the 2D functions are polished. And i've already made a 3D engine aswell :)



Alimentary drawing routines - draw line, circle, polygon, etc.

Planned, started but not finished :)



* More examples that easily demonstrate the operation.

More demos is comming, there will be some game demos in the future aswell, and there have been some interest in writing tutorials aswell.



There are many more things that you can add but I think the above is the elementary features that is needed to be added (apart from Physics, 3D features).
Sadly the current semester don’t leave me any of free time.. but I will try to help you in any of the above topics.

There's a few more things i have in progress, a tile engine is one of em, with support for both rectangular and isometric perspectives and with sprite collision support. Going to add perspective calculations to the sprite engine aswell so it also supports isometric perspective.

XTRiZ
20-11-2006, 06:00 PM
I fired up my BDS2006 env, and thought i could load your examples .. hehe, the sprite example for example, this one isn't really for BDS ??, .lpi gotta be another env. But hey renamed, removed a ifdef, and started to try to compile it, but i guess i have to do more testing as it doesn't compile.. Are you going to put in some BDS examples later too ??

rgrds,
Peter

cairnswm
21-11-2006, 05:34 AM
.lpi is for Lazarus.

But last time I checked there were only minor changes required to get it working in Delphi (But I used D7)

tanffn
21-11-2006, 10:47 AM
Thanks Andreas for the clear response :)



I'm not shure what you mean with skinnable as each component is rendered as a image, this makes resizing components somewhat difficult to handle (stretched gui controls don't look good, trust me)

I mean use 6-8 images to buld the form/window.

http://upload4.postimage.org/1708782/stam.jpg (http://upload4.postimage.org/1708782/photo_hosting.html)

a-d edges, e-f (+2 for asymmetrical form) are small and are drawn several times to complete the entire length.

Andreaz
22-11-2006, 07:00 AM
I see what you mean, had some discussions yesterday about redesigning the rendering of the gui engine, partly so it's easier to do it the way you sugggested:

Instead of now, where you select a image for each component, the engine will have a list of wanted pattern indexes, for example:

button_normal
button_down
checkbox_normal
checkbox_checked

and so on. Then in the gui editor the user will be able to pick a pattern index for each of the predefined faces above, thus the gui will only consist of one image with alot of patterns.

tanffn
22-11-2006, 08:22 AM
I don’t think it worth making a major change to the GUI, resizable components are ‘nice to have’ but I don’t think its mandatory. I actually proffer the 3D features that you said you won’t include :roll:

bigsofty
22-11-2006, 12:39 PM
Remember the title of this thread, this is all about a better 2D game engine, a couple of buttons and check boxes are fine for the end users game options, as for GUI for the creation of editors etc. well allow a windowed mode and let Delphi take of the windows based GUI.

Andreaz
22-11-2006, 06:06 PM
Well, i'm almost done with the new version of the gui, and i must say it's vastly supperior to the old variant, so stay tuned for it :)

Andreaz
01-12-2006, 10:50 AM
Been putting alot of hours into the editors latly and decided to give a sneek preview:

http://www.phoenixlib.net/

Inlcuded in the rar is the Image, Animation, Particle and GUI editors, take a look if you're interested :)

savage
01-12-2006, 11:21 AM
Will Pheonix handle isometric games as well? Maybe as a future enhancement?

Andreaz
01-12-2006, 11:37 AM
I'd really love to make both the sprite engine and the planned tile engine to be able to handle both the current, rectangular perspective and an isometric one, but i havn't came up with a good way of doing it. Ideas is welcome

I really want to make a tile engine that handles isometric as well as top-down perspective but havnt really come up with enough features to really start it.

One more thing that i really want to improve is the collison engine, adding support for rotations, fast moving objects and collision points.

Traveler
01-12-2006, 11:48 AM
The editor download link on your page doesn't seem to be working.

I did check those demos and I must say those are pretty incredible. I totally loved the gui interface. I was wondering though, the window in the back, displaying all the stuff that's going on in the background, can it be turned off?

Andreaz
01-12-2006, 02:31 PM
The editor download ]
I hate case sensive systems, it's working now :) Thanks

[quote="Traveler"]
I did check those demos and I must say those are pretty incredible. I totally loved the gui interface. I was wondering though, the window in the back, displaying all the stuff that's going on in the background, can it be turned off?
Good to hear you like it, you've been a huge source of inspiration for me over the years :)

The gui in the page is old it looks even better now :) What window are you talking about ? In the gui demo there's only one window, the rest is just a background image and some textout's :)

Traveler
01-12-2006, 04:03 PM
What window are you talking about ?

Ah, I understand your confusion. I actually meant the console that opens up when starting a demo. It's displaying texts about initializing the engine, loading of images and more.

Andreaz
01-12-2006, 11:18 PM
Oh, yes, you can just create a datamodule as the main form and ignoring the apptype console and you doesnt get the console window, good for debug through :)

Andreaz
02-12-2006, 10:01 AM
One additon to the above, make shure to undefine the LOG_TO_SCREEN define in phxConfig.inc if you dont have a console window :)

Galfar
29-01-2007, 12:58 PM
Is Phoenix still being developed?
I'm thinking of using it in one of my projects but I would like to know if there will be some new versions and updates.

Andreaz
29-01-2007, 04:44 PM
Well it aint dead if it that you mean, i have some serious lack of spare time to devote to it atm through, but I always have time for support and questions about the engine :)

Galfar
30-01-2007, 04:35 PM
Thanks for reply, that's good to hear (except the lack of spare time of course).

Galfar
20-02-2007, 01:25 PM
Well it aint dead if it that you mean, i have some serious lack of spare time to devote to it atm through, but I always have time for support and questions about the engine

I'll be using Phoenix for my Multiplexity entry. Is there a version newer than Phoenix2006-11-17.rar from phoenixlib.net out there somewhere? I'll be probably doing some modifications/additions/fixes to Phoenix (some new GUI controls, some canvas drawing - line/circle/..., another texture manager, maybe DXTC for textures, ...).

Andreaz
16-03-2007, 06:15 AM
I'll be using Phoenix for my Multiplexity entry. Is there a version newer than Phoenix2006-11-17.rar from phoenixlib.net out there somewhere? I'll be probably doing some modifications/additions/fixes to Phoenix (some new GUI controls, some canvas drawing - line/circle/..., another texture manager, maybe DXTC for textures, ...).

Hey, sorry for the late reply, have been moving to a new apartment thus i've had no internet for a while.

There's no official release since november, there's however a number of fixes done since then, for instance the canvas drawing is added already, aswell as some fixes to the gui engine, default buttons and some other stuff.

What part of the texture management do you feel is lacking in Phoenix, exept for DXTC compression ?

godbeast
16-03-2007, 09:58 AM
Hey Andreaz!

I have some questions regarding Phoenix. I'm a total newbe to OpenGL, I've been looking at Phoenix sources to see how to use Ogl in 2d. Phoenix turned out to be something what I've been looking for, it totally suits my needs for 2d. Now the question is, does Phoenix allow such process:

1) do Phoenix stuff in 2d
2) swith to 3d view by OpenGl routines
3) do 3d OpenGL stuff (model animation)

etc. I.e., is there a possibility of stable mixing Phoenix/OpenGL?

Andreaz
16-03-2007, 02:48 PM
Hey Andreaz!

I have some questions regarding Phoenix. I'm a total newbe to OpenGL, I've been looking at Phoenix sources to see how to use Ogl in 2d. Phoenix turned out to be something what I've been looking for, it totally suits my needs for 2d. Now the question is, does Phoenix allow such process:

1) do Phoenix stuff in 2d
2) swith to 3d view by OpenGl routines
3) do 3d OpenGL stuff (model animation)

etc. I.e., is there a possibility of stable mixing Phoenix/OpenGL?

Yeah thats's totally possible, i dont mess with OpenGL in some special way to make it 2D only, there's a setOrthoMode function in phxScreen that sets the screen to orthographic mode as default

I have no plans right now of creating any model animation stuff myself for it but there's no problem from the phoenix point of view of implementing it. (You may wanna skip the imagelist for loading textures for the models and go via the texrure loading classes as the imagelist creates some overhead to speed up the 2D rendering that's not needed for 3D textures)

godbeast
16-03-2007, 04:18 PM
Just great, thats what I need. Phoenix seems easy to use, learing OpenGL is different, but I plan to implement model animation system myself (you will probably be faster than me).

Galfar
16-03-2007, 05:01 PM
There's no official release since november, there's however a number of fixes done since then, for instance the canvas drawing is added already, aswell as some fixes to the gui engine, default buttons and some other stuff.
Could you please put those new sources somewhere for download?



What part of the texture management do you feel is lacking in Phoenix, exept for DXTC compression ?
I just don't want that 1MB FreeImage DLL so I will add alternative loader.

wagenheimer
20-03-2007, 06:21 PM
My Game, "Abra Academy", done using the Phoenix Engine, was just released by BigFishGames!

http://www.bigfishgames.com/downloads/abraacademy/index.html

I really want to thanks Andreaz for all help and support that he give me! =)

I´have implemmented a lot of new things to Phoenix... but my code is a mess! I did see that there more people here implemmenting news things to the engine.... it would be nice to everybody that changed things, comment it and show here what was doing. What did you think?

I would like to help any way possible!

Traveler
20-03-2007, 11:14 PM
A bit off topic, but your game looks very professional. You really should create annother thread about it, with some additional info on how you made it, how long it took, a screenshot, etc. I or one of the another admins will most likely make an newsitem out of it.

As for your Phoenix changes suggestion, I can only agree with that.

Andreaz
21-03-2007, 06:17 AM
I´have implemmented a lot of new things to Phoenix... but my code is a mess! I did see that there more people here implemmenting news things to the engine.... it would be nice to everybody that changed things, comment it and show here what was doing. What did you think?

Great idea!

The source and demo for the canvas stuff is avaiable here:

http://www.phoenixlib.net/files/Canvas.zip

Don't feel that the whole lib is in a state for release atm, need to test so nothing has broke ;)

Andreaz
23-03-2007, 06:24 AM
I just don't want that 1MB FreeImage DLL so I will add alternative loader.

Oh, i see. Have you taken a look at the texture loading framework in phxTexture, as you see it's plug and play and it's really easy adding a different loader then freeimage. If you need any help with this, please let me know ;)

Galfar
25-03-2007, 12:10 AM
Oh, i see. Have you taken a look at the texture loading framework in phxTexture, as you see it's plug and play and it's really easy adding a different loader then freeimage. If you need any help with this, please let me know ;)
Yes, it looks quite easy. I'll let you know if will have some questions.

Just one unrelated question: do you know a way of telling Phoenix's glfw window not to have a maximize button and not to allow resizing?

Andreaz
25-03-2007, 03:58 PM
Just one unrelated question: do you know a way of telling Phoenix's glfw window not to have a maximize button and not to allow resizing?

Well, there's some code that in the CVS repository of glfw for it, but it hasn't been relased or compiled to a dll yet, but i suppose it's in the pipe.

godbeast
12-04-2007, 05:28 PM
I came up with something like this (fpc messages):

First compilation of e:\projekty\fpc\2.0.4\units\phoenix\src\phxscreen. pas
phxscreen.pas(474,47) Error: Incompatible type for arg no. 1: Got "<address>", expected "<procedure>"
phxscreen.pas(475,46) Error: Incompatible type for arg no. 1: Got "<address>", expected "<procedure>"
phxscreen.pas(547,42) Error: range check error while evaluating constants
phxscreen.pas(608) Fatal: There were 3 errors compiling module, stopping
phxscreen.pas(608) Fatal: Compilation aborted

What's wrong? I don't mess with fpc cfg, I use standard configuration and my version is 2.0.4. I'll fight by myself right now, but if somebody knows the solution?

godbeast
12-04-2007, 05:30 PM
And this is when it happens:

In phxscreen.pas: glfwSetWindowCloseCallback(@WindowCloseEvent);
Line 474

Andreaz
14-04-2007, 06:31 AM
Hmm, that's strange i have 2.0.4 aswell but i don't get that error, anyone has any ideas of what's causing it ?

godbeast
14-04-2007, 09:05 AM
These comes out when I try to compile with standard fpc configuration mady by installer. When I change certain options, fpc shows other strange errors.

If you have 2.0.4 also, I think that reasons could be either my config file for fpc or I messed up with Phoenix installation. I just added phoenix\src and phoenix\lib directories to fpc units path. Should I do something more?

Galfar
15-04-2007, 01:07 PM
Oh, i see. Have you taken a look at the texture loading framework in phxTexture, as you see it's plug and play and it's really easy adding a different loader then freeimage. If you need any help with this, please let me know
I've added texture loader which uses Vampyre Imaging Library to load/save image instead of FreeImage. As you wrote, it was really easy to extend Phoenix in this way. If you are interested the modified source is here: http://galfar.vevb.net/temp/phx/phxTexture.pas.

But I have a question about GUI. In archive labeled "Demo of the editors (particle, image, animation and gui)" on phoenixlib.net is GUI editor with listbox and scrollbar controls and whole GUI uses controls.phximg for skinning. However, archive with source code contains some different version of GUI engine (without listbox and without using patterns for skinning). Which one of those should be used? Any chance you could upload current GUI engine somewhere?

Andreaz
15-04-2007, 07:09 PM
Good work with the image loader :)

I've decided to release what's new since the last release, note that there's alot of untested stuff in this release, but i guess most thing should work, there's alot of improvments in the gui part, mouse selection in listbox, mouse works for scrollbar aswell, default and cancel buttons and alot of bugfixes.

I've also improved the imagelist editor, a start version of a texture packer is included but there's some nasty bug that makes an access violation that i havn't been able to track down yet, also improved the pattern editing, now you can even zoom :)

Get it while it's hot
http://www.phoenixlib.net/

Galfar
15-04-2007, 10:32 PM
Get it while it's hot
http://www.phoenixlib.net/
Great stuff here, thanks.

godbeast
16-04-2007, 12:06 PM
Would like to taste it, but still can't compile. What enviroment do you poeple use to compile Phoenix?

Galfar
16-04-2007, 12:17 PM
Would like to taste it, but still can't compile. What enviroment do you poeple use to compile Phoenix?
I use Delphi 2006. I tried it with latest Lazarus (default installation in Windows) and it works too.

Andreaz
16-04-2007, 03:35 PM
Would like to taste it, but still can't compile. What enviroment do you poeple use to compile Phoenix?

I'm mainly using Delphi 7 for the development.

One think i can think of through; are you using standalone fpc or lazarus ?

godbeast
16-04-2007, 03:43 PM
Standalone fpc

Andreaz
16-04-2007, 03:47 PM
Standalone fpc

Okey, then it's probably something lazarus does different, dont ask me what through, i'm no lazarus expert

godbeast
16-04-2007, 03:56 PM
I'll install it and will post later if something moves on, thanks for the clue :D

godbeast
16-04-2007, 04:36 PM
Compiles awfully nice with Lazarus :D Anyway I'm gonna findout why Phoenix doesn't like clean FPC

WILL
16-04-2007, 06:24 PM
What version of Lazarus are you using? The current one uses FPC 2.0.4.

Perhaps it's a compiler directive that Laz uses and it's simply missing with your usage of FPC raw.

Galfar
17-04-2007, 09:00 AM
Compiles awfully nice with Lazarus :D Anyway I'm gonna findout why Phoenix doesn't like clean FPC
I've found the problem, it is compiler mode related thing in glfw.pas.
Just add this:
{$IFDEF FPC}
{$mode objfpc}
{$ENDIF}

to glfw.pas somewhere (I put it right after interface keyword and it works).
Looks like Lazarus automatically uses OBJFPC mode but clean FPC does not.

Andreaz
30-04-2007, 03:25 PM
Hi again :)

Some progress update and v1.0 roadmap!

I'm currently working on a tile engine and editor, why a tile editor you say, cant the sprite engine cope with that. Short answer is that it might but there's alot of speed optimizations that can be done when we know we're dealing with tile maps instead of random sprites.

As a side project to get this flexible i'm extending and fixxing the collision detection and responce functions, look forward to circle->plygon collisions and such, if i can get the SAT to work ofc :roll:

But writing a generic tile editor for the sprite engine is tricky to say the least.

However the tile engine will support collision with sprites in the sprite engine, thus the combination sprite engine for player and other objects and then the tile engine for the "static" map. Now i havn't really decided on the feature set or how advanced it will be, what's clear now atleast:

* Unlimited size, but no disk streaming, may be to complex
* One image per map (tileset, with non rectangular patterns)
* Animated tiles
* Collision data for each tile
* Custom flags for each tile (object creation)
* Trigger areas (rectangular)
* Scripts included in the engine (language independent, lua pax...)
* Edge flags for the tiles, good for ai scripting and collision handling
* Support for "bigger then one tile" tiles (ie a 128*32 tile in a 32x32 tilemap).
* Alpha blending for all layers
* Object support with Y-sorting

features undecided upon / to be discussed (that's why this post)
* Layers: Static number (5 or so) or dynamic.
This really is a big cornerstone, have dynamic number of layers has the benefit on being very dynamic, but the file format of the tile maps gets very complicated and it will slow down rendering. The static variant has the benefits of being faster and easier to implement, both in the editor part and in the file format.

For the static layer variant i have 5 layers in mind if so:
Background: Basicallt the background layer
FringeBack : Fringe layer for creating transitions (sand->grass)
Object : Object layer, here will the character walk,
Foreground: Rendered above the object and background layers
FringeFore : Another fringe layer

As far as i can ses this woud be sufficent for most games, from top-view rpg's to side scrolling games, any ideas ?

Basically this and getting the page running is what i'm planning to do before releasing the first really official version, ideas and improvements is appriciated.

Legolas
30-04-2007, 03:45 PM
Nice features! About tilemap layers: what about a static-layer tilemap with the possibility to render another static-layers map on top? I'm thinking about a flag or a field in the map file format to specify another map to render on top of the current. Ugly, but it could do the job :scratch:

Andreaz
07-05-2007, 03:53 PM
Nice features! About tilemap layers: what about a static-layer tilemap with the possibility to render another static-layers map on top? I'm thinking about a flag or a field in the map file format to specify another map to render on top of the current. Ugly, but it could do the job :scratch:

After some testing and such i've decided for a linked list approach, every cell in the tilemap has t pointers pointing to the foreground layers and background layers, thus each tile can have different ammount of layers.

A bonus of this method is that's it really fast to draw each cell, there's no need to test if a layer has any data to render, and no extra looping for the empty tiles.

It will require some special code for the editor through, may have to do some kind of max_layer thingy in the editor and use static arrays there, just to get it alot easer to edit the maps...

Andreaz
07-05-2007, 04:21 PM
I've compiled a small demo of the tile engine so far, not that much fancy stuff, but a small preview.

The demo runs at 600fps or so at my system.

http://phoenixlib.net/files/TileDemo.zip

Traveler
07-05-2007, 08:19 PM
I have tested your tile demo. There's something funky going on though.
http://upload8.postimage.org/242147/test.jpg (http://upload8.postimage.org/242147/photo_hosting.html)

All images are somehow split in half and fps is terrible at ~55 and ~35 when scrolling.

It could possibly be related to Windows Vista, but I'm not really sure abou that.

Specs:
Core 2 Dual 2.6ghz,
2GB RAM,
GF 8800 GTS
Windows Vista
:oops:

Galfar
07-05-2007, 08:22 PM
Runs ok here, 450 fps with radeon x1950pro in Windows XP.

Legolas
07-05-2007, 09:55 PM
I have tested your tile demo. There's something funky going on though.
http://upload8.postimage.org/242147/test.jpg (http://upload8.postimage.org/242147/photo_hosting.html)

All images are somehow split in half and fps is terrible at ~55 and ~35 when scrolling.

It could possibly be related to Windows Vista, but I'm not really sure abou that.

Specs:
Core 2 Dual 2.6ghz,
2GB RAM,
GF 8800 GTS
Windows Vista
:oops:

Same problem here :think:
There is my logfile (http://pastebin.ca/476128), if it could be useful :)


Specs:
Core Duo @ 1.66 Ghz
1GB RAM
GF 7600
Windows XP

Andreaz
08-05-2007, 04:57 AM
I have tested your tile demo. There's something funky going on though.
http://upload8.postimage.org/242147/test.jpg (http://upload8.postimage.org/242147/photo_hosting.html)

All images are somehow split in half and fps is terrible at ~55 and ~35 when scrolling.

It could possibly be related to Windows Vista, but I'm not really sure abou that.

Specs:
Core 2 Dual 2.6ghz,
2GB RAM,
GF 8800 GTS
Windows Vista
:oops:

I've managed to repreduce that error in the editor, works in the console version trhrough... odd.

what seems to cause it through is the following code snippet



Procedure Draw
var AVertices &#58; Array&#91;0..3&#93; of TVector3f;
var ATexCoords &#58; Array&#91;0..3&#93; of TVector2f;
var AColors &#58; Array&#91;0..3&#93; of TColor4f;
begin
glVertexPointer &#40;3, GL_FLOAT, SizeOf&#40;TVector3f&#41;, @AVertices&#91;0&#93;&#41;;
glTexCoordPointer&#40;2, GL_FLOAT, SizeOf&#40;TVector2f&#41;, @ATexCoords&#91;0&#93;&#41;;

glDrawArrays&#40;GL_TRIANGLE_STRIP, 0, 4&#41;;
end;


by moving the arrays out of the loop it works again through...


var AVertices &#58; Array&#91;0..3&#93; of TVector3f;
var ATexCoords &#58; Array&#91;0..3&#93; of TVector2f;
var AColors &#58; Array&#91;0..3&#93; of TColor4f;

Procedure Draw
begin
glVertexPointer &#40;3, GL_FLOAT, SizeOf&#40;TVector3f&#41;, @AVertices&#91;0&#93;&#41;;
glTexCoordPointer&#40;2, GL_FLOAT, SizeOf&#40;TVector2f&#41;, @ATexCoords&#91;0&#93;&#41;;

glDrawArrays&#40;GL_TRIANGLE_STRIP, 0, 4&#41;;
end;


Strange to say the least

Andreaz
08-05-2007, 05:04 AM
I've uploaded a fixxed version, the same link as the last one, try if it's any better.

(Using the vertex buffers is a factor 2 or 3 times faster then using displaylist calls fyi ;) )

Traveler
08-05-2007, 09:49 PM
The odd tiledivision is gone now. :)
FPS is still not even near the values you, Legolas and Galfar have posted though. Around 75, and 60 when scrolling.

I've tested the other demos for similar problems, but they performed a lot better.
Particle demo : ~800 fps
Sprites demo : ~2000fps

Legolas
09-05-2007, 03:09 PM
The odd tiledivision is gone now. :)
FPS is still not even near the values you, Legolas and Galfar have posted though. Around 75, and 60 when scrolling.

I've tested the other demos for similar problems, but they performed a lot better.
Particle demo : ~800 fps
Sprites demo : ~2000fps

I get a low framerate too (55/60 fps) on my laptop. The strange thing is that I get 80 fps on an older pc with an 8 megs ATI graphic card :shock:
Maybe is an issue related to nvidia cards.
On the other hand, on that old pc I can see the tiledivision when I scroll the map; some other tiles are flashing too passing from "left side bush" to "right side palm leaf"

Andreaz
11-05-2007, 04:37 AM
The odd tiledivision is gone now. :)
FPS is still not even near the values you, Legolas and Galfar have posted though. Around 75, and 60 when scrolling.

I've tested the other demos for similar problems, but they performed a lot better.
Particle demo : ~800 fps
Sprites demo : ~2000fps

Okey, strange that you are getting worse fps on the demos using vertex buffers (particles and tiles) when they are so much faster with my ATI X800 then the displaylists used by the sprites. Mine is really limited by fill rates and nothing else, i'm going to get together a few more tests...

One thing to note through is that the tileengine renders the whole level at once in that version and it will only render what's visible on a later stadge.

Diaboli
12-05-2007, 09:03 PM
i got OK fps (350) on my comp
2,8Ghz P4
1gig ram
128mb radeon 9800 atlantis pro

but there is one tile that seem to be swaping once each second. is that supposed to do that?

chronozphere
12-05-2007, 09:50 PM
Works great! :)

Particles: ~500 fps
Sprites: ~1800 fps

The particles look brilliant. Good job. :thumbup:

Edit: Tiledemo FPS is indeed a bit low. about 48 FPS here, but it looks fine. :)

specs:
AMD X2 5400+ (2x 2.8 Ghz)
2 GB RAM
Gforce 8600 GT.

Andreaz
13-05-2007, 05:14 PM
but there is one tile that seem to be swaping once each second. is that supposed to do that?

Yepp that's working as intended, it's showing that the tiles can be animated ;)

I've uploaded a new demo, first version of the editor with the basic functionallity implemented, loading and saving is working aswell.

A've also changed the drawing from triangle strips to quad, if you feel like it test if it works better;

http://www.phoenixlib.net/files/phxTiles.zip

Traveler
13-05-2007, 08:10 PM
I've also changed the drawing from triangle strips to quad, if you feel like it test if it works better;


Ohh, this is much better! I'm getting around 2000fps now. :D

Nice work on the editor too, btw!

Andreaz
13-05-2007, 08:22 PM
Thanks, odd that the quad rendering is faster, shouldnt really be, but well, it works better so ;)

pstudio
11-06-2007, 06:17 PM
How is it going with this lib? I've finally got a chance to check it out and it looks really promising. :D

WILL
11-06-2007, 06:26 PM
I think there has yet to be an official thread about the Phoenix Engine/Library. :lol: But it does seem to have a decent calling so far.