WinRT: merged with latest, official, SDL 2.x sources (at rev. bea100d73d13)
This commit is contained in:
commit
41ce3814e2
289 changed files with 10187 additions and 10275 deletions
|
@ -64,8 +64,8 @@ static const SDL_RenderDriver *render_drivers[] = {
|
|||
#if SDL_VIDEO_RENDER_DIRECTFB
|
||||
&DirectFB_RenderDriver,
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_NDS
|
||||
&NDS_RenderDriver,
|
||||
#if SDL_VIDEO_RENDER_PSP
|
||||
&PSP_RenderDriver,
|
||||
#endif
|
||||
&SW_RenderDriver,
|
||||
#if SDL_VIDEO_RENDER_D3D11
|
||||
|
@ -89,9 +89,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;
|
||||
|
@ -702,8 +701,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);
|
||||
|
@ -739,8 +737,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,
|
||||
|
@ -807,8 +804,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) {
|
||||
|
@ -904,8 +900,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! */
|
||||
|
@ -916,12 +911,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 */
|
||||
|
@ -986,8 +979,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;
|
||||
|
@ -1205,8 +1197,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;
|
||||
|
@ -1233,8 +1224,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;
|
||||
|
@ -1250,8 +1240,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;
|
||||
|
@ -1289,8 +1278,7 @@ RenderDrawLinesWithRects(SDL_Renderer * renderer,
|
|||
|
||||
frects = SDL_stack_alloc(SDL_FRect, count-1);
|
||||
if (!frects) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
status = 0;
|
||||
|
@ -1345,8 +1333,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;
|
||||
|
@ -1362,8 +1349,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;
|
||||
|
@ -1415,8 +1401,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;
|
||||
|
@ -1462,8 +1447,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;
|
||||
|
@ -1475,8 +1459,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;
|
||||
|
@ -1504,8 +1487,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;
|
||||
|
@ -1573,12 +1555,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;
|
||||
|
@ -1630,8 +1610,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) {
|
||||
|
@ -1736,8 +1715,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)
|
||||
|
@ -1750,8 +1728,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: */
|
||||
|
|
|
@ -176,8 +176,8 @@ extern SDL_RenderDriver GLES_RenderDriver;
|
|||
#if SDL_VIDEO_RENDER_DIRECTFB
|
||||
extern SDL_RenderDriver DirectFB_RenderDriver;
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_NDS
|
||||
extern SDL_RenderDriver NDS_RenderDriver;
|
||||
#if SDL_VIDEO_RENDER_PSP
|
||||
extern SDL_RenderDriver PSP_RenderDriver;
|
||||
#endif
|
||||
extern SDL_RenderDriver SW_RenderDriver;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -476,8 +474,11 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
}
|
||||
|
||||
for (d3dxVersion=50;d3dxVersion>0;d3dxVersion--) {
|
||||
SDL_snprintf(d3dxDLLFile, 49, "D3DX9_%02d.dll", d3dxVersion);
|
||||
data->d3dxDLL = SDL_LoadObject(d3dxDLLFile);
|
||||
LPTSTR dllName;
|
||||
SDL_snprintf(d3dxDLLFile, sizeof(d3dxDLLFile), "D3DX9_%02d.dll", d3dxVersion);
|
||||
dllName = WIN_UTF8ToString(d3dxDLLFile);
|
||||
data->d3dxDLL = (void *)LoadLibrary(dllName); /* not using SDL_LoadObject() as we want silently fail - no error message */
|
||||
SDL_free(dllName);
|
||||
if (data->d3dxDLL) {
|
||||
HRESULT (WINAPI *D3DXCreateMatrixStack) (DWORD Flags, LPD3DXMATRIXSTACK* ppStack);
|
||||
D3DXCreateMatrixStack = (HRESULT (WINAPI *) (DWORD, LPD3DXMATRIXSTACK*)) SDL_LoadFunction(data->d3dxDLL, "D3DXCreateMatrixStack");
|
||||
|
@ -701,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();
|
||||
|
||||
|
@ -729,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;
|
||||
|
@ -764,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;
|
||||
|
@ -801,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;
|
||||
|
@ -878,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;
|
||||
|
@ -933,8 +928,7 @@ D3D_RenderClear(SDL_Renderer * renderer)
|
|||
}
|
||||
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("Clear()", result);
|
||||
return -1;
|
||||
return D3D_SetError("Clear()", result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -994,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);
|
||||
|
@ -1014,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;
|
||||
}
|
||||
|
@ -1040,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);
|
||||
|
@ -1070,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;
|
||||
}
|
||||
|
@ -1097,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);
|
||||
|
@ -1143,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;
|
||||
|
@ -1221,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;
|
||||
|
@ -1345,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);
|
||||
|
@ -1391,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;
|
||||
|
@ -1424,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,
|
||||
|
|
|
@ -1,315 +0,0 @@
|
|||
/*
|
||||
* Note: The Nintendo DS port to SDL uses excerpts from the libGL2D,
|
||||
* with permission of the original author. The following is mostly his
|
||||
* code/comments.
|
||||
*
|
||||
*
|
||||
* Easy GL2D
|
||||
*
|
||||
* Relminator 2010
|
||||
* Richard Eric M. Lope BSN RN
|
||||
*
|
||||
* http://rel.betterwebber.com
|
||||
*
|
||||
* A very small and simple DS rendering lib using the 3d core to render 2D stuff
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_NDS
|
||||
|
||||
#include "SDL_libgl2D.h"
|
||||
|
||||
/*
|
||||
* Our static global variable used for Depth values since we cannot
|
||||
* disable depth testing in the DS hardware This value is incremented
|
||||
* for every draw call. */
|
||||
v16 g_depth;
|
||||
int gCurrentTexture;
|
||||
|
||||
/*
|
||||
* !!! PRIVATE !!! Set orthographic projection at 1:1 correspondence
|
||||
* to screen coords glOrtho expects f32 values but if we use the
|
||||
* standard f32 values, we need to rescale either every vert or the
|
||||
* modelview matrix by the same amount to make it work. That's gonna
|
||||
* give us lots of overflows and headaches. So we "scale down" and
|
||||
* use an all integer value.
|
||||
*/
|
||||
void SetOrtho(void)
|
||||
{
|
||||
glMatrixMode(GL_PROJECTION); // set matrixmode to projection
|
||||
glLoadIdentity(); // reset
|
||||
glOrthof32(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1 << 12, 1 << 12); // downscale projection matrix
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes GL in 2D mode Also initializes GL in 3d mode so that we
|
||||
* could combine 2D and 3D later Almost a direct copy from the DS
|
||||
* example files
|
||||
*/
|
||||
void glScreen2D(void)
|
||||
{
|
||||
// initialize gl
|
||||
glInit();
|
||||
|
||||
// enable textures
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
// enable antialiasing
|
||||
glEnable(GL_ANTIALIAS);
|
||||
|
||||
// setup the rear plane
|
||||
glClearColor(0, 0, 0, 31); // BG must be opaque for AA to work
|
||||
glClearPolyID(63); // BG must have a unique polygon ID for AA to work
|
||||
|
||||
glClearDepth(GL_MAX_DEPTH);
|
||||
|
||||
// this should work the same as the normal gl call
|
||||
glViewport(0,0,255,191);
|
||||
|
||||
// any floating point gl call is being converted to fixed prior to being implemented
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(70, 256.0 / 192.0, 1, 200);
|
||||
|
||||
gluLookAt( 0.0, 0.0, 1.0, //camera possition
|
||||
0.0, 0.0, 0.0, //look at
|
||||
0.0, 1.0, 0.0); //up
|
||||
|
||||
glMaterialf(GL_AMBIENT, RGB15(31,31,31));
|
||||
glMaterialf(GL_DIFFUSE, RGB15(31,31,31));
|
||||
glMaterialf(GL_SPECULAR, BIT(15) | RGB15(31,31,31));
|
||||
glMaterialf(GL_EMISSION, RGB15(31,31,31));
|
||||
|
||||
// ds uses a table for shinyness..this generates a half-ass one
|
||||
glMaterialShinyness();
|
||||
|
||||
// not a real gl function and will likely change
|
||||
glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets up OpenGL for 2d rendering Call this before drawing any of
|
||||
* GL2D's drawing or sprite functions.
|
||||
*/
|
||||
void glBegin2D(void)
|
||||
{
|
||||
// save 3d perpective projection matrix
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
|
||||
// save 3d modelview matrix for safety
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
||||
|
||||
// what?!! No glDisable(GL_DEPTH_TEST)?!!!!!!
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glDisable(GL_ANTIALIAS); // disable AA
|
||||
glDisable(GL_OUTLINE); // disable edge-marking
|
||||
|
||||
glColor(0x7FFF); // max color
|
||||
|
||||
glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); // no culling
|
||||
|
||||
SetOrtho();
|
||||
|
||||
glMatrixMode(GL_TEXTURE); // reset texture matrix just in case we did some funky stuff with it
|
||||
glLoadIdentity();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW); // reset modelview matrix. No need to scale up by << 12
|
||||
glLoadIdentity();
|
||||
|
||||
gCurrentTexture = 0; // set current texture to 0
|
||||
g_depth = 0; // set depth to 0. We need this var since we cannot disable depth testing
|
||||
}
|
||||
|
||||
/*
|
||||
* Issue this after drawing 2d so that we don't mess the matrix stack.
|
||||
* The complement of glBegin2D.
|
||||
*/
|
||||
void glEnd2D(void)
|
||||
{
|
||||
// restore 3d matrices and set current matrix to modelview
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix(1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Draws a pixel
|
||||
* Parameters:
|
||||
* x,y -> First coordinate of the line
|
||||
* color -> RGB15/ARGB16 color
|
||||
*/
|
||||
void glPutPixel(int x, int y, int color)
|
||||
{
|
||||
glBindTexture(0, 0);
|
||||
glColor(color);
|
||||
glBegin(GL_TRIANGLES);
|
||||
gxVertex3i(x, y, g_depth);
|
||||
gxVertex2i(x, y);
|
||||
gxVertex2i(x, y);
|
||||
glEnd();
|
||||
glColor(0x7FFF);
|
||||
g_depth++;
|
||||
gCurrentTexture = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Draws a line
|
||||
* Parameters:
|
||||
* x1,y1 -> First coordinate of the line
|
||||
* x2,y2 -> Second coordinate of the line
|
||||
* color -> RGB15/ARGB16 color
|
||||
*/
|
||||
void glLine(int x1, int y1, int x2, int y2, int color)
|
||||
{
|
||||
x2++;
|
||||
y2++;
|
||||
|
||||
glBindTexture(0, 0);
|
||||
glColor(color);
|
||||
glBegin(GL_TRIANGLES);
|
||||
gxVertex3i(x1, y1, g_depth);
|
||||
gxVertex2i(x2, y2);
|
||||
gxVertex2i(x2, y2);
|
||||
glEnd();
|
||||
glColor(0x7FFF);
|
||||
g_depth++;
|
||||
gCurrentTexture = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Draws a Filled Box
|
||||
* Parameters:
|
||||
* x1,y1 -> Top-left corner of the box
|
||||
* x2,y2 -> Bottom-Right corner of the box
|
||||
* color -> RGB15/ARGB16 color
|
||||
*/
|
||||
void glBoxFilled(int x1, int y1, int x2, int y2, int color)
|
||||
{
|
||||
x2++;
|
||||
y2++;
|
||||
|
||||
glBindTexture(0, 0);
|
||||
glColor(color);
|
||||
glBegin(GL_QUADS);
|
||||
gxVertex3i(x1, y1, g_depth); // use 3i for first vertex so that we increment HW depth
|
||||
gxVertex2i(x1, y2); // no need for 3 vertices as 2i would share last depth call
|
||||
gxVertex2i(x2, y2);
|
||||
gxVertex2i(x2, y1);
|
||||
glEnd();
|
||||
glColor(0x7FFF);
|
||||
g_depth++;
|
||||
gCurrentTexture = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Create a tile.
|
||||
* Very rigid and prone to human error.
|
||||
*
|
||||
* Parameters:
|
||||
* *sprite -> pointer to a glImage
|
||||
* texture_width -> width/height of the texture;
|
||||
* texture_height -> valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM (see glTexImage2d)
|
||||
* sprite_width
|
||||
* sprite_height -> width/height of the picture in the texture.
|
||||
* type -> The format of the texture (see glTexImage2d)
|
||||
* param -> parameters for the texture (see glTexImage2d)
|
||||
*/
|
||||
int glLoadTile(glImage *sprite,
|
||||
int texture_width,
|
||||
int texture_height,
|
||||
int sprite_width,
|
||||
int sprite_height,
|
||||
GL_TEXTURE_TYPE_ENUM type,
|
||||
int param,
|
||||
int pallette_width,
|
||||
const u16 *palette,
|
||||
const uint8 *texture)
|
||||
{
|
||||
int textureID;
|
||||
|
||||
glGenTextures(1, &textureID);
|
||||
glBindTexture(0, textureID);
|
||||
glTexImage2D(0, 0, type, texture_width, texture_height, 0, param, texture);
|
||||
glColorTableEXT(0, 0, pallette_width, 0, 0, palette);
|
||||
|
||||
sprite->width = sprite_width;
|
||||
sprite->height = sprite_height;
|
||||
sprite->textureID = textureID;
|
||||
|
||||
return textureID;
|
||||
}
|
||||
|
||||
/*
|
||||
* I made this since the scale wrappers are either the vectorized mode
|
||||
* or does not permit you to scale only the axis you want to
|
||||
* scale. Needed for sprite scaling.
|
||||
*/
|
||||
static inline void gxScalef32(s32 x, s32 y, s32 z)
|
||||
{
|
||||
MATRIX_SCALE = x;
|
||||
MATRIX_SCALE = y;
|
||||
MATRIX_SCALE = z;
|
||||
}
|
||||
|
||||
/*
|
||||
* I this made for future naming conflicts.
|
||||
*/
|
||||
static inline void gxTranslate3f32(int32 x, int32 y, int32 z)
|
||||
{
|
||||
MATRIX_TRANSLATE = x;
|
||||
MATRIX_TRANSLATE = y;
|
||||
MATRIX_TRANSLATE = z;
|
||||
}
|
||||
|
||||
/*
|
||||
* Draws an axis exclusive scaled sprite
|
||||
* Parameters:
|
||||
* x -> x position of the sprite
|
||||
* y -> y position of the sprite
|
||||
* scaleX -> 20.12 FP X axis scale value (1 << 12 is normal)
|
||||
* scaleY -> 20.12 FP Y axis scale value (1 << 12 is normal)
|
||||
* flipmode -> mode for flipping (see GL_FLIP_MODE enum)
|
||||
* *spr -> pointer to a glImage
|
||||
*/
|
||||
void glSpriteScaleXY(int x, int y, s32 scaleX, s32 scaleY, int flipmode, const glImage *spr)
|
||||
{
|
||||
const int x1 = 0;
|
||||
const int y1 = 0;
|
||||
const int x2 = spr->width;
|
||||
const int y2 = spr->height;
|
||||
const int u1 = ((flipmode & GL_FLIP_H) ? spr->width-1 : 0);
|
||||
const int u2 = ((flipmode & GL_FLIP_H) ? 0 : spr->width-1);
|
||||
const int v1 = ((flipmode & GL_FLIP_V) ? spr->height-1 : 0);
|
||||
const int v2 = ((flipmode & GL_FLIP_V) ? 0 : spr->height-1);
|
||||
|
||||
if (spr->textureID != gCurrentTexture)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, spr->textureID);
|
||||
gCurrentTexture = spr->textureID;
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
gxTranslate3f32(x, y, 0);
|
||||
gxScalef32(scaleX, scaleY, 1 << 12);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
gxTexcoord2i(u1, v1); gxVertex3i(x1, y1, g_depth);
|
||||
gxTexcoord2i(u1, v2); gxVertex2i(x1, y2);
|
||||
gxTexcoord2i(u2, v2); gxVertex2i(x2, y2);
|
||||
gxTexcoord2i(u2, v1); gxVertex2i(x2, y1);
|
||||
|
||||
glEnd();
|
||||
|
||||
glPopMatrix(1);
|
||||
g_depth++;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_NDS */
|
|
@ -1,154 +0,0 @@
|
|||
/*
|
||||
* Note: The Nintendo DS port to SDL uses excerpts from the libGL2D,
|
||||
* with permission of the original author. The following is mostly his
|
||||
* code/comments.
|
||||
*
|
||||
*
|
||||
* Easy GL2D
|
||||
*
|
||||
* Relminator 2010
|
||||
* Richard Eric M. Lope BSN RN
|
||||
*
|
||||
* http://rel.betterwebber.com
|
||||
*
|
||||
* A very small and simple DS rendering lib using the 3d core to render 2D stuff
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_NDS
|
||||
|
||||
#include <nds/arm9/videoGL.h>
|
||||
|
||||
/* LibGL extension(s) */
|
||||
static inline void gxTexcoord2i(t16 u, t16 v)
|
||||
{
|
||||
GFX_TEX_COORD = (v << 20) | ((u << 4) & 0xFFFF);
|
||||
}
|
||||
|
||||
static inline void gxVertex3i(v16 x, v16 y, v16 z)
|
||||
{
|
||||
GFX_VERTEX16 = (y << 16) | (x & 0xFFFF);
|
||||
GFX_VERTEX16 = ((uint32)(uint16)z);
|
||||
}
|
||||
|
||||
static inline void gxVertex2i(v16 x, v16 y)
|
||||
{
|
||||
GFX_VERTEX_XY = (y << 16) | (x & 0xFFFF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Enums selecting flipping mode.
|
||||
*
|
||||
* These enums are bits for flipping the sprites.
|
||||
* You can "|" (or) GL_FLIP_V and GL_FLIP_H to flip
|
||||
* both ways.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GL_FLIP_NONE = (1 << 0), /* No flipping */
|
||||
GL_FLIP_V = (1 << 1), /* Sprite is rendered vertically flipped */
|
||||
GL_FLIP_H = (1 << 2), /* Sprite is rendered horizontally flipped */
|
||||
} GL_FLIP_MODE;
|
||||
|
||||
/* Struct for out GL-Based Images. */
|
||||
typedef struct
|
||||
{
|
||||
int width; /* Width of the Sprite */
|
||||
int height; /* Height of the Sprite */
|
||||
int textureID; /* Texture handle (used in glDeleteTextures())
|
||||
The texture handle in VRAM (returned by glGenTextures())
|
||||
ie. This references the actual texture stored in VRAM. */
|
||||
} glImage;
|
||||
|
||||
extern v16 g_depth;
|
||||
extern int gCurrentTexture;
|
||||
|
||||
/*
|
||||
* Draws an Axis Exclusive Scaled Sprite
|
||||
* Parameters:
|
||||
* x X position of the sprite.
|
||||
* y Y position of the sprite.
|
||||
* scaleX 20.12 fixed-point X-Axis scale value (1 << 12 is normal).
|
||||
* scaleY 20.12 fixed-point Y-Axis scale value (1 << 12 is normal).
|
||||
* flipmode mode for flipping (see GL_FLIP_MODE enum).
|
||||
* *spr pointer to a glImage.
|
||||
*/
|
||||
void glSpriteScaleXY(int x, int y, s32 scaleX, s32 scaleY, int flipmode, const glImage *spr);
|
||||
|
||||
/* Initializes our Tileset (like glInitSpriteset()) but without the use of Texture Packer auto-generated files.
|
||||
* Can only be used when tiles in a tilset are of the same dimensions.
|
||||
* Parameters:
|
||||
* *sprite Pointer to an array of glImage.
|
||||
* tile_wid Width of each tile in the texture.
|
||||
* tile_hei Height of each tile in the texture.
|
||||
* bmp_wid Width of of the texture or tileset.
|
||||
* bmp_hei height of of the texture or tileset.
|
||||
* type The format of the texture (see glTexImage2d()).
|
||||
* sizeX The horizontal size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM (see glTexImage2d()).
|
||||
* sizeY The vertical size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM (see glTexImage2d()).
|
||||
* param parameters for the texture (see glTexImage2d()).
|
||||
* pallette_width Length of the palette. Valid values are <b>4, 16, 32, 256</b> (if <b>0</b>, then palette is removed from currently bound texture).
|
||||
* *palette Pointer to the palette data to load (if NULL, then palette is removed from currently bound texture).
|
||||
* *texture Pointer to the texture data to load.
|
||||
*/
|
||||
int glLoadTile(glImage *sprite,
|
||||
int texture_width,
|
||||
int texture_height,
|
||||
int sprite_width,
|
||||
int sprite_height,
|
||||
GL_TEXTURE_TYPE_ENUM type,
|
||||
int param,
|
||||
int pallette_width,
|
||||
const u16 *palette,
|
||||
const uint8 *texture);
|
||||
|
||||
/* Initializes GL in 2D mode */
|
||||
void glScreen2D(void);
|
||||
|
||||
/*
|
||||
* Sets up OpenGL for 2d rendering.
|
||||
*
|
||||
* Call this before drawing any of GL2D's drawing or sprite functions.
|
||||
*/
|
||||
void glBegin2D(void);
|
||||
|
||||
/*
|
||||
* Issue this after drawing 2d so that we don't mess the matrix stack.
|
||||
*
|
||||
* The complement of glBegin2D().
|
||||
*/
|
||||
void glEnd2D(void);
|
||||
|
||||
/*
|
||||
* Draws a Pixel
|
||||
* x X position of the pixel.
|
||||
* y Y position of the pixel.
|
||||
* color RGB15/ARGB16 color.
|
||||
*/
|
||||
void glPutPixel(int x, int y, int color);
|
||||
|
||||
/*
|
||||
* Draws a Line
|
||||
* x1,y1 Top-Left coordinate of the line.
|
||||
* x2,y2 Bottom-Right coordinate of the line.
|
||||
* color RGB15/ARGB16 color.
|
||||
*/
|
||||
void glLine(int x1, int y1, int x2, int y2, int color);
|
||||
|
||||
/*
|
||||
* Draws a Box
|
||||
* x1,y1 Top-Left coordinate of the box.
|
||||
* x2,y2 Bottom-Right coordinate of the box.
|
||||
* color RGB15/ARGB16 color.
|
||||
*/
|
||||
void glBox(int x1, int y1, int x2, int y2, int color);
|
||||
|
||||
/*
|
||||
* Draws a Filled Box
|
||||
* x1,y1 Top-Left coordinate of the box.
|
||||
* x2,y2 Bottom-Right coordinate of the box.
|
||||
* color RGB15/ARGB16 color.
|
||||
*/
|
||||
void glBoxFilled(int x1, int y1, int x2, int y2, int color);
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_NDS */
|
|
@ -1,418 +0,0 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_NDS
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <nds.h>
|
||||
|
||||
#include "SDL_libgl2D.h"
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "../../video/SDL_sysvideo.h"
|
||||
#include "SDL_render.h"
|
||||
#include "../SDL_sysrender.h"
|
||||
#include "SDL_log.h"
|
||||
|
||||
/* Draws a partial sprite. Based on glSprite. */
|
||||
static void glSpritePartial(const SDL_Rect * srcrect, int x, int y, int flipmode, const glImage *spr)
|
||||
{
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int x2 = x + srcrect->w;
|
||||
int y2 = y + srcrect->h;
|
||||
|
||||
int u1 = srcrect->x + ((flipmode & GL_FLIP_H) ? spr->width-1 : 0);
|
||||
int u2 = srcrect->x + ((flipmode & GL_FLIP_H) ? 0 : srcrect->h);
|
||||
int v1 = srcrect->y + ((flipmode & GL_FLIP_V) ? spr->height-1 : 0);
|
||||
int v2 = srcrect->y + ((flipmode & GL_FLIP_V) ? 0 : srcrect->h);
|
||||
|
||||
if (spr->textureID != gCurrentTexture) {
|
||||
glBindTexture(GL_TEXTURE_2D, spr->textureID);
|
||||
gCurrentTexture = spr->textureID;
|
||||
}
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
gxTexcoord2i(u1, v1); gxVertex3i(x1, y1, g_depth);
|
||||
gxTexcoord2i(u1, v2); gxVertex2i(x1, y2);
|
||||
gxTexcoord2i(u2, v2); gxVertex2i(x2, y2);
|
||||
gxTexcoord2i(u2, v1); gxVertex2i(x2, y1);
|
||||
|
||||
glEnd();
|
||||
|
||||
g_depth++;
|
||||
}
|
||||
|
||||
/* SDL NDS renderer implementation */
|
||||
|
||||
extern SDL_RenderDriver NDS_RenderDriver;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Whether current 3D engine is on the main or sub screen. */
|
||||
int is_sub;
|
||||
} NDS_RenderData;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
glImage image[1];
|
||||
} NDS_TextureData;
|
||||
|
||||
static int NDS_UpdateViewport(SDL_Renderer *renderer)
|
||||
{
|
||||
/* Nothing to do. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_Rect * dstrect)
|
||||
{
|
||||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
|
||||
int dest_y;
|
||||
|
||||
if (data->is_sub) {
|
||||
dest_y = dstrect->y;
|
||||
} else {
|
||||
dest_y = dstrect->y-SCREEN_HEIGHT;
|
||||
}
|
||||
|
||||
if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
|
||||
/* No scaling */
|
||||
glSpritePartial(srcrect, dstrect->x, dest_y, GL_FLIP_NONE, txdat->image);
|
||||
} else {
|
||||
/* Convert the scaling proportion into a 20.12 value. */
|
||||
s32 scale_w = divf32(dstrect->w << 12, texture->w << 12);
|
||||
s32 scale_h = divf32(dstrect->h << 12, texture->h << 12);
|
||||
|
||||
glSpriteScaleXY(dstrect->x, dest_y, scale_w, scale_h, GL_FLIP_NONE, txdat->image);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int NDS_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
NDS_TextureData *txdat = NULL;
|
||||
int i;
|
||||
|
||||
SDL_Log("NDS_CreateTexture: NDS_CreateTexture.\n");
|
||||
|
||||
/* Sanity checks. */
|
||||
for (i=0; i<NDS_RenderDriver.info.num_texture_formats; i++) {
|
||||
if (texture->format == NDS_RenderDriver.info.texture_formats[i])
|
||||
break;
|
||||
}
|
||||
if (i == NDS_RenderDriver.info.num_texture_formats) {
|
||||
SDL_SetError("Unsupported texture format (%x)", texture->format);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (texture->w > NDS_RenderDriver.info.max_texture_width) {
|
||||
SDL_SetError("Texture too large (%d)", texture->w);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (texture->h > NDS_RenderDriver.info.max_texture_height) {
|
||||
SDL_SetError("Texture too tall (%d)", texture->h);
|
||||
return -1;
|
||||
}
|
||||
|
||||
texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData));
|
||||
txdat = (NDS_TextureData *) texture->driverdata;
|
||||
if (!txdat) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
NDS_TextureData *txdat = texture->driverdata;
|
||||
|
||||
/* free anything else allocated for texture */
|
||||
SDL_free(txdat);
|
||||
}
|
||||
|
||||
/* size is no more than 512. */
|
||||
static int get_gltexture_size(unsigned int size)
|
||||
{
|
||||
if (size > 256)
|
||||
return TEXTURE_SIZE_512;
|
||||
else if (size > 128)
|
||||
return TEXTURE_SIZE_256;
|
||||
else if (size > 64)
|
||||
return TEXTURE_SIZE_128;
|
||||
else if (size > 32)
|
||||
return TEXTURE_SIZE_64;
|
||||
else if (size > 16)
|
||||
return TEXTURE_SIZE_32;
|
||||
else if (size > 8)
|
||||
return TEXTURE_SIZE_16;
|
||||
else
|
||||
return TEXTURE_SIZE_8;
|
||||
}
|
||||
|
||||
static int NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels, int pitch)
|
||||
{
|
||||
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
|
||||
char *new_pixels = NULL;
|
||||
const int gl_w = get_gltexture_size(rect->w);
|
||||
const int gl_h = get_gltexture_size(rect->h);
|
||||
const int w = 1 << (3+gl_w); /* Texture sizes must be a power of 2. */
|
||||
const int h = 1 << (3+gl_h); /* Texture sizes must be a power of 2. */
|
||||
|
||||
if (w != rect->w || h != rect->h) {
|
||||
/* Allocate a temporary surface and copy pixels into it while
|
||||
* enlarging the pitch. */
|
||||
const char *src;
|
||||
char *dst;
|
||||
int new_pitch = 2 * w;
|
||||
int i;
|
||||
|
||||
new_pixels = malloc(2 * w * h);
|
||||
if (!new_pixels)
|
||||
return SDL_ENOMEM;
|
||||
|
||||
src = pixels;
|
||||
dst = new_pixels;
|
||||
for (i=0; i<rect->h; i++) {
|
||||
memcpy(dst, src, pitch);
|
||||
src += pitch;
|
||||
dst += new_pitch;
|
||||
}
|
||||
}
|
||||
|
||||
glLoadTile(txdat->image,
|
||||
gl_w, gl_h,
|
||||
rect->w, rect->h,
|
||||
texture->format == SDL_PIXELFORMAT_ABGR1555 ? GL_RGBA : GL_RGB,
|
||||
TEXGEN_OFF, 0, NULL,
|
||||
new_pixels? new_pixels : pixels);
|
||||
|
||||
if (new_pixels)
|
||||
free(new_pixels);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int NDS_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_Log("enter %s (todo)\n", __func__);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void NDS_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
SDL_Log("enter %s\n", __func__);
|
||||
/* stub! */
|
||||
}
|
||||
|
||||
static int NDS_RenderClear(SDL_Renderer *renderer)
|
||||
{
|
||||
glClearColor(renderer->r >> 3,
|
||||
renderer->g >> 3,
|
||||
renderer->b >> 3,
|
||||
renderer->a >> 3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void NDS_RenderPresent(SDL_Renderer * renderer)
|
||||
{
|
||||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
|
||||
glEnd2D();
|
||||
|
||||
glFlush(0);
|
||||
|
||||
swiWaitForVBlank();
|
||||
|
||||
/* wait for capture unit to be ready */
|
||||
while(REG_DISPCAPCNT & DCAP_ENABLE);
|
||||
|
||||
/* 3D engine can only work on one screen at a time. */
|
||||
data->is_sub = !data->is_sub;
|
||||
if (data->is_sub) {
|
||||
lcdMainOnBottom();
|
||||
vramSetBankC(VRAM_C_LCD);
|
||||
vramSetBankD(VRAM_D_SUB_SPRITE);
|
||||
REG_DISPCAPCNT = DCAP_BANK(2) | DCAP_ENABLE | DCAP_SIZE(3);
|
||||
} else {
|
||||
lcdMainOnTop();
|
||||
vramSetBankD(VRAM_D_LCD);
|
||||
vramSetBankC(VRAM_C_SUB_BG);
|
||||
REG_DISPCAPCNT = DCAP_BANK(3) | DCAP_ENABLE | DCAP_SIZE(3);
|
||||
}
|
||||
|
||||
glBegin2D();
|
||||
}
|
||||
|
||||
static int NDS_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points,
|
||||
int count)
|
||||
{
|
||||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
int i;
|
||||
int color = RGB15(renderer->r >> 3,
|
||||
renderer->g >> 3,
|
||||
renderer->b >> 3);
|
||||
|
||||
for (i=0; i < count; i++) {
|
||||
if (data->is_sub) {
|
||||
glPutPixel(points[i].x, points[i].y, color);
|
||||
} else {
|
||||
glPutPixel(points[i].x, points[i].y - SCREEN_HEIGHT, color);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int NDS_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points,
|
||||
int count)
|
||||
{
|
||||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
int i;
|
||||
int color = RGB15(renderer->r >> 3,
|
||||
renderer->g >> 3,
|
||||
renderer->b >> 3);
|
||||
|
||||
for (i=0; i < count-1; i++) {
|
||||
if (data->is_sub) {
|
||||
glLine(points[i].x, points[i].y, points[i+1].x, points[i+1].y, color);
|
||||
} else {
|
||||
glLine(points[i].x, points[i].y - SCREEN_HEIGHT,
|
||||
points[i+1].x, points[i+1].y - SCREEN_HEIGHT, color);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int NDS_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect *rects,
|
||||
int count)
|
||||
{
|
||||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
int i;
|
||||
int color = RGB15(renderer->r >> 3,
|
||||
renderer->g >> 3,
|
||||
renderer->b >> 3);
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
if (data->is_sub) {
|
||||
glBoxFilled(rects[i].x, rects[i].y,
|
||||
rects[i].x + rects[i].w,
|
||||
rects[i].y + rects[i].h, color);
|
||||
} else {
|
||||
glBoxFilled(rects[i].x, rects[i].y - SCREEN_HEIGHT,
|
||||
rects[i].x + rects[i].w,
|
||||
rects[i].y + rects[i].h - SCREEN_HEIGHT,
|
||||
color);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static SDL_Renderer *
|
||||
NDS_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
{
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_DisplayMode *displayMode = &display->current_mode;
|
||||
SDL_Renderer *renderer;
|
||||
NDS_RenderData *data;
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
if (displayMode->format != SDL_PIXELFORMAT_ABGR1555) {
|
||||
SDL_SetError("Unsupported pixel format (%x)", displayMode->format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp,
|
||||
&Rmask, &Gmask, &Bmask, &Amask)) {
|
||||
SDL_SetError("Unknown display format");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (NDS_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
renderer->info = NDS_RenderDriver.info;
|
||||
renderer->info.flags = SDL_RENDERER_ACCELERATED;
|
||||
|
||||
renderer->CreateTexture = NDS_CreateTexture;
|
||||
renderer->UpdateTexture = NDS_UpdateTexture;
|
||||
renderer->LockTexture = NDS_LockTexture;
|
||||
renderer->UnlockTexture = NDS_UnlockTexture;
|
||||
renderer->UpdateViewport = NDS_UpdateViewport;
|
||||
renderer->RenderClear = NDS_RenderClear;
|
||||
renderer->RenderDrawPoints = NDS_RenderDrawPoints;
|
||||
renderer->RenderDrawLines = NDS_RenderDrawLines;
|
||||
renderer->RenderFillRects = NDS_RenderFillRects;
|
||||
renderer->RenderCopy = NDS_RenderCopy;
|
||||
/* renderer->RenderReadPixels = NDS_RenderReadPixels; - todo ? */
|
||||
renderer->RenderPresent = NDS_RenderPresent;
|
||||
renderer->DestroyTexture = NDS_DestroyTexture;
|
||||
/* renderer->DestroyRenderer = NDS_DestroyRenderer; - todo ? */
|
||||
|
||||
renderer->driverdata = data;
|
||||
|
||||
return renderer;
|
||||
}
|
||||
|
||||
SDL_RenderDriver NDS_RenderDriver = {
|
||||
.CreateRenderer = NDS_CreateRenderer,
|
||||
.info = {
|
||||
.name = "nds",
|
||||
.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC,
|
||||
.num_texture_formats = 2,
|
||||
.texture_formats = { [0] = SDL_PIXELFORMAT_ABGR1555,
|
||||
[1] = SDL_PIXELFORMAT_BGR555,
|
||||
},
|
||||
.max_texture_width = 512,
|
||||
.max_texture_height = 512,
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_NDS */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -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;
|
||||
}
|
||||
|
@ -804,7 +793,6 @@ static int
|
|||
GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect)
|
||||
{
|
||||
|
||||
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
|
||||
GLfloat minx, miny, maxx, maxy;
|
||||
|
@ -1007,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);
|
||||
|
@ -1091,7 +1078,8 @@ GLES_DestroyRenderer(SDL_Renderer * renderer)
|
|||
SDL_free(renderer);
|
||||
}
|
||||
|
||||
static int GLES_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh) {
|
||||
static int GLES_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh)
|
||||
{
|
||||
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
|
||||
GLES_ActivateRenderer(renderer);
|
||||
|
@ -1105,7 +1093,8 @@ static int GLES_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, floa
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int GLES_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) {
|
||||
static int GLES_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
|
||||
{
|
||||
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
|
||||
GLES_ActivateRenderer(renderer);
|
||||
|
@ -1114,7 +1103,6 @@ static int GLES_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL_ES && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -1258,6 +1234,8 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s
|
|||
case SDL_PIXELFORMAT_RGB888:
|
||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (GLES2_SelectProgram(renderer, sourceType, blendMode) < 0)
|
||||
|
@ -1313,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;
|
||||
}
|
||||
|
@ -1424,6 +1400,8 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
|
|||
case SDL_PIXELFORMAT_RGB888:
|
||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (GLES2_SelectProgram(renderer, sourceType, blendMode) < 0)
|
||||
|
@ -1495,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;
|
||||
}
|
||||
|
@ -1521,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);
|
||||
|
@ -1576,7 +1551,6 @@ static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, flo
|
|||
GLES2_TextureData *texturedata = (GLES2_TextureData *)texture->driverdata;
|
||||
GLES2_ActivateRenderer(renderer);
|
||||
|
||||
data->glActiveTexture(GL_TEXTURE0);
|
||||
data->glBindTexture(texturedata->texture_type, texturedata->texture);
|
||||
|
||||
if(texw) *texw = 1.0;
|
||||
|
|
1023
src/render/psp/SDL_render_psp.c
Normal file
1023
src/render/psp/SDL_render_psp.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -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