SDL2 combined with the Chromium Embedded Framework
This repository has an additional sample program that combines SDL2 with CEF. Heavy influence from this which I couldn't get to compile and some input mapping from this. I have only tested this in linux and am 100% sure it will not compile elsewhere. All my changes (with the exception of the top level CMakeLists.txt) are in the sdl-cef directory.
The above gif is what the program should look like at runtime (although at a better frame rate). There is a sample text input field, displays about which key events have been received, a button executing javascript code, and a button executing C++ code.
The remainder of this readme is pretty much from the CEF project repo.
The Chromium Embedded Framework (CEF) is a simple framework for embedding Chromium-based browsers in other applications. The original repository hosts a sample project called "cef-project" that can be used as the starting point for third-party applications built using CEF.
First install some necessary tools and download the cef-project source code.
1. Install CMake, a cross-platform open-source build system. Version 2.8.12.1 or newer is required.
2. Install Python. Version 2.x is required. If Python is not installed to the default location you can set the PYTHON_EXECUTABLE
environment variable before running CMake (watch for errors during the CMake generation step below).
3. Install platform-specific build tools.
4. Download the cef-project source code from the Downloads page or by using Git command-line tools:
git clone https://bitbucket.org/chromiumembedded/cef-project.git
Now run CMake which will download the CEF binary distribution from the Spotify automated builder and generate build files for your platform. Then build using platform build tools. For example, using the most recent tool versions on each platform:
cd /path/to/cef-project
# Create and enter the build directory.
mkdir build
cd build
# To perform a Linux build using a 32-bit CEF binary distribution on a 32-bit
# Linux platform or a 64-bit CEF binary distribution on a 64-bit Linux platform:
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
make -j4 sdlcef
# To perform a macOS build using a 64-bit CEF binary distribution:
cmake -G "Xcode" ..
# Then, open build\cef.xcodeproj in Xcode and select Product > Build.
# To perform a Windows build using a 32-bit CEF binary distribution:
cmake -G "Visual Studio 15" ..
# Then, open build\cef.sln in Visual Studio 2017 and select Build > Build Solution.
# To perform a Windows build using a 64-bit CEF binary distribution:
cmake -G "Visual Studio 15 Win64" ..
# Then, open build\cef.sln in Visual Studio 2017 and select Build > Build Solution.
CMake supports different generators on each platform. Run cmake --help
to list all supported generators. Generators that have been tested with CEF include:
Ninja is a cross-platform open-source tool for running fast builds using pre-installed platform toolchains (GNU, clang, Xcode or MSVC). See comments in the "third_party/cef/cef_binary_*/CMakeLists.txt" file for Ninja usage instructions.
CEF provides a number of examples that you can use as a starting point or reference for your own CEF-based development.
-DWITH_EXAMPLES=Off
to the cmake command-line if you do not wish to build the examples targets.Here are some activities you might want to try next to gain a better understanding of CEF:
1. Update the CEF version used to build your local copy of cef-project:
-DWITH_EXAMPLES=Off
to the cmake command-line to disable targets from the examples directory because they may not build successfully with the new CEF version.2. Add your own project source code:
add_subdirectory(myproject)
command near the end of top-level CMakeLists.txt file after the existing add_subdirectory commands.3. Gain a better understanding of the cefsimple application by reading the Tutorial Wiki page.
4. Fork the cef-project repository using Bitbucket and Git to store the source code for your own CEF-based project. See the ContributingWithGit Wiki page for details (replace all instances of "cef" with "cef-project" in those instructions).
5. Review the GeneralUsage Wiki page for additional details on CEF implementation and usage.
If you have any questions about CEF or cef-project please ask on the CEF Forum. If you would like to make contributions please see the "Helping Out" section of the CEF Main Page.