PDA

View Full Version : ZenGL



Andru
10-11-2010, 10:19 PM
http://zengl.org/logo_mini.png
Hello,

I have just completed to translate comments in demos into English(but my English is not well) and want to present you my own cross-platform library for game development :) It's fully written in Pascal without using any third party libraries, except some API's like OpenGL/OpenAL and Direct3D/DirectSound.

Current version: 0.2 RC4 (2010.11.11)
Official website: http://zengl.org
Download: Full package (http://zengl.googlecode.com/files/zengl-0.2rc4.7z)(demos, source code, headers, extra units), Direct3D version (http://zengl.googlecode.com/files/zengl-direct3d-0.2rc4.7z)(source code only, without demos)
SVN repository: http://zengl.googlecode.com/svn/trunk/
Tools:
ZenFont for GNU/Linux (http://andru-kun.inf.ua/zengl/tools/zenfont/ZenFont-linux-0.2.0.7z) and Windows (http://andru-kun.inf.ua/zengl/tools/zenfont/ZenFont-win32-0.2.0.7z) - old versions, new are coming soon
FontBuilder (http://code.google.com/p/fontbuilder/)(third part tool that support ZenGL format)
Help: Compilation (http://code.google.com/p/zengl/wiki/en02Compilation)

Supported OS: GNU/Linux, Windows, MacOS X
Supported compilers: FreePascal (http://freepascal.org) 2.2+, Delphi 7+
Graphics API: OpenGL, Direct3D 8/9
Sound API: OpenAL, DirectSound
License: GNU LGPL version 3 (http://www.gnu.org/licenses/lgpl-3.0.txt)

Main
- can be used as so/dll/dylib or statically compiled with your application
- rendering to own or any other prepared window
- logging
- resource loading from files and memory
- easy way to add supporting for new resource format
Configuration of
- antialiasing, screen resolution, refresh rate and vertical synchronization
- aspect correction
- title, position and size of window
- cursor visibility in window space
Input
- handling keyboard, mouse and joystick input
- handling of Unicode text input
- possibility to restrict the input to the Latin alphabet
Textures
- supports tga, png and jpg
- correct work with NPOT textures
- control the filter parameters
- masking
- render targets for rendering into texture
Text
- textured Unicode-font
- rendering UTF-8 or ANSI text
- rendering text with alignment and other options like size, color and count of symbols
2D-subsystem
- batch render for high-speed rendering
- rendering different primitives
- sprite engine
- rendering static and animated sprites and tiles
- rendering distortion grid
- rendering sprites with new texture coordinates(with the pixel dimension and the usual 0..1)
- control the blend mode and color mix mode
- control the color and alpha of vertices of sprites and primitives
- additional sprite transformations(flipping, zooming, vertices offset)
- fast clipping of invisible sprites
- 2D camera with ability to zoom and rotate the scene
Sound
- works through OpenAL or DirectSound in depends on configuration or OS
- correct work without soundcard
- supports wav and ogg as sound samples
- playing ogg files in separate thread
- control the volume and playback speed
- moving sound sources in 3D space
Mathematic
- basic set of additional math functions
- triangulation functions
- basic set of collision functions
Additional
- reading and writing ini-files
- functions for work with files and memory

http://zengl.org/screens/screen01s.jpg (http://zengl.org/screens/screen01.jpg)http://zengl.org/screens/screen02s.jpg (http://zengl.org/screens/screen02.jpg)http://zengl.org/screens/screen03s.jpg (http://zengl.org/screens/screen03.jpg)http://zengl.org/screens/screen04s.png (http://zengl.org/screens/screen04.png)

paul_nicholls
10-11-2010, 11:29 PM
Nice work! I will have to check this out :)

cheers,
Paul

WILL
11-11-2010, 12:30 AM
Very cool! I was wondering when some kind of announcement was going to come from this project.

I love the fact that it's all encompassing with it's features. One of the nicer things is that it's multi-thread supportive too. (Looking back to your loading demo you posted about before.) This will help games made with it run so much nicer on newer systems that have multi-core processors. ie. My iMac is a Quad Core i7 so the threading support will make a huge difference on my system for example.

All these new engines and game libraries coming out now, I'm going to have to bring back my game library guide for newcomers. :)

dazappa
11-11-2010, 01:44 AM
This looks like it might replace my use of andorra and SDL. I am curious what "basic set of collision-functions" you have (based on a translated page), I am guessing it might be bounding-box, and circles. Polygon and pixel perfect would be marvelous, however these can require some effort...

Andru
11-11-2010, 05:38 AM
it's multi-thread supportive too
This version doesn't support this feature. There are a lot of work, that must be done(some functions must be modified(not only loading resources), and also there is something that I don't like in architecture :)), so I decided not to include multi-threaded resource loading in this version.


I am curious what "basic set of collision-functions" you have (based on a translated page)
Some set of functions that check if points, rectangles, circles and lines are collide. Oriented bounding-box maybe will be added later. I just have not thought about it, because didn't encountered with this.

WILL
11-11-2010, 06:08 AM
Oh ok, well then I don't like it anymore. :P lol Just kidding, but it was a really neat demo. It would be good to have such features in your game engine eventually.

dazappa
11-11-2010, 06:52 AM
Hm, I get an "Error while linking" under Ubuntu 10.10 (for any demo). I'm about to reboot and try it under win7.

Andru
11-11-2010, 07:01 AM
Hm, I get an "Error while linking" under Ubuntu 10.10 (for any demo)
Just read Compilation (http://code.google.com/p/zengl/wiki/en02Compilation) help :) You must install these packages:
- libgl1-mesa-dev
- libglu1-mesa-dev

all other needed packages comes with fpc 2.4.0 from Ubuntu repository(I don't know what about deb's on official website). And I want to warn you - demo08 will not work, if you don't put some dll's(libogg and other) to bin directory :) You can download them here (http://www.andru-kun.inf.ua/zengl/extra/libogg-win32.7z)

mobilus
11-11-2010, 08:10 AM
Great framework and seems to be easy to use.

Andru
11-11-2010, 08:17 AM
dazappa
My answer to you about bounding-box was little strange... I just thought about OBB in 2D, not AABB(I called it like "rectangle") :)

mobilus
Thanks :)

Brainer
11-11-2010, 09:48 AM
Looks solid, but why is it all procedural?

Andru
11-11-2010, 10:01 AM
Looks solid, but why is it all procedural?
Because I like it :) All object-oriented things(for example sprite engine) will be in separate units.

chronozphere
11-11-2010, 10:47 AM
Wow... yet another game library in pascal. :o Awesome job. Your feature list is quite impressive. How long did it take you to complete this?

It seems to me that alot of pascal dev's are making their own engines (yes I'm guilty too ;) ). I would like to see an updated list of all game engines written in our lovely language, because I feel that there might be too many with a lot of overlapping features. I rather see one or two well supported/maintained ones than 10+ libs that are maintained by individuals. After all, we should be making games instead of engines.
This is also worrying me, because I feel that my engine project is getting more "redundant" day by day, so I need to think of ways to make a difference. :P

However, don't let this stop you from developing your engine. Looks like it can compete with Andorra or PhoenixLib. :)

Andru
11-11-2010, 11:35 AM
Looks like it can compete with Andorra or PhoenixLib.
Maybe, but I don't like them - too many depends and huge size... Also there is no well support for Linux-developers(As I remember Andorra can't be compiled without modifying a source code, but maybe something changed in the latest version).


How long did it take you to complete this?
Oh, I can't answer exactly :) I started it three years ago, but there was many pauses between developing. And ZenGL was changing every time(there even was a simple 3D one time :)). After one year of fun I have reworked it. In 2009 I added MacOS X support for one commercial project(I made a port of game that was written on Asphyre for Windows). Now it used in another one commercial project(with versions for Windows and MacOS X), and in some other "secret" projects :)

dazappa
12-11-2010, 02:32 AM
Anyway, I tried to bench the basic sprite drawing as best I could. I more or less just took a modified miku example with no auto-spawning / deleting, no movement, no randomized initing, anim, etc. The engine seems a bit sluggish, unless I'm not performing the most basic drawing. I can draw a max of 2900 sprites at 30 FPS with ZGL. With Game Maker, which is notoriously slow, it can still handle drawing a max of 6300 sprites at 30 FPS. I think ZGL needs some optimizations somewhere.

