Code:
CEFClient:
- Code: Select all
class CEFBrowser : public CefClient, public CefRenderHandler, public CefLifeSpanHandler
{
public:
CEFBrowser()
{
}
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override
{
return this;
}
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() override
{
return this;
}
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
virtual bool GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect) override;
virtual void OnPaint(CefRefPtr<CefBrowser> browser,
PaintElementType type,
const RectList& dirtyRects,
const void* buffer,
int width,
int height) override;
IMPLEMENT_REFCOUNTING(CEFBrowser);
};
Main app:
- Code: Select all
CefMainArgs mainArgs;
void* sandboxInfo = nullptr;
CefSettings settings;
char currentDirectoryStr[FILENAME_MAX];
GetCurrentDir(currentDirectoryStr, sizeof(currentDirectoryStr));
std::string currentDirectory = std::string(currentDirectoryStr);
CefString(&settings.browser_subprocess_path).FromString((currentDirectory + "/cef/modernTVrenderer.exe").c_str());
CefString(&settings.resources_dir_path).FromString((currentDirectory + "/cef/").c_str());
CefString(&settings.locales_dir_path).FromString((currentDirectory + "/cef/locales").c_str());
CefString(&settings.log_file).FromString((currentDirectory + "/cef/cefdebug.log").c_str());
settings.remote_debugging_port = 9222;
settings.log_severity = cef_log_severity_t::LOGSEVERITY_ERROR;
//settings.multi_threaded_message_loop = true;
settings.windowless_rendering_enabled = true;
CefInitialize(mainArgs, settings, nullptr, nullptr);
//other code...
CefRefPtr<CEFBrowser> pWebView = new CEFBrowser();
CefWindowInfo windowInfo;
CefBrowserSettings browserSettings;
//windows
#if _WIN32
SDL_SysWMinfo wmInfo;
SDL_VERSION(&wmInfo.version);
SDL_GetWindowWMInfo(window->GetSDLWindow(), &wmInfo);
#endif
windowInfo.SetAsWindowless(wmInfo.info.win.window);
CefBrowserHost::CreateBrowser(windowInfo, pWebView, "http://google.com", browserSettings, nullptr);
//In my main loop
CefDoMessageLoopWork();
Renderer process:
- Code: Select all
#include <cef_app.h>
#include <include/cef_client.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdShow, int nCmdShow)
{
// Structure for passing command-line arguments.
// The definition of this structure is platform-specific.
CefMainArgs main_args(hInstance);
// Optional implementation of the CefApp interface.
//CefRefPtr<MyApp> app(new MyApp);
// Execute the sub-process logic. This will block until the sub-process should exit.
return CefExecuteProcess(main_args, nullptr, nullptr);
}
Any ideas?
Thank you