Skip to content

Instantly share code, notes, and snippets.

View adamjs's full-sized avatar
🤠
Wranglin' code

Adam Simmons adamjs

🤠
Wranglin' code
View GitHub Profile
#include "gl_texture_surface.h"
#include <iostream>
#include <cstring>
#include <cstdlib>
GLRAMTextureSurface::GLRAMTextureSurface(int width, int height) : texture_id_(0),
buffer_(0), bpp_(4), rowspan_(0), width_(width), height_(height) {
rowspan_ = width_ * bpp_;
buffer_ = new unsigned char[rowspan_ * height_];
needs_update_ = false;

hello

@adamjs
adamjs / gl_texture_surface.cc
Created September 7, 2013 02:02
Implementation of OpenGL Texture Surface (used with SDL-based WebFlow sample in the Awesomium SDK)
#include "gl_texture_surface.h"
#include <iostream>
#include <cstring>
#include <cstdlib>
GLRAMTextureSurface::GLRAMTextureSurface(int width, int height) : texture_id_(0),
buffer_(0), bpp_(4), rowspan_(0), width_(width), height_(height) {
rowspan_ = width_ * bpp_;
buffer_ = new unsigned char[rowspan_ * height_];
needs_update_ = false;
@adamjs
adamjs / gist:5932868
Created July 5, 2013 08:12
crude demonstration of how to handle SDL_TEXTINPUT (SDL 2.0) with Awesomium's WebKeyboardEvent API
void handleTextInputEvent(const SDL_Event& event) {
Awesomium::WebKeyboardEvent keyEvent;
keyEvent.type = Awesomium::WebKeyboardEvent::kTypeChar;
// WebKit's WebKeyboardEvent only supports up to 4 chars per "text" event
// but SDL supports up to 32 chars. If we really wanted to do this right,
// we'd probably need to inject several events for text > 4 chars.
// Let's just trim it down to 4 for now.
for (int i = 0; i < 4; i++) {
keyEvent.text[i] = (wchar16)event.text.text[i];
@adamjs
adamjs / gl_texture_surface.cc
Created March 11, 2013 10:39
This Surface (and corresponding SurfaceFactory) implementation demonstrates how to blit Awesomium paint events directly to an OpenGL texture.
#include "gl_texture_surface.h"
#include <iostream>
GLRAMTextureSurface::GLRAMTextureSurface(int width, int height) : texture_id_(0),
buffer_(0), bpp_(4), rowspan_(0), width_(width), height_(height) {
rowspan_ = width_ * bpp_;
buffer_ = new unsigned char[rowspan_ * height_];
needs_update_ = false;
glGenTextures(1, &texture_id_);