FlixelCommunity / flixel

Community fork of Adam “Atomic” Saltsman's popular game engine Flixel. Distilled from a variety of Flash games he worked on over the last couple years, including Gravity Hook, Fathom and Canabalt, its primary function is to provide some useful base classes that you can extend to make your own game objects.
http://flixelcommunity.org/
Other
84 stars 17 forks source link

Make Flixel GPU accelerated #219

Closed Dovyski closed 9 years ago

Dovyski commented 9 years ago

I am really happy to issue this pull request. It makes Flixel Community GPU accelerated by using Genome2D as a render.

This is the first step to bring Flixel to the GPU world, there is still room for improvement. Despite of that I've ran some tests and the new GPU render is way faster than the CPU blitting one.

I have tried to keep changes to a minimum, avoiding modifications that would break too many things. I think the only significant modification I've made that deeply changes the current API was the addition of a Camera param in FlxBasic#draw(), which is now FlxBasic#draw(Camera:FlxCamera). There was no way I could think of to implement multiple cameras without that change.

Special thanks to @pshtif and @Beeblerox for helping making it happen!

Fix #90

IQAndreas commented 9 years ago

Awesome work!

High five

I have never played with GPU rendering, so this is over my head. You are going to have to find someone else to do the double checking. Or if you have tested the code enough and feel comfortable that it is stable, I trust your judgement and coding. We can always open new issues and fix any unexpected bugs that arise further down the line.

Is there a flag or variable you can set to switch between Bitmap and GPU rendering, or is it always on?

Beeblerox commented 9 years ago

i want to play with your code this week (while i'm on vacation and have plenty of time), but can't promise anything

Dovyski commented 9 years ago

@IQAndreas Thanks! :D I will try to get as much feedback as I can (code review, play testing, etc) before merging this. If it is not stable/smooth enough, we can ship it as an experimental feature disabled by default.

s there a flag or variable you can set to switch between Bitmap and GPU rendering, or is it always on?

Yep, during the game creation, the last parameter of FlxGame is UseGPU:Boolean = false (GPU disabled by default).

@Beeblerox Awesome! Just let me know if you need anything.

jboadas commented 9 years ago

Nice news. While gpu render is better for mobile games, software render is better for web games, you are going to keep both renders ?

Dovyski commented 9 years ago

Yes, both renders are available. It's up to developers to choose the best one during the game creation.

WingEraser commented 9 years ago

How to get this running? I've download several Genome2D repositories, imported in FDT and FlixelCommuntiy got reference to them. Still getting error.

Dovyski commented 9 years ago

@WingEraser You have to download Genome2D SWC at build.genome2D.com and include it in your project. It should compile just fine after that. If you have any problems, let me know.

WingEraser commented 9 years ago

Downloaded. I'm not sure why there are a lot of errors which doesn't make sense. I'm better off getting rid of FDT4 and use other IDE. A lot of changes has been made. It will cost me too much time to check all the changes. I cannot run Mode. Can you also do a PR for mode.

Dovyski commented 9 years ago

I've updated our fork of Mode to make it run against version 2.57 (with GPU support).

Using FlashDevelop, all you have to do is clone the dev branch and add Flixel code (Genome2D SWC is already included in the project).

IQAndreas commented 9 years ago

Do you feel the the GPU support stable enough to be merged into dev? If so, would you like to merge it?

I have some free time this week (a rare commodity these days) and would like to spend it rearranging the functions, and merging some of Flixel Power Tools. I figured if these massive changes are merged, there will be less merge conflicts to deal with.

... all you have to do is clone the dev branch and add Flixel code (Genome2D SWC is already included in the project).

Actually, he would have to clone Dovyski:fix-issue-90 (add Dovyski/flixel as a remote, and checkout the fix-issue-90 branch); since this pull request hasn't been merged yet.

Dovyski commented 9 years ago

I think it is stable enough to be merged, but there are a few rough edges we need to smooth. I think it's a good idea to merge it now to avoid any merge conflicts. The GPU acceleration is disabled by default, so I think it will not bite anyone.

I will try to finish all my pending pull requests, so we can merge them as well.