/*  $Id: provider_test.cpp,v 1.3 2003/09/16 14:31:28 sphair Exp $
**
**  ClanLib Game SDK
**  Copyright (C) 2003  The ClanLib Team
**  For a total list of contributers see the file CREDITS.
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**
**  This library is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
**  Lesser General Public License for more details.
**
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*/

#include "provider_test.h"

ProviderTest app;

int
ProviderTest::main(int argc, char** argv)
{
        CL_SetupCore::init();
        CL_SetupDisplay::init();
#ifdef USE_SDL        
        CL_SetupSDL::init();
#else
        CL_SetupGL::init();
#endif
        // Set a videomode - 640x480x16bpp
        // false means that this program should not run full-screen
        CL_DisplayWindow window("ProviderTest", 640, 480);

        CL_Surface colorkeyed_png("colorkeyed_png.png");
        CL_Surface indexed_png("indexed_png.png");
        CL_Surface grayscaled_png("grayscaled_png.png");
        CL_Surface grayscaled_alpha_png("grayscaled_alpha_png.png");
        CL_Surface grayscaled_colorkey_png("grayscaled_colorkey_png.png");
        CL_Surface rgb_png("rgb_png.png");
        CL_Surface rgba_png("rgba_png.png");
        CL_Surface grayscaled_jpg("grayscaled_jpg.jpg");
        CL_Surface truecolor_jpg("truecolor_jpg.jpg");

        while (!CL_Keyboard::get_keycode(CL_KEY_ESCAPE))
        {
                const int check_size = 16;
                CL_Display::clear(CL_Color(0, 0, 0));
                for (int y = 0; y < 640; y += check_size*2)
                {
                        for (int x = 0; x < 640; x += check_size*2)
                                CL_Display::fill_rect(CL_Rect(x, y, x + check_size, y + check_size),
                                                      CL_Color(100, 100, 100));
                        for (int x = check_size; x < 640; x += check_size*2)
                                CL_Display::fill_rect(CL_Rect(x, y + check_size, 
                                                              x + check_size, y + check_size*2),
                                                      CL_Color(100, 100, 100));
                }

                colorkeyed_png.draw(40, 30);
                indexed_png.draw(240, 30);
                rgba_png.draw(440, 30);
	   
                grayscaled_png.draw(40, 180);
                grayscaled_alpha_png.draw(240, 180);
                grayscaled_colorkey_png.draw(440, 180);

                rgb_png.draw(40, 330);
                grayscaled_jpg.draw(240, 330);
                truecolor_jpg.draw(440, 330);

                CL_Display::flip();
                CL_System::keep_alive();
                CL_System::sleep(10);
        }
        
#ifdef USE_SDL        
        CL_SetupSDL::deinit();
#else
        CL_SetupGL::deinit();
#endif
        CL_SetupDisplay::deinit();
        CL_SetupCore::deinit();

        return 0;
}

/* EOF */
