// Workshop 1 part 2

import sdljava.*;
import sdljava.video.*;

class part2
{
	public static void main(String[] args)
	{
			// Create an SDL object
		SDLMain sdl = new SDLMain();

			// SDL uses exceptions when it encounters problems
		try
		{
				// Initialise SDL to use its video (graphics) capabilities
			sdl.init(SDLMain.SDL_INIT_VIDEO);
				// SDL uses what it calls a 'surface' as a window.
			SDLSurface screen = SDLVideo.setVideoMode(640, 480, 0, 0 );


			/* ********************************************************* */
			/*         New Stuff                                         */

				// Now we start to reveal what SDL surfaces can do for us.
				// An SDL surface represents an area of graphical memory.
				// This can be used as, for example, the window...
				// ...or an image:
			SDLSurface image = SDLVideo.loadBMP("bgd.bmp");

				// We now have two surfaces:
				//   screen  is our window screen
				//   image   is our loaded bmp image
				// What we want to do is to get our image onto our screen.
				// To do this, we need to do a blit (bit-block-transfer).
				// For our convenience, SDL has functions for this:
			if( image.blitSurface(screen) == -1 )
					// If it went wrong,
					// we can print out a message
				System.out.println("Blit did not work"); 

				// This operation is required to get the screen surface to
				// display its contents. Don't worry about it for now, as
				// this operation will be revealed in the lecture series
				// under 'The Framebuffer' and 'double buffering'.
			screen.flip();


			/*         New Stuff                                         */
			/* ********************************************************* */

				// Make our program sleep for a couple of seconds so we
				// can admire our blank window...
			java.lang.Thread.sleep(2500);
		}
		catch(Exception e) // Just catching all problems for now
		{
				// We shall handle any problems by printing a stack trace:
			e.printStackTrace();
				// and an explanation if that wasn't enough
			System.out.println("SDL could not initialise");
		}

	}
}