mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 15:14:35 +00:00
Updates SDL to 2.0.5
This commit is contained in:
parent
00a4a21e3f
commit
1e671bfc7a
274 changed files with 11502 additions and 4656 deletions
|
|
@ -234,12 +234,11 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
|
||||
if (hint) {
|
||||
if (*hint == '0') {
|
||||
flags &= ~SDL_RENDERER_PRESENTVSYNC;
|
||||
} else {
|
||||
if (SDL_GetHint(SDL_HINT_RENDER_VSYNC)) {
|
||||
if (SDL_GetHintBoolean(SDL_HINT_RENDER_VSYNC, SDL_TRUE)) {
|
||||
flags |= SDL_RENDERER_PRESENTVSYNC;
|
||||
} else {
|
||||
flags &= ~SDL_RENDERER_PRESENTVSYNC;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1106,6 +1105,8 @@ SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
renderer->viewport.y = 0;
|
||||
renderer->viewport.w = texture->w;
|
||||
renderer->viewport.h = texture->h;
|
||||
SDL_zero(renderer->clip_rect);
|
||||
renderer->clipping_enabled = SDL_FALSE;
|
||||
renderer->scale.x = 1.0f;
|
||||
renderer->scale.y = 1.0f;
|
||||
renderer->logical_w = texture->w;
|
||||
|
|
@ -1144,6 +1145,9 @@ UpdateLogicalSize(SDL_Renderer *renderer)
|
|||
float scale;
|
||||
SDL_Rect viewport;
|
||||
|
||||
if (!renderer->logical_w || !renderer->logical_h) {
|
||||
return 0;
|
||||
}
|
||||
if (SDL_GetRendererOutputSize(renderer, &w, &h) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1154,7 +1158,19 @@ UpdateLogicalSize(SDL_Renderer *renderer)
|
|||
/* Clear the scale because we're setting viewport in output coordinates */
|
||||
SDL_RenderSetScale(renderer, 1.0f, 1.0f);
|
||||
|
||||
if (SDL_fabs(want_aspect-real_aspect) < 0.0001) {
|
||||
if (renderer->integer_scale) {
|
||||
if (want_aspect > real_aspect) {
|
||||
scale = (float)(w / renderer->logical_w);
|
||||
} else {
|
||||
scale = (float)(h / renderer->logical_h);
|
||||
}
|
||||
viewport.w = (int)SDL_ceil(renderer->logical_w * scale);
|
||||
viewport.x = (w - viewport.w) / 2;
|
||||
viewport.h = (int)SDL_ceil(renderer->logical_h * scale);
|
||||
viewport.y = (h - viewport.h) / 2;
|
||||
|
||||
SDL_RenderSetViewport(renderer, &viewport);
|
||||
} else if (SDL_fabs(want_aspect-real_aspect) < 0.0001) {
|
||||
/* The aspect ratios are the same, just scale appropriately */
|
||||
scale = (float)w / renderer->logical_w;
|
||||
SDL_RenderSetViewport(renderer, NULL);
|
||||
|
|
@ -1215,6 +1231,24 @@ SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_RenderSetIntegerScale(SDL_Renderer * renderer, SDL_bool enable)
|
||||
{
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
renderer->integer_scale = enable;
|
||||
|
||||
return UpdateLogicalSize(renderer);
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer)
|
||||
{
|
||||
CHECK_RENDERER_MAGIC(renderer, SDL_FALSE);
|
||||
|
||||
return renderer->integer_scale;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_RenderSetViewport(SDL_Renderer * renderer, const SDL_Rect * rect)
|
||||
{
|
||||
|
|
@ -1425,6 +1459,7 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer,
|
|||
if (count < 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
|
|
@ -1534,6 +1569,7 @@ SDL_RenderDrawLines(SDL_Renderer * renderer,
|
|||
if (count < 2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
|
|
@ -1607,6 +1643,7 @@ SDL_RenderDrawRects(SDL_Renderer * renderer,
|
|||
if (renderer->hidden) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
if (SDL_RenderDrawRect(renderer, &rects[i]) < 0) {
|
||||
return -1;
|
||||
|
|
@ -1648,6 +1685,7 @@ SDL_RenderFillRects(SDL_Renderer * renderer,
|
|||
if (count < 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
|
|
@ -1686,6 +1724,11 @@ SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
return SDL_SetError("Texture was not created with this renderer");
|
||||
}
|
||||
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
real_srcrect.x = 0;
|
||||
real_srcrect.y = 0;
|
||||
real_srcrect.w = texture->w;
|
||||
|
|
@ -1710,11 +1753,6 @@ SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
texture = texture->native;
|
||||
}
|
||||
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
frect.x = real_dstrect.x * renderer->scale.x;
|
||||
frect.y = real_dstrect.y * renderer->scale.y;
|
||||
frect.w = real_dstrect.w * renderer->scale.x;
|
||||
|
|
@ -1735,7 +1773,7 @@ SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
SDL_FRect frect;
|
||||
SDL_FPoint fcenter;
|
||||
|
||||
if (flip == SDL_FLIP_NONE && angle == 0) { /* fast path when we don't need rotation or flipping */
|
||||
if (flip == SDL_FLIP_NONE && (int)(angle/360) == angle/360) { /* fast path when we don't need rotation or flipping */
|
||||
return SDL_RenderCopy(renderer, texture, srcrect, dstrect);
|
||||
}
|
||||
|
||||
|
|
@ -1749,6 +1787,11 @@ SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
return SDL_SetError("Renderer does not support RenderCopyEx");
|
||||
}
|
||||
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
real_srcrect.x = 0;
|
||||
real_srcrect.y = 0;
|
||||
real_srcrect.w = texture->w;
|
||||
|
|
@ -1772,8 +1815,9 @@ SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
texture = texture->native;
|
||||
}
|
||||
|
||||
if(center) real_center = *center;
|
||||
else {
|
||||
if (center) {
|
||||
real_center = *center;
|
||||
} else {
|
||||
real_center.x = real_dstrect.w/2;
|
||||
real_center.y = real_dstrect.h/2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,9 @@ struct SDL_Renderer
|
|||
int logical_w_backup;
|
||||
int logical_h_backup;
|
||||
|
||||
/* Whether or not to force the viewport to even integer intervals */
|
||||
SDL_bool integer_scale;
|
||||
|
||||
/* The drawable area within the window */
|
||||
SDL_Rect viewport;
|
||||
SDL_Rect viewport_backup;
|
||||
|
|
|
|||
|
|
@ -512,7 +512,6 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
D3D_RenderData *data;
|
||||
SDL_SysWMinfo windowinfo;
|
||||
HRESULT result;
|
||||
const char *hint;
|
||||
D3DPRESENT_PARAMETERS pparams;
|
||||
IDirect3DSwapChain9 *chain;
|
||||
D3DCAPS9 caps;
|
||||
|
|
@ -607,8 +606,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
device_flags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
|
||||
}
|
||||
|
||||
hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D_THREADSAFE);
|
||||
if (hint && SDL_atoi(hint)) {
|
||||
if (SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_FALSE)) {
|
||||
device_flags |= D3DCREATE_MULTITHREADED;
|
||||
}
|
||||
|
||||
|
|
@ -1004,6 +1002,10 @@ D3D_RecreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
if (!texturedata) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (D3D_RecreateTextureRep(data->device, &texturedata->texture, texture->format, texture->w, texture->h) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1307,6 +1309,10 @@ D3D_RenderClear(SDL_Renderer * renderer)
|
|||
BackBufferHeight = data->pparams.BackBufferHeight;
|
||||
}
|
||||
|
||||
if (renderer->clipping_enabled) {
|
||||
IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, FALSE);
|
||||
}
|
||||
|
||||
/* Don't reset the viewport if we don't have to! */
|
||||
if (!renderer->viewport.x && !renderer->viewport.y &&
|
||||
renderer->viewport.w == BackBufferWidth &&
|
||||
|
|
@ -1336,6 +1342,10 @@ D3D_RenderClear(SDL_Renderer * renderer)
|
|||
IDirect3DDevice9_SetViewport(data->device, &viewport);
|
||||
}
|
||||
|
||||
if (renderer->clipping_enabled) {
|
||||
IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, TRUE);
|
||||
}
|
||||
|
||||
if (FAILED(result)) {
|
||||
return D3D_SetError("Clear()", result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ extern ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNat
|
|||
#endif /* __WINRT__ */
|
||||
|
||||
|
||||
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
|
||||
|
||||
#define SAFE_RELEASE(X) if ((X)) { IUnknown_Release(SDL_static_cast(IUnknown*, X)); X = NULL; }
|
||||
|
||||
|
||||
|
|
@ -136,14 +138,31 @@ typedef struct
|
|||
} D3D11_RenderData;
|
||||
|
||||
|
||||
/* Defined here so we don't have to include uuid.lib */
|
||||
static const GUID IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } };
|
||||
static const GUID IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } };
|
||||
static const GUID IID_IDXGIDevice3 = { 0x6007896c, 0x3244, 0x4afd, { 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23 } };
|
||||
static const GUID IID_ID3D11Texture2D = { 0x6f15aaf2, 0xd208, 0x4e89, { 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c } };
|
||||
static const GUID IID_ID3D11Device1 = { 0xa04bfb29, 0x08ef, 0x43d6, { 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86 } };
|
||||
static const GUID IID_ID3D11DeviceContext1 = { 0xbb2c6faa, 0xb5fb, 0x4082, { 0x8e, 0x6b, 0x38, 0x8b, 0x8c, 0xfa, 0x90, 0xe1 } };
|
||||
static const GUID IID_ID3D11Debug = { 0x79cf2233, 0x7536, 0x4948, { 0x9d, 0x36, 0x1e, 0x46, 0x92, 0xdc, 0x57, 0x60 } };
|
||||
/* Define D3D GUIDs here so we don't have to include uuid.lib.
|
||||
*
|
||||
* Fix for SDL bug https://bugzilla.libsdl.org/show_bug.cgi?id=3437:
|
||||
* The extra 'SDL_' was added to the start of each IID's name, in order
|
||||
* to prevent build errors on both MinGW-w64 and WinRT/UWP.
|
||||
* (SDL bug https://bugzilla.libsdl.org/show_bug.cgi?id=3336 led to
|
||||
* linker errors in WinRT/UWP builds.)
|
||||
*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-const-variable"
|
||||
#endif
|
||||
|
||||
static const GUID SDL_IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } };
|
||||
static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } };
|
||||
static const GUID SDL_IID_IDXGIDevice3 = { 0x6007896c, 0x3244, 0x4afd, { 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23 } };
|
||||
static const GUID SDL_IID_ID3D11Texture2D = { 0x6f15aaf2, 0xd208, 0x4e89, { 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c } };
|
||||
static const GUID SDL_IID_ID3D11Device1 = { 0xa04bfb29, 0x08ef, 0x43d6, { 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86 } };
|
||||
static const GUID SDL_IID_ID3D11DeviceContext1 = { 0xbb2c6faa, 0xb5fb, 0x4082, { 0x8e, 0x6b, 0x38, 0x8b, 0x8c, 0xfa, 0x90, 0xe1 } };
|
||||
static const GUID SDL_IID_ID3D11Debug = { 0x79cf2233, 0x7536, 0x4948, { 0x9d, 0x36, 0x1e, 0x46, 0x92, 0xdc, 0x57, 0x60 } };
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
/* Direct3D 11.x shaders
|
||||
|
||||
|
|
@ -961,7 +980,7 @@ D3D11_CreateBlendMode(SDL_Renderer * renderer,
|
|||
blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
|
||||
result = ID3D11Device_CreateBlendState(data->d3dDevice, &blendDesc, blendStateOutput);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateBlendState", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBlendState"), result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -976,13 +995,11 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc;
|
||||
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
|
||||
PFN_D3D11_CREATE_DEVICE D3D11CreateDeviceFunc;
|
||||
IDXGIAdapter *d3dAdapter = NULL;
|
||||
ID3D11Device *d3dDevice = NULL;
|
||||
ID3D11DeviceContext *d3dContext = NULL;
|
||||
IDXGIDevice1 *dxgiDevice = NULL;
|
||||
HRESULT result = S_OK;
|
||||
UINT creationFlags;
|
||||
const char *hint;
|
||||
|
||||
/* This array defines the set of DirectX hardware feature levels this app will support.
|
||||
* Note the ordering should be preserved.
|
||||
|
|
@ -1041,16 +1058,16 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
}
|
||||
#endif /* __WINRT__ */
|
||||
|
||||
result = CreateDXGIFactoryFunc(&IID_IDXGIFactory2, &data->dxgiFactory);
|
||||
result = CreateDXGIFactoryFunc(&SDL_IID_IDXGIFactory2, (void **)&data->dxgiFactory);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", CreateDXGIFactory", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("CreateDXGIFactory"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* FIXME: Should we use the default adapter? */
|
||||
result = IDXGIFactory2_EnumAdapters(data->dxgiFactory, 0, &data->dxgiAdapter);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", D3D11CreateDevice", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D11CreateDevice"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1060,8 +1077,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
|
||||
|
||||
/* Make sure Direct3D's debugging feature gets used, if the app requests it. */
|
||||
hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D11_DEBUG);
|
||||
if (hint && SDL_atoi(hint) > 0) {
|
||||
if (SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE)) {
|
||||
creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||
}
|
||||
|
||||
|
|
@ -1079,25 +1095,25 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
&d3dContext /* Returns the device immediate context. */
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", D3D11CreateDevice", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D11CreateDevice"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
result = ID3D11Device_QueryInterface(d3dDevice, &IID_ID3D11Device1, &data->d3dDevice);
|
||||
result = ID3D11Device_QueryInterface(d3dDevice, &SDL_IID_ID3D11Device1, (void **)&data->d3dDevice);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device to ID3D11Device1", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device to ID3D11Device1"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
result = ID3D11DeviceContext_QueryInterface(d3dContext, &IID_ID3D11DeviceContext1, &data->d3dContext);
|
||||
result = ID3D11DeviceContext_QueryInterface(d3dContext, &SDL_IID_ID3D11DeviceContext1, (void **)&data->d3dContext);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext to ID3D11DeviceContext1", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext to ID3D11DeviceContext1"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
result = ID3D11Device_QueryInterface(d3dDevice, &IID_IDXGIDevice1, &dxgiDevice);
|
||||
result = ID3D11Device_QueryInterface(d3dDevice, &SDL_IID_IDXGIDevice1, (void **)&dxgiDevice);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device to IDXGIDevice1", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device to IDXGIDevice1"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1106,7 +1122,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
*/
|
||||
result = IDXGIDevice1_SetMaximumFrameLatency(dxgiDevice, 1);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIDevice1::SetMaximumFrameLatency", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIDevice1::SetMaximumFrameLatency"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1135,7 +1151,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
break;
|
||||
|
||||
default:
|
||||
SDL_SetError(__FUNCTION__ ", Unexpected feature level: %d", data->featureLevel);
|
||||
SDL_SetError("%s, Unexpected feature level: %d", __FUNCTION__, data->featureLevel);
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -1148,7 +1164,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
&data->vertexShader
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateVertexShader", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateVertexShader"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1161,7 +1177,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
&data->inputLayout
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateInputLayout", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateInputLayout"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1173,7 +1189,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
&data->colorPixelShader
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreatePixelShader ['color' shader]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreatePixelShader ['color' shader]"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1184,7 +1200,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
&data->texturePixelShader
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreatePixelShader ['textures' shader]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreatePixelShader ['textures' shader]"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1195,7 +1211,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
&data->yuvPixelShader
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreatePixelShader ['yuv' shader]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreatePixelShader ['yuv' shader]"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1210,7 +1226,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
&data->vertexShaderConstants
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateBuffer [vertex shader constants]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBuffer [vertex shader constants]"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1230,7 +1246,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
&data->nearestPixelSampler
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateSamplerState [nearest-pixel filter]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateSamplerState [nearest-pixel filter]"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1240,7 +1256,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
&data->linearSampler
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateSamplerState [linear filter]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateSamplerState [linear filter]"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1258,14 +1274,14 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
|||
rasterDesc.SlopeScaledDepthBias = 0.0f;
|
||||
result = ID3D11Device_CreateRasterizerState(data->d3dDevice, &rasterDesc, &data->mainRasterizer);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateRasterizerState [main rasterizer]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRasterizerState [main rasterizer]"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
rasterDesc.ScissorEnable = TRUE;
|
||||
result = ID3D11Device_CreateRasterizerState(data->d3dDevice, &rasterDesc, &data->clippedRasterizer);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateRasterizerState [clipped rasterizer]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRasterizerState [clipped rasterizer]"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1358,7 +1374,6 @@ D3D11_GetRotationForCurrentRenderTarget(SDL_Renderer * renderer)
|
|||
static int
|
||||
D3D11_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRect, D3D11_RECT * outRect, BOOL includeViewportOffset)
|
||||
{
|
||||
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
|
||||
const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer);
|
||||
switch (rotation) {
|
||||
case DXGI_MODE_ROTATION_IDENTITY:
|
||||
|
|
@ -1444,7 +1459,7 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
|
|||
&data->swapChain
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIFactory2::CreateSwapChainForCoreWindow", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForCoreWindow"), result);
|
||||
goto done;
|
||||
}
|
||||
} else if (usingXAML) {
|
||||
|
|
@ -1454,18 +1469,18 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
|
|||
NULL,
|
||||
&data->swapChain);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIFactory2::CreateSwapChainForComposition", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForComposition"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
|
||||
result = ISwapChainBackgroundPanelNative_SetSwapChain(WINRT_GlobalSwapChainBackgroundPanelNative, (IDXGISwapChain *) data->swapChain);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ISwapChainBackgroundPanelNative::SetSwapChain", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ISwapChainBackgroundPanelNative::SetSwapChain"), result);
|
||||
goto done;
|
||||
}
|
||||
#else
|
||||
SDL_SetError(__FUNCTION__ ", XAML support is not yet available for Windows Phone");
|
||||
SDL_SetError(SDL_COMPOSE_ERROR("XAML support is not yet available for Windows Phone"));
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
#endif
|
||||
|
|
@ -1484,7 +1499,7 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
|
|||
&data->swapChain
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIFactory2::CreateSwapChainForHwnd", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForHwnd"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1545,7 +1560,7 @@ D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
|
|||
*/
|
||||
goto done;
|
||||
} else if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain::ResizeBuffers", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::ResizeBuffers"), result);
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1576,7 +1591,7 @@ D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
|
|||
if (data->swapEffect == DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL) {
|
||||
result = IDXGISwapChain1_SetRotation(data->swapChain, data->rotation);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain1::SetRotation", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain1::SetRotation"), result);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -1584,11 +1599,11 @@ D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
|
|||
|
||||
result = IDXGISwapChain_GetBuffer(data->swapChain,
|
||||
0,
|
||||
&IID_ID3D11Texture2D,
|
||||
&backBuffer
|
||||
&SDL_IID_ID3D11Texture2D,
|
||||
(void **)&backBuffer
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain::GetBuffer [back-buffer]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::GetBuffer [back-buffer]"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1599,7 +1614,7 @@ D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
|
|||
&data->mainRenderTargetView
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device::CreateRenderTargetView", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device::CreateRenderTargetView"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1618,14 +1633,12 @@ done:
|
|||
static HRESULT
|
||||
D3D11_UpdateForWindowSizeChange(SDL_Renderer * renderer)
|
||||
{
|
||||
D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
|
||||
return D3D11_CreateWindowSizeDependentResources(renderer);
|
||||
}
|
||||
|
||||
HRESULT
|
||||
D3D11_HandleDeviceLost(SDL_Renderer * renderer)
|
||||
{
|
||||
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
|
||||
HRESULT result = S_OK;
|
||||
|
||||
D3D11_ReleaseAll(renderer);
|
||||
|
|
@ -1661,7 +1674,7 @@ D3D11_Trim(SDL_Renderer * renderer)
|
|||
HRESULT result = S_OK;
|
||||
IDXGIDevice3 *dxgiDevice = NULL;
|
||||
|
||||
result = ID3D11Device_QueryInterface(data->d3dDevice, &IID_IDXGIDevice3, &dxgiDevice);
|
||||
result = ID3D11Device_QueryInterface(data->d3dDevice, &SDL_IID_IDXGIDevice3, &dxgiDevice);
|
||||
if (FAILED(result)) {
|
||||
//WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device to IDXGIDevice3", result);
|
||||
return;
|
||||
|
|
@ -1702,7 +1715,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
D3D11_TEXTURE2D_DESC textureDesc;
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc;
|
||||
|
||||
if (textureFormat == SDL_PIXELFORMAT_UNKNOWN) {
|
||||
if (textureFormat == DXGI_FORMAT_UNKNOWN) {
|
||||
return SDL_SetError("%s, An unsupported SDL pixel format (0x%x) was specified",
|
||||
__FUNCTION__, texture->format);
|
||||
}
|
||||
|
|
@ -1747,7 +1760,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
);
|
||||
if (FAILED(result)) {
|
||||
D3D11_DestroyTexture(renderer, texture);
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1765,7 +1778,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
);
|
||||
if (FAILED(result)) {
|
||||
D3D11_DestroyTexture(renderer, texture);
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1776,7 +1789,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
);
|
||||
if (FAILED(result)) {
|
||||
D3D11_DestroyTexture(renderer, texture);
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1792,7 +1805,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
);
|
||||
if (FAILED(result)) {
|
||||
D3D11_DestroyTexture(renderer, texture);
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ "ID3D11Device1::CreateShaderResourceView", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1804,7 +1817,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
);
|
||||
if (FAILED(result)) {
|
||||
D3D11_DestroyTexture(renderer, texture);
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ "ID3D11Device1::CreateShaderResourceView", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result);
|
||||
return -1;
|
||||
}
|
||||
result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice,
|
||||
|
|
@ -1814,7 +1827,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
);
|
||||
if (FAILED(result)) {
|
||||
D3D11_DestroyTexture(renderer, texture);
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ "ID3D11Device1::CreateShaderResourceView", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1831,7 +1844,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
&textureData->mainTextureRenderTargetView);
|
||||
if (FAILED(result)) {
|
||||
D3D11_DestroyTexture(renderer, texture);
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateRenderTargetView", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRenderTargetView"), result);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1887,7 +1900,7 @@ D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *tex
|
|||
NULL,
|
||||
&stagingTexture);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D [create staging texture]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1900,7 +1913,7 @@ D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *tex
|
|||
&textureMemory
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext1::Map [map staging texture]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result);
|
||||
SAFE_RELEASE(stagingTexture);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -2062,7 +2075,7 @@ D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
NULL,
|
||||
&textureData->stagingTexture);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D [create staging texture]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -2075,7 +2088,7 @@ D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
&textureMemory
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext1::Map [map staging texture]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result);
|
||||
SAFE_RELEASE(textureData->stagingTexture);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -2359,7 +2372,7 @@ D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
|
|||
&mappedResource
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext1::Map [vertex buffer]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [vertex buffer]"), result);
|
||||
return -1;
|
||||
}
|
||||
SDL_memcpy(mappedResource.pData, vertexData, dataSizeInBytes);
|
||||
|
|
@ -2383,7 +2396,7 @@ D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
|
|||
&rendererData->vertexBuffer
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateBuffer [vertex buffer]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBuffer [vertex buffer]"), result);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -2842,18 +2855,18 @@ D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
HRESULT result;
|
||||
int status = -1;
|
||||
D3D11_TEXTURE2D_DESC stagingTextureDesc;
|
||||
D3D11_RECT srcRect;
|
||||
D3D11_RECT srcRect = {0, 0, 0, 0};
|
||||
D3D11_BOX srcBox;
|
||||
D3D11_MAPPED_SUBRESOURCE textureMemory;
|
||||
|
||||
/* Retrieve a pointer to the back buffer: */
|
||||
result = IDXGISwapChain_GetBuffer(data->swapChain,
|
||||
0,
|
||||
&IID_ID3D11Texture2D,
|
||||
&backBuffer
|
||||
&SDL_IID_ID3D11Texture2D,
|
||||
(void **)&backBuffer
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain1::GetBuffer [get back buffer]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain1::GetBuffer [get back buffer]"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -2870,7 +2883,7 @@ D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
NULL,
|
||||
&stagingTexture);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D [create staging texture]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -2902,7 +2915,7 @@ D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
0,
|
||||
&textureMemory);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext1::Map [map staging texture]", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -2921,7 +2934,7 @@ D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
* Get the error message, and attach some extra data to it.
|
||||
*/
|
||||
char errorMessage[1024];
|
||||
SDL_snprintf(errorMessage, sizeof(errorMessage), __FUNCTION__ ", Convert Pixels failed: %s", SDL_GetError());
|
||||
SDL_snprintf(errorMessage, sizeof(errorMessage), "%s, Convert Pixels failed: %s", __FUNCTION__, SDL_GetError());
|
||||
SDL_SetError("%s", errorMessage);
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -2991,7 +3004,7 @@ D3D11_RenderPresent(SDL_Renderer * renderer)
|
|||
/* We probably went through a fullscreen <-> windowed transition */
|
||||
D3D11_CreateWindowSizeDependentResources(renderer);
|
||||
} else {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain::Present", result);
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::Present"), result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -390,7 +390,6 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
{
|
||||
SDL_Renderer *renderer;
|
||||
GL_RenderData *data;
|
||||
const char *hint;
|
||||
GLint value;
|
||||
Uint32 window_flags;
|
||||
int profile_mask = 0, major = 0, minor = 0;
|
||||
|
|
@ -450,7 +449,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
renderer->GL_BindTexture = GL_BindTexture;
|
||||
renderer->GL_UnbindTexture = GL_UnbindTexture;
|
||||
renderer->info = GL_RenderDriver.info;
|
||||
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
||||
renderer->info.flags = SDL_RENDERER_ACCELERATED;
|
||||
renderer->driverdata = data;
|
||||
renderer->window = window;
|
||||
|
||||
|
|
@ -528,8 +527,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
}
|
||||
|
||||
/* Check for shader support */
|
||||
hint = SDL_GetHint(SDL_HINT_RENDER_OPENGL_SHADERS);
|
||||
if (!hint || *hint != '0') {
|
||||
if (SDL_GetHintBoolean(SDL_HINT_RENDER_OPENGL_SHADERS, SDL_TRUE)) {
|
||||
data->shaders = GL_CreateShaderContext();
|
||||
}
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "OpenGL shaders: %s",
|
||||
|
|
@ -594,7 +592,6 @@ static int
|
|||
GL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
|
||||
{
|
||||
SDL_GL_GetDrawableSize(renderer->window, w, h);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -664,6 +661,11 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
|
||||
GL_ActivateRenderer(renderer);
|
||||
|
||||
if (texture->access == SDL_TEXTUREACCESS_TARGET &&
|
||||
!renderdata->GL_EXT_framebuffer_object_supported) {
|
||||
return SDL_SetError("Render targets not supported by OpenGL");
|
||||
}
|
||||
|
||||
if (!convert_format(renderdata, texture->format, &internalFormat,
|
||||
&format, &type)) {
|
||||
return SDL_SetError("Texture format %s not supported by OpenGL",
|
||||
|
|
@ -980,6 +982,10 @@ GL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
|
||||
GL_ActivateRenderer(renderer);
|
||||
|
||||
if (!data->GL_EXT_framebuffer_object_supported) {
|
||||
return SDL_SetError("Render targets not supported by OpenGL");
|
||||
}
|
||||
|
||||
if (texture == NULL) {
|
||||
data->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
return 0;
|
||||
|
|
@ -1013,7 +1019,7 @@ GL_UpdateViewport(SDL_Renderer * renderer)
|
|||
} else {
|
||||
int w, h;
|
||||
|
||||
SDL_GetRendererOutputSize(renderer, &w, &h);
|
||||
SDL_GL_GetDrawableSize(renderer->window, &w, &h);
|
||||
data->glViewport(renderer->viewport.x, (h - renderer->viewport.y - renderer->viewport.h),
|
||||
renderer->viewport.w, renderer->viewport.h);
|
||||
}
|
||||
|
|
@ -1051,7 +1057,7 @@ GL_UpdateClipRect(SDL_Renderer * renderer)
|
|||
} else {
|
||||
int w, h;
|
||||
|
||||
SDL_GetRendererOutputSize(renderer, &w, &h);
|
||||
SDL_GL_GetDrawableSize(renderer->window, &w, &h);
|
||||
data->glScissor(renderer->viewport.x + rect->x, h - renderer->viewport.y - rect->y - rect->h, rect->w, rect->h);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1089,21 +1095,17 @@ GL_SetBlendMode(GL_RenderData * data, int blendMode)
|
|||
if (blendMode != data->current.blendMode) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_NONE:
|
||||
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
data->glDisable(GL_BLEND);
|
||||
break;
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
data->glEnable(GL_BLEND);
|
||||
data->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
data->glEnable(GL_BLEND);
|
||||
data->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
data->glEnable(GL_BLEND);
|
||||
data->glBlendFuncSeparate(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE);
|
||||
break;
|
||||
|
|
@ -1141,8 +1143,16 @@ GL_RenderClear(SDL_Renderer * renderer)
|
|||
(GLfloat) renderer->b * inv255f,
|
||||
(GLfloat) renderer->a * inv255f);
|
||||
|
||||
if (renderer->clipping_enabled) {
|
||||
data->glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
data->glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
if (renderer->clipping_enabled) {
|
||||
data->glEnable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1409,7 +1419,7 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
Uint32 pixel_format, void * pixels, int pitch)
|
||||
{
|
||||
GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
|
||||
Uint32 temp_format = SDL_PIXELFORMAT_ARGB8888;
|
||||
Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ARGB8888;
|
||||
void *temp_pixels;
|
||||
int temp_pitch;
|
||||
GLint internalFormat;
|
||||
|
|
@ -1426,7 +1436,11 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
convert_format(data, temp_format, &internalFormat, &format, &type);
|
||||
if (!convert_format(data, temp_format, &internalFormat, &format, &type)) {
|
||||
SDL_free(temp_pixels);
|
||||
return SDL_SetError("Texture format %s not supported by OpenGL",
|
||||
SDL_GetPixelFormatName(temp_format));
|
||||
}
|
||||
|
||||
SDL_GetRendererOutputSize(renderer, &w, &h);
|
||||
|
||||
|
|
@ -1434,28 +1448,30 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
data->glPixelStorei(GL_PACK_ROW_LENGTH,
|
||||
(temp_pitch / SDL_BYTESPERPIXEL(temp_format)));
|
||||
|
||||
data->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h,
|
||||
format, type, temp_pixels);
|
||||
data->glReadPixels(rect->x, renderer->target ? rect->y : (h-rect->y)-rect->h,
|
||||
rect->w, rect->h, format, type, temp_pixels);
|
||||
|
||||
if (GL_CheckError("glReadPixels()", renderer) < 0) {
|
||||
SDL_free(temp_pixels);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Flip the rows to be top-down */
|
||||
length = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch;
|
||||
dst = (Uint8*)temp_pixels;
|
||||
tmp = SDL_stack_alloc(Uint8, length);
|
||||
rows = rect->h / 2;
|
||||
while (rows--) {
|
||||
SDL_memcpy(tmp, dst, length);
|
||||
SDL_memcpy(dst, src, length);
|
||||
SDL_memcpy(src, tmp, length);
|
||||
dst += temp_pitch;
|
||||
src -= temp_pitch;
|
||||
/* Flip the rows to be top-down if necessary */
|
||||
if (!renderer->target) {
|
||||
length = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch;
|
||||
dst = (Uint8*)temp_pixels;
|
||||
tmp = SDL_stack_alloc(Uint8, length);
|
||||
rows = rect->h / 2;
|
||||
while (rows--) {
|
||||
SDL_memcpy(tmp, dst, length);
|
||||
SDL_memcpy(dst, src, length);
|
||||
SDL_memcpy(src, tmp, length);
|
||||
dst += temp_pitch;
|
||||
src -= temp_pitch;
|
||||
}
|
||||
SDL_stack_free(tmp);
|
||||
}
|
||||
SDL_stack_free(tmp);
|
||||
|
||||
status = SDL_ConvertPixels(rect->w, rect->h,
|
||||
temp_format, temp_pixels, temp_pitch,
|
||||
|
|
|
|||
|
|
@ -129,8 +129,6 @@ typedef struct
|
|||
GLES_FBOList *framebuffers;
|
||||
GLuint window_framebuffer;
|
||||
|
||||
SDL_bool useDrawTexture;
|
||||
SDL_bool GL_OES_draw_texture_supported;
|
||||
SDL_bool GL_OES_blend_func_separate_supported;
|
||||
} GLES_RenderData;
|
||||
|
||||
|
|
@ -369,19 +367,6 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_DRIVER_PANDORA
|
||||
data->GL_OES_draw_texture_supported = SDL_FALSE;
|
||||
data->useDrawTexture = SDL_FALSE;
|
||||
#else
|
||||
if (SDL_GL_ExtensionSupported("GL_OES_draw_texture")) {
|
||||
data->GL_OES_draw_texture_supported = SDL_TRUE;
|
||||
data->useDrawTexture = SDL_TRUE;
|
||||
} else {
|
||||
data->GL_OES_draw_texture_supported = SDL_FALSE;
|
||||
data->useDrawTexture = SDL_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
value = 0;
|
||||
data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
|
||||
renderer->info.max_texture_width = value;
|
||||
|
|
@ -605,6 +590,7 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
data->format,
|
||||
data->formattype,
|
||||
src);
|
||||
renderdata->glDisable(data->type);
|
||||
SDL_free(blob);
|
||||
|
||||
if (renderdata->glGetError() != GL_NO_ERROR) {
|
||||
|
|
@ -686,18 +672,27 @@ GLES_UpdateViewport(SDL_Renderer * renderer)
|
|||
} else {
|
||||
int w, h;
|
||||
|
||||
SDL_GetRendererOutputSize(renderer, &w, &h);
|
||||
SDL_GL_GetDrawableSize(renderer->window, &w, &h);
|
||||
data->glViewport(renderer->viewport.x, (h - renderer->viewport.y - renderer->viewport.h),
|
||||
renderer->viewport.w, renderer->viewport.h);
|
||||
}
|
||||
|
||||
data->glMatrixMode(GL_PROJECTION);
|
||||
data->glLoadIdentity();
|
||||
if (renderer->viewport.w && renderer->viewport.h) {
|
||||
data->glMatrixMode(GL_PROJECTION);
|
||||
data->glLoadIdentity();
|
||||
data->glOrthof((GLfloat) 0,
|
||||
(GLfloat) renderer->viewport.w,
|
||||
(GLfloat) renderer->viewport.h,
|
||||
(GLfloat) 0, 0.0, 1.0);
|
||||
if (renderer->target) {
|
||||
data->glOrthof((GLfloat) 0,
|
||||
(GLfloat) renderer->viewport.w,
|
||||
(GLfloat) 0,
|
||||
(GLfloat) renderer->viewport.h,
|
||||
0.0, 1.0);
|
||||
} else {
|
||||
data->glOrthof((GLfloat) 0,
|
||||
(GLfloat) renderer->viewport.w,
|
||||
(GLfloat) renderer->viewport.h,
|
||||
(GLfloat) 0,
|
||||
0.0, 1.0);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -720,7 +715,7 @@ GLES_UpdateClipRect(SDL_Renderer * renderer)
|
|||
} else {
|
||||
int w, h;
|
||||
|
||||
SDL_GetRendererOutputSize(renderer, &w, &h);
|
||||
SDL_GL_GetDrawableSize(renderer->window, &w, &h);
|
||||
data->glScissor(renderer->viewport.x + rect->x, h - renderer->viewport.y - rect->y - rect->h, rect->w, rect->h);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -749,11 +744,9 @@ GLES_SetBlendMode(GLES_RenderData * data, int blendMode)
|
|||
if (blendMode != data->current.blendMode) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_NONE:
|
||||
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
data->glDisable(GL_BLEND);
|
||||
break;
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
data->glEnable(GL_BLEND);
|
||||
if (data->GL_OES_blend_func_separate_supported) {
|
||||
data->glBlendFuncSeparateOES(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
|
@ -762,7 +755,6 @@ GLES_SetBlendMode(GLES_RenderData * data, int blendMode)
|
|||
}
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
data->glEnable(GL_BLEND);
|
||||
if (data->GL_OES_blend_func_separate_supported) {
|
||||
data->glBlendFuncSeparateOES(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE);
|
||||
|
|
@ -771,7 +763,6 @@ GLES_SetBlendMode(GLES_RenderData * data, int blendMode)
|
|||
}
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
data->glEnable(GL_BLEND);
|
||||
if (data->GL_OES_blend_func_separate_supported) {
|
||||
data->glBlendFuncSeparateOES(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE);
|
||||
|
|
@ -825,9 +816,17 @@ GLES_RenderClear(SDL_Renderer * renderer)
|
|||
(GLfloat) renderer->g * inv255f,
|
||||
(GLfloat) renderer->b * inv255f,
|
||||
(GLfloat) renderer->a * inv255f);
|
||||
|
||||
if (renderer->clipping_enabled) {
|
||||
data->glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
data->glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
if (renderer->clipping_enabled) {
|
||||
data->glEnable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -952,71 +951,42 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
|
||||
GLES_SetTexCoords(data, SDL_TRUE);
|
||||
|
||||
if (data->GL_OES_draw_texture_supported && data->useDrawTexture) {
|
||||
/* this code is a little funny because the viewport is upside down vs SDL's coordinate system */
|
||||
GLint cropRect[4];
|
||||
int w, h;
|
||||
SDL_Window *window = renderer->window;
|
||||
minx = dstrect->x;
|
||||
miny = dstrect->y;
|
||||
maxx = dstrect->x + dstrect->w;
|
||||
maxy = dstrect->y + dstrect->h;
|
||||
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
if (renderer->target) {
|
||||
cropRect[0] = srcrect->x;
|
||||
cropRect[1] = srcrect->y;
|
||||
cropRect[2] = srcrect->w;
|
||||
cropRect[3] = srcrect->h;
|
||||
data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES,
|
||||
cropRect);
|
||||
data->glDrawTexfOES(renderer->viewport.x + dstrect->x, renderer->viewport.y + dstrect->y, 0,
|
||||
dstrect->w, dstrect->h);
|
||||
} else {
|
||||
cropRect[0] = srcrect->x;
|
||||
cropRect[1] = srcrect->y + srcrect->h;
|
||||
cropRect[2] = srcrect->w;
|
||||
cropRect[3] = -srcrect->h;
|
||||
data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES,
|
||||
cropRect);
|
||||
data->glDrawTexfOES(renderer->viewport.x + dstrect->x,
|
||||
h - (renderer->viewport.y + dstrect->y) - dstrect->h, 0,
|
||||
dstrect->w, dstrect->h);
|
||||
}
|
||||
} else {
|
||||
minu = (GLfloat) srcrect->x / texture->w;
|
||||
minu *= texturedata->texw;
|
||||
maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
|
||||
maxu *= texturedata->texw;
|
||||
minv = (GLfloat) srcrect->y / texture->h;
|
||||
minv *= texturedata->texh;
|
||||
maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
|
||||
maxv *= texturedata->texh;
|
||||
|
||||
minx = dstrect->x;
|
||||
miny = dstrect->y;
|
||||
maxx = dstrect->x + dstrect->w;
|
||||
maxy = dstrect->y + dstrect->h;
|
||||
vertices[0] = minx;
|
||||
vertices[1] = miny;
|
||||
vertices[2] = maxx;
|
||||
vertices[3] = miny;
|
||||
vertices[4] = minx;
|
||||
vertices[5] = maxy;
|
||||
vertices[6] = maxx;
|
||||
vertices[7] = maxy;
|
||||
|
||||
minu = (GLfloat) srcrect->x / texture->w;
|
||||
minu *= texturedata->texw;
|
||||
maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
|
||||
maxu *= texturedata->texw;
|
||||
minv = (GLfloat) srcrect->y / texture->h;
|
||||
minv *= texturedata->texh;
|
||||
maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
|
||||
maxv *= texturedata->texh;
|
||||
texCoords[0] = minu;
|
||||
texCoords[1] = minv;
|
||||
texCoords[2] = maxu;
|
||||
texCoords[3] = minv;
|
||||
texCoords[4] = minu;
|
||||
texCoords[5] = maxv;
|
||||
texCoords[6] = maxu;
|
||||
texCoords[7] = maxv;
|
||||
|
||||
vertices[0] = minx;
|
||||
vertices[1] = miny;
|
||||
vertices[2] = maxx;
|
||||
vertices[3] = miny;
|
||||
vertices[4] = minx;
|
||||
vertices[5] = maxy;
|
||||
vertices[6] = maxx;
|
||||
vertices[7] = maxy;
|
||||
data->glVertexPointer(2, GL_FLOAT, 0, vertices);
|
||||
data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
|
||||
data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
texCoords[0] = minu;
|
||||
texCoords[1] = minv;
|
||||
texCoords[2] = maxu;
|
||||
texCoords[3] = minv;
|
||||
texCoords[4] = minu;
|
||||
texCoords[5] = maxv;
|
||||
texCoords[6] = maxu;
|
||||
texCoords[7] = maxv;
|
||||
|
||||
data->glVertexPointer(2, GL_FLOAT, 0, vertices);
|
||||
data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
|
||||
data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
data->glDisable(GL_TEXTURE_2D);
|
||||
|
||||
return 0;
|
||||
|
|
@ -1117,7 +1087,7 @@ GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
Uint32 pixel_format, void * pixels, int pitch)
|
||||
{
|
||||
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
||||
Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888;
|
||||
Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888;
|
||||
void *temp_pixels;
|
||||
int temp_pitch;
|
||||
Uint8 *src, *dst, *tmp;
|
||||
|
|
@ -1136,23 +1106,25 @@ GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
|
||||
data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
|
||||
data->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels);
|
||||
data->glReadPixels(rect->x, renderer->target ? rect->y : (h-rect->y)-rect->h,
|
||||
rect->w, rect->h, GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels);
|
||||
|
||||
/* Flip the rows to be top-down */
|
||||
length = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch;
|
||||
dst = (Uint8*)temp_pixels;
|
||||
tmp = SDL_stack_alloc(Uint8, length);
|
||||
rows = rect->h / 2;
|
||||
while (rows--) {
|
||||
SDL_memcpy(tmp, dst, length);
|
||||
SDL_memcpy(dst, src, length);
|
||||
SDL_memcpy(src, tmp, length);
|
||||
dst += temp_pitch;
|
||||
src -= temp_pitch;
|
||||
/* Flip the rows to be top-down if necessary */
|
||||
if (!renderer->target) {
|
||||
length = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch;
|
||||
dst = (Uint8*)temp_pixels;
|
||||
tmp = SDL_stack_alloc(Uint8, length);
|
||||
rows = rect->h / 2;
|
||||
while (rows--) {
|
||||
SDL_memcpy(tmp, dst, length);
|
||||
SDL_memcpy(dst, src, length);
|
||||
SDL_memcpy(src, tmp, length);
|
||||
dst += temp_pitch;
|
||||
src -= temp_pitch;
|
||||
}
|
||||
SDL_stack_free(tmp);
|
||||
}
|
||||
SDL_stack_free(tmp);
|
||||
|
||||
status = SDL_ConvertPixels(rect->w, rect->h,
|
||||
temp_format, temp_pixels, temp_pitch,
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ GLES2_UpdateViewport(SDL_Renderer * renderer)
|
|||
} else {
|
||||
int w, h;
|
||||
|
||||
SDL_GetRendererOutputSize(renderer, &w, &h);
|
||||
SDL_GL_GetDrawableSize(renderer->window, &w, &h);
|
||||
data->glViewport(renderer->viewport.x, (h - renderer->viewport.y - renderer->viewport.h),
|
||||
renderer->viewport.w, renderer->viewport.h);
|
||||
}
|
||||
|
|
@ -417,7 +417,7 @@ GLES2_UpdateClipRect(SDL_Renderer * renderer)
|
|||
} else {
|
||||
int w, h;
|
||||
|
||||
SDL_GetRendererOutputSize(renderer, &w, &h);
|
||||
SDL_GL_GetDrawableSize(renderer->window, &w, &h);
|
||||
data->glScissor(renderer->viewport.x + rect->x, h - renderer->viewport.y - rect->y - rect->h, rect->w, rect->h);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1327,8 +1327,16 @@ GLES2_RenderClear(SDL_Renderer * renderer)
|
|||
data->clear_a = renderer->a;
|
||||
}
|
||||
|
||||
if (renderer->clipping_enabled) {
|
||||
data->glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
data->glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
if (renderer->clipping_enabled) {
|
||||
data->glEnable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1817,7 +1825,7 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
Uint32 pixel_format, void * pixels, int pitch)
|
||||
{
|
||||
GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
|
||||
Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888;
|
||||
Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888;
|
||||
void *temp_pixels;
|
||||
int temp_pitch;
|
||||
Uint8 *src, *dst, *tmp;
|
||||
|
|
@ -1834,26 +1842,28 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
|
||||
SDL_GetRendererOutputSize(renderer, &w, &h);
|
||||
|
||||
data->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels);
|
||||
data->glReadPixels(rect->x, renderer->target ? rect->y : (h-rect->y)-rect->h,
|
||||
rect->w, rect->h, GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels);
|
||||
if (GL_CheckError("glReadPixels()", renderer) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Flip the rows to be top-down */
|
||||
length = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch;
|
||||
dst = (Uint8*)temp_pixels;
|
||||
tmp = SDL_stack_alloc(Uint8, length);
|
||||
rows = rect->h / 2;
|
||||
while (rows--) {
|
||||
SDL_memcpy(tmp, dst, length);
|
||||
SDL_memcpy(dst, src, length);
|
||||
SDL_memcpy(src, tmp, length);
|
||||
dst += temp_pitch;
|
||||
src -= temp_pitch;
|
||||
/* Flip the rows to be top-down if necessary */
|
||||
if (!renderer->target) {
|
||||
length = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch;
|
||||
dst = (Uint8*)temp_pixels;
|
||||
tmp = SDL_stack_alloc(Uint8, length);
|
||||
rows = rect->h / 2;
|
||||
while (rows--) {
|
||||
SDL_memcpy(tmp, dst, length);
|
||||
SDL_memcpy(dst, src, length);
|
||||
SDL_memcpy(src, tmp, length);
|
||||
dst += temp_pitch;
|
||||
src -= temp_pitch;
|
||||
}
|
||||
SDL_stack_free(tmp);
|
||||
}
|
||||
SDL_stack_free(tmp);
|
||||
|
||||
status = SDL_ConvertPixels(rect->w, rect->h,
|
||||
temp_format, temp_pixels, temp_pitch,
|
||||
|
|
@ -1959,9 +1969,15 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
|||
int profile_mask = 0, major = 0, minor = 0;
|
||||
SDL_bool changed_window = SDL_FALSE;
|
||||
|
||||
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask);
|
||||
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major);
|
||||
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor);
|
||||
if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
window_flags = SDL_GetWindowFlags(window);
|
||||
if (!(window_flags & SDL_WINDOW_OPENGL) ||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ static SDL_Renderer *PSP_CreateRenderer(SDL_Window * window, Uint32 flags);
|
|||
static void PSP_WindowEvent(SDL_Renderer * renderer,
|
||||
const SDL_WindowEvent *event);
|
||||
static int PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
static int PSP_SetTextureColorMod(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
static int PSP_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels,
|
||||
int pitch);
|
||||
|
|
@ -359,6 +361,7 @@ PSP_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
|
||||
renderer->WindowEvent = PSP_WindowEvent;
|
||||
renderer->CreateTexture = PSP_CreateTexture;
|
||||
renderer->SetTextureColorMod = PSP_SetTextureColorMod;
|
||||
renderer->UpdateTexture = PSP_UpdateTexture;
|
||||
renderer->LockTexture = PSP_LockTexture;
|
||||
renderer->UnlockTexture = PSP_UnlockTexture;
|
||||
|
|
@ -501,6 +504,11 @@ PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
PSP_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
void
|
||||
TextureActivate(SDL_Texture * texture)
|
||||
|
|
@ -853,7 +861,7 @@ PSP_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
Uint32 pixel_format, void * pixels, int pitch)
|
||||
|
||||
{
|
||||
return 0;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -677,8 +677,8 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
}
|
||||
|
||||
if (!retval) {
|
||||
SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, -angle, &dstwidth, &dstheight, &cangle, &sangle);
|
||||
surface_rotated = SDLgfx_rotateSurface(surface_scaled, -angle, dstwidth/2, dstheight/2, GetScaleQuality(), flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle);
|
||||
SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, angle, &dstwidth, &dstheight, &cangle, &sangle);
|
||||
surface_rotated = SDLgfx_rotateSurface(surface_scaled, angle, dstwidth/2, dstheight/2, GetScaleQuality(), flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle);
|
||||
if(surface_rotated) {
|
||||
/* Find out where the new origin is by rotating the four final_rect points around the center and then taking the extremes */
|
||||
abscenterx = final_rect.x + (int)center->x;
|
||||
|
|
|
|||
|
|
@ -110,31 +110,105 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle,
|
|||
int *dstwidth, int *dstheight,
|
||||
double *cangle, double *sangle)
|
||||
{
|
||||
double x, y, cx, cy, sx, sy;
|
||||
double radangle;
|
||||
int dstwidthhalf, dstheighthalf;
|
||||
|
||||
/*
|
||||
* Determine destination width and height by rotating a centered source box
|
||||
*/
|
||||
radangle = angle * (M_PI / 180.0);
|
||||
*sangle = SDL_sin(radangle);
|
||||
*cangle = SDL_cos(radangle);
|
||||
x = (double)(width / 2);
|
||||
y = (double)(height / 2);
|
||||
cx = *cangle * x;
|
||||
cy = *cangle * y;
|
||||
sx = *sangle * x;
|
||||
sy = *sangle * y;
|
||||
|
||||
dstwidthhalf = MAX((int)
|
||||
SDL_ceil(MAX(MAX(MAX(SDL_fabs(cx + sy), SDL_fabs(cx - sy)), SDL_fabs(-cx + sy)), SDL_fabs(-cx - sy))), 1);
|
||||
dstheighthalf = MAX((int)
|
||||
SDL_ceil(MAX(MAX(MAX(SDL_fabs(sx + cy), SDL_fabs(sx - cy)), SDL_fabs(-sx + cy)), SDL_fabs(-sx - cy))), 1);
|
||||
*dstwidth = 2 * dstwidthhalf;
|
||||
*dstheight = 2 * dstheighthalf;
|
||||
/* The trig code below gets the wrong size (due to FP inaccuracy?) when angle is a multiple of 90 degrees */
|
||||
int angle90 = (int)(angle/90);
|
||||
if(angle90 == angle/90) { /* if the angle is a multiple of 90 degrees */
|
||||
angle90 %= 4;
|
||||
if(angle90 < 0) angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
if(angle90 & 1) {
|
||||
*dstwidth = height;
|
||||
*dstheight = width;
|
||||
*cangle = 0;
|
||||
*sangle = angle90 == 1 ? -1 : 1; /* reversed because our rotations are clockwise */
|
||||
} else {
|
||||
*dstwidth = width;
|
||||
*dstheight = height;
|
||||
*cangle = angle90 == 0 ? 1 : -1;
|
||||
*sangle = 0;
|
||||
}
|
||||
} else {
|
||||
double x, y, cx, cy, sx, sy;
|
||||
double radangle;
|
||||
int dstwidthhalf, dstheighthalf;
|
||||
/*
|
||||
* Determine destination width and height by rotating a centered source box
|
||||
*/
|
||||
radangle = angle * (M_PI / -180.0); /* reverse the angle because our rotations are clockwise */
|
||||
*sangle = SDL_sin(radangle);
|
||||
*cangle = SDL_cos(radangle);
|
||||
x = (double)(width / 2);
|
||||
y = (double)(height / 2);
|
||||
cx = *cangle * x;
|
||||
cy = *cangle * y;
|
||||
sx = *sangle * x;
|
||||
sy = *sangle * y;
|
||||
|
||||
dstwidthhalf = MAX((int)
|
||||
SDL_ceil(MAX(MAX(MAX(SDL_fabs(cx + sy), SDL_fabs(cx - sy)), SDL_fabs(-cx + sy)), SDL_fabs(-cx - sy))), 1);
|
||||
dstheighthalf = MAX((int)
|
||||
SDL_ceil(MAX(MAX(MAX(SDL_fabs(sx + cy), SDL_fabs(sx - cy)), SDL_fabs(-sx + cy)), SDL_fabs(-sx - cy))), 1);
|
||||
*dstwidth = 2 * dstwidthhalf;
|
||||
*dstheight = 2 * dstheighthalf;
|
||||
}
|
||||
}
|
||||
|
||||
/* Computes source pointer X/Y increments for a rotation that's a multiple of 90 degrees. */
|
||||
static void
|
||||
computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int flipy,
|
||||
int *sincx, int *sincy, int *signx, int *signy)
|
||||
{
|
||||
int pitch = flipy ? -src->pitch : src->pitch;
|
||||
if (flipx) {
|
||||
bpp = -bpp;
|
||||
}
|
||||
switch (angle) { /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
case 0: *sincx = bpp; *sincy = pitch - src->w * *sincx; *signx = *signy = 1; break;
|
||||
case 1: *sincx = -pitch; *sincy = bpp - *sincx * src->h; *signx = 1; *signy = -1; break;
|
||||
case 2: *sincx = -bpp; *sincy = -src->w * *sincx - pitch; *signx = *signy = -1; break;
|
||||
case 3: default: *sincx = pitch; *sincy = -*sincx * src->h - bpp; *signx = -1; *signy = 1; break;
|
||||
}
|
||||
if (flipx) {
|
||||
*signx = -*signx;
|
||||
}
|
||||
if (flipy) {
|
||||
*signy = -*signy;
|
||||
}
|
||||
}
|
||||
|
||||
/* Performs a relatively fast rotation/flip when the angle is a multiple of 90 degrees. */
|
||||
#define TRANSFORM_SURFACE_90(pixelType) \
|
||||
int dy, dincy = dst->pitch - dst->w*sizeof(pixelType), sincx, sincy, signx, signy; \
|
||||
Uint8 *sp = (Uint8*)src->pixels, *dp = (Uint8*)dst->pixels, *de; \
|
||||
\
|
||||
computeSourceIncrements90(src, sizeof(pixelType), angle, flipx, flipy, &sincx, &sincy, &signx, &signy); \
|
||||
if (signx < 0) sp += (src->w-1)*sizeof(pixelType); \
|
||||
if (signy < 0) sp += (src->h-1)*src->pitch; \
|
||||
\
|
||||
for (dy = 0; dy < dst->h; sp += sincy, dp += dincy, dy++) { \
|
||||
if (sincx == sizeof(pixelType)) { /* if advancing src and dest equally, use memcpy */ \
|
||||
SDL_memcpy(dp, sp, dst->w*sizeof(pixelType)); \
|
||||
sp += dst->w*sizeof(pixelType); \
|
||||
dp += dst->w*sizeof(pixelType); \
|
||||
} else { \
|
||||
for (de = dp + dst->w*sizeof(pixelType); dp != de; sp += sincx, dp += sizeof(pixelType)) { \
|
||||
*(pixelType*)dp = *(pixelType*)sp; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
static void
|
||||
transformSurfaceRGBA90(SDL_Surface * src, SDL_Surface * dst, int angle, int flipx, int flipy)
|
||||
{
|
||||
TRANSFORM_SURFACE_90(tColorRGBA);
|
||||
}
|
||||
|
||||
static void
|
||||
transformSurfaceY90(SDL_Surface * src, SDL_Surface * dst, int angle, int flipx, int flipy)
|
||||
{
|
||||
TRANSFORM_SURFACE_90(tColorY);
|
||||
}
|
||||
|
||||
#undef TRANSFORM_SURFACE_90
|
||||
|
||||
/* !
|
||||
\brief Internal 32 bit rotozoomer with optional anti-aliasing.
|
||||
|
|
@ -341,9 +415,9 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
|
|||
{
|
||||
SDL_Surface *rz_src;
|
||||
SDL_Surface *rz_dst;
|
||||
int is32bit;
|
||||
int is32bit, angle90;
|
||||
int i;
|
||||
Uint8 r,g,b;
|
||||
Uint8 r = 0, g = 0, b = 0;
|
||||
Uint32 colorkey = 0;
|
||||
int colorKeyAvailable = 0;
|
||||
double sangleinv, cangleinv;
|
||||
|
|
@ -370,18 +444,13 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
|
|||
*/
|
||||
rz_src = src;
|
||||
} else {
|
||||
Uint32 format = SDL_MasksToPixelFormatEnum(32,
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
|
||||
#else
|
||||
0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
|
||||
#endif
|
||||
);
|
||||
rz_src = SDL_ConvertSurfaceFormat(src, format, src->flags);
|
||||
rz_src = SDL_ConvertSurfaceFormat(src, SDL_PIXELFORMAT_ARGB32, src->flags);
|
||||
if (rz_src == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
is32bit = 1;
|
||||
}
|
||||
|
||||
|
||||
/* Determine target size */
|
||||
/* _rotozoomSurfaceSizeTrig(rz_src->w, rz_src->h, angle, &dstwidth, &dstheight, &cangle, &sangle); */
|
||||
|
||||
|
|
@ -394,7 +463,6 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
|
|||
/*
|
||||
* Alloc space to completely contain the rotated surface
|
||||
*/
|
||||
rz_dst = NULL;
|
||||
if (is32bit) {
|
||||
/*
|
||||
* Target surface is 32bit with source RGBA/ABGR ordering
|
||||
|
|
@ -430,6 +498,18 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
|
|||
SDL_LockSurface(rz_src);
|
||||
}
|
||||
|
||||
/* check if the rotation is a multiple of 90 degrees so we can take a fast path and also somewhat reduce
|
||||
* the off-by-one problem in _transformSurfaceRGBA that expresses itself when the rotation is near
|
||||
* multiples of 90 degrees.
|
||||
*/
|
||||
angle90 = (int)(angle/90);
|
||||
if (angle90 == angle/90) {
|
||||
angle90 %= 4;
|
||||
if (angle90 < 0) angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
} else {
|
||||
angle90 = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check which kind of surface we have
|
||||
*/
|
||||
|
|
@ -437,10 +517,11 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
|
|||
/*
|
||||
* Call the 32bit transformation routine to do the rotation (using alpha)
|
||||
*/
|
||||
_transformSurfaceRGBA(rz_src, rz_dst, centerx, centery,
|
||||
(int) (sangleinv), (int) (cangleinv),
|
||||
flipx, flipy,
|
||||
smooth);
|
||||
if (angle90 >= 0) {
|
||||
transformSurfaceRGBA90(rz_src, rz_dst, angle90, flipx, flipy);
|
||||
} else {
|
||||
_transformSurfaceRGBA(rz_src, rz_dst, centerx, centery, (int) (sangleinv), (int) (cangleinv), flipx, flipy, smooth);
|
||||
}
|
||||
/*
|
||||
* Turn on source-alpha support
|
||||
*/
|
||||
|
|
@ -457,9 +538,11 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
|
|||
/*
|
||||
* Call the 8bit transformation routine to do the rotation
|
||||
*/
|
||||
transformSurfaceY(rz_src, rz_dst, centerx, centery,
|
||||
(int) (sangleinv), (int) (cangleinv),
|
||||
flipx, flipy);
|
||||
if(angle90 >= 0) {
|
||||
transformSurfaceY90(rz_src, rz_dst, angle90, flipx, flipy);
|
||||
} else {
|
||||
transformSurfaceY(rz_src, rz_dst, centerx, centery, (int)(sangleinv), (int)(cangleinv), flipx, flipy);
|
||||
}
|
||||
SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue