Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Making the API simpler, the renderer present semantics are always hav…
Browse files Browse the repository at this point in the history
…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 59260a5
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 294 deletions.
23 changes: 1 addition & 22 deletions include/SDL_video.h
Expand Up @@ -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.
Expand Down
22 changes: 7 additions & 15 deletions src/SDL_compat.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
}
}
Expand Down
13 changes: 2 additions & 11 deletions src/video/SDL_renderer_gl.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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__
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions src/video/SDL_renderer_gles.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 59260a5

Please sign in to comment.