Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sfFlash - Flash UI for SFML  (Read 17644 times)

0 Members and 1 Guest are viewing this topic.

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
sfFlash - Flash UI for SFML
« on: April 08, 2010, 02:23:46 pm »
This library enables you to embed any swf file as your GUI.

It is a free alternative to the pricey ScaleForm.

Here's a screenshot of the library in action:


You can play with the slider and the color picker.

The library consists of 2 part

SwfUI:
This is a fork of Hikari http://www.ogre3d.org/forums/viewtopic.php?t=41999 , a flash UI Library for Ogre .
I stripped away all the Ogre related part and replace them with abstractions.
I also follow SFML design goal and keep everything as simple as possible.

Feature:
-API independent. You can provide your own render API-specific implementation
-C++ can call action script functions. Action script can call C++ functions through a simple interface. Data types are transparently converted.
-Unicode support
-Automatic capture of keyboard input
-Dynamically load IShockwaveFlashObject from a .ocx file so client machine does not need to have flash installed.

sfFlash:
This is the SFML render implementation of SwfUI.

Feature:
-Deadly simple interface. This is how you load a control:
Code: [Select]

sf::FlashControl test(512,512);
test.load(L"controls.swf");
test.SetPosition(100.0f,200.0f);
test.SetRotation(45.0f);//Yes, your control still works even when it's rotated
test.setRenderQuality(SwfUI::RQ_AUTOHIGH);

And render it:
Code: [Select]
window.Draw(test);//window is of type sf::RenderWindow
-Efficient rendering through a dirty rectangle system.
-Automatic conversion between flash data types and SFML data types. Currently, only ActionScript colors (passed as floats) are converted to sf::Color.

Limitation:
-Windows only
-Performance is not good enough. Currently, i'm using glTexSubImage2D to update the texture. My crappy graphic card does not support PBO so I cannot provide a better implementation.

How SwfUI is implemented:
It is the similar to how Hikari did it:
Create a windowless OLE container. Put an IShockwaveFlashObject inside.
Everytime the control need to be redrawn, call OleDraw to draw the dirty part in my own DC.
Copy the dirty part to a separate buffer (make it contiguous) and call glTexSubImage2D to update the texture.
Events are sent using window messages.

TODO:
-A proper tutorial
-Better data sharing between C++ and flash (loading flash files from memory, send image from C++ to ActionScript...)
-Get rid of the annoying exceptions in flash.ocx

Help needed:
-Someone who can implement a better rending technique (through PBO?)
-Someone who is experienced in COM in general and flash COM interface.

Project page(with download links):
https://code.google.com/p/swfui/

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
sfFlash - Flash UI for SFML
« Reply #1 on: April 08, 2010, 11:45:02 pm »
Sorry I can't even compile it. What does it use? SFML2, SFML1.6, SFML1.5? I already tried 2 and 1.6.

I would really like to use it. It would be amazing if you can interact with SWF's in a program... :-D

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
sfFlash - Flash UI for SFML
« Reply #2 on: April 09, 2010, 11:05:45 am »
Strange, it compiles fine on my machine.

What compiler errors did you get?

I'm using SFML 1.7 (svn) but i don't think there's much difference in the interface. Anyway, I'm just inheriting from sf::Sprite for convenience and do the rendering in GDI + OpenGL.

You also need to have flash player installed to compile since I import the flash interface from registry. And I only tested it on MSVC 2008 Express.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
sfFlash - Flash UI for SFML
« Reply #3 on: April 09, 2010, 12:55:16 pm »
EDIT

It worked at last. I installed SFML-1.7, cleaned the project and built. Now it works.

Looks amazing! I will try to use it.

So you say it only works under Windows?

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
sfFlash - Flash UI for SFML
« Reply #4 on: April 09, 2010, 01:55:31 pm »
I'm glad that you can use it.

However, I still want to know what kind of error did you get since I don't think SFML version really makes a different. The public API of 1.x are quite similar.

Yes, since I embed the official flash engine through COM. It will only works under Windows.

I don't know how flash is implemented on Mac or Linux. But I believe a similar approach can be used.

