Skip to content

Instantly share code, notes, and snippets.

@khrona
khrona / gdi_main.cc
Created August 3, 2012 07:15
How to use the latest 1.7 API correctly (with WebView::set_native_view) within a GDI environment
#include <Awesomium/WebCore.h>
#include <Awesomium/BitmapSurface.h>
#include <Awesomium/STLHelpers.h>
#include <iostream>
#define MAX_LOADSTRING 100
using namespace Awesomium;
// Global Variables:
@khrona
khrona / sdl_key_translation_sample.cc
Created August 2, 2012 17:53
Example of how to translate SDL Key Events into Awesomium Keyboard Events
/// Forward declaration
int getWebKeyFromSDLKey(SDLKey key);
///
/// Inject an SDL Key Event into a given WebView
///
void handleSDLKeyEvent(Awesomium::WebView* webView, const SDL_Event& event) {
if (!(event.type == SDL_KEYDOWN || event.type == SDL_KEYUP))
return;
@khrona
khrona / popup_menu_gdi_sample_main.cc
Created July 19, 2012 21:02
Quick example of how to handle popup (dropdown) menus in Awesomium 1.7 RC2 with GDI on Windows.
#include <Awesomium/WebCore.h>
#include <Awesomium/BitmapSurface.h>
#include <Awesomium/STLHelpers.h>
#include <iostream>
#define MAX_LOADSTRING 100
using namespace Awesomium;
// Global Variables:
@khrona
khrona / gist:2999122
Created June 26, 2012 21:17
Additional command-line options (for WebConfig in Awesomium 1.7.0)
"dart-flags"
"disable-3d-apis"
"disable-accelerated-compositing"
"disable-data-transfer-items"
"disable-desktop-notifications"
"disable-file-system"
"disable-geolocation"
"disable-gl-multisampling"
"disable-glsl-translator"
"ignore-gpu-blacklist"
@khrona
khrona / scripted_input_screenshot.cpp
Created October 3, 2011 22:21
A full example based off the "HelloAwesomium" sample (1.6.2) that demonstrates how to load a page from Wikipedia, jump to a certain named anchor, and render a screenshot of the result.
// Various included headers
#include <Awesomium/WebCore.h>
#include <iostream>
#if defined(__WIN32__) || defined(_WIN32)
#include <windows.h>
#elif defined(__APPLE__)
#include <unistd.h>
#endif
// Various macro definitions
@khrona
khrona / main.cpp
Created July 28, 2011 22:23
Captures a web-page to a JPEG (or series of JPEGs if the height is too great). Uses Awesomium 1.6.2 (r159+) and C API.
#include <Awesomium/awesomium_capi.h>
#include <string.h>
#include <stdio.h>
#if defined(__WIN32__) || defined(_WIN32)
#include <windows.h>
#elif defined(__APPLE__)
#include <unistd.h>
#endif
// The URL to render
@khrona
khrona / WinExample.cpp
Created July 19, 2011 21:42
Example of using Awesomium r148 API with GDI/WinForms/WinAPI
// WinTest.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "WinTest.h"
#include <Awesomium/WebCore.h>
#include <iostream>
#define MAX_LOADSTRING 100
@khrona
khrona / Local Flash Hack.cpp
Created March 28, 2011 16:24
We wish to load a local HTML file (page.html) that references a local Flash file (example.swf). Flash's local security policy prevents us from doing so without first prompting the user. This example shows how to workaround this using ResourceInterceptor i
using namespace Awesomium;
class MyResourceInterceptor : public ResourceInterceptor
{
ResourceResponse* onRequest(WebView* caller,
const std::string& url,
const std::string& referrer,
const std::string& httpMethod,
const char* uploadData,
size_t uploadDataSize) {