#include "GraphicsApi.h"
#include "Fenster.h"
#include "Bild.h"

using namespace Framework;


GraphicsApi::GraphicsApi( GraphicApiType typ )
    : ReferenceCounter()
{
    this->typ = typ;
    fenster = 0;
    backBufferSize = Vec2<int>( 0, 0 );
    fullScreen = 0;
}

GraphicsApi::~GraphicsApi()
{
#ifdef _WIN32
    if( fenster )
        fenster->release();
#endif
}

void GraphicsApi::initialize( WFenster * fenster, Vec2<int> backBufferSize, bool fullScreen )
{
#ifdef _WIN32
    if( this->fenster )
        this->fenster->release();
    this->fenster = fenster;
    if( !backBufferSize.x || !backBufferSize.y )
        backBufferSize = fenster ? fenster->getKörperGröße() : Punkt( 0, 0 );
#endif
    this->backBufferSize = backBufferSize;
    this->fullScreen = fullScreen;
}

void GraphicsApi::setBackBufferSize( Vec2< int > size )
{
    backBufferSize = size;
    update();
}

void GraphicsApi::setFullScreen( bool fullScreen )
{
    this->fullScreen = fullScreen;
    update();
}

void GraphicsApi::beginFrame( bool fill2D, bool fill3D, int fillColor )
{}

void GraphicsApi::renderKamera( Kam3D * zKamera )
{}

Textur *GraphicsApi::createOrGetTextur( const char *name, Bild * b )
{
    if( b )
        b->release();
    return 0;
}

GraphicApiType GraphicsApi::getTyp() const
{
    return typ;
}

Vec2< int > GraphicsApi::getBackBufferSize() const
{
    return backBufferSize;
}

bool GraphicsApi::isFullScreen() const
{
    return fullScreen;
}