Updated: The project is now located at: https://code.google.com/p/swfui/
License for SwfUI( flash embedding library) is LGPL since it is a fork of Hikari.
sfFlash(SFML renderer) will be licensed under zlib.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
sfFlash - Flash UI for SFML
« Reply #5 on: April 09, 2010, 05:11:16 pm »
First I tried to compile with SFML2. SFML2 API changed a lot since 1.x, so it gave me compiler errors.
Then I tried to compile using SFML1.6, giving me linking errors about RenderImage. This was my fault because I didn't rebuild the whole project, so Visual Studio tried to link RenderImage (which don't exists in SFML1.x).

So it works fine!

Try to go through SFML2.0, you can use RenderImages (using FBO or PBuffers) to draw SWFs!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sfFlash - Flash UI for SFML
« Reply #6 on: April 09, 2010, 06:10:06 pm »
SFML 2 doesn't allow custom OpenGL rendering in drawables anymore, I didn't look at your code but porting it to SFML 2 may be harder than you think.
Laurent Gomila - SFML developer

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
sfFlash - Flash UI for SFML
« Reply #7 on: April 09, 2010, 06:56:03 pm »
Quote
SFML 2 doesn't allow custom OpenGL rendering in drawables anymore

All I did was calling an sf::Image::Bind() and update it with glTexSubImage2D.
The updated image is rendered through a sprite.
There's no custom OpenGL rendering. It should be OK right?

But why is custom OpenGL rendering disabled? How to create custom drawables then?

Quote
Try to go through SFML2.0, you can use RenderImages (using FBO or PBuffers) to draw SWFs!

PBuffer disallows GDI rendering on it.
FBO doesn't really help me much.
Currently, the performance is still acceptable if there's not too much animations that leads to big dirty areas. This should be the case for most GUI control.
Dont plan to embed a flash game though.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sfFlash - Flash UI for SFML
« Reply #8 on: April 09, 2010, 07:01:51 pm »
Quote
All I did was calling an sf::Image::Bind() and update it with glTexSubImage2D.
The updated image is rendered through a sprite.
There's no custom OpenGL rendering. It should be OK right?

Ah ok. Yes it should be alright :)

Quote
But why is custom OpenGL rendering disabled? How to create custom drawables then?

Because the rendering process is internally optimized, there is now a Renderer class between SFML and OpenGL :)
Laurent Gomila - SFML developer

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
sfFlash - Flash UI for SFML
« Reply #9 on: April 09, 2010, 07:55:21 pm »
What do you mean with
Quote
SFML 2 doesn't allow custom OpenGL rendering in drawables anymore
...?

I mean, are we still able to draw with OpenGL to RenderWindow and RenderImage, aren't we?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sfFlash - Flash UI for SFML
« Reply #10 on: April 10, 2010, 10:30:13 am »
Quote
I mean, are we still able to draw with OpenGL to RenderWindow and RenderImage, aren't we?

Yes, but not inside drawables. Well, it may work using the SaveGLStates/RestoreGLStates functions, but it may become insanely slow if you render too many of these objects.

However I'm not completely satisfied with the current design, and I'll see if I can find something "better".
Laurent Gomila - SFML developer

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
sfFlash - Flash UI for SFML
« Reply #11 on: April 24, 2010, 06:20:09 pm »
Update:

-SFML 2.0 support
-A Simple GUIManager class

Silvatre

  • Newbie
  • *
  • Posts: 1
    • View Profile
sfFlash - Flash UI for SFML
« Reply #12 on: April 04, 2011, 03:37:27 pm »
Hello guys.
Does anybody know if there is any way to display flash animation with correct colors using this library? My colors doesn't display properly.

Maybe someone know any other free library similiar to this one?

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
sfFlash - Flash UI for SFML
« Reply #13 on: April 04, 2011, 03:40:57 pm »
Last time I tried, everything display correctly.
Can you send me your flash movie?

Anyway, you won't be able to play a complex movie with decent framerate with the current implementation. May be PBO can speed it up.

This is just a hobby project of mine and I don't think I will update it any time soon. If you have any questions regarding the implementation, just ask me.

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
sfFlash - Flash UI for SFML
« Reply #14 on: October 04, 2011, 06:44:08 pm »
If I were to convert an AVI/some other video format to SWF, would this play it, sound and all?
SFML 2.1

 

anything