Hikari (v0.3)

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
Post Reply
User avatar
DanielSefton
Ogre Magi
Posts: 1235
Joined: Fri Oct 26, 2007 12:36 am
Location: Mountain View, CA
x 10
Contact:

Post by DanielSefton »

Not had much of a play yet, but awesome stuff so far! Got it overlayed very nicely. :D

I've been using Flash for 4+ years now, so finally I can use something I'm familiar with in my project. 8) A lovely CEGUI replacement. I'll inform you of my progress.

[Edit]
Input injection working beautifully! Next step, SWF event feedback.

P.S. How do you stop it from moving the window about with right click?
User avatar
dazKind
Gnoblar
Posts: 24
Joined: Thu May 04, 2006 10:43 am
Contact:

Post by dazKind »

This is awesome! :D

Concerning the code I instantly felt at home after all this time working with Navi. Works mighty fine for its first release!

edit:
Just ran some tests and the results are stunning. No matter what I throw at it comes out all fine. Even a complete & heavily animated website runs at an acceptable speed. You notice that it runs not super smooth but for a first release thats awesome. Even my old flash-based internet-radio-player works without a flaw.

Hikari is definately my new GUI-lib of choice.
Last edited by dazKind on Mon Jun 09, 2008 12:33 am, edited 1 time in total.
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

DanielSefton wrote:Not had much of a play yet, but awesome stuff so far! Got it overlayed very nicely. :D

I've been using Flash for 4+ years now, so finally I can use something I'm familiar with in my project. 8) A lovely CEGUI replacement. I'll inform you of my progress.

[Edit]
Input injection working beautifully! Next step, SWF event feedback.

P.S. How do you stop it from moving the window about with right click?
I'm very glad to hear that! The callback system in Hikari is actually very powerful, I will try to put up a mini tutorial tonight.

As for disabling the right-button-drag, I neglected to implement lots of the non-essentials because v0.2 was intended to simply demonstrate and refine the basic implementation. So fear not, more functionality is coming. ;)
dazKind wrote:This is awesome! :D

Concerning the code I instantly felt at home after all this time working with Navi. Works mighty fine for its first release!
Thanks, I tried to keep the API simple and familiar. ^^
User avatar
cybereality
Hobgoblin
Posts: 563
Joined: Wed Jul 12, 2006 5:40 pm
x 12

Post by cybereality »

This looks very promising so far. Nice work.
User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am
x 3

Post by johnhpus »

johnpus wrote:
The demo is very cool, but I noticed a slight lag when dragging the slider back and forth.

Any idea on the cause? In Navi there can be a similar lag when using non-Flash sliders and I think it's because it's copying the entire buffer instead of just the dirty area (not at all sure about that). Are you copying the buffer entirely or concentrating on parts that have changed?


That slider is quite the stress-test because of several factors: it employs "live-dragging" (constantly notifies listeners during the drag), updates a small bit of text below the slider, invalidates the area, and alters the material's opacity with every pixel the slider is dragged.

Hikari definitely employs dirty-rectangling-- during updates, only the dirty area is rendered by Flash. This isn't to say that the dirty-rectangling is perfect: I had several issues getting the HardwarePixelBuffer to lock with arbitrary rectangles and so I instead maintain an internal shadow buffer to handle rectangle merging and then blit the entire shadow buffer to the pixel buffer using simple row-memcpy. The method, though imperfect, is still quite effective because profiling shows that the Flash software renderer is, naturally, the biggest CPU hog in the chain-- comparatively, the memcpy is negligible.

Nevertheless, I'll see if I can't find a compatible way to do dirty-rectangle updates directly in Ogre3D, to squeeze the maximum amount of performance out.
Excellent. It sounds like you're right on top of things. Good work and thanks again for making this public. I'm eager to get the time to try it outside of the current demo.
pratty70
Gnome
Posts: 341
Joined: Thu May 13, 2004 4:52 pm
Location: Wales - UK

Post by pratty70 »

Windows only at the moment?
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

pratty70 wrote:Windows only at the moment?
It's entirely Windows-dependent (ActiveX, OLE, message hooks), and will most definitely remain so. Sorry.


Anyways, for those eager to utilize Flash/ActionScript <-> C++ communication in Hikari, read on.

FlashValue Basics

