#include "renderer.h"
#include "tinyptc/tinyptc.h"
#include <stdio.h>
#include <stdlib.h>

extern "C"
{
void
ptc_cleanup_callback (void)
{
 // fprintf (stderr, "Callback!\n");
}

}

Renderer::Renderer()
{
    sprintf(title, "test");
    width = 640;
    height = 480;

    pixel = (int*)malloc(sizeof(int)*width*height);
    
    if (!ptc_open(title, width, height))
        throw "Could not open renderer";
}

Renderer::~Renderer()
{    
    ptc_close();
}

void Renderer::Update()
{    
    ptc_update (pixel);
}

void Renderer::SetPixel(int x, int y, unsigned long color)
{
    pixel[y*width+x] = color;
}

int Renderer::Width()
{
    return width;
}

int Renderer::Height()
{
    return height;
}
