Commit 61fb3587 authored by callum_linden's avatar callum_linden
Browse files

Convert Windows line endings to UNIX because it's not like this is the 21st...

Convert Windows line endings to UNIX because it's not like this is the 21st century and people get sad about it or anything...
parent 3d89f87d
This diff is collapsed.
This diff is collapsed.
## Dullahan Examples
Some examples of how you might Dullahan. None of them are meant to be full featured, solid applications - just snippets of how you might do something in your own code.
Contributions showing off different features or ideas would be much appreciated.
## Console (Windows)
Windows command line application to render a given URL to a bitmap and save it as a bitmap called `output.bmp` and a PDF called `output.pdf` in the current directory when the page finishes loading or stops animating.
![Screen shot:](../docs/console.png?raw=true "Console example")
Notes:
* Pass a URL as command line parameter to render it
* Some sites are not fully ready when they "complete loading" (when the application saves the bitmap)
## Web Cube (Windows)
Slightly more complex OpenGL application using native Win32 because some of the calls to CEF (and therefore Dullahan) require native Windows messages.
![Screen shot:](../docs/webcube.png?raw=true "Web Cube example")
Notes:
* Displays same URL on each side of a cube
* It would be easy to add a different one to each side but make the code longer
* Start page is a local HTML page in `tools` folder
* Move the cube by holding down SHIFT key and using mouse and mouse wheel
* Interact with pages via mouse and keyboard (somewhat) normally
* Press ESC key to exit
* Enter any URL into the top edit control
* Expose some features via menu - e.g. Print to PDF
## OSXGL (macOS)
Simple macOS OpenGL app that displays a 2D bitmap rendered by Dullahan.
![Screen shot:](../docs/osxgl.png?raw=true "OSXGL example")
Notes:
* Needs some work to improve shutdown correctly (any macOS devs want to help?)
## cef_minimal (Windows)
An unusual C++ example that doesn't use Dullahan. Rather, it just initializes CEF directly and renders a page. Used as a test bed for fixing issues - most recently a crash on shutdown - without requiring consumers download and set up Dullahan.
![Screen shot:](../docs/cef_minimal.png?raw=true "cef_minimal example")
Notes:
* Works on Windows but could be made to work on macOS very easily by replacing the message loop
\ No newline at end of file
## Dullahan Examples
Some examples of how you might Dullahan. None of them are meant to be full featured, solid applications - just snippets of how you might do something in your own code.
Contributions showing off different features or ideas would be much appreciated.
## Console (Windows)
Windows command line application to render a given URL to a bitmap and save it as a bitmap called `output.bmp` and a PDF called `output.pdf` in the current directory when the page finishes loading or stops animating.
![Screen shot:](../docs/console.png?raw=true "Console example")
Notes:
* Pass a URL as command line parameter to render it
* Some sites are not fully ready when they "complete loading" (when the application saves the bitmap)
## Web Cube (Windows)
Slightly more complex OpenGL application using native Win32 because some of the calls to CEF (and therefore Dullahan) require native Windows messages.
![Screen shot:](../docs/webcube.png?raw=true "Web Cube example")
Notes:
* Displays same URL on each side of a cube
* It would be easy to add a different one to each side but make the code longer
* Start page is a local HTML page in `tools` folder
* Move the cube by holding down SHIFT key and using mouse and mouse wheel
* Interact with pages via mouse and keyboard (somewhat) normally
* Press ESC key to exit
* Enter any URL into the top edit control
* Expose some features via menu - e.g. Print to PDF
## OSXGL (macOS)
Simple macOS OpenGL app that displays a 2D bitmap rendered by Dullahan.
![Screen shot:](../docs/osxgl.png?raw=true "OSXGL example")
Notes:
* Needs some work to improve shutdown correctly (any macOS devs want to help?)
## cef_minimal (Windows)
An unusual C++ example that doesn't use Dullahan. Rather, it just initializes CEF directly and renders a page. Used as a test bed for fixing issues - most recently a crash on shutdown - without requiring consumers download and set up Dullahan.
![Screen shot:](../docs/cef_minimal.png?raw=true "cef_minimal example")
Notes:
* Works on Windows but could be made to work on macOS very easily by replacing the message loop
......@@ -26,118 +26,118 @@
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <functional>
#include "freeglut.h"
#include "dullahan.h"
dullahan* gDullahan;
const GLuint gTextureWidth = 1024;
const GLuint gTextureHeight = 1024;
GLuint gAppWindowWidth = gTextureWidth;
GLuint gAppWindowHeight = gTextureHeight;
////////////////////////////////////////////////////////////////////////////////
//
void glutResize(int width, int height)
{
gAppWindowWidth = width;
gAppWindowHeight = height;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, width, height);
glOrtho(0.0f, width, height, 0.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
////////////////////////////////////////////////////////////////////////////////
//
void glutDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 0.0f);
glVertex2d(gAppWindowWidth, 0);
glTexCoord2f(0.0f, 0.0f);
glVertex2d(0, 0);
glTexCoord2f(0.0f, 1.0f);
glVertex2d(0, gAppWindowHeight);
glTexCoord2f(1.0f, 1.0f);
glVertex2d(gAppWindowWidth, gAppWindowHeight);
glEnd();
glutSwapBuffers();
}
////////////////////////////////////////////////////////////////////////////////
//
void glutIdle()
{
gDullahan->update();
glutPostRedisplay();
}
////////////////////////////////////////////////////////////////////////////////
//
void glutMouseButton(int button, int state, int x, int y)
{
int scaled_x = x * gTextureWidth / gAppWindowWidth;
int scaled_y = y * gTextureHeight / gAppWindowHeight;
if (button == GLUT_LEFT_BUTTON)
{
if (state == GLUT_DOWN)
{
gDullahan->setFocus();
gDullahan->mouseButton(dullahan::MB_MOUSE_BUTTON_LEFT, dullahan::ME_MOUSE_DOWN, scaled_x, scaled_y);
}
else if (state == GLUT_UP)
{
gDullahan->setFocus();
gDullahan->mouseButton(dullahan::MB_MOUSE_BUTTON_LEFT, dullahan::ME_MOUSE_UP, scaled_x, scaled_y);
}
}
glutPostRedisplay();
}
////////////////////////////////////////////////////////////////////////////////
//
void glutMouseMove(int x, int y)
{
int scaled_x = x * gTextureWidth / gAppWindowWidth;
int scaled_y = y * gTextureHeight / gAppWindowHeight;
gDullahan->mouseMove(scaled_x, scaled_y);
glutPostRedisplay();
}
/////////////////////////////////////////////////////////////////////////////////
//
void onPageChangedCallback(const unsigned char* pixels, int x, int y, const int width, const int height)
{
glTexSubImage2D(GL_TEXTURE_2D, 0,
x, y,
width, height,
GL_BGRA_EXT,
GL_UNSIGNED_BYTE,
pixels);
}
*/
#include <iostream>
#include <string>
#include <functional>
#include "freeglut.h"
#include "dullahan.h"
dullahan* gDullahan;
const GLuint gTextureWidth = 1024;
const GLuint gTextureHeight = 1024;
GLuint gAppWindowWidth = gTextureWidth;
GLuint gAppWindowHeight = gTextureHeight;
////////////////////////////////////////////////////////////////////////////////
//
void glutResize(int width, int height)
{
gAppWindowWidth = width;
gAppWindowHeight = height;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, width, height);
glOrtho(0.0f, width, height, 0.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
////////////////////////////////////////////////////////////////////////////////
//
void glutDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 0.0f);
glVertex2d(gAppWindowWidth, 0);
glTexCoord2f(0.0f, 0.0f);
glVertex2d(0, 0);
glTexCoord2f(0.0f, 1.0f);
glVertex2d(0, gAppWindowHeight);
glTexCoord2f(1.0f, 1.0f);
glVertex2d(gAppWindowWidth, gAppWindowHeight);
glEnd();
glutSwapBuffers();
}
////////////////////////////////////////////////////////////////////////////////
//
void glutIdle()
{
gDullahan->update();
glutPostRedisplay();
}
////////////////////////////////////////////////////////////////////////////////
//
void glutMouseButton(int button, int state, int x, int y)
{
int scaled_x = x * gTextureWidth / gAppWindowWidth;
int scaled_y = y * gTextureHeight / gAppWindowHeight;
if (button == GLUT_LEFT_BUTTON)
{
if (state == GLUT_DOWN)
{
gDullahan->setFocus();
gDullahan->mouseButton(dullahan::MB_MOUSE_BUTTON_LEFT, dullahan::ME_MOUSE_DOWN, scaled_x, scaled_y);
}
else if (state == GLUT_UP)
{
gDullahan->setFocus();
gDullahan->mouseButton(dullahan::MB_MOUSE_BUTTON_LEFT, dullahan::ME_MOUSE_UP, scaled_x, scaled_y);
}
}
glutPostRedisplay();
}
////////////////////////////////////////////////////////////////////////////////
//
void glutMouseMove(int x, int y)
{
int scaled_x = x * gTextureWidth / gAppWindowWidth;
int scaled_y = y * gTextureHeight / gAppWindowHeight;
gDullahan->mouseMove(scaled_x, scaled_y);
glutPostRedisplay();
}
/////////////////////////////////////////////////////////////////////////////////
//
void onPageChangedCallback(const unsigned char* pixels, int x, int y, const int width, const int height)
{
glTexSubImage2D(GL_TEXTURE_2D, 0,
x, y,
width, height,
GL_BGRA_EXT,
GL_UNSIGNED_BYTE,
pixels);
}
/////////////////////////////////////////////////////////////////////////////////
// sadly need this so that the app can find the start URL when you start it
......@@ -154,45 +154,45 @@ const std::string getStartURL()
// return path to start page (CEF converts this to a file:// URL)
return std::string(buffer).substr(0, pos + 1) + page_filename;
}
////////////////////////////////////////////////////////////////////////////////
//
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(80, 0);
glutInitWindowSize(gAppWindowWidth, gAppWindowHeight);
glutCreateWindow("SimpleGL");
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);
glutDisplayFunc(glutDisplay);
glutIdleFunc(glutIdle);
glutMouseFunc(glutMouseButton);
glutPassiveMotionFunc(glutMouseMove);
glutMotionFunc(glutMouseMove);
glutReshapeFunc(glutResize);
GLuint app_texture;
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &app_texture);
glBindTexture(GL_TEXTURE_2D, app_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, gTextureWidth, gTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glViewport(0, 0, gTextureWidth, gTextureHeight);
glOrtho(0.0f, gTextureWidth, gTextureHeight, 0.0f, -1.0f, 1.0f);
gDullahan = new dullahan();
std::cout << "Version: " << gDullahan->composite_version() << std::endl;
}
////////////////////////////////////////////////////////////////////////////////
//
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(80, 0);
glutInitWindowSize(gAppWindowWidth, gAppWindowHeight);
glutCreateWindow("SimpleGL");
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);
glutDisplayFunc(glutDisplay);
glutIdleFunc(glutIdle);
glutMouseFunc(glutMouseButton);
glutPassiveMotionFunc(glutMouseMove);
glutMotionFunc(glutMouseMove);
glutReshapeFunc(glutResize);
GLuint app_texture;
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &app_texture);
glBindTexture(GL_TEXTURE_2D, app_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, gTextureWidth, gTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glViewport(0, 0, gTextureWidth, gTextureHeight);
glOrtho(0.0f, gTextureWidth, gTextureHeight, 0.0f, -1.0f, 1.0f);
gDullahan = new dullahan();
std::cout << "Version: " << gDullahan->composite_version() << std::endl;
gDullahan->setOnPageChangedCallback(std::bind(&onPageChangedCallback, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5));
dullahan::dullahan_settings settings;
settings.accept_language_list = "en-US";
settings.background_color = 0x80ffffff;
......@@ -214,24 +214,24 @@ int main(int argc, char* argv[])
settings.javascript_enabled = true;
settings.media_stream_enabled = true;
settings.plugins_enabled = true;
settings.user_agent_substring = gDullahan->makeCompatibleUserAgentString("SimpleGL");
settings.webgl_enabled = true;
bool result = gDullahan->init(settings);
if (result)
{
std::string url = getStartURL();
if (2 == argc)
{
url = std::string(argv[1]);
}
gDullahan->navigate(url);
}
glutMainLoop();
gDullahan->shutdown();
std::cout << "Exiting cleanly" << std::endl;
}
\ No newline at end of file
settings.user_agent_substring = gDullahan->makeCompatibleUserAgentString("SimpleGL");
settings.webgl_enabled = true;
bool result = gDullahan->init(settings);
if (result)
{
std::string url = getStartURL();
if (2 == argc)
{
url = std::string(argv[1]);
}
gDullahan->navigate(url);
}
glutMainLoop();
gDullahan->shutdown();
std::cout << "Exiting cleanly" << std::endl;
}
#### This is the Dullahan host application required by CEF
#### This is the Dullahan host application required by CEF
# Tools that are useful for working with CEF and Dullahan
`build_win.bat`
Simple batch file to build Dullahan as well as an example application. Pass in 32 or 64 for 32/64bit versions.
`build_mac.sh`
Simple shell script to build 64 bit macOS version of Dullahan.
`cef_download_build.bat`
Batch file that grabs the latest version of automate-git.py and uses it to build CEF from source. You might want to do this if you want to enable the embedded support of media including MPEG-4 files. Since the Chromium dependency on Visual Studio 2015 was introduced, this batch file no longer works but is left here in case parts of it are useful.
`dullahan_test_urls.html`
Simple HTML page that contains links to various sites that test Dullahan functionality.
`make_dullahan_cef_pkg.bat`
A simple Windows batch file that uses a CEF build from the [Spotify](http://opensource.spotify.com/cefbuilds/index.html) CEF site and extracts files (dlls, lib, Resource files etc.) that Dullahan needs.
`make_dullahan_cef_pkg.sh`
A simple macOS shell script that uses a CEF build from the [Spotify](http://opensource.spotify.com/cefbuilds/index.html) CEF site and extracts files (headers, libs, frameworks etc.) that Dullahan needs.
`make_src_hash.bat`
Batch file used to generate a hash of the cpp/h source files that is used as part of the Dullahan version number. A testbed before actually using in the client. A post-build step in the Windows version used to use this but no longer does.
`astyle.bat`
I find it useful to use [Artistic Style](http://astyle.sourceforge.net/) to reformat the code occasionally and maintain control of tabs/space and line endings. This batch file assumes astyle is installed on your system and runs it with selected command line options.
\ No newline at end of file
# Tools that are useful for working with CEF and Dullahan
`build_win.bat`
Simple batch file to build Dullahan as well as an example application. Pass in 32 or 64 for 32/64bit versions.
`build_mac.sh`
Simple shell script to build 64 bit macOS version of Dullahan.
`cef_download_build.bat`
Batch file that grabs the latest version of automate-git.py and uses it to build CEF from source. You might want to do this if you want to enable the embedded support of media including MPEG-4 files. Since the Chromium dependency on Visual Studio 2015 was introduced, this batch file no longer works but is left here in case parts of it are useful.
`dullahan_test_urls.html`
Simple HTML page that contains links to various sites that test Dullahan functionality.
`make_dullahan_cef_pkg.bat`
A simple Windows batch file that uses a CEF build from the [Spotify](http://opensource.spotify.com/cefbuilds/index.html) CEF site and extracts files (dlls, lib, Resource files etc.) that Dullahan needs.
`make_dullahan_cef_pkg.sh`
A simple macOS shell script that uses a CEF build from the [Spotify](http://opensource.spotify.com/cefbuilds/index.html) CEF site and extracts files (headers, libs, frameworks etc.) that Dullahan needs.
`make_src_hash.bat`
Batch file used to generate a hash of the cpp/h source files that is used as part of the Dullahan version number. A testbed before actually using in the client. A post-build step in the Windows version used to use this but no longer does.
`astyle.bat`
I find it useful to use [Artistic Style](http://astyle.sourceforge.net/) to reformat the code occasionally and maintain control of tabs/space and line endings. This batch file assumes astyle is installed on your system and runs it with selected command line options.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment