Source

gb_emulator / gb_emulator / include / gb_emulator / gb_video_sdl.h

Full commit
/*  Copyright © 2011 Chris Spencer <spencercw@gmail.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

#ifndef GB_VIDEO_SDL_H_75A9CC80_1B63_11E1_B757_0002A5D5C51B
#define GB_VIDEO_SDL_H_75A9CC80_1B63_11E1_B757_0002A5D5C51B

#include <gb_emulator/gb_config.h>
#include <gb_emulator/gb_video.hpp>

struct SDL_Surface;

//! SDL video driver.
class GbVideoSdl: public GbVideo
{
public:
	//! Constructor; opens the display.
	/**
	 * \param gb The emulator context.
	 * \param renderer The renderer to use. Only software rendering is supported by the SDL driver.
	 */
	GbVideoSdl(Gb &gb, GbConfig::Renderer renderer);


	//! Indicates whether the video driver is available.
	/**
	 * The implementation for this class always returns \c true.
	 * \return \c true.
	 */
	bool isAvailable()
	{
		return true;
	}

	//! Performs initialisation.
	/**
	 * The implementation for this class does nothing.
	 */
	void initialise()
	{
	}

#ifdef _WIN32
	//! Returns the window handle.
	HWND window() const;
#endif

private:
	SDL_Surface *surface_;

	// Pixel buffers
	boost::scoped_array<uint32_t> unscaledPixelBuffer_;
	boost::scoped_array<uint32_t> scaledPixelBuffer_;

	// Redraws the display
	void draw(uint16_t *pixelBuffer, bool gbc);
};

#endif