I'm trying to embed CEF in my game, Beat Hazard 2. My game uses SDL2 and that creates the game window.
I've based my code on CefSimple and I've got a browser window opening successfully alongside my game window.
I'm now trying to enable off screen rendering. I've implemented a CefRenderHandler.
However, if I set settings.windowless_rendering_enabled = true; I still get a browser window opening.
Further to that, a window is opened as soon as CefInitialize(main_args, settings, app.get(), NULL); is called. (This doens't happen in the simple test code)
As the game runs, browser windows keep opening an closing all the time.
Any ideas on where I'm going wrong?
Here's my code:
- Code: Select all
// -----------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------
int Ccef::init()
{
// Enable High-DPI support on Windows 7 or newer.
CefEnableHighDPISupport();
HINSTANCE hInst = ::GetModuleHandle(NULL);
// Provide CEF with command-line arguments.
CefMainArgs main_args(hInst);
// CEF applications have multiple sub-processes (render, plugin, GPU, etc)
// that share the same executable. This function checks the command-line and,
// if this is a sub-process, executes the appropriate logic.
int exit_code = CefExecuteProcess(main_args, NULL, NULL);
if(exit_code >= 0) {
// The sub-process has completed so return here.
return exit_code;
}
// Specify CEF global settings here.
CefSettings settings;
settings.no_sandbox = true;
settings.windowless_rendering_enabled = true;
//settings.single_process = true;
// SimpleApp implements application-level callbacks for the browser process.
// It will create the first browser instance in OnContextInitialized() after
// CEF has initialized.
CefRefPtr<SimpleApp> app(new SimpleApp);
// Initialize CEF.
CefInitialize(main_args, settings, app.get(), NULL);
wasInit = true;
return 0;
}
// -----------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------
void Ccef::process()
{
if(!wasInit)
return;
// Run the CEF message loop
CefDoMessageLoopWork();
}
// -----------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------
void Ccef::shutdown()
{
// Shut down CEF.
CefShutdown();
}