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

Making the API simpler, texture color and alpha modulation are suppor…

…ted by all renderers.
  • Loading branch information
slouken committed Feb 1, 2011
1 parent a8fe501 commit 4c63b7abe8aabcff882fd838e489980da91ad593
@@ -186,7 +186,6 @@ typedef struct SDL_RendererInfo
{
const char *name; /**< The name of the renderer */
Uint32 flags; /**< Supported ::SDL_RendererFlags */
Uint32 mod_modes; /**< A mask of supported channel modulation */
Uint32 num_texture_formats; /**< The number of available texture formats */
Uint32 texture_formats[50]; /**< The available texture formats */
int max_texture_width; /**< The maximimum texture width */
@@ -79,10 +79,6 @@ static int GL_SetTexturePalette(SDL_Renderer * renderer,
static int GL_GetTexturePalette(SDL_Renderer * renderer,
SDL_Texture * texture, SDL_Color * colors,
int firstcolor, int ncolors);
static int GL_SetTextureColorMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int GL_SetTextureAlphaMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels,
int pitch);
@@ -118,8 +114,6 @@ SDL_RenderDriver GL_RenderDriver = {
"opengl",
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD |
SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
(SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
SDL_TEXTUREMODULATE_ALPHA),
15,
{
SDL_PIXELFORMAT_INDEX1LSB,
@@ -291,8 +285,6 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->QueryTexturePixels = GL_QueryTexturePixels;
renderer->SetTexturePalette = GL_SetTexturePalette;
renderer->GetTexturePalette = GL_GetTexturePalette;
renderer->SetTextureColorMod = GL_SetTextureColorMod;
renderer->SetTextureAlphaMod = GL_SetTextureAlphaMod;
renderer->UpdateTexture = GL_UpdateTexture;
renderer->LockTexture = GL_LockTexture;
renderer->UnlockTexture = GL_UnlockTexture;
@@ -947,18 +939,6 @@ SetupTextureUpdate(GL_RenderData * renderdata, SDL_Texture * texture,
HACK_RYAN_FIXME);
}

static int
GL_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
return 0;
}

static int
GL_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
return 0;
}

static int
GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels, int pitch)
@@ -67,10 +67,6 @@ static int GLES_SetTexturePalette(SDL_Renderer * renderer,
static int GLES_GetTexturePalette(SDL_Renderer * renderer,
SDL_Texture * texture, SDL_Color * colors,
int firstcolor, int ncolors);
static int GLES_SetTextureColorMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int GLES_SetTextureAlphaMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels,
int pitch);
@@ -104,8 +100,6 @@ SDL_RenderDriver GL_ES_RenderDriver = {
"opengl_es",
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD |
SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
(SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
SDL_TEXTUREMODULATE_ALPHA),
{
/* OpenGL ES 1.x supported formats list */
SDL_PIXELFORMAT_RGBA4444,
@@ -231,8 +225,6 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->QueryTexturePixels = GLES_QueryTexturePixels;
renderer->SetTexturePalette = GLES_SetTexturePalette;
renderer->GetTexturePalette = GLES_GetTexturePalette;
renderer->SetTextureColorMod = GLES_SetTextureColorMod;
renderer->SetTextureAlphaMod = GLES_SetTextureAlphaMod;
renderer->UpdateTexture = GLES_UpdateTexture;
renderer->LockTexture = GLES_LockTexture;
renderer->UnlockTexture = GLES_UnlockTexture;
@@ -496,18 +488,6 @@ SetupTextureUpdate(GLES_RenderData * renderdata, SDL_Texture * texture,
renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
}

static int
GLES_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
return 0;
}

static int
GLES_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
return 0;
}

static int
GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels, int pitch)
@@ -49,6 +49,8 @@ static int SW_SetTextureColorMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int SW_SetTextureAlphaMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int SW_SetTextureBlendMode(SDL_Renderer * renderer,
SDL_Texture * texture);
static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels,
int pitch);
@@ -82,8 +84,6 @@ SDL_RenderDriver SW_RenderDriver = {
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC),
(SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
SDL_TEXTUREMODULATE_ALPHA),
14,
{
SDL_PIXELFORMAT_INDEX8,
@@ -172,12 +172,12 @@ Setup_SoftwareRenderer(SDL_Renderer * renderer)
renderer->GetTexturePalette = SW_GetTexturePalette;
renderer->SetTextureColorMod = SW_SetTextureColorMod;
renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod;
renderer->SetTextureBlendMode = SW_SetTextureBlendMode;
renderer->UpdateTexture = SW_UpdateTexture;
renderer->LockTexture = SW_LockTexture;
renderer->UnlockTexture = SW_UnlockTexture;
renderer->DestroyTexture = SW_DestroyTexture;

renderer->info.mod_modes = SW_RenderDriver.info.mod_modes;
renderer->info.num_texture_formats =
SW_RenderDriver.info.num_texture_formats;
SDL_memcpy(renderer->info.texture_formats,
@@ -86,8 +86,6 @@ struct SDL_Renderer
void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
void (*DirtyTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
int numrects, const SDL_Rect * rects);
int (*SetDrawColor) (SDL_Renderer * renderer);
int (*SetDrawBlendMode) (SDL_Renderer * renderer);
int (*RenderClear) (SDL_Renderer * renderer);
int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points,
int count);
@@ -2074,7 +2074,11 @@ SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b)
texture->r = r;
texture->g = g;
texture->b = b;
return renderer->SetTextureColorMod(renderer, texture);
if (renderer->SetTextureColorMod) {
return renderer->SetTextureColorMod(renderer, texture);
} else {
return 0;
}
}

