Berkelium in Ogre

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!
User avatar
my.name
Goblin
Posts: 222
Joined: Tue Aug 08, 2006 2:58 pm
Location: Moscow
x 1

Re: Berkelium in Ogre

Post by my.name »

Image
Image
Image
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Berkelium in Ogre

Post by jacmoe »

=)

You've been busy. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Simie
Gnoblar
Posts: 6
Joined: Sun Mar 21, 2010 10:50 pm

Re: Berkelium in Ogre

Post by Simie »

First, thanks for this! I plan on using this for the GUI in a small project I'm working on.

I was wondering if there you had any 64-bit plans for this library, or even if chromium supports it yet. We had planned to try and make our game 64-bit, but I admit we don't know how advantageous this would be yet.


Thanks :)
Nesetalis
Gnoblar
Posts: 20
Joined: Thu Dec 17, 2009 5:27 am

Re: Berkelium in Ogre

Post by Nesetalis »

ohh this looks interesting :D
what level of doneness is this library? i mean, is it relatively finished or is it still a beta.

Is anyone using this in ogre yet? I couldn't get the demo on the first page to work, just a black screen.
User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Re: Berkelium in Ogre

Post by Brocan »

I'm currently using berkelium embbeded in MyGUI, it runs well, but I have a problem: I can't logging in any webpage! forums, gmail, youtube... i think that problem is related with cookies or javascript.

Any idea?

Thanks in advance!
User avatar
Falagard
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2060
Joined: Thu Feb 26, 2004 12:11 am
Location: Toronto, Canada
x 3
Contact:

Re: Berkelium in Ogre

Post by Falagard »

Sorry for raising this old thread from the dead but I had someone send me a PM asking about my evaluation of Berkelium and I thought I'd post it here.

We're using Berkelium in our commercial home design software as our UI library, so yes we've evaluated and used it heavily.

It's great, and works pretty much exactly like our previous library did (Astral which was the core of the Navi library, predecessor to Awesomium) but with the faster and more up to date Chromium engine rather than Mozilla / Gecko.

We never could get Gecko to compile from sources, so we had to work with Astral binaries and that was a big negative for us, because once Astral stopped being worked on, we couldn't get up to date changes to Gecko / Mozilla.

With Berkelium and Chromium, we can compile everything from source and make changes and bug fixes as we find them.

The person who PM'd me asked how Berkelium communicates with our application and whether or not you have access to DOM events. There's an API for sending data from javascript running in a web page to the hosting application, and that triggers a listener / callback in C++ with the data that was passed. We use this as our mechanism for passing data from the page to our app and have written our own simple system for binding functions to these messages. We pass a function name and name/value pairs for parameters from javascript and then call the appropriate function in C++ and pass the data to the function.

For communicating back from the app to javascript we use the executeJavascript function in Berkelium which simply evaluates a string of javascript and executes it in the web page, and use a similar system of function and name/value pairs.

We've seen that Berkelium has ways to help you bind functions in C++, etc. I think but we ported from a different system to Berkelium and kept things the way we already had them.

If you want to handle DOM events in the hosting application you need to specifically write Javascript in the web page that intercepts the events and sends them to the application.

I hope that answers your questions.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Berkelium in Ogre

Post by jacmoe »

I am shocked! Good old Falagard - what a pleasure. :)
Thanks for your review of Berkelium.
Sounds like a worthwhile GUI alternative.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Equinox
Gnoblar
Posts: 1
Joined: Thu Feb 17, 2011 11:20 am

Re: Berkelium in Ogre

Post by Equinox »

Hey there,

I'm kind of new to using Berkelium, and I've been at it for days with no result.

Are there some tutorials that I can look at to get me started?

I don't need anything fancy because it's just a proof-of-concept for my thesis. However somewhere along the line I will need to split up the page into elements (I'll be coding the pages myself since it's only a POC, so no need to worry about how the split's gonna happen) to move them around.

Any pointers would be greatly appreciated!
Last edited by Equinox on Thu Feb 17, 2011 11:31 am, edited 1 time in total.
User avatar
so0os
Bugbear
Posts: 833
Joined: Thu Apr 15, 2010 7:42 am
Location: Poznan, Poland
x 33

Re: Berkelium in Ogre

Post by so0os »

Berk won't mess with your page, it just renders, so you can:
a) use heavy javascripting
b) split your page yourself

Also, look up wiki for dynamic textures, it's all you need to get it going.
Sos Sosowski :)
http://www.sos.gd
User avatar
Xplodwild
Goblin
Posts: 231
Joined: Thu Feb 12, 2009 3:49 pm
Location: France
x 13
Contact:

Re: Berkelium in Ogre

Post by Xplodwild »

