mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Update to ultralight 1.3.0
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
color: white;
|
||||||
|
font-family: -apple-system, 'Segoe UI', 'Roboto', 'Ubuntu', 'Arial', sans-serif;
|
||||||
|
background: linear-gradient(45deg, #4e95ff, #6032e4, #c478ff);
|
||||||
|
}
|
||||||
|
|
||||||
|
div {
|
||||||
|
width: 350px;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 5px;
|
||||||
|
background: linear-gradient(45deg, #61a0ff, #6737e9, #cb86ff);
|
||||||
|
}
|
||||||
|
|
||||||
|
body, div {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
padding: 1em;
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<h1>Hello Ultralight!<br>Hello <b>Glitchy Engine!</b></h1>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -57,7 +57,7 @@ class UltralightLayer : Layer
|
|||||||
|
|
||||||
private static bool done = false;
|
private static bool done = false;
|
||||||
|
|
||||||
private static void onFinishLoading(void* user_data, ULView caller,
|
private static void OnFinishLoading(void* user_data, ULView caller,
|
||||||
uint64 frame_id, bool is_main_frame, ULString url)
|
uint64 frame_id, bool is_main_frame, ULString url)
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
@@ -75,35 +75,33 @@ class UltralightLayer : Layer
|
|||||||
private void RenderToPng()
|
private void RenderToPng()
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
/// Setup our config. The config can be used to customize various
|
/// Setup our config.
|
||||||
/// options within the renderer and WebCore module.
|
|
||||||
///
|
///
|
||||||
/// Our config uses 2x DPI scale and "Arial" as the default font.
|
/// @note:
|
||||||
|
/// We don't set any config options in this sample but you could set your own options here.
|
||||||
///
|
///
|
||||||
ULConfig config = ulCreateConfig();
|
ULConfig config = ulCreateConfig();
|
||||||
|
|
||||||
ulConfigSetDeviceScale(config, 2.0);
|
|
||||||
|
|
||||||
ULString font_family = ulCreateString("Arial");
|
|
||||||
ulConfigSetFontFamilyStandard(config, font_family);
|
|
||||||
ulDestroyString(font_family);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// We need to tell config where our resources are so it can load our
|
/// We must provide our own Platform API handlers since we're not using ulCreateApp().
|
||||||
/// bundled certificate chain and make HTTPS requests.
|
|
||||||
///
|
///
|
||||||
ULString resource_path = ulCreateString("./resources/");
|
/// The Platform API handlers we can set are:
|
||||||
ulConfigSetResourcePath(config, resource_path);
|
|
||||||
ulDestroyString(resource_path);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Make sure the GPU renderer is disabled so we can render to an offscreen
|
/// | | ulCreateRenderer() | ulCreateApp() |
|
||||||
/// pixel buffer surface. (This is disabled by default, so not needed here)
|
/// |-------------------|--------------------|---------------|
|
||||||
|
/// | FileSystem | **Required** | *Provided* |
|
||||||
|
/// | FontLoader | **Required** | *Provided* |
|
||||||
|
/// | Clipboard | *Optional* | *Provided* |
|
||||||
|
/// | GPUDriver | *Optional* | *Provided* |
|
||||||
|
/// | Logger | *Optional* | *Provided* |
|
||||||
|
/// | SurfaceDefinition | *Provided* | *Provided* |
|
||||||
///
|
///
|
||||||
ulConfigSetUseGPURenderer(config, false);
|
/// The only Platform API handlers we are required to provide are file system and font loader.
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Use AppCore's font loader singleton to load fonts from the OS.
|
/// In this sample we will use AppCore's font loader and file system via
|
||||||
|
/// ulEnablePlatformFontLoader() and ulEnablePlatformFileSystem() respectively.
|
||||||
|
///
|
||||||
|
/// You can replace these with your own implementations later.
|
||||||
///
|
///
|
||||||
ulEnablePlatformFontLoader();
|
ulEnablePlatformFontLoader();
|
||||||
|
|
||||||
@@ -124,31 +122,41 @@ class UltralightLayer : Layer
|
|||||||
///
|
///
|
||||||
/// Create our renderer using the Config we just set up.
|
/// Create our renderer using the Config we just set up.
|
||||||
///
|
///
|
||||||
/// The Renderer singleton maintains the lifetime of the library and
|
/// The Renderer singleton maintains the lifetime of the library and is required before creating
|
||||||
/// is required before creating any Views. It should outlive any Views.
|
/// any Views. It should outlive any Views.
|
||||||
|
///
|
||||||
|
/// You should set up any platform handlers before creating this.
|
||||||
///
|
///
|
||||||
ULRenderer renderer = ulCreateRenderer(config);
|
ULRenderer renderer = ulCreateRenderer(config);
|
||||||
|
|
||||||
|
ulDestroyConfig(config);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create our View.
|
/// Create our View.
|
||||||
///
|
///
|
||||||
/// Views are sized containers for loading and displaying web content.
|
/// Views are sized containers for loading and displaying web content.
|
||||||
///
|
///
|
||||||
ULView view = ulCreateView(renderer, 1600, 1600, false, null, false);
|
/// Let's set a 2x DPI scale and disable GPU acceleration so we can render to a bitmap.
|
||||||
|
///
|
||||||
|
ULViewConfig view_config = ulCreateViewConfig();
|
||||||
|
ulViewConfigSetInitialDeviceScale(view_config, 2.0);
|
||||||
|
ulViewConfigSetIsAccelerated(view_config, false);
|
||||||
|
|
||||||
|
ULView view = ulCreateView(renderer, 1600, 800, view_config, null);
|
||||||
|
|
||||||
|
ulDestroyViewConfig(view_config);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Register OnFinishLoading() callback with our View.
|
/// Register OnFinishLoading() callback with our View.
|
||||||
///
|
///
|
||||||
ulViewSetFinishLoadingCallback(view, => onFinishLoading, null);
|
ulViewSetFinishLoadingCallback(view, => OnFinishLoading, null);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Load a string of HTML into our View. (For code readability, the string
|
/// Load a local HTML file into the View (uses the file system defined above).
|
||||||
/// is defined in the htmlString() function at the bottom of this file)
|
|
||||||
///
|
///
|
||||||
/// **Note**:
|
/// @note:
|
||||||
/// This operation may not complete immediately-- we will call
|
/// This operation may not complete immediately-- we will call ulUpdate() continuously
|
||||||
/// Renderer::Update continuously and wait for the OnFinishLoading event
|
/// and wait for the OnFinishLoading event before rendering our View.
|
||||||
/// before rendering our View.
|
|
||||||
///
|
///
|
||||||
/// Views can also load remote URLs, try replacing the code below with:
|
/// Views can also load remote URLs, try replacing the code below with:
|
||||||
///
|
///
|
||||||
@@ -156,25 +164,32 @@ class UltralightLayer : Layer
|
|||||||
/// ulViewLoadURL(view, url_string);
|
/// ulViewLoadURL(view, url_string);
|
||||||
/// ulDestroyString(url_string);
|
/// ulDestroyString(url_string);
|
||||||
///
|
///
|
||||||
ULString html_string = ulCreateString(htmlString);
|
ULString url_string = ulCreateString("file:///page.html");
|
||||||
ulViewLoadHTML(view, html_string);
|
ulViewLoadURL(view, url_string);
|
||||||
ulDestroyString(html_string);
|
ulDestroyString(url_string);
|
||||||
|
|
||||||
Log.ClientLogger.Info("Waiting for page to load...");
|
Log.ClientLogger.Info("Starting Run(), waiting for page to load...");
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Continuously update our Renderer until our done flag is set to true.
|
/// Continuously update until OnFinishLoading() is called below (which sets done = true).
|
||||||
///
|
///
|
||||||
/// **Note**:
|
/// @note:
|
||||||
/// Calling Renderer::Update handles any pending network requests,
|
/// Calling ulUpdate() handles any pending network requests, resource loads, and
|
||||||
/// resource loads, and JavaScript timers.
|
/// JavaScript timers.
|
||||||
///
|
///
|
||||||
while (!done)
|
while (!done)
|
||||||
{
|
{
|
||||||
ulUpdate(renderer);
|
ulUpdate(renderer);
|
||||||
ulRender(renderer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Render our View.
|
||||||
|
///
|
||||||
|
/// @note:
|
||||||
|
/// Calling ulRender will render any dirty Views to their respective Surfaces.
|
||||||
|
///
|
||||||
|
ulRender(renderer);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get our View's rendering surface.
|
/// Get our View's rendering surface.
|
||||||
///
|
///
|
||||||
@@ -183,25 +198,16 @@ class UltralightLayer : Layer
|
|||||||
///
|
///
|
||||||
/// Get the underlying bitmap.
|
/// Get the underlying bitmap.
|
||||||
///
|
///
|
||||||
/// @note We're using the default surface definition which is BitmapSurface,
|
/// @note We're using the default surface definition which is BitmapSurface, you can override
|
||||||
/// you can override the surface implementation via
|
/// the surface implementation via ulPlatformSetSurfaceDefinition()
|
||||||
/// ulPlatformSetSurfaceDefinition()
|
|
||||||
///
|
///
|
||||||
ULBitmap bitmap = ulBitmapSurfaceGetBitmap(surface);
|
ULBitmap bitmap = ulBitmapSurfaceGetBitmap(surface);
|
||||||
|
|
||||||
///
|
|
||||||
/// The renderer uses a BGRA pixel format but PNG expects RGBA format,
|
|
||||||
/// let's convert the format by swapping Red and Blue channels.
|
|
||||||
///
|
|
||||||
ulBitmapSwapRedBlueChannels(bitmap);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Write our bitmap to a PNG in the current working directory.
|
/// Write our bitmap to a PNG in the current working directory.
|
||||||
///
|
///
|
||||||
ulBitmapWritePNG(bitmap, "result.png");
|
ulBitmapWritePNG(bitmap, "result.png");
|
||||||
|
|
||||||
Log.ClientLogger.Info("Saved a render of our page to result.png.");
|
Log.ClientLogger.Info("Saved a render of our page to result.png.");
|
||||||
|
|
||||||
Log.ClientLogger.Info("Finished.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vendored
+1
-1
Submodule GlitchyEngine/vendor/Ultralight-beef updated: 63114e238a...8066ec887b
Reference in New Issue
Block a user