Hikari::FlashValue is essentially a variant class that represents an ActionScript value. It supports the basic types of: null, boolean, number, and string. You check its type using FlashValue::getType and then you retrieve its value using FlashValue::getBool, getNumber, or getString. When declaring a FlashValue in C++, its type is determined automatically by how you initialize it (see FlashValue.h for more info).

Hikari::Arguments is just a typedef for a vector of FlashValue's.

Communicating from Flash to C++

First, define your callback function in C++, it can be either a member function or a static function, it just needs to have the same signature as the example below:

Code: Select all

FlashValue onPlayerLogin(FlashControl* caller, const Arguments& args)
{
	String username = args.at(0).getString();
	String password = args.at(1).getString();
	
	bool success = netManager.login(username, password);
	
	if(success)
		return "Welcome to the world!";
	else
		return "Incorrect username/password.";
}
Next, bind your callback function to a certain name on the desired FlashControl.

Code: Select all

myFlashControl->bind("playerLogin", &onPlayerLogin);
Please note that if your callback function is a member function of some class, you need to declare the FlashDelegate explicitly like this (see "FlashControl.h" for more details):

Code: Select all

myFlashControl->bind("playerLogin", FlashDelegate(this, &MyClass::onPlayerLogin));
Now you can call the C++ function "playerLogin" from ActionScript using "ExternalInterface.call('functionName')":

Code: Select all

function loginClick(event:MouseEvent):void
{
	caption.text = ExternalInterface.call("playerLogin", username, password);
}
Note that we are taking the return value of the C++ function we defined earlier (we returned a string-type) and assigning it to the text of a caption (which is also a string-type). It is important to match up your variable types when communicating across both languages.


Communicating from C++ to Flash

First, define your callback function in ActionScript.

Code: Select all

function setHP(hp:Number):void
{
	hpBar.value = hp;
}
Then, still in ActionScript, bind the function to a name using "ExternalInterface.addCallback('functionName', function)":

Code: Select all

ExternalInterface.addCallback("setHP", setHP);
Now you can call this function from C++ using FlashControl::callFunction.

Code: Select all

myFlashControl->callFunction("setHP", Args(hpValue));
Note that Hikari::Args is a helper class that can be used to quickly declare Hikari::Arguments inline. The syntax for using it is something like this:

Code: Select all

Args(arg1)(arg2)(arg3)(arg4)...
Also note that FlashControl::callFunction returns a FlashValue-- if the function call was successful, this will hold the return value from the actual ActionScript function call.


Voila, I think I've covered the essentials-- if you need any help, feel free to ask, and I hope to see lots of cool creations from you hackers out there! :D
pratty70
Gnome
Posts: 341
Joined: Thu May 13, 2004 4:52 pm
Location: Wales - UK

Post by pratty70 »

It's entirely Windows-dependent (ActiveX, OLE, message hooks), and will most definitely remain so. Sorry.
OK, no worries. Looks damn good though!
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

ajs15822 wrote:The method, though imperfect, is still quite effective because profiling shows that the Flash software renderer is, naturally, the biggest CPU hog in the chain-- comparatively, the memcpy is negligible.
so I wonder if flash 10 will work. Seeing as that apparantly uses hardware acceleration (FINALLY). If they work together it might boost it considerably... or crash horribly :)
User avatar
DanielSefton
Ogre Magi
Posts: 1235
Joined: Fri Oct 26, 2007 12:36 am
Location: Mountain View, CA
x 10
Contact:

Post by DanielSefton »

Vectrex wrote:so I wonder if flash 10 will work. Seeing as that apparantly uses hardware acceleration (FINALLY). If they work together it might boost it considerably... or crash horribly :)
Dude... Are you like, psychic. :shock: Before you posted that, I wrote "I hope you'll still be working on Hikari for the release of Flash Player 10. It uses hardware acceleration (FINALLY)".