int
@@ -2116,7 +2120,11 @@ SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha)
texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA;
}
texture->a = alpha;
return renderer->SetTextureAlphaMod(renderer, texture);
if (renderer->SetTextureAlphaMod) {
return renderer->SetTextureAlphaMod(renderer, texture);
} else {
return 0;
}
}

int
@@ -2143,7 +2151,11 @@ SDL_SetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode blendMode)
return -1;
}
texture->blendMode = blendMode;
return renderer->SetTextureBlendMode(renderer, texture);
if (renderer->SetTextureBlendMode) {
return renderer->SetTextureBlendMode(renderer, texture);
} else {
return 0;
}
}

int
@@ -2258,11 +2270,7 @@ SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
renderer->g = g;
renderer->b = b;
renderer->a = a;
if (renderer->SetDrawColor) {
return renderer->SetDrawColor(renderer);
} else {
return 0;
}
return 0;
}

int
@@ -2299,11 +2307,7 @@ SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode)
return -1;
}
renderer->blendMode = blendMode;
if (renderer->SetDrawBlendMode) {
return renderer->SetDrawBlendMode(renderer);
} else {
return 0;
}
return 0;
}

int
@@ -51,10 +51,6 @@ static int DirectFB_GetTexturePalette(SDL_Renderer * renderer,
SDL_Texture * texture,
SDL_Color * colors,
int firstcolor, int ncolors);
static int DirectFB_SetTextureAlphaMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int DirectFB_SetTextureColorMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int DirectFB_UpdateTexture(SDL_Renderer * renderer,
SDL_Texture * texture,
const SDL_Rect * rect,
@@ -68,7 +64,6 @@ static void DirectFB_UnlockTexture(SDL_Renderer * renderer,
static void DirectFB_DirtyTexture(SDL_Renderer * renderer,
SDL_Texture * texture, int numrects,
const SDL_Rect * rects);
static int DirectFB_SetDrawBlendMode(SDL_Renderer * renderer);
static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer,
const SDL_Point * points, int count);
static int DirectFB_RenderDrawLines(SDL_Renderer * renderer,
@@ -96,8 +91,6 @@ SDL_RenderDriver DirectFB_RenderDriver = {
SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD |
SDL_RENDERER_ACCELERATED),
(SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
SDL_TEXTUREMODULATE_ALPHA),
14,
{
SDL_PIXELFORMAT_INDEX4LSB,
@@ -275,16 +268,12 @@ DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->QueryTexturePixels = DirectFB_QueryTexturePixels;
renderer->SetTexturePalette = DirectFB_SetTexturePalette;
renderer->GetTexturePalette = DirectFB_GetTexturePalette;
renderer->SetTextureAlphaMod = DirectFB_SetTextureAlphaMod;
renderer->SetTextureColorMod = DirectFB_SetTextureColorMod;
renderer->UpdateTexture = DirectFB_UpdateTexture;
renderer->LockTexture = DirectFB_LockTexture;
renderer->UnlockTexture = DirectFB_UnlockTexture;
renderer->DirtyTexture = DirectFB_DirtyTexture;
renderer->RenderDrawPoints = DirectFB_RenderDrawPoints;
renderer->RenderDrawLines = DirectFB_RenderDrawLines;
/* SetDrawColor - no needed */
renderer->SetDrawBlendMode = DirectFB_SetDrawBlendMode;
renderer->RenderFillRects = DirectFB_RenderFillRects;
renderer->RenderDrawRects = DirectFB_RenderDrawRects;
/* RenderDrawEllipse - no reference implementation yet */
@@ -635,18 +624,6 @@ DirectFB_GetTexturePalette(SDL_Renderer * renderer,
return -1;
}

static int
DirectFB_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
return 0;
}

static int
DirectFB_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
return 0;
}

static int
DirectFB_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
@@ -50,10 +50,6 @@ static int NDS_SetTexturePalette(SDL_Renderer * renderer,
static int NDS_GetTexturePalette(SDL_Renderer * renderer,
SDL_Texture * texture, SDL_Color * colors,
int firstcolor, int ncolors);
static int NDS_SetTextureColorMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int NDS_SetTextureAlphaMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels,
int pitch);
@@ -76,7 +72,6 @@ SDL_RenderDriver NDS_RenderDriver = {
NDS_CreateRenderer,
{"nds", /* char* name */
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC), /* u32 flags */
(SDL_TEXTUREMODULATE_NONE), /* u32 mod_modes */
3, /* u32 num_texture_formats */
{
SDL_PIXELFORMAT_INDEX8,
@@ -175,14 +170,11 @@ NDS_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->QueryTexturePixels = NDS_QueryTexturePixels;
renderer->SetTexturePalette = NDS_SetTexturePalette;
renderer->GetTexturePalette = NDS_GetTexturePalette;
renderer->SetTextureColorMod = NDS_SetTextureColorMod;
renderer->SetTextureAlphaMod = NDS_SetTextureAlphaMod;
renderer->UpdateTexture = NDS_UpdateTexture;
renderer->LockTexture = NDS_LockTexture;
renderer->UnlockTexture = NDS_UnlockTexture;
renderer->DestroyTexture = NDS_DestroyTexture;

renderer->info.mod_modes = NDS_RenderDriver.info.mod_modes;
renderer->info.num_texture_formats =
NDS_RenderDriver.info.num_texture_formats;
SDL_memcpy(renderer->info.texture_formats,
@@ -557,18 +549,4 @@ NDS_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
return 0;
}

static int
NDS_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
/* stub! */
return 0;
}

static int
NDS_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
/* stub! */
return 0;
}

/* vi: set ts=4 sw=4 expandtab: */

0 comments on commit 4c63b7a

Please sign in to comment.