PDA

View Full Version : Soft :: A software rendering engine



dazappa
28-02-2010, 04:01 PM
I've created a simple software rendering engine for my own purposes, and it seems like a good time to release a beta version of it. This is basically a single unit that provides a double buffered panel, sprite management, and easy drawing functions.

I've only tested this on Lazarus/FPC, but it should work just fine with Delphi (Should. I don't have Delphi, sorry). By default, I only included PNG/BMP images allowed to be loaded by the engine itself, so if you're on delphi without PNG support, make sure you change the Soft unit.

I have included a simple Lazarus project to show the basics of how the engine works. Basically, you load sprites, the Soft engine creates an object, and it returns an integer. You can access the object array of sprites directly, of course (just like with the canvas, etc.)

I designed this engine for extreme ease of use, in my opinion. You tell the engine to create sprites, all you have to keep track of is integers. The engine handles collisions (currently bounding box only) and provides a few methods you can override to your liking (The drawing and "step" functions). The step functions of all objects are called before the object is drawn, so you can perform movement calculations and have the latest update drawn.

As I'm still a novice, I've got a little list here:
Todo (what I can do):

Particle system (would be quite basic)
Depth
Make 'File format not supported' more specific
Change gravity and x/yspeed to use deltatime
Mouse handling


Need help on:

Dirty rectangles (where only the part of the screen that has changed is redrawn)
Transparent BMPs
Terminating application from Soft unit
Opacity
Full Screen
Text drawing (On Windows Vista, this was a rectangle. Linux, this seemed fine.)
Freeing resources


If you'd be so kind as to help, I'd be quite grateful ;)
** As noted in the todo, deltatime is not yet used, so if a machine is running at a different FPS, the game will play slower/faster. I added a way to set the FPS, but this, of course, does not guarantee the FPS will stay constant.

The Soft engine should take care of everything in terms of creating an environment to draw on. If you look at the uses clause of the unit, you'll see a description of why certain units are needed. Currently, the engine creates a TPanel on whatever parent is passed to it, and it creates a timer as well and bitmap for double buffering. I could have probably made it so that it would access the parent's canvas directly (assuming there was one), but this method seems to be rather failsafe.

License: BSD
(Sorry, no screenshots. It's a 10kb download, so I hope you'll still try it ;))
Tested on Ubuntu 9.04 and Windows Vista. (Should work on all other versions of Windows, distros of Linux, and Mac OS)
Download:
Mirror 1 (http://uploading.com/files/68m64891/Soft.zip/)
Mirror 2 (http://www.megaupload.com/?d=K6H1ERZ1)

PS: I've yet to create a game with my own framework. I'd like to improve the collisions, get transparent BMPs, opacity, and text to work properly before I attempt to create anything with it.

Brainer
01-03-2010, 03:32 PM
I'm interested, but can you provide us with an EXE? I don't have Lazarus to compile it. :(

dazappa
01-03-2010, 11:17 PM
I'm interested, but can you provide us with an EXE? I don't have Lazarus to compile it. :(

Hi a few things. First, the demo is currently relatively unimpressive, consisting of no more than a ball that you can control with the arrow keys, and run into a block to reset the ball's position.

Second, you don't *need* Lazarus (or at least, I hope you don't!) All of the example's code can be found in unit1 (I don't know why there's a unit2, but it's empty). All you really need to get started with Soft is to create a blank application (with a form) and include the Soft unit. After you verify that the Soft unit and your application will compile happily, you should be able to pop open unit1.pas again and look through the example to see how it works. For the most part, I think you'd be able to copy and paste the code.

But if you still want an EXE demo, that's something I can provide. (Also, if you have any simple ideas for what I should make the default example (or an example), I'd like to hear them.) More or less, this is only a means to create the drawing environment for you. All other code, such as game logic, will have to be handled by you.

Reiter
10-04-2010, 10:53 AM
As I'm still a novice, I've got a little list here:
Todo (what I can do):
Particle system (would be quite basic)
Depth
Make 'File format not supported' more specific
Change gravity and x/yspeed to use deltatime
Mouse handling

Need help on:
Dirty rectangles (where only the part of the screen that has changed is redrawn)
Transparent BMPs
Terminating application from Soft unit
Opacity
Full Screen
Text drawing (On Windows Vista, this was a rectangle. Linux, this seemed fine.)
Freeing resources

Hi there, nice project. However I wonder, why wouldn't you use SDL and extend it to your needs since it includes most of the features you have to "todo" or need help on. Probably there are good reasons for you not to use SDL, still curious though :).

chronozphere
10-04-2010, 12:08 PM
Nice work!

I understand that he's not using any existing library like SDL. Doing everything yourself is a great learning experience, though I wouldn't use the code very any serious game projects. :)

WILL
03-10-2010, 07:52 AM
Hows this little project coming along? You didn't happen to make any videos of it running did you?

dazappa
03-10-2010, 08:43 PM
*Sigh* Darn thing just ate the post I was going to write.

Anyway, development has mostly stopped as there's not much else to be added, and text on Windows will most likely never be implemented correctly. You seem to have to draw with both a background and foreground color when drawing text on Windows, and if the background is transparent it just becomes a solid rectangle.

I never made a video either, as there was never much to show. This unit is most useful for platforms which support Laz & FPC but not SDL, as it provides an easy way to get up and running with little dependencies.

edit:
This may also be of use for any newbies wondering about the basic concepts of game programming, like what exactly double buffering is.

code_glitch
03-10-2010, 08:51 PM
If you need text and etc I can post up some simple procedures and functions I wrote a while back. Although they're built for sdl and fpc, I don't see too many issues getting them to work with OpenGl and Lazarus. Also, I would be quite interested in some of the features of your project for the Prometheus project I am currently working on if that would be alright.

cheers,
code_glitch

dazappa
03-10-2010, 10:35 PM
The goal is to rely on as few external dependencies as possible (hence why no SDL), and Soft is meant to be a software rendering engine, utilizing OGL would make it a hardware rendering engine ;) As is posted in the first post, the license for this is BSD, so if you think you can pull anything useful from it you can use it as long as the license is compatible with Prometheus'. (And to be honest, I doubt there would be anything worth while ;) )