Skip to content

Instantly share code, notes, and snippets.

@Dav1dde
Last active December 10, 2015 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dav1dde/4380690 to your computer and use it in GitHub Desktop.
Save Dav1dde/4380690 to your computer and use it in GitHub Desktop.
Awesomium OpenGL test
private {
import gl3n.linalg;
import glamour.gl;
import glamour.shader;
import glamour.texture;
import glamour.sampler;
import glamour.vbo;
import glwtf.glfw;
import glwtf.window;
import wonne.all;
import wonne.ext.glfw;
import wonne.ext.opengl;
import std.stdio : writefln;
import std.exception : enforceEx;
}
enum URL = "http://google.com";
static this() {
DerelictGL3.load();
version(DynamicGLFW) {
DerelictGLFW3.load();
}
enforceEx!Exception(glfwInit(), "glfwInit failure");
}
class HelloWorld {
Window window;
int width;
int height;
bool _exit = false;
Webview webview;
WebviewRenderer webview_renderer;
this(int width, int height) {
this.width = width;
this.height = height;
window = new Window();
window.resizable = false;
window.create_highest_available_context(width, height, "OpenGL Awesomium Demo in D");
window.make_context_current();
window.single_key_down[GLFW_KEY_ESCAPE].connect(&exit);
auto glv = DerelictGL3.reload();
debug writefln("OpenGL Version: %s", glv);
glViewport(0, 0, width, height);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
webview = new Webview(width, height, true);
webview.transparent = true;
new GLFWAWEBridge(webview, window);
webview_renderer = new WebviewRenderer(webview);
webview.load_url(URL);
webview.focus();
}
void display() {
webcore.update();
glClearColor(0.117f, 0.490f, 0.745f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
webview_renderer.display();
}
void run() {
scope(exit) webview_renderer.remove();
scope(exit) webview.destroy();
while(!_exit) {
display();
window.swap_buffers();
glfwPollEvents();
}
}
void exit() {
_exit = true;
}
}
int real_main() {
scope(exit) glfwTerminate();
webcore.initialize(true, // enable plugins
false, // enable javascript
false, // enable databases
"", // package path
"", // locale path
"", // user-data path
"", // plugin path
"", // log path
awe_loglevel.AWE_LL_VERBOSE, // loglevel
false, // force single process
"self", // child process path (if "self", requires AWESingleProcessMain!())
true, // enable auto detect encoding
"", // accept language override
"", // default charset override
"", // user-agent override
"", // proxy-server
"", // proxy-config script
"", // auth-server whitelist
false, // save cache and cookies
0, // max cache size
false, // disable same origin policy
false, // disable win-message pump
""); // custom css
auto hello_world = new HelloWorld(1000, 800);
hello_world.run();
return 0;
}
mixin AWESingleProcessMain!(real_main);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment