Example #1
0
/**
 * Wrapper around various software and OpenGL screen buffer pushing functions which zoom.
 * Basically called just from Screen::flip()
 */
void Zoom::flipWithZoom(SDL_Surface *src, SDL_Surface *dst, OpenGL *glOut)
{
	if (Screen::isOpenGLEnabled() && glOut->buffer_surface)
	{
		SDL_BlitSurface(src, 0, glOut->buffer_surface->getSurface(), 0); // TODO; this is less than ideal...

		glOut->refresh(glOut->linear, glOut->iwidth, glOut->iheight, dst->w, dst->h);
		SDL_GL_SwapBuffers();
	} else
	{
		_zoomSurfaceY(src, dst, 0, 0);
	}
}
Example #2
0
/**
 * Wrapper around various software and OpenGL screen buffer pushing functions which zoom.
 * Basically called just from Screen::flip()
 *
 * @param src The surface to zoom (input).
 * @param dst The zoomed surface (output).
 * @param topBlackBand Size of top black band in pixels (letterboxing).
 * @param bottomBlackBand Size of bottom black band in pixels (letterboxing).
 * @param leftBlackBand Size of left black band in pixels (letterboxing).
 * @param rightBlackBand Size of right black band in pixels (letterboxing).
 * @param glOut OpenGL output.
 */
void Zoom::flipWithZoom(SDL_Surface *src, SDL_Surface *dst, int topBlackBand, int bottomBlackBand, int leftBlackBand, int rightBlackBand, OpenGL *glOut)
{
	assert (0 && "not implemented");
#if 0
	if (Screen::isOpenGLEnabled())
	{
#ifndef __NO_OPENGL
		if (glOut->buffer_surface)
		{
			SDL_BlitSurface(src, 0, glOut->buffer_surface->getSurface(), 0); // TODO; this is less than ideal...

			glOut->refresh(glOut->linear, glOut->iwidth, glOut->iheight, dst->w, dst->h, topBlackBand, bottomBlackBand, leftBlackBand, rightBlackBand);
			SDL_GL_SwapBuffers();
		}
#endif
	}
	else if (topBlackBand <= 0 && bottomBlackBand <= 0 && leftBlackBand <= 0 && rightBlackBand <= 0)
	{
		_zoomSurfaceY(src, dst, 0, 0);
	}
	else if (dst->w - leftBlackBand - rightBlackBand == src->w && dst->h - topBlackBand - bottomBlackBand == src->h)
	{
		SDL_Rect dstrect = {(Sint16)leftBlackBand, (Sint16)topBlackBand, (Uint16)src->w, (Uint16)src->h};
		SDL_BlitSurface(src, NULL, dst, &dstrect);
	}
	else
	{
		SDL_Surface *tmp = SDL_CreateRGBSurface(dst->flags, dst->w - leftBlackBand - rightBlackBand, dst->h - topBlackBand - bottomBlackBand, dst->format->BitsPerPixel, 0, 0, 0, 0);
		_zoomSurfaceY(src, tmp, 0, 0);
		if (src->format->palette != NULL)
		{
			SDL_SetPalette(tmp, SDL_LOGPAL|SDL_PHYSPAL, src->format->palette->colors, 0, src->format->palette->ncolors);
		}
		SDL_Rect dstrect = {(Sint16)leftBlackBand, (Sint16)topBlackBand, (Uint16)tmp->w, (Uint16)tmp->h};
		SDL_BlitSurface(tmp, NULL, dst, &dstrect);
		SDL_FreeSurface(tmp);
	}
#endif
}
Example #3
0
/**
 * Renders the buffer's contents onto the screen, applying
 * any necessary filters or conversions in the process.
 * If the scaling factor is bigger than 1, the entire contents
 * of the buffer are resized by that factor (eg. 2 = doubled)
 * before being put on screen.
 */
void Screen::flip()
{
    if (getWidth() != BASE_WIDTH || getHeight() != BASE_HEIGHT)
    {
        _zoomSurfaceY(_surface->getSurface(), _screen, 0, 0);
    }
    else
    {
        SDL_BlitSurface(_surface->getSurface(), 0, _screen, 0);
    }

    if (SDL_Flip(_screen) == -1)
    {
        throw Exception(SDL_GetError());
    }
}