Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Streamlined the API a bit and optimized the software renderer.
  • Loading branch information
slouken committed Jul 15, 2006
1 parent 73496da commit fa78c259a882e6ca597c234cd721675769558227
@@ -176,9 +176,7 @@ typedef enum
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_RenderTarget = 0x00000040, /**< The renderer can create texture render targets */
SDL_Renderer_Accelerated = 0x00000080, /**< The renderer uses hardware acceleration */
SDL_Renderer_Minimal = 0x00000100, /**< The renderer only supports the read/write pixel and present functions */
SDL_Renderer_Accelerated = 0x00000040, /**< The renderer uses hardware acceleration */
} SDL_RendererFlags;

/**
@@ -193,7 +191,7 @@ typedef struct SDL_RendererInfo
Uint32 blend_modes; /**< A mask of supported blend modes */
Uint32 scale_modes; /**< A mask of supported scale modes */
Uint32 num_texture_formats; /**< The number of available texture formats */
Uint32 texture_formats[32]; /**< The available texture formats */
Uint32 texture_formats[16]; /**< The available texture formats */
int max_texture_width; /**< The maximimum texture width */
int max_texture_height; /**< The maximimum texture height */
} SDL_RendererInfo;
@@ -205,9 +203,8 @@ typedef struct SDL_RendererInfo
*/
typedef enum
{
SDL_TextureAccess_Render, /**< Unlockable video memory, rendering allowed */
SDL_TextureAccess_Remote, /**< Unlockable video memory */
SDL_TextureAccess_Local, /**< Lockable system memory */
SDL_TextureAccess_Remote, /**< Unlockable video memory */
} SDL_TextureAccess;

/**
@@ -836,11 +833,16 @@ extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_WindowID windowID);
extern DECLSPEC int SDLCALL SDL_GetNumRenderers(void);

/**
* \fn SDL_RendererInfo *SDL_GetRendererInfo(int index)
* \fn int SDL_GetRendererInfo(int index, SDL_RendererInfo *info)
*
* \brief Get information about a specific render manager on the current
* display.
*
* \param index The index to query information about, or -1 to query the currently renderer
* \param info A pointer to an SDL_RendererInfo struct to be filled with information on the renderer
*
* \return 0 on success, -1 if the index was out of range
*
* \sa SDL_CreateRenderer()
*/
extern DECLSPEC int SDLCALL SDL_GetRendererInfo(int index,
@@ -31,6 +31,7 @@


static SDL_WindowID SDL_VideoWindow;
static SDL_RendererInfo SDL_VideoRendererInfo;
static SDL_TextureID SDL_VideoTexture;
static SDL_Surface *SDL_VideoSurface;
static SDL_Surface *SDL_ShadowSurface;
@@ -442,10 +443,12 @@ 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) <
0) {
if (SDL_CreateRenderer
(SDL_VideoWindow, -1,
SDL_Renderer_SingleBuffer | SDL_Renderer_PresentDiscard) < 0) {
return NULL;
}
SDL_GetRendererInfo(-1, &SDL_VideoRendererInfo);

/* Create a texture for the screen surface */
SDL_VideoTexture =
@@ -642,8 +645,19 @@ SDL_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects)
screen = SDL_VideoSurface;
}
if (screen == SDL_VideoSurface) {
for (i = 0; i < numrects; ++i) {
SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i],
if (SDL_VideoRendererInfo.flags & SDL_Renderer_PresentCopy) {
for (i = 0; i < numrects; ++i) {
SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i],
SDL_TextureBlendMode_None,
SDL_TextureScaleMode_None);
}
} else {
SDL_Rect rect;
rect.x = 0;
rect.y = 0;
rect.w = screen->w;
rect.h = screen->h;
SDL_RenderCopy(SDL_VideoTexture, &rect, &rect,
SDL_TextureBlendMode_None,
SDL_TextureScaleMode_None);
}

0 comments on commit fa78c25

Please sign in to comment.