Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Ultralight 1.2.1 #54

Open
8 tasks
ImVexed opened this issue Oct 3, 2022 · 1 comment
Open
8 tasks

Update to Ultralight 1.2.1 #54

ImVexed opened this issue Oct 3, 2022 · 1 comment
Assignees

Comments

@ImVexed
Copy link
Owner

ImVexed commented Oct 3, 2022

I'm currently working on getting this ported to the most recent Ultralight version, which at the time of writing is 1.2.1. Soon 1.3 will be going into beta and I'll look at migrating to that once it's been fully released, even if the API is already frozen.

Currently work is being done on https://github.com/ImVexed/muon/tree/1.2.1-support

To be clear, none of this currently works. The bindings compile, but there are lots of runtime errors. And if someone does successfully manage to get this to actually run, please tell me how.

Things left to do:

@ImVexed ImVexed pinned this issue Oct 3, 2022
@ImVexed ImVexed self-assigned this Oct 3, 2022
@javea7171
Copy link

I got the c api sample working, all of the setup had to be done within a newly spawned C thread, js callbacks work etc.

e.g.

`void Init()
{

printf("init\n");

///
/// Create default settings/config
///

printf("create settings and config\n");
ULSettings settings = ulCreateSettings();
ulSettingsSetForceCPURenderer(settings, true);
ULConfig config = ulCreateConfig();

printf("create app\n");

///
/// Create our App
///
app = ulCreateApp(settings, config);

printf("destroy config\n");

///
/// Done using settings/config, make sure to destroy anything we create
///
ulDestroySettings(settings);
ulDestroyConfig(config);

///
/// Create our window, make it 500x500 with a titlebar and resize handles.
///
window = ulCreateWindow(ulAppGetMainMonitor(app), 500, 500, false,
kWindowFlags_Titled | kWindowFlags_Resizable);

///
/// Set our window title.
///
ulWindowSetTitle(window, "Ultralight Sample 6 - Intro to C API");

///
/// Register a callback to handle window resize.
///
ulWindowSetResizeCallback(window, OnResize, 0);

///
/// Tell our app to use this window as the main window.
///
ulAppSetWindow(app, window);

overlay = ulCreateOverlay(window, ulWindowGetWidth(window), ulWindowGetHeight(window), 0, 0);

///
/// Get the overlay's view.
///
view = ulOverlayGetView(overlay);

// js callback
ulViewSetDOMReadyCallback(view, OnDOMReady, 0);

ULString newhtml = ulCreateString(InitialHTML);

ulViewLoadHTML(view, newhtml);
ulDestroyString(newhtml);

ulAppRun(app);

Shutdown();
}

///
/// This is called whenever the window resizes. Width and height are in
/// DPI-independent logical coordinates (not pixels).
///
void OnResize(void *user_data, unsigned int width, unsigned int height)
{
ulOverlayResize(overlay, width, height);
}

// put string into IninitialHTML
void SetInitialHTML(char *htmls)
{
printf("create initial url string\n");
InitialHTML = htmls;

// print initial html
printf("SET InitialHTML as: %s", InitialHTML);
}

// put string into IninitialHTML
void SetInitialURL(char *urlz)
{
printf("create initial url string\n");
InitialURL = urlz;

// print initial html
printf("SET InitialURL as: %s", InitialURL);
}

/// We tear down our application here.
void Shutdown()
{
///
/// Explicitly destroy everything we created in Init().
///
ulDestroyOverlay(overlay);
ulDestroyWindow(window);
ulDestroyApp(app);
}

// typedef unsigned long DWORD;

DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
Init();
return 0;
}

void Run()
{
// print started
printf("Started\n");

HANDLE hThread;
DWORD threadID;

hThread = CreateThread(NULL, 0, ThreadProc, NULL, 0, &threadID);
if (hThread == NULL)
{
printf("Error creating thread\n");
}
else
{
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
}
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants