int S9xOpenGLDisplayDriver::init ()
{
    initialized = false;

    if (!create_context ())
    {
        return -1;
    }

    if (!opengl_defaults ())
    {
        return -1;
    }

    buffer[0] = malloc (image_padded_size);
    buffer[1] = malloc (scaled_padded_size);

    clear_buffers ();

    padded_buffer[0] = (void *) (((uint8 *) buffer[0]) + image_padded_offset);
    padded_buffer[1] = (void *) (((uint8 *) buffer[1]) + scaled_padded_offset);

    GFX.Screen = (uint16 *) padded_buffer[0];
    GFX.Pitch = image_width * image_bpp;

    context->swap_interval (config->sync_to_vblank);

    initialized = true;

    return 0;
}
int
S9xOpenGLDisplayDriver::init (void)
{
    int padding;
    initialized = 0;

    if (!init_glx ())
    {
        return -1;
    }

    if (!opengl_defaults ())
    {
        return -1;
    }

    /* Create two system buffers to avoid DMA contention */

    buffer[0] = malloc (image_padded_size);
    buffer[1] = malloc (scaled_padded_size);

    clear_buffers ();

    padding = (image_padded_size - image_size) / 2;
    padded_buffer[0] = (void *) (((uint8 *) buffer[0]) + padding);

    padding = (scaled_padded_size - scaled_size) / 2;
    padded_buffer[1] = (void *) (((uint8 *) buffer[1]) + padding);

    GFX.Screen = (uint16 *) padded_buffer[0];
    GFX.Pitch = image_width * image_bpp;

    filtering = -1;

    swap_control (config->sync_to_vblank);

    initialized = 1;

    return 0;
}
int
S9xOpenGLDisplayDriver::init (void)
{
    int padding;

    opengl_defaults ();

    /* Create two system buffers to avoid DMA contention */

    buffer[0] = malloc (image_padded_size);
    buffer[1] = malloc (scaled_padded_size);

    // TODO MIKEL the "+ 32" is to prevent overflow from drawing to the right, fix the overflow
    buffer[2] = malloc (image_padded_size + 32); // buffers for second (anaglyphed) screen
    buffer[3] = malloc (scaled_padded_size + 32);

    combined_buffer = malloc(scaled_padded_size);

    clear_buffers ();

    padding = (image_padded_size - image_size) / 2;
    padded_buffer[0] = (void *) (((uint8 *) buffer[0]) + padding);
    padded_buffer[2] = (void *) (((uint8 *) buffer[2]) + padding);

    padding = (scaled_padded_size - scaled_size) / 2;
    padded_buffer[1] = (void *) (((uint8 *) buffer[1]) + padding);
    padded_buffer[3] = (void *) (((uint8 *) buffer[3]) + padding);
    padded_combined_buffer = (void *) (((uint8 *) padded_combined_buffer) + padding);


    GFX.Screen = (uint16 *) padded_buffer[0];
    GFX.Screen2 = (uint16 *) padded_buffer[2];
    GFX.Pitch = image_width * image_bpp;

    filtering = -1;

    this->swap_control (config->sync_to_vblank);

    return 0;
}