Andru
12-11-2010, 05:25 AM
With Game Maker, which is notoriously slow, it can still handle drawing a max of 6300 sprites at 30 FPS
What sprites did you use in Game Maker, and what about sorting sprites by layers(in Game Maker)? Also, give me a log file please, and info about your PC. And if you can - attach "benches" here(with sources and exe for Game Maker bench :)), please.


I think ZGL needs some optimizations somewhere.
Rendering in ZenGL is well optimized, be sure. Seems only Sprite Engine have some "problem" with stable sorting algorithm, or something happened in your benchmarks :)

dazappa
12-11-2010, 06:57 AM
What sprites did you use in Game Maker, and what about sorting sprites by layers(in Game Maker)? Also, give me a log file please, and info about your PC. And if you can - attach "benches" here(with sources and exe for Game Maker bench :)), please.


Rendering in ZenGL is well optimized, be sure. Seems only Sprite Engine have some "problem" with stable sorting algorithm, or something happened in your benchmarks :)
Aha! Yes I guess I should have expected the image to be critical. I restructured my bench of GM and did another quick dummy test in c++. Basically, they are all even for me now. All get about 3k 128x128 sized miku's drawn on the screen when the fps begins to drop below 30. I guess you have nothing to worry about then! Just me being silly with inaccurate bench marks.

(So in my case, the limit is my GPU, likely. I have an i5 @ 2.3ghz, and an nvidia 310m) Time to play with ZGL some more now I guess. The particles demo has a warning not to use it in the source, but it seems to have run just fine for me! I can still post my mini-benches if you still want them heh.

Andru
12-11-2010, 07:07 AM
Aha! Yes I guess I should have expected the image to be critical.
Yeah, fillrate is very critical :)


The particles demo has a warning not to use it in the source, but it seems to have run just fine for me!
Particles subsystem is not ready for simple use... all parameters are set by code, and there is no emitter manager in ZenGL for now.

dazappa
12-11-2010, 06:13 PM
Currently playing around with point in poly (which seems to work), but I am very confused with mouse_x()/y() and mouse_dx()/dy().

Here's a scenario:


if(col2d_PointInTriangle(mouse_X(),mouse_Y(),p1,p2 ,p3)) then
begin
// Visual response
end;

text_Draw( fntMain, 0, 64, 'FPS: ' + u_IntToStr( zgl_Get( SYS_FPS ) ) +' | '+u_inttostr(mouse_x())+','+u_inttostr(mouse_y())) ;

The mouse coords initialize to where the mouse was when the game was launched, but never update after.



if(col2d_PointInTriangle(mouse_DX(),mouse_DY(),p1, p2,p3)) then
begin
// Visual response
end;

text_Draw( fntMain, 0, 64, 'FPS: ' + u_IntToStr( zgl_Get( SYS_FPS ) ) +' | '+u_inttostr(mouse_dx())+','+u_inttostr(mouse_dy() ));

Coords output are changing as I move the mouse, but still no collision response.



if(col2d_PointInTriangle(mouse_X(),mouse_Y(),p1,p2 ,p3)) then
begin
// Visual response
end;

No collision response



if(col2d_PointInTriangle(mouse_X(),mouse_Y(),p1,p2 ,p3)) then
begin
// Visual response
end;

text_Draw( fntMain, 0, 64, 'FPS: ' + u_IntToStr( zgl_Get( SYS_FPS ) ) +' | '+u_inttostr(mouse_dx())+','+u_inttostr(mouse_dy() ));

For some reason this works the way I want it to.

Anyway, I can't really find docs anywhere so I'm a bit confused about their behaviors, but at least I got it working the way I wanted after some very random guessing.

Andru
12-11-2010, 07:11 PM
The mouse coords initialize to where the mouse was when the game was launched, but never update after.
Did you watch this demo - "02 - Input"? There are few lines of code in function Timer(at end of it) that very important:


// EN: Necessarily clear all the states.
key_ClearState();
mouse_ClearState();
joy_ClearState();