Equinox wrote:Hey there,

I'm kind of new to using Berkelium, and I've been at it for days with no result.

Are there some tutorials that I can look at to get me started?
Bump here, the demo on previous page doesn't work anymore (404), and it's not really clear how to integrate it. Some quick demo would be very useful.
Nodrev
Gremlin
Posts: 193
Joined: Fri Jan 25, 2008 6:55 pm
Location: Nantes / France
x 17

Re: Berkelium in Ogre

Post by Nodrev »

Hi,

Don't like to use a showcase topic as a help topic, but as I have worked on Berkelium integration, I'll share my experience on using it. There's two thing you must know about it:
First, if your application got more than one process, it can be very complicated to integrate berkelium.
The second is on the way it work: you have an executable that is run to "populate" Berkelium's process (it may have change but I don't think so regarding developers response on their forum). It's not very "polished" in my opinion.
So, for my part, I switched to a Awesomium fork, Chromium Offscreen Renderer (from the last LGPL release). I had to patch (I still have to send this patch to the developers) it a little, but it was working well, except some errors on some online webpages, but if you know which html data you'll run on it (if you got the hand on that data, to test it and make sure html seems correct for COR), I recommand you to use it (even if Chromium version used by it is a little hold).
I do not have Berkelium code anymore, but COR integration code in Ogre can be find on this svn, you can check it even if you wish to use Berkelium, as rtt rendering code and keyboard/mouse/javascript events injection should be very comparable.

<edit>One more thing, I saw on your website that you want a linux version for your game, and Berkelium is windows only if I remember well.</edit>
<edit2>forget the last edit, I'm litlle late for april fools... I feel so dumb :lol:</edit2>
User avatar
kulik
Gremlin
Posts: 183
Joined: Sun May 01, 2005 2:00 pm
x 23
Contact:

Re: Berkelium in Ogre

Post by kulik »

Just a little plug for those interested. I've made a Berkelium integration into CEGUI (works with all renderers, including Ogre) a while back, I don't have time for it and it has some issues but they can be easily resolved. I have a little local test where I render Berkelium content into CEGUI images so I can even skin CEGUI Windows with moving Flash, SVGs and GIF :twisted: It's super easy to use with stuff like FlashWidget, HTMLWidget, etc... Plugs into CEGUI's resource system.

A very dated proof :lol:
[youtube]eZbIZEffilU[/youtube]
mpreisler on IRC | CEGUI team member, CEGUI Unified Editor developer, OISB founder
Giggzee
Gnoblar
Posts: 4
Joined: Wed Aug 17, 2011 10:56 am

Re: Berkelium in Ogre

Post by Giggzee »

Last edited by Giggzee on Fri Jul 25, 2014 3:30 pm, edited 1 time in total.
User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80
Contact:

Re: Berkelium in Ogre

Post by duststorm »

I've also made an effort of including it in my application.
The result is a minimal-amount-of-code version to get berkelium to render to a texture in ogre. (there is no input handling)
It was educational, as I learned how to use pixelboxes for fiddling with texture buffers. This will come in handy in other projects.
This code is created for the current stable API version of berkelium (Berkelium 8.0.552.23)

For those interested:

BrowserWindow.cpp

Code: Select all

#include "include/BrowserWindow.h"
#include "berkelium/Context.hpp"

