Make SDL_SetError and friends unconditionally return -1.
This lets us change things like this... if (Failed) { SDL_SetError("We failed"); return -1; } ...into this... if (Failed) { return SDL_SetError("We failed"); } Fixes Bugzilla #1778.
This commit is contained in:
parent
8c6b9f4743
commit
4f438b70a2
106 changed files with 616 additions and 1189 deletions
|
@ -82,9 +82,8 @@ int
|
|||
SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info)
|
||||
{
|
||||
if (index < 0 || index >= SDL_GetNumRenderDrivers()) {
|
||||
SDL_SetError("index must be in the range of 0 - %d",
|
||||
SDL_GetNumRenderDrivers() - 1);
|
||||
return -1;
|
||||
return SDL_SetError("index must be in the range of 0 - %d",
|
||||
SDL_GetNumRenderDrivers() - 1);
|
||||
}
|
||||
*info = render_drivers[index]->info;
|
||||
return 0;
|
||||
|
@ -695,8 +694,7 @@ SDL_UpdateTextureYUV(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
||||
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
||||
if (!temp_pixels) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
|
||||
rect->w, rect->h, temp_pixels, temp_pitch);
|
||||
|
@ -732,8 +730,7 @@ SDL_UpdateTextureNative(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
||||
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
||||
if (!temp_pixels) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_ConvertPixels(rect->w, rect->h,
|
||||
texture->format, pixels, pitch,
|
||||
|
@ -800,8 +797,7 @@ SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
|
||||
SDL_SetError("SDL_LockTexture(): texture must be streaming");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_LockTexture(): texture must be streaming");
|
||||
}
|
||||
|
||||
if (!rect) {
|
||||
|
@ -897,8 +893,7 @@ int
|
|||
SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
if (!SDL_RenderTargetSupported(renderer)) {
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
if (texture == renderer->target) {
|
||||
/* Nothing to do! */
|
||||
|
@ -909,12 +904,10 @@ SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
if (texture) {
|
||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
if (renderer != texture->renderer) {
|
||||
SDL_SetError("Texture was not created with this renderer");
|
||||
return -1;
|
||||
return SDL_SetError("Texture was not created with this renderer");
|
||||
}
|
||||
if (texture->access != SDL_TEXTUREACCESS_TARGET) {
|
||||
SDL_SetError("Texture not created with SDL_TEXTUREACCESS_TARGET");
|
||||
return -1;
|
||||
return SDL_SetError("Texture not created with SDL_TEXTUREACCESS_TARGET");
|
||||
}
|
||||
if (texture->native) {
|
||||
/* Always render to the native texture */
|
||||
|
@ -979,8 +972,7 @@ UpdateLogicalSize(SDL_Renderer *renderer)
|
|||
SDL_GetWindowSize(renderer->window, &w, &h);
|
||||
} else {
|
||||
/* FIXME */
|
||||
SDL_SetError("Internal error: No way to get output resolution");
|
||||
return -1;
|
||||
return SDL_SetError("Internal error: No way to get output resolution");
|
||||
}
|
||||
|
||||
want_aspect = (float)renderer->logical_w / renderer->logical_h;
|
||||
|
@ -1198,8 +1190,7 @@ RenderDrawPointsWithRects(SDL_Renderer * renderer,
|
|||
|
||||
frects = SDL_stack_alloc(SDL_FRect, count);
|
||||
if (!frects) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
frects[i].x = points[i].x * renderer->scale.x;
|
||||
|
@ -1226,8 +1217,7 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!points) {
|
||||
SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points");
|
||||
}
|
||||
if (count < 1) {
|
||||
return 0;
|
||||
|
@ -1243,8 +1233,7 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer,
|
|||
|
||||
fpoints = SDL_stack_alloc(SDL_FPoint, count);
|
||||
if (!fpoints) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
fpoints[i].x = points[i].x * renderer->scale.x;
|
||||
|
@ -1282,8 +1271,7 @@ RenderDrawLinesWithRects(SDL_Renderer * renderer,
|
|||
|
||||
frects = SDL_stack_alloc(SDL_FRect, count-1);
|
||||
if (!frects) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
status = 0;
|
||||
|
@ -1338,8 +1326,7 @@ SDL_RenderDrawLines(SDL_Renderer * renderer,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!points) {
|
||||
SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
|
||||
}
|
||||
if (count < 2) {
|
||||
return 0;
|
||||
|
@ -1355,8 +1342,7 @@ SDL_RenderDrawLines(SDL_Renderer * renderer,
|
|||
|
||||
fpoints = SDL_stack_alloc(SDL_FPoint, count);
|
||||
if (!fpoints) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
fpoints[i].x = points[i].x * renderer->scale.x;
|
||||
|
@ -1408,8 +1394,7 @@ SDL_RenderDrawRects(SDL_Renderer * renderer,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!rects) {
|
||||
SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
|
||||
}
|
||||
if (count < 1) {
|
||||
return 0;
|
||||
|
@ -1455,8 +1440,7 @@ SDL_RenderFillRects(SDL_Renderer * renderer,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!rects) {
|
||||
SDL_SetError("SDL_RenderFillRects(): Passed NULL rects");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_RenderFillRects(): Passed NULL rects");
|
||||
}
|
||||
if (count < 1) {
|
||||
return 0;
|
||||
|
@ -1468,8 +1452,7 @@ SDL_RenderFillRects(SDL_Renderer * renderer,
|
|||
|
||||
frects = SDL_stack_alloc(SDL_FRect, count);
|
||||
if (!frects) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
frects[i].x = rects[i].x * renderer->scale.x;
|
||||
|
@ -1497,8 +1480,7 @@ SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (renderer != texture->renderer) {
|
||||
SDL_SetError("Texture was not created with this renderer");
|
||||
return -1;
|
||||
return SDL_SetError("Texture was not created with this renderer");
|
||||
}
|
||||
|
||||
real_srcrect.x = 0;
|
||||
|
@ -1566,12 +1548,10 @@ SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (renderer != texture->renderer) {
|
||||
SDL_SetError("Texture was not created with this renderer");
|
||||
return -1;
|
||||
return SDL_SetError("Texture was not created with this renderer");
|
||||
}
|
||||
if (!renderer->RenderCopyEx) {
|
||||
SDL_SetError("Renderer does not support RenderCopyEx");
|
||||
return -1;
|
||||
return SDL_SetError("Renderer does not support RenderCopyEx");
|
||||
}
|
||||
|
||||
real_srcrect.x = 0;
|
||||
|
@ -1623,8 +1603,7 @@ SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!renderer->RenderReadPixels) {
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
if (!format) {
|
||||
|
@ -1729,8 +1708,7 @@ int SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh)
|
|||
return renderer->GL_BindTexture(renderer, texture, texw, texh);
|
||||
}
|
||||
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int SDL_GL_UnbindTexture(SDL_Texture *texture)
|
||||
|
@ -1743,8 +1721,7 @@ int SDL_GL_UnbindTexture(SDL_Texture *texture)
|
|||
return renderer->GL_UnbindTexture(renderer, texture);
|
||||
}
|
||||
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -896,8 +896,7 @@ SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format)
|
|||
|
||||
if (!SDL_PixelFormatEnumToMasks
|
||||
(target_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask) || bpp < 15) {
|
||||
SDL_SetError("Unsupported YUV destination format");
|
||||
return -1;
|
||||
return SDL_SetError("Unsupported YUV destination format");
|
||||
}
|
||||
|
||||
swdata->target_format = target_format;
|
||||
|
@ -1057,8 +1056,8 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
|||
swdata->colortab = (int *) SDL_malloc(4 * 256 * sizeof(int));
|
||||
swdata->rgb_2_pix = (Uint32 *) SDL_malloc(3 * 768 * sizeof(Uint32));
|
||||
if (!swdata->pixels || !swdata->colortab || !swdata->rgb_2_pix) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_SW_DestroyYUVTexture(swdata);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1197,9 +1196,8 @@ SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
|||
if (rect
|
||||
&& (rect->x != 0 || rect->y != 0 || rect->w != swdata->w
|
||||
|| rect->h != swdata->h)) {
|
||||
SDL_SetError
|
||||
return SDL_SetError
|
||||
("YV12 and IYUV textures only support full surface locks");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1309,8 +1307,7 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
|
|||
Cb = lum + 3;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unsupported YUV format in copy");
|
||||
return (-1);
|
||||
return SDL_SetError("Unsupported YUV format in copy");
|
||||
}
|
||||
mod = (pitch / SDL_BYTESPERPIXEL(target_format));
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ typedef struct
|
|||
float u, v;
|
||||
} Vertex;
|
||||
|
||||
static void
|
||||
static int
|
||||
D3D_SetError(const char *prefix, HRESULT result)
|
||||
{
|
||||
const char *error;
|
||||
|
@ -322,7 +322,7 @@ D3D_SetError(const char *prefix, HRESULT result)
|
|||
error = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
SDL_SetError("%s: %s", prefix, error);
|
||||
return SDL_SetError("%s: %s", prefix, error);
|
||||
}
|
||||
|
||||
static D3DFORMAT
|
||||
|
@ -373,8 +373,7 @@ D3D_Reset(SDL_Renderer * renderer)
|
|||
/* Don't worry about it, we'll reset later... */
|
||||
return 0;
|
||||
} else {
|
||||
D3D_SetError("Reset()", result);
|
||||
return -1;
|
||||
return D3D_SetError("Reset()", result);
|
||||
}
|
||||
}
|
||||
IDirect3DDevice9_SetVertexShader(data->device, NULL);
|
||||
|
@ -422,8 +421,7 @@ D3D_ActivateRenderer(SDL_Renderer * renderer)
|
|||
result = IDirect3DDevice9_BeginScene(data->device);
|
||||
}
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("BeginScene()", result);
|
||||
return -1;
|
||||
return D3D_SetError("BeginScene()", result);
|
||||
}
|
||||
data->beginScene = SDL_FALSE;
|
||||
}
|
||||
|
@ -704,8 +702,7 @@ D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
|
||||
data = (D3D_TextureData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
data->scaleMode = GetScaleQuality();
|
||||
|
||||
|
@ -732,8 +729,7 @@ D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
PixelFormatToD3DFMT(texture->format),
|
||||
pool, &data->texture, NULL);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("CreateTexture()", result);
|
||||
return -1;
|
||||
return D3D_SetError("CreateTexture()", result);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -767,8 +763,7 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
}
|
||||
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("LockRect()", result);
|
||||
return -1;
|
||||
return D3D_SetError("LockRect()", result);
|
||||
}
|
||||
|
||||
src = pixels;
|
||||
|
@ -804,8 +799,7 @@ D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
|
||||
result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("LockRect()", result);
|
||||
return -1;
|
||||
return D3D_SetError("LockRect()", result);
|
||||
}
|
||||
*pixels = locked.pBits;
|
||||
*pitch = locked.Pitch;
|
||||
|
@ -881,13 +875,11 @@ D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
texturedata = (D3D_TextureData *) texture->driverdata;
|
||||
result = IDirect3DTexture9_GetSurfaceLevel(texturedata->texture, 0, &data->currentRenderTarget);
|
||||
if(FAILED(result)) {
|
||||
D3D_SetError("GetSurfaceLevel()", result);
|
||||
return -1;
|
||||
return D3D_SetError("GetSurfaceLevel()", result);
|
||||
}
|
||||
result = IDirect3DDevice9_SetRenderTarget(data->device, 0, data->currentRenderTarget);
|
||||
if(FAILED(result)) {
|
||||
D3D_SetError("SetRenderTarget()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetRenderTarget()", result);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -936,8 +928,7 @@ D3D_RenderClear(SDL_Renderer * renderer)
|
|||
}
|
||||
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("Clear()", result);
|
||||
return -1;
|
||||
return D3D_SetError("Clear()", result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -997,8 +988,7 @@ D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points,
|
|||
IDirect3DDevice9_SetTexture(data->device, 0,
|
||||
(IDirect3DBaseTexture9 *) 0);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetTexture()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetTexture()", result);
|
||||
}
|
||||
|
||||
color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
|
||||
|
@ -1017,8 +1007,7 @@ D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points,
|
|||
vertices, sizeof(*vertices));
|
||||
SDL_stack_free(vertices);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("DrawPrimitiveUP()", result);
|
||||
return -1;
|
||||
return D3D_SetError("DrawPrimitiveUP()", result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1043,8 +1032,7 @@ D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
|
|||
IDirect3DDevice9_SetTexture(data->device, 0,
|
||||
(IDirect3DBaseTexture9 *) 0);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetTexture()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetTexture()", result);
|
||||
}
|
||||
|
||||
color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
|
||||
|
@ -1073,8 +1061,7 @@ D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
|
|||
|
||||
SDL_stack_free(vertices);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("DrawPrimitiveUP()", result);
|
||||
return -1;
|
||||
return D3D_SetError("DrawPrimitiveUP()", result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1100,8 +1087,7 @@ D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects,
|
|||
IDirect3DDevice9_SetTexture(data->device, 0,
|
||||
(IDirect3DBaseTexture9 *) 0);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetTexture()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetTexture()", result);
|
||||
}
|
||||
|
||||
color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
|
||||
|
@ -1146,8 +1132,7 @@ D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects,
|
|||
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN,
|
||||
2, vertices, sizeof(*vertices));
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("DrawPrimitiveUP()", result);
|
||||
return -1;
|
||||
return D3D_SetError("DrawPrimitiveUP()", result);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -1224,28 +1209,24 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
IDirect3DDevice9_SetTexture(data->device, 0, (IDirect3DBaseTexture9 *)
|
||||
texturedata->texture);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetTexture()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetTexture()", result);
|
||||
}
|
||||
if (shader) {
|
||||
result = IDirect3DDevice9_SetPixelShader(data->device, shader);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetShader()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetShader()", result);
|
||||
}
|
||||
}
|
||||
result =
|
||||
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
|
||||
vertices, sizeof(*vertices));
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("DrawPrimitiveUP()", result);
|
||||
return -1;
|
||||
return D3D_SetError("DrawPrimitiveUP()", result);
|
||||
}
|
||||
if (shader) {
|
||||
result = IDirect3DDevice9_SetPixelShader(data->device, NULL);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetShader()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetShader()", result);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -1348,28 +1329,24 @@ D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
IDirect3DDevice9_SetTexture(data->device, 0, (IDirect3DBaseTexture9 *)
|
||||
texturedata->texture);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetTexture()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetTexture()", result);
|
||||
}
|
||||
if (shader) {
|
||||
result = IDirect3DDevice9_SetPixelShader(data->device, shader);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetShader()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetShader()", result);
|
||||
}
|
||||
}
|
||||
result =
|
||||
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
|
||||
vertices, sizeof(*vertices));
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("DrawPrimitiveUP()", result);
|
||||
return -1;
|
||||
return D3D_SetError("DrawPrimitiveUP()", result);
|
||||
}
|
||||
if (shader) {
|
||||
result = IDirect3DDevice9_SetPixelShader(data->device, NULL);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetShader()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetShader()", result);
|
||||
}
|
||||
}
|
||||
ID3DXMatrixStack_Pop(data->matrixStack);
|
||||
|
@ -1394,30 +1371,26 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
|
||||
result = IDirect3DDevice9_GetBackBuffer(data->device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("GetBackBuffer()", result);
|
||||
return -1;
|
||||
return D3D_SetError("GetBackBuffer()", result);
|
||||
}
|
||||
|
||||
result = IDirect3DSurface9_GetDesc(backBuffer, &desc);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("GetDesc()", result);
|
||||
IDirect3DSurface9_Release(backBuffer);
|
||||
return -1;
|
||||
return D3D_SetError("GetDesc()", result);
|
||||
}
|
||||
|
||||
result = IDirect3DDevice9_CreateOffscreenPlainSurface(data->device, desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surface, NULL);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("CreateOffscreenPlainSurface()", result);
|
||||
IDirect3DSurface9_Release(backBuffer);
|
||||
return -1;
|
||||
return D3D_SetError("CreateOffscreenPlainSurface()", result);
|
||||
}
|
||||
|
||||
result = IDirect3DDevice9_GetRenderTargetData(data->device, backBuffer, surface);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("GetRenderTargetData()", result);
|
||||
IDirect3DSurface9_Release(surface);
|
||||
IDirect3DSurface9_Release(backBuffer);
|
||||
return -1;
|
||||
return D3D_SetError("GetRenderTargetData()", result);
|
||||
}
|
||||
|
||||
d3drect.left = rect->x;
|
||||
|
@ -1427,10 +1400,9 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
|
||||
result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("LockRect()", result);
|
||||
IDirect3DSurface9_Release(surface);
|
||||
IDirect3DSurface9_Release(backBuffer);
|
||||
return -1;
|
||||
return D3D_SetError("LockRect()", result);
|
||||
}
|
||||
|
||||
SDL_ConvertPixels(rect->w, rect->h,
|
||||
|
|
|
@ -208,8 +208,7 @@ GL_LoadFunctions(GL_RenderData * data)
|
|||
do { \
|
||||
data->func = SDL_GL_GetProcAddress(#func); \
|
||||
if ( ! data->func ) { \
|
||||
SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \
|
||||
return -1; \
|
||||
return SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \
|
||||
} \
|
||||
} while ( 0 );
|
||||
#endif /* __SDL_NOGETPROCADDR__ */
|
||||
|
@ -500,15 +499,13 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
|
||||
if (!convert_format(renderdata, texture->format, &internalFormat,
|
||||
&format, &type)) {
|
||||
SDL_SetError("Texture format %s not supported by OpenGL",
|
||||
SDL_GetPixelFormatName(texture->format));
|
||||
return -1;
|
||||
return SDL_SetError("Texture format %s not supported by OpenGL",
|
||||
SDL_GetPixelFormatName(texture->format));
|
||||
}
|
||||
|
||||
data = (GL_TextureData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
||||
|
@ -522,9 +519,8 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
}
|
||||
data->pixels = SDL_calloc(1, size);
|
||||
if (!data->pixels) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(data);
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -746,8 +742,7 @@ GL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
/* Check FBO status */
|
||||
status = data->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
|
||||
SDL_SetError("glFramebufferTexture2DEXT() failed");
|
||||
return -1;
|
||||
return SDL_SetError("glFramebufferTexture2DEXT() failed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1157,8 +1152,7 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
||||
if (!temp_pixels) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
convert_format(data, temp_format, &internalFormat, &format, &type);
|
||||
|
|
|
@ -135,7 +135,7 @@ typedef struct
|
|||
GLES_FBOList *fbo;
|
||||
} GLES_TextureData;
|
||||
|
||||
static void
|
||||
static int
|
||||
GLES_SetError(const char *prefix, GLenum result)
|
||||
{
|
||||
const char *error;
|
||||
|
@ -166,7 +166,7 @@ GLES_SetError(const char *prefix, GLenum result)
|
|||
error = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
SDL_SetError("%s: %s", prefix, error);
|
||||
return SDL_SetError("%s: %s", prefix, error);
|
||||
}
|
||||
|
||||
static int GLES_LoadFunctions(GLES_RenderData * data)
|
||||
|
@ -186,8 +186,7 @@ static int GLES_LoadFunctions(GLES_RenderData * data)
|
|||
do { \
|
||||
data->func = SDL_GL_GetProcAddress(#func); \
|
||||
if ( ! data->func ) { \
|
||||
SDL_SetError("Couldn't load GLES function %s: %s\n", #func, SDL_GetError()); \
|
||||
return -1; \
|
||||
return SDL_SetError("Couldn't load GLES function %s: %s\n", #func, SDL_GetError()); \
|
||||
} \
|
||||
} while ( 0 );
|
||||
#endif /* _SDL_NOGETPROCADDR_ */
|
||||
|
@ -442,23 +441,20 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Texture format not supported");
|
||||
return -1;
|
||||
return SDL_SetError("Texture format not supported");
|
||||
}
|
||||
|
||||
data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
||||
data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
|
||||
data->pixels = SDL_calloc(1, texture->h * data->pitch);
|
||||
if (!data->pixels) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(data);
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -495,8 +491,7 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
|
||||
result = renderdata->glGetError();
|
||||
if (result != GL_NO_ERROR) {
|
||||
GLES_SetError("glTexImage2D()", result);
|
||||
return -1;
|
||||
return GLES_SetError("glTexImage2D()", result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -521,17 +516,13 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
/* Reformat the texture data into a tightly packed array */
|
||||
srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format);
|
||||
src = (Uint8 *)pixels;
|
||||
if (pitch != srcPitch)
|
||||
{
|
||||
if (pitch != srcPitch) {
|
||||
blob = (Uint8 *)SDL_malloc(srcPitch * rect->h);
|
||||
if (!blob)
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
if (!blob) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
src = blob;
|
||||
for (y = 0; y < rect->h; ++y)
|
||||
{
|
||||
for (y = 0; y < rect->h; ++y) {
|
||||
SDL_memcpy(src, pixels, srcPitch);
|
||||
src += srcPitch;
|
||||
pixels = (Uint8 *)pixels + pitch;
|
||||
|
@ -559,8 +550,7 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
|
||||
if (renderdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to update texture");
|
||||
return -1;
|
||||
return SDL_SetError("Failed to update texture");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -613,8 +603,7 @@ GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
/* Check FBO status */
|
||||
status = data->glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_OES) {
|
||||
SDL_SetError("glFramebufferTexture2DOES() failed");
|
||||
return -1;
|
||||
return SDL_SetError("glFramebufferTexture2DOES() failed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1006,8 +995,7 @@ GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
||||
if (!temp_pixels) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
|
|
|
@ -189,8 +189,7 @@ static int GLES2_LoadFunctions(GLES2_DriverContext * data)
|
|||
do { \
|
||||
data->func = SDL_GL_GetProcAddress(#func); \
|
||||
if ( ! data->func ) { \
|
||||
SDL_SetError("Couldn't load GLES2 function %s: %s\n", #func, SDL_GetError()); \
|
||||
return -1; \
|
||||
return SDL_SetError("Couldn't load GLES2 function %s: %s\n", #func, SDL_GetError()); \
|
||||
} \
|
||||
} while ( 0 );
|
||||
#endif /* _SDL_NOGETPROCADDR_ */
|
||||
|
@ -372,16 +371,13 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Texture format not supported");
|
||||
return -1;
|
||||
return SDL_SetError("Texture format not supported");
|
||||
}
|
||||
|
||||
/* Allocate a texture struct */
|
||||
tdata = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData));
|
||||
if (!tdata)
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
if (!tdata) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
tdata->texture = 0;
|
||||
tdata->texture_type = GL_TEXTURE_2D;
|
||||
|
@ -390,15 +386,12 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
scaleMode = GetScaleQuality();
|
||||
|
||||
/* Allocate a blob for image data */
|
||||
if (texture->access == SDL_TEXTUREACCESS_STREAMING)
|
||||
{
|
||||
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
||||
tdata->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
|
||||
tdata->pixel_data = SDL_calloc(1, tdata->pitch * texture->h);
|
||||
if (!tdata->pixel_data)
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
if (!tdata->pixel_data) {
|
||||
SDL_free(tdata);
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -414,10 +407,9 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
rdata->glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Texture creation failed");
|
||||
rdata->glDeleteTextures(1, &tdata->texture);
|
||||
SDL_free(tdata);
|
||||
return -1;
|
||||
return SDL_SetError("Texture creation failed");
|
||||
}
|
||||
texture->driverdata = tdata;
|
||||
|
||||
|
@ -497,13 +489,10 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
|
|||
/* Reformat the texture data into a tightly packed array */
|
||||
srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format);
|
||||
src = (Uint8 *)pixels;
|
||||
if (pitch != srcPitch)
|
||||
{
|
||||
if (pitch != srcPitch) {
|
||||
blob = (Uint8 *)SDL_malloc(srcPitch * rect->h);
|
||||
if (!blob)
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
if (!blob) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
src = blob;
|
||||
for (y = 0; y < rect->h; ++y)
|
||||
|
@ -533,10 +522,8 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
|
|||
SDL_free(blob);
|
||||
}
|
||||
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to update texture");
|
||||
return -1;
|
||||
if (rdata->glGetError() != GL_NO_ERROR) {
|
||||
return SDL_SetError("Failed to update texture");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -558,8 +545,7 @@ GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
/* Check FBO status */
|
||||
status = data->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
||||
SDL_SetError("glFramebufferTexture2D() failed");
|
||||
return -1;
|
||||
return SDL_SetError("glFramebufferTexture2D() failed");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -636,9 +622,9 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex,
|
|||
rdata->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful);
|
||||
if (rdata->glGetError() != GL_NO_ERROR || !linkSuccessful)
|
||||
{
|
||||
SDL_SetError("Failed to link shader program");
|
||||
rdata->glDeleteProgram(entry->id);
|
||||
SDL_free(entry);
|
||||
SDL_SetError("Failed to link shader program");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -930,10 +916,8 @@ GLES2_SetOrthographicProjection(SDL_Renderer *renderer)
|
|||
locProjection = rdata->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION];
|
||||
rdata->glGetError();
|
||||
rdata->glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection);
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to set orthographic projection");
|
||||
return -1;
|
||||
if (rdata->glGetError() != GL_NO_ERROR) {
|
||||
return SDL_SetError("Failed to set orthographic projection");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1066,8 +1050,7 @@ GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int cou
|
|||
|
||||
/* Emit the specified vertices as points */
|
||||
vertices = SDL_stack_alloc(GLfloat, count * 2);
|
||||
for (idx = 0; idx < count; ++idx)
|
||||
{
|
||||
for (idx = 0; idx < count; ++idx) {
|
||||
GLfloat x = points[idx].x + 0.5f;
|
||||
GLfloat y = points[idx].y + 0.5f;
|
||||
|
||||
|
@ -1078,10 +1061,8 @@ GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int cou
|
|||
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
rdata->glDrawArrays(GL_POINTS, 0, count);
|
||||
SDL_stack_free(vertices);
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to render lines");
|
||||
return -1;
|
||||
if (rdata->glGetError() != GL_NO_ERROR) {
|
||||
return SDL_SetError("Failed to render lines");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1099,8 +1080,7 @@ GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int coun
|
|||
|
||||
/* Emit a line strip including the specified vertices */
|
||||
vertices = SDL_stack_alloc(GLfloat, count * 2);
|
||||
for (idx = 0; idx < count; ++idx)
|
||||
{
|
||||
for (idx = 0; idx < count; ++idx) {
|
||||
GLfloat x = points[idx].x + 0.5f;
|
||||
GLfloat y = points[idx].y + 0.5f;
|
||||
|
||||
|
@ -1117,10 +1097,8 @@ GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int coun
|
|||
rdata->glDrawArrays(GL_POINTS, count-1, 1);
|
||||
}
|
||||
SDL_stack_free(vertices);
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to render lines");
|
||||
return -1;
|
||||
if (rdata->glGetError() != GL_NO_ERROR) {
|
||||
return SDL_SetError("Failed to render lines");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1157,10 +1135,8 @@ GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
|
|||
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to render lines");
|
||||
return -1;
|
||||
if (rdata->glGetError() != GL_NO_ERROR) {
|
||||
return SDL_SetError("Failed to render lines");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1315,10 +1291,8 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s
|
|||
texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h;
|
||||
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords);
|
||||
rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to render texture");
|
||||
return -1;
|
||||
if (rdata->glGetError() != GL_NO_ERROR) {
|
||||
return SDL_SetError("Failed to render texture");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1499,10 +1473,8 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
|
|||
rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_CENTER);
|
||||
rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE);
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to render texture");
|
||||
return -1;
|
||||
if (rdata->glGetError() != GL_NO_ERROR) {
|
||||
return SDL_SetError("Failed to render texture");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1525,8 +1497,7 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
||||
if (!temp_pixels) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
|
|
|
@ -493,9 +493,8 @@ PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
|
||||
if(!psp_texture->data)
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(psp_texture);
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
texture->driverdata = psp_texture;
|
||||
|
||||
|
|
|
@ -159,8 +159,7 @@ SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
|
|||
}
|
||||
return 0;
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,8 +188,7 @@ SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
|
|||
}
|
||||
return 0;
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,14 +199,12 @@ SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
|
|||
SDL_Rect clipped;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* If 'rect' == NULL, then fill the whole surface */
|
||||
|
@ -274,14 +270,12 @@ SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
|
|||
int status = 0;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
|
||||
}
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
|
|
|
@ -711,14 +711,12 @@ SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
|||
BlendLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("SDL_BlendLine(): Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_BlendLine(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateBlendLineFunc(dst->format);
|
||||
if (!func) {
|
||||
SDL_SetError("SDL_BlendLine(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_BlendLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
|
@ -742,14 +740,12 @@ SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
|||
BlendLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateBlendLineFunc(dst->format);
|
||||
if (!func) {
|
||||
SDL_SetError("SDL_BlendLines(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_BlendLines(): Unsupported surface format");
|
||||
}
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
|
|
|
@ -159,8 +159,7 @@ SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uin
|
|||
}
|
||||
return 0;
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,8 +188,7 @@ SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Ui
|
|||
}
|
||||
return 0;
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,14 +197,12 @@ SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r
|
|||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
if (!dst) {
|
||||
SDL_SetError("Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
|
@ -272,14 +268,12 @@ SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
|||
int status = 0;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
|
||||
return (-1);
|
||||
return SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
|
||||
}
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
|
|
|
@ -145,14 +145,12 @@ SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
|
|||
DrawLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("SDL_DrawLine(): Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_DrawLine(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateDrawLineFunc(dst->format);
|
||||
if (!func) {
|
||||
SDL_SetError("SDL_DrawLine(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_DrawLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
|
@ -176,14 +174,12 @@ SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
|||
DrawLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("SDL_DrawLines(): Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_DrawLines(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateDrawLineFunc(dst->format);
|
||||
if (!func) {
|
||||
SDL_SetError("SDL_DrawLines(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_DrawLines(): Unsupported surface format");
|
||||
}
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
|
|
|
@ -30,14 +30,12 @@ int
|
|||
SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
|
||||
{
|
||||
if (!dst) {
|
||||
SDL_SetError("Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
|
@ -55,8 +53,7 @@ SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
|
|||
DRAW_FASTSETPIXELXY2(x, y);
|
||||
break;
|
||||
case 3:
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
case 4:
|
||||
DRAW_FASTSETPIXELXY4(x, y);
|
||||
break;
|
||||
|
@ -74,14 +71,12 @@ SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
|||
int x, y;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
|
||||
}
|
||||
|
||||
minx = dst->clip_rect.x;
|
||||
|
@ -105,8 +100,7 @@ SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
|||
DRAW_FASTSETPIXELXY2(x, y);
|
||||
break;
|
||||
case 3:
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
case 4:
|
||||
DRAW_FASTSETPIXELXY4(x, y);
|
||||
break;
|
||||
|
|
|
@ -200,8 +200,7 @@ SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
|
||||
if (!SDL_PixelFormatEnumToMasks
|
||||
(texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
|
||||
SDL_SetError("Unknown texture format");
|
||||
return -1;
|
||||
return SDL_SetError("Unknown texture format");
|
||||
}
|
||||
|
||||
texture->driverdata =
|
||||
|
@ -357,8 +356,7 @@ SW_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points,
|
|||
|
||||
final_points = SDL_stack_alloc(SDL_Point, count);
|
||||
if (!final_points) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
int x = renderer->viewport.x;
|
||||
|
@ -407,8 +405,7 @@ SW_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
|
|||
|
||||
final_points = SDL_stack_alloc(SDL_Point, count);
|
||||
if (!final_points) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
int x = renderer->viewport.x;
|
||||
|
@ -456,8 +453,7 @@ SW_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count)
|
|||
|
||||
final_rects = SDL_stack_alloc(SDL_Rect, count);
|
||||
if (!final_rects) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
int x = renderer->viewport.x;
|
||||
|
@ -647,8 +643,7 @@ SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
|
||||
if (rect->x < 0 || rect->x+rect->w > surface->w ||
|
||||
rect->y < 0 || rect->y+rect->h > surface->h) {
|
||||
SDL_SetError("Tried to read outside of surface bounds");
|
||||
return -1;
|
||||
return SDL_SetError("Tried to read outside of surface bounds");
|
||||
}
|
||||
|
||||
src_format = surface->format->format;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue