Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Making the API simpler, the renderer present semantics are always hav…

…ing a backbuffer and then discarding it. This is best for hardware accelerated rendering.
  • Loading branch information
slouken committed Feb 1, 2011
1 parent 4c63b7a commit 59260a5c95ee510ff787ca15739737dc613227d1
@@ -151,33 +151,12 @@ typedef enum
*/
typedef enum
{
SDL_RENDERER_SINGLEBUFFER = 0x00000001, /**< Render directly to the
window, if possible */

SDL_RENDERER_PRESENTCOPY = 0x00000002, /**< Present uses a copy from
back buffer to the front
buffer */

SDL_RENDERER_PRESENTFLIP2 = 0x00000004, /**< Present uses a flip,
swapping back buffer and
front buffer */

SDL_RENDERER_PRESENTFLIP3 = 0x00000008, /**< Present uses a flip,
rotating between two back
buffers and a front buffer
*/

SDL_RENDERER_PRESENTDISCARD = 0x00000010, /**< Present leaves the contents
of the backbuffer undefined
*/

SDL_RENDERER_PRESENTVSYNC = 0x00000020, /**< Present is synchronized
with the refresh rate */

SDL_RENDERER_ACCELERATED = 0x00000040 /**< The renderer uses hardware
acceleration */

} SDL_RendererFlags;
} SDL_RendererFlags;

/**
* \brief Information on the capabilities of a render driver or context.
@@ -667,9 +667,7 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
}

/* Create a renderer for the window */
if (SDL_CreateRenderer
(SDL_VideoWindow, -1,
SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD) < 0) {
if (SDL_CreateRenderer(SDL_VideoWindow, -1, 0) < 0) {
return NULL;
}
SDL_GetRendererInfo(&SDL_VideoRendererInfo);
@@ -861,6 +859,7 @@ void
SDL_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects)
{
int i;
SDL_Rect rect;

if (screen == SDL_ShadowSurface) {
for (i = 0; i < numrects; ++i) {
@@ -887,18 +886,11 @@ SDL_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects)
SDL_UpdateTexture(SDL_VideoTexture, rect, pixels, pitch);
}
}
if (SDL_VideoRendererInfo.flags & SDL_RENDERER_PRESENTCOPY) {
for (i = 0; i < numrects; ++i) {
SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i]);
}
} else {
SDL_Rect rect;
rect.x = 0;
rect.y = 0;
rect.w = screen->w;
rect.h = screen->h;
SDL_RenderCopy(SDL_VideoTexture, &rect, &rect);
}
rect.x = 0;
rect.y = 0;
rect.w = screen->w;
rect.h = screen->h;
SDL_RenderCopy(SDL_VideoTexture, &rect, &rect);
SDL_RenderPresent();
}
}
@@ -112,8 +112,7 @@ SDL_RenderDriver GL_RenderDriver = {
GL_CreateRenderer,
{
"opengl",
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD |
SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
(SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
15,
{
SDL_PIXELFORMAT_INDEX1LSB,
@@ -252,7 +251,6 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
SDL_Renderer *renderer;
GL_RenderData *data;
GLint value;
int doublebuffer;

/* Render directly to the window, unless we're compositing */
#ifndef __MACOSX__
@@ -304,8 +302,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->window = window;
renderer->driverdata = data;

renderer->info.flags =
(SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED);
renderer->info.flags = SDL_RENDERER_ACCELERATED;

if (GL_LoadFunctions(data) < 0) {
GL_DestroyRenderer(renderer);
@@ -337,12 +334,6 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
}

if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doublebuffer) == 0) {
if (!doublebuffer) {
renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER;
}
}

data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
renderer->info.max_texture_width = value;
data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
@@ -98,8 +98,7 @@ SDL_RenderDriver GL_ES_RenderDriver = {
GLES_CreateRenderer,
{
"opengl_es",
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD |
SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
(SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
{
/* OpenGL ES 1.x supported formats list */
SDL_PIXELFORMAT_RGBA4444,
@@ -241,8 +240,7 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->window = window;
renderer->driverdata = data;

renderer->info.flags =
(SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED);
renderer->info.flags = SDL_RENDERER_ACCELERATED;

#if defined(__QNXNTO__)
#if _NTO_VERSION<=641

0 comments on commit 59260a5

Please sign in to comment.