Apparently they are trying to compete with SUN, so it looks very promising. I hope so, because it's important for our project to remain cross-platform. Looks like I'm going to have to keep CEGUI in my project for now, and Linux and Mac will have to endure a less visual UI. =[
As for disabling the right-button-drag, I neglected to implement lots of the non-essentials because v0.2 was intended to simply demonstrate and refine the basic implementation. So fear not, more functionality is coming.
Any tips for disabling it now? :P

Thanks for the guide btw. I think you need to create a Wiki page.
rtlpixy
Gnoblar
Posts: 6
Joined: Mon Jun 09, 2008 4:04 pm
x 1

Post by rtlpixy »

I currently use Code::Blocks to develop with Ogre 3D (on Windows).
It is possible, after compiling Hikary libs using MVSC2005, using it with Code::Blocks ?
.overlord.
Halfling
Posts: 52
Joined: Wed Jun 06, 2007 5:01 pm

Post by .overlord. »

Hey,

looks pretty cool. Have you looked into using boost?
It's kinda frustrating seeing all these UIs that use
things like callbacks and variants and whatnot and
end up coding their own.

bind/signals/slots/any might be worth looking into

anyways, keep up the good work!
Murphy
Greenskin
Posts: 102
Joined: Tue May 10, 2005 11:42 pm
Location: SF, California
Contact:

Post by Murphy »

The only problem with using something like boost in a library project is then you are dependent on it. Then people that want to you your library have to get ahold of boost. And they might have to get the right version of boost too. So if I am using an older version of boost and I want to use the library, now I need to upgrade to the latest version of boost (which may not be possible for some people).

I do really like boost however :)
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16
Contact:

Post by KungFooMasta »

It's kinda frustrating seeing all these UIs that use
things like callbacks and variants and whatnot and
end up coding their own.
Its only 2 small classes required to implement a good callback system. 40 lines of code, or adding a dependency... easy choice. :P
Creator of QuickGUI!
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

got this error

Error 1 error C3500: invalid ProgID 'ShockwaveFlash.ShockwaveFlash' c:\Documents and Settings\Administrator\Desktop\Downloads\Programming\Hikari Source - v0.2\Hikari\include\impl\FlashSite.h 25

Error 2 fatal error C1103: fatal error importing progid: 'ShockwaveFlash.ShockwaveFlash' c:\Documents and Settings\Administrator\Desktop\Downloads\Programming\Hikari Source - v0.2\Hikari\include\impl\FlashSite.h 25

I've never used #import before so I'm not sure if I'm supposed to download some flash component or something

edit: Actually, I have flash 10 beta installed. Would that be messing with it?
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

.overlord. wrote:Hey,

looks pretty cool. Have you looked into using boost?
It's kinda frustrating seeing all these UIs that use
things like callbacks and variants and whatnot and
end up coding their own.

bind/signals/slots/any might be worth looking into

anyways, keep up the good work!
I love Boost and am well acquainted with it-- still, like the others say, I didn't want to introduce any extra dependencies. Besides, I didn't actually "code my own", I generated the "FlashDelegate" class automatically using the FastDelegate macros. ;)
rtlpixy wrote:I currently use Code::Blocks to develop with Ogre 3D (on Windows).
It is possible, after compiling Hikary libs using MVSC2005, using it with Code::Blocks ?
Possibly, the API doesn't expose any MSVC-specific code to my knowledge.
Dude... Are you like, psychic. :shock: Before you posted that, I wrote "I hope you'll still be working on Hikari for the release of Flash Player 10. It uses hardware acceleration (FINALLY)".