BrowserWindow::BrowserWindow(Ogre::String materialName, uint width, uint height)
{
    mMaterialName = materialName;
    mTextureName = materialName.append("_texture");
    // TODO assert size > 0
    mWidth = width;
    mHeight = height;

    // Create texture to render to
    mTexture = Ogre::TextureManager::getSingleton().createManual(
            mTextureName,
            Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
            Ogre::TEX_TYPE_2D,
            width,
            height,
            0,  // no mipmaps
            Ogre::PF_BYTE_BGRA,
            Ogre::TU_DYNAMIC);

    // Create a material using the texture
    Ogre::MaterialPtr mMaterial = Ogre::MaterialManager::getSingleton().create(mMaterialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    mMaterial->getTechnique(0)->getPass(0)->createTextureUnitState(mTextureName);

    // Create new browser window in Berkelium
    Berkelium::Context * context = Berkelium::Context::create();
    mWindow = Berkelium::Window::create(context);
    mWindow->resize(width, height);

    // Listen to updates of the browser window to render them to the texture
    mWindow->setDelegate(this);

    // Browse to webpage
    browseToPage("http://www.google.com");
}

BrowserWindow::~BrowserWindow()
{
    mWindow->destroy();
}


void BrowserWindow::onPaint(
        Berkelium::Window *win,
        const unsigned char *sourceBuffer,
        const Berkelium::Rect &sourceBufferRect,
        size_t numCopyRects,
        const Berkelium::Rect *copyRects,
        int dx,
        int dy,
        const Berkelium::Rect &scrollRect)
{
    // Pixels to be written to texture
    const Ogre::PixelBox srcBox = Ogre::PixelBox(
           // Box that defines position of src buffer within complete browser window
       rectToBox(sourceBufferRect),
       Ogre::PF_BYTE_BGRA,
       const_cast<unsigned char*>(sourceBuffer)
    );

    // Update texture
    Ogre::HardwarePixelBufferSharedPtr pixelBuffer = mTexture->getBuffer();
    // There might be multiple areas of the texture to update
    for( int i =0; i<numCopyRects; i++) {
        // Box that defines area of texture that has to be updated)
        const Ogre::Box::Box destBox = rectToBox(copyRects[i]);

        // Copy updated browser surface to texture (note: Don't lock the buffer yourself!! blitFromMemory does this)
        pixelBuffer->blitFromMemory(srcBox.getSubVolume(destBox), destBox);
    }

}

inline Ogre::Box BrowserWindow::rectToBox(Berkelium::Rect rect)
{
    return Ogre::Box(
            rect.left(),
            rect.top(),
            0,
            rect.right(),
            rect.bottom(),
            1);
}

Ogre::String BrowserWindow::getMaterialName()
{
    return mMaterialName;
}

Ogre::String BrowserWindow::getTextureName()
{
    return mTextureName;
}

Ogre::MaterialPtr BrowserWindow::getMaterial()
{
    return Ogre::MaterialManager::getSingletonPtr()->getByName(getMaterialName());
}

Ogre::TexturePtr BrowserWindow::getTexture()
{
    return Ogre::TextureManager::getSingletonPtr()->getByName(getTextureName());
}

void BrowserWindow::browseToPage(Ogre::String url)
{
    mUrl = url;
    mWindow->navigateTo(url.data(), url.length());
}

Ogre::String BrowserWindow::getCurrentPage()
{
    return mUrl;
}
BrowserWindow.h

Code: Select all

#ifndef OGREBROWSERWINDOW_H
#define OGREBROWSERWINDOW_H

#include <berkelium/WindowDelegate.hpp>
#include <Ogre.h>

class BrowserWindow : public Berkelium::WindowDelegate
{
public:
    BrowserWindow(Ogre::String textureName, uint width=1024, uint height=1024);
    ~BrowserWindow();

    virtual void onPaint(
        Berkelium::Window *win,
        const unsigned char *sourceBuffer,
        const Berkelium::Rect &sourceBufferRect,
        size_t numCopyRects,
        const Berkelium::Rect *copyRects,
        int dx, int dy,
        const Berkelium::Rect &scrollRect);

    virtual Ogre::String getMaterialName(void);
    virtual Ogre::String getTextureName(void);

    Ogre::MaterialPtr getMaterial(void);
    Ogre::TexturePtr getTexture(void);

    void browseToPage(Ogre::String url);
    Ogre::String getCurrentPage(void);

    inline Ogre::Box rectToBox(Berkelium::Rect rect);

private:
    Ogre::String mTextureName;
    Ogre::String mMaterialName;
    Ogre::TexturePtr mTexture;
    Ogre::String mUrl;
    uint mWidth;
    uint mHeight;

    Berkelium::Window *mWindow;
};

#endif // OGREBROWSERWINDOW_H
Just include these two files in your code. To create a plane with a browser on it, do this:

Code: Select all

    // Initialise the global Berkelium browser manager
    Berkelium::init(Berkelium::FileString::empty());

    // Create a browser instance
    BrowserWindow *browserWindow = new BrowserWindow("BerkeliumMaterial");

    // Create plane for testing browser component on
    Ogre::MeshManager::getSingletonPtr()->createPlane("BerkeliumPlane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                      Ogre::Plane(Ogre::Vector3::UNIT_Z, 0), 3, 3);
    Ogre::Entity *browserPlaneEnt = mSceneMgr->createEntity("BrowserPlane", "BerkeliumPlane");
    mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(browserPlaneEnt);

    // Assign it the material with the browser texture
    browserPlaneEnt->setMaterial(browserWindow->getMaterial());

    // Position the plane
    Ogre::SceneNode *sceneNode = browserPlaneEnt->getParentSceneNode();
    sceneNode->setPosition(Ogre::Vector3(0, 3, 5));
By default it will go to google.com
To make it go to another website you can

Code: Select all

    mBrowserWindow->browseToPage("http://www.ogre3d.org");
Now you only need to update Berkelium regularly. To do this, add this line somewhere in the frameRenderingQueued() method of your application:

Code: Select all

// Update Berkelium
Berkelium::update();
I'm thinking of creating an article for it on the wiki to get people started quickly. I think this code is interesting to teach others how the buffer update using rectangles or ogre boxes works. But before that, I'll leave the code here for reviewal from others, and some possible improvements.
Last edited by duststorm on Mon Jul 16, 2012 3:40 pm, edited 4 times in total.
Developer @ MakeHuman.org
Delaney
Gnoblar
Posts: 9
Joined: Fri Jan 20, 2006 9:12 pm
Location: Las Vegas, NV
Contact:

Re: Berkelium in Ogre

Post by Delaney »

Tried to use this sample code to get Berkelium into my ogre 1.7 project but all I'm seeing is a black square. Also noticed that a breakpoint at the top of BrowserWindow::onPaint is never getting called. Is there extra bootstrapping needed to get BrowserWindow going outside of this example? Thanks!
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: Berkelium in Ogre

Post by Klaim »

Do you call Berkelium's update function regularly?
User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Re: Berkelium in Ogre

Post by Brocan »

I don't know what version of berkelium are you using, but keep in mind that the "onPaint" interface was changed in one of the berkelium revisions. Look if you don't have the old version of the interface (so the virtual function is no called).

Cheers!
User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80
Contact:

Re: Berkelium in Ogre

Post by duststorm »

Yes, now I see. Apparently I forgot to mention one tiny bit :oops:

You need to update Berkelium regularly, which is not said in my post.
In the method frameRenderingQueued() of your application, add this part somewhere:

Code: Select all

// Update Berkelium
Berkelium::update();
Developer @ MakeHuman.org
Delaney
Gnoblar
Posts: 9
Joined: Fri Jan 20, 2006 9:12 pm
Location: Las Vegas, NV
Contact:

Re: Berkelium in Ogre

Post by Delaney »

Thanks guys! Figured it was something simple thought there might be some magic hook up I wasn't seeing.
User avatar
mattmatt
Gnoblar
Posts: 12
Joined: Tue Feb 14, 2012 2:06 pm

Berkelium 64-bits

Post by mattmatt »

Hi!

This thread is pretty old, but I hope there is still some people interested in Berkelium!

Berkelium seems very awsome, I tried the little demo from the site.

We have a project in which we would like to use berkelium, but the thing is that it's "Windows x64", and Chromium is only 32-bit for the moment. :?

Would it exist a solution to use a 64-bit project with berkelium, using a 32-bit Chromium?


Thanx in advance for the help
User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80
Contact:

Re: Berkelium in Ogre

Post by duststorm »

There seems to exist no easy (or even possible) solution for linking 64bit to 32bit libraries.
http://stackoverflow.com/questions/1943 ... it-program
http://stackoverflow.com/questions/1116 ... 2-bit-dlls

What I would do is use a 32bit ogre (and make your application 32bit) and link it with berkelium.
64bit systems can run 32 bit applications (on linux for example with ia32)

I believe there is no 64bit berkelium because some time ago there was simply no 64bit chromium. Who knows, if you try compiling berkelium yourself with a newer chromium in 64bit it might just work.

That's actually the biggest disadvantage of berkelium: chromium is a huge and complex dependency.
Developer @ MakeHuman.org
User avatar
saejox
Goblin
Posts: 260
Joined: Tue Oct 25, 2011 1:07 am
x 36

Re: Berkelium in Ogre

Post by saejox »

there three alternatives to berkelium i know of:

1 - http://code.google.com/p/chromiumembedded/ - BSD
2 - QtWebkit - lgpl
3 - Awesomium - $$$

check them. maybe they can compile to 64bit
i use 32bit berkelium.
Nimet - Advanced Ogre3D Mesh/dotScene Viewer
asPEEK - Remote Angelscript debugger with html interface
ogreHTML - HTML5 user interfaces in Ogre
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: Berkelium in Ogre

Post by AshMcConnell »

Awesomium is free for indie developers (if you made < $100k last year)

http://awesomium.com/buy/

I'm hoping to use it for ORC
User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80
Contact:

Re: Berkelium in Ogre

Post by duststorm »

I already wanted to do this for a long time but I have finally created a wiki article about this sample. Hope it proves useful to someone ;)
Developer @ MakeHuman.org
Kosmos
Kobold
Posts: 29
Joined: Mon Aug 01, 2011 5:08 pm
Location: Russia

Re: Berkelium in Ogre

Post by Kosmos »

Is there anyway to use window.external in JavaScript code to execute C++ functions?
I can see it support this to execute JS code:
virtual void executeJavascript (WideString javascript)=0
Execute Javascript in the context of the Window.

But is there anyway to call c++ functions from JS?
Post Reply