ultralight-ux / Ultralight

Lightweight, high-performance HTML renderer for game and app developers.
https://ultralig.ht
4.69k stars 197 forks source link

Documentation Request: Quick Start for Embedded Projects which gives correct rendered Bitmap #246

Open 3dmedium opened 4 years ago

3dmedium commented 4 years ago

I'm having some troubles while using Ultralight for a Project which will render completely offscreen.

First of all:

renderer->CreateView(1920,1080,true);
// do some other stuff
renderer->Render();
bitmap = view->bitmap();
bitmap->width();   // is returning 1132 Pixel
bitmap->height();    // is returning 1982 Pixel

so the created Bitmap is 52 Pixels bigger in each dimension than expected

When running my application as service or from ssh shell i get a exception and have to set export DISPLAY=:0. I think this is due to OpenGL. Is it possible to run Ultralight completely offscreen?

At the Moment i also get only Black Pixels while rendering to Bitmap. Is there any example Code to run Offscreen. I really like the simplicity of the Quick Start.

As for now my code is somethin like

ultralight::Config plattform_config;
plattform_config.use_bgra_for_offscreen_rendering = true;
plattform_config.device_scale_hint = 1.0;
ultralight::Platform::instance().set_config(plattform_config);

renderer = ultralight::Renderer::Create();
view = renderer->CreateView(1920,1080, true);
view->LoadURL("http://localhost/");    // also tried with loadHTML

// later in the process
while(running){
     while( time_passed > 20ms){
          renderer->Update();
          sleep(1ms);     // a callback for need Update would be nice.
     }
     renderer->Render();

     ultralight::RefPtr<ultralight::Bitmap> bitmap = view->bitmap();
     void* pixels = bitmap->LockPixels();
     // pixels contains 8974496 Bytes of 0b00000000
     // this is a black Image with the wrong dimension
     // even after running for some minutes there where no colored bytes
     bitmap->UnlockPixels();

     time_passed = 0;
}

I really like the simplicity of this Library. But some additional Documentation / Quick Start for API usage would be perfect.

TinkerWorX commented 4 years ago

OpenGL has had some black screen issues recently. Updating graphics drivers has solved the issue for some, so probably a good first step.

SupinePandora43 commented 4 years ago

i had black pixels when trying to render google.com, i changed to https://google.com and everything is work