Apparently they are trying to compete with SUN, so it looks very promising. I hope so, because it's important for our project to remain cross-platform. Looks like I'm going to have to keep CEGUI in my project for now, and Linux and Mac will have to endure a less visual UI. =[
Flash Player 10 should work (theoretically!) with Hikari-- the GPU acceleration and 3D features are certainly exciting.

I have no idea if Adobe will ever release a true, cross-platform runtime (and not just OS-specific controls), but I certainly hope that with their new open-source initiative they will make plans to do so.
Any tips for disabling [right-button drag] now?
Sure, in your mouse input handler, don't inject right-mouse-button events.

Vectrex wrote:got this error

Error 1 error C3500: invalid ProgID 'ShockwaveFlash.ShockwaveFlash' c:\Documents and Settings\Administrator\Desktop\Downloads\Programming\Hikari Source - v0.2\Hikari\include\impl\FlashSite.h 25

Error 2 fatal error C1103: fatal error importing progid: 'ShockwaveFlash.ShockwaveFlash' c:\Documents and Settings\Administrator\Desktop\Downloads\Programming\Hikari Source - v0.2\Hikari\include\impl\FlashSite.h 25

I've never used #import before so I'm not sure if I'm supposed to download some flash component or something

edit: Actually, I have flash 10 beta installed. Would that be messing with it?
Hmm, that's interesting-- maybe the beta is messing with the class ID definitions. I want you to open up regedit, go to COMPUTER/HKEY_CLASSES_ROOT, and scroll down to the "ShockwaveFlash.*" area. Give me a listing of which classes (such as ShockwaveFlash.ShockwaveFlash.9) you have listed there.
User avatar
Zeal
Ogre Magi
Posts: 1260
Joined: Mon Aug 07, 2006 6:16 am
Location: Colorado Springs, CO USA

Post by Zeal »

It's entirely Windows-dependent (ActiveX, OLE, message hooks), and will most definitely remain so. Sorry.
Seems like a good idea to just focus on one platform in these early stages, but theoretically, whats holding it back from going multiplatform? I assume there have to be similar things to ActiveX on mac, ect... no?

I just think it would be wise to adopt a sort of 'platform indepenent' methodology when designing the api (like Ogre), even if you have no immediate plans to support something like that. Then down the road im sure other people will be willing to do all the work for you when it comes to supporting mac/linux ect...

*btw is it pronounced Hickory, like Hickory smoked turkey? What does it mean anyway?
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

Zeal wrote:
It's entirely Windows-dependent (ActiveX, OLE, message hooks), and will most definitely remain so. Sorry.
Seems like a good idea to just focus on one platform in these early stages, but theoretically, whats holding it back from going multiplatform? I assume there have to be similar things to ActiveX on mac, ect... no?

I just think it would be wise to adopt a sort of 'platform indepenent' methodology when designing the api (like Ogre), even if you have no immediate plans to support something like that. Then down the road im sure other people will be willing to do all the work for you when it comes to supporting mac/linux ect...

*btw is it pronounced Hickory, like Hickory smoked turkey? What does it mean anyway?
The API isn't too platform-dependent, the majority of the Windows-specific stuff is under the covers. The three most implementation-dependent classes-- the OLE site, keyboard hook, and event handler-- are all modularized in their own classes. Just a little more abstraction is needed to make the API truly platform-independent.

But you're right-- what's holding Hikari back from multi-platform is my own inexperience with other operating systems. If Linux/Mac talent were to research Flash embedding on their respective OS and offer me a hand, I'd be thrilled. :)

Hikari (pronounced "Hee-kah-ree") is Japanese for "Light" (as in "a glimmer of light faded from the horizon"). :D
User avatar
Zeal
Ogre Magi
Posts: 1260
Joined: Mon Aug 07, 2006 6:16 am
Location: Colorado Springs, CO USA

Post by Zeal »

the majority of the Windows-specific stuff is under the covers.
Good thats the only point I wanted to make. Im sure if you keep the platform specific stuff low level enough, there will be enough mac/linux fanbois who will be willing to do all the work for you.

I mean seriously who isnt foaming at the mouth over Hikari? You now command an army of loyal zombie servants, your will is our command.
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

Post by Praetor »

The Flash activex control is relatively easy to access and wrap. Getting this activex control to consistently work and work well cross-platform is nearly impossible.

The only option to get a cross-platform Flash working is to go for the flash mozilla/opera/safari plugin (instead of the activex control). These are two completely different implementations with two completely different APIs. While you can find info on the interfaces for embedding the Flash activex control, embedding the mozilla plugin version has nearly zero information anywhere and is an outrageous effort to make it work properly. And you get the added bonus of no help in any way from Adobe.
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

Praetor wrote:The only option to get a cross-platform Flash working is to go for the flash mozilla/opera/safari plugin (instead of the activex control). These are two completely different implementations with two completely different APIs. While you can find info on the interfaces for embedding the Flash activex control, embedding the mozilla plugin version has nearly zero information anywhere and is an outrageous effort to make it work properly. And you get the added bonus of no help in any way from Adobe.
At the very least, there's hope. :D


For the interested, I've just posted some basic tutorials (based on my previous posts) in the Hikari Wiki.
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

ajs15822 wrote:Hmm, that's interesting-- maybe the beta is messing with the class ID definitions. I want you to open up regedit, go to COMPUTER/HKEY_CLASSES_ROOT, and scroll down to the "ShockwaveFlash.*" area. Give me a listing of which classes (such as ShockwaveFlash.ShockwaveFlash.9) you have listed there.
ahh. I've got nothing. The installer must have installed the opera/firefox plugins but no activeX at all (It doesn't work in IE). Which is odd.
But is there a way to use the included flash.ocx without flash actually being installed on the computer? Or a different version?

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash]
@="Flash Movie"

[HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash\DefaultIcon]
@="C:\\Program Files\\Adobe\\Adobe Flash CS3\\flash.exe,2"

[HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash\shell]
@=""

[HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash\shell\open]
@=""

[HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash\shell\open\command]
@=""C:\\Program Files\\Adobe\\Adobe Flash CS3\\Players\\FlashPlayer.exe" %1"

User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

Vectrex wrote:
ajs15822 wrote:Hmm, that's interesting-- maybe the beta is messing with the class ID definitions. I want you to open up regedit, go to COMPUTER/HKEY_CLASSES_ROOT, and scroll down to the "ShockwaveFlash.*" area. Give me a listing of which classes (such as ShockwaveFlash.ShockwaveFlash.9) you have listed there.
ahh. I've got nothing. The installer must have installed the opera/firefox plugins but no activeX at all (It doesn't work in IE). Which is odd.
But is there a way to use the included flash.ocx without flash actually being installed on the computer? Or a different version?

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash]
@="Flash Movie"

[HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash\DefaultIcon]
@="C:\\Program Files\\Adobe\\Adobe Flash CS3\\flash.exe,2"

[HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash\shell]
@=""

[HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash\shell\open]
@=""

[HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash\shell\open\command]
@=""C:\\Program Files\\Adobe\\Adobe Flash CS3\\Players\\FlashPlayer.exe" %1"

Very peculiar-- have you tried installing this?

And yes, you can bundle the actual control with Hikari by placing "Flash.ocx" in the working directory of your executable. You should be able to obtain it by navigating to "C:\WINDOWS\system32\Macromed\Flash", there you will find something like "Flash9b.ocx". Just copy that file to your working directory and rename it to "Flash.ocx" and you're good to go. (To stay legally air-tight while distributing the Flash control, you need to apply for a free license)
User avatar
manowar
Orc
Posts: 419
Joined: Thu Apr 07, 2005 2:11 pm
Location: UK
Contact:

Post by manowar »

This sounds like a really good project and I could not wait to test it. Unfortunately I have not managed to compile it. I am using visual studio express 2005.

Code: Select all

1>.\source\FlashControl.cpp(342) : error C2039: 'CallFunction' : is not a member of 'ShockwaveFlashObjects::IShockwaveFlash'
1>        c:\documents and settings\administrator\desktop\hikari source - v0.2\hikari\objects\release\flash6.tlh(50) : see declaration of 'ShockwaveFlashObjects::IShockwaveFlash'
1>.\source\FlashControl.cpp(420) : error C2039: 'SetReturnValue' : is not a member of 'ShockwaveFlashObjects::IShockwaveFlash'
1>        c:\documents and settings\administrator\desktop\hikari source - v0.2\hikari\objects\release\flash6.tlh(50) : see declaration of 'ShockwaveFlashObjects::IShockwaveFlash'
I do not know much about activeX programming. From what I understand the file flash6.tlh is autogenerated and I guess the problem is related to that file.

Thanks for any help
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

manowar wrote:This sounds like a really good project and I could not wait to test it. Unfortunately I have not managed to compile it. I am using visual studio express 2005.

Code: Select all

1>.\source\FlashControl.cpp(342) : error C2039: 'CallFunction' : is not a member of 'ShockwaveFlashObjects::IShockwaveFlash'
1>        c:\documents and settings\administrator\desktop\hikari source - v0.2\hikari\objects\release\flash6.tlh(50) : see declaration of 'ShockwaveFlashObjects::IShockwaveFlash'
1>.\source\FlashControl.cpp(420) : error C2039: 'SetReturnValue' : is not a member of 'ShockwaveFlashObjects::IShockwaveFlash'
1>        c:\documents and settings\administrator\desktop\hikari source - v0.2\hikari\objects\release\flash6.tlh(50) : see declaration of 'ShockwaveFlashObjects::IShockwaveFlash'
I do not know much about activeX programming. From what I understand the file flash6.tlh is autogenerated and I guess the problem is related to that file.

Thanks for any help
It seems that you have the Flash Player 6 ActiveX Control installed, to compile Hikari you need the Flash Player 9 ActiveX Control-- you can download it here (you may need to open the link from Internet Explorer to get the correct distribution).
Last edited by ajs15822 on Tue Jun 10, 2008 10:42 am, edited 1 time in total.
Post Reply