dazappa
12-11-2010, 07:38 PM
I guess I had misunderstood its function based on the source. I thought it only cleared button states, at any rate it works nicely with mouse_clearState.

Andru
12-11-2010, 07:54 PM
I thought it only cleared button states
Under Windows it also clearing yet another state, because WinAPI GetCursorPos is slow function, and ZenGL call it only one time per iteration.

Andru
13-11-2010, 02:02 AM
New font generator have just released :) Here (http://zengl.googlecode.com/files/zenfont-source-0.2.4.7z) the source code of it. Just create directory "tools" in ZenGL directory and unpack archive there. After you can compile it with Lazarus 0.9.29. Little bit later I will provide GNU/Linux and Windows binary archives, because now I want to sleep :)
http://andru-kun.inf.ua/zengl/tools/zenfont/screen02s.png (http://andru-kun.inf.ua/zengl/tools/zenfont/screen02.png)

sesillabubu
13-11-2010, 10:40 AM
Fantastic Project. What about shader?

Thanks
Sesilla

virtual
13-11-2010, 11:38 AM
this framework looks elegant , thanks for sharing
but i was hoping that the bin directory is full of exe

Andru
13-11-2010, 01:58 PM
virtual
Ok, next release will be with binaries for Windows(and maybe for other OS'es) in separate package. And this minor release will be soon, because I have already found and fixed some errors in svn(text rendering using font with more than one page and "problem" with tiles2d_Draw)

sesillabubu
13-11-2010, 02:00 PM
Any chance of seeing it for ios? And shader?

Thanks
Sesilla

Andru
14-11-2010, 12:17 PM
Now (http://andru-kun.inf.ua/zengl/demos/magiczen-windows.7z) ZenGL can use third party particles - Magic Particles (http://www.astralax.com/projects/particles/dev) :) And show something like this:
http://andru-kun.inf.ua/zengl/demos/magiczen_s01.jpg (http://andru-kun.inf.ua/zengl/demos/magiczen_01.jpg)

WILL
14-11-2010, 01:29 PM
Well, that it quite impressive. :)

dazappa
14-11-2010, 05:32 PM
Well, that it quite impressive. :)
Provided you have access to high-res particle images, this type of effect can be done with a lot of different engines.

@virtual:
If you have a working Lazarus installation, it couldn't be easier to run the demos. Simply download ZGL and unarchive it, open up the demo you want, and hit run. You don't have to fiddle with any project options because Andru created the demos with a relative path to the ZGL source.

code_glitch
14-11-2010, 11:54 PM
Thank you so much for the font creator. I'm just curious: but could I use some of your audio and font code in Prometheus? (along with the editor?).

Just a thought, since I can see this speeding up development and making it easier to use. Perhaps even a chance for easy porting from Prometheus to ZenGl if projects get serious even...

cheers,
code_glitch

Andru
15-11-2010, 12:13 AM
I'm just curious: but could I use some of your audio and font code in Prometheus? (along with the editor?).
You can use it while all modified ZenGL units(or units, that use ZenGL code) have copyrights. But audio... I think it won't be easy to port without using a lot of ZenGL units, but you can try to do this :)

Andru
18-11-2010, 04:30 AM
So, ZenGL got an official website - zengl.org (http://zengl.org). In few days I will try to complete it, but my designer skills... never mind :)

paul_nicholls
18-11-2010, 04:42 AM
So, ZenGL got an official website - zengl.org (http://zengl.org). In few days I will try to complete it, but my designer skills... never mind :)

Good to see :)

PS. an english version of the forum would be very handy for us non-russians ;)

cheers,
Paul

Andru
18-11-2010, 04:52 AM
PS. an english version of the forum would be very handy for us non-russians
Hmm, maybe I will ask WILL to help me with this and get English forum for ZenGL here on PGD :)

virtual
18-11-2010, 12:53 PM
all the demos work great except number 9 (Render to Texture) , show only back window

Andru
18-11-2010, 01:08 PM
all the demos work great except number 9 (Render to Texture) , show only back window
Interesting, can you give me log.txt and configuratiopn of your PC?

virtual
19-11-2010, 08:13 AM
ok my office pc is really weak

CPU : intel Celeron 2.2GHz
RAM : 512Mb
graphics card : : Geforce fx 5500
-------------------------------
here is the log file:
=====================
=== ZenGL 0.2 RC4 ===
=====================
[00000002ms] Begin
[00000004ms] Current mode: 1024 x 768
[00000443ms] wglChoosePixelFormatARB: zDepth = 24; stencil = 0; fsaa = 0
[00000540ms] Create OpenGL Context
[00000559ms] Making current OpenGL context
[00000559ms] GL_VERSION: 2.1.1
[00000559ms] GL_RENDERER: GeForce FX 5500/AGP/SSE2
[00000559ms] GL_MAX_TEXTURE_SIZE: 4096
[00000559ms] GL_ARB_TEXTURE_COMPRESSION: TRUE
[00000559ms] GL_EXT_TEXTURE_COMPRESSION_S3TC: TRUE
[00000559ms] GL_MAX_TEXTURE_UNITS_ARB: 4
[00000559ms] GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: 8
[00000559ms] GL_EXT_BLEND_FUNC_SEPARATE: TRUE
[00000559ms] GL_ARB_VERTEX_BUFFER_OBJECT: TRUE
[00000559ms] GL_EXT_FRAMEBUFFER_OBJECT: TRUE
[00000559ms] WGL_PBUFFER: TRUE
[00000560ms] Support WaitVSync: TRUE
[00000585ms] Texture loaded: "../../res/tux_stand.png"
[00000679ms] Texture loaded: "../../res/font-page0.png"
[00002561ms] Average FPS: 384
[00002572ms] Timers to free: 2
[00002572ms] Render Targets to free: 1
[00002606ms] Atlases to free: 0
[00002606ms] Textures to free: 3
[00002608ms] Fonts to free: 1
[00002608ms] Sounds to free: 0
[00002702ms] End

Andru
19-11-2010, 11:49 AM
virtual
Thanks for info. Can you test this compiled demo (http://zengl.org/tmp/demo09.7z), please? Just put it in bin directory and run.

WILL
19-11-2010, 01:12 PM
Hmm, maybe I will ask WILL to help me with this and get English forum for ZenGL here on PGD :)

Sure, I can make that happen. ;)

virtual
19-11-2010, 01:47 PM
yes , this work fine , but where is the bug in my compiled exe? , i am using delphi 7

Andru
19-11-2010, 02:01 PM
virtual

yes , this work fine , but where is the bug in my compiled exe?
Seems I catched known bug for GeForce FX videocards, that was released when FBO wasn't a standard... In my compiled demo I have removed one line of code(attaching depth buffer to FBO). So, maybe I will disable FBO for GeForce FX and switch to PBuffer, or I will try to make some "magic" with MipMaps(like described here (http://www.opengl.org/wiki/Common_Mistakes#Render_To_Texture)), or... just disable depth buffer because ZenGL for now is 2D only :)

WILL
Thanks a lot :)

dazappa
20-11-2010, 08:04 AM
Fullscreen mode seems extremely twitchy under Windows 7 (x64); I have an nVidia 310m. I suppose I could always look for driver updates again, but just thought I'd mention this anyway. Keep up the great work, this has been working mostly flawlessly for me on both Windows and Linux.

edit: hm, looks like you have a bug tracker. I'll try submitting something tomorrow (it's late).

Andru
20-11-2010, 08:37 AM
Fullscreen mode seems extremely twitchy under Windows 7 (x64)
I can remember only one bug - first time when you close ZenGL application(with OpenGL render), screen will blink. After this no blinks anymore. If you have another situation, so create a new topic about it here (http://www.pascalgamedevelopment.com/forumdisplay.php?63-ZenGL) :)

Andru
22-11-2010, 03:24 PM
dazappa
Seems I got the same bug with crazy windows in fullscreen mode... I will fix it. It appears in svn revision 789, but this revision fixed some problem with two monitors, that have all engines what I saw... I hate WinAPI >_<

update: I found solution... why something bad always happening when I make new package, and many people will download buggy version? :)
update 2: ZenGL 0.2 RC5 reuploaded with hotfix.