WinRT: made use of SDL's framebuffer emulation code, instead of the custom stuff; then removed SDL_winrtrenderer
This commit is contained in:
parent
ba872e50c7
commit
46530ef818
11 changed files with 6 additions and 356 deletions
|
@ -248,9 +248,7 @@
|
|||
<ClInclude Include="..\..\src\video\windowsrt\SDLmain_WinRT_common.h" />
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_WinRTApp.h" />
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h" />
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtframebuffer_c.h" />
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h" />
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtrenderer.h" />
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -366,24 +364,12 @@
|
|||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtframebuffer.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtrenderer.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
|
|
|
@ -333,15 +333,9 @@
|
|||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtframebuffer_c.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtrenderer.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
|
@ -593,15 +587,9 @@
|
|||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtevents.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtframebuffer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtrenderer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
@ -151,14 +151,6 @@
|
|||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtframebuffer.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
|
@ -167,14 +159,6 @@
|
|||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtrenderer.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
|
@ -293,9 +277,7 @@
|
|||
<ClInclude Include="..\..\src\video\windowsrt\SDLmain_WinRT_common.h" />
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_WinRTApp.h" />
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h" />
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtframebuffer_c.h" />
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h" />
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtrenderer.h" />
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -234,15 +234,9 @@
|
|||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtevents.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtframebuffer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtrenderer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -356,9 +350,6 @@
|
|||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtframebuffer_c.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
|
@ -578,9 +569,6 @@
|
|||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtrenderer.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "SDLmain_WinRT_common.h"
|
||||
#include "SDL_WinRTApp.h"
|
||||
#include "ppltasks.h"
|
||||
|
||||
extern "C" {
|
||||
#include "SDL_assert.h"
|
||||
|
@ -47,8 +48,7 @@ SDL_WinRTApp::SDL_WinRTApp() :
|
|||
m_windowClosed(false),
|
||||
m_windowVisible(true),
|
||||
m_sdlWindowData(NULL),
|
||||
m_useRelativeMouseMode(false),
|
||||
m_renderer(nullptr)
|
||||
m_useRelativeMouseMode(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,6 @@ void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
|
|||
|
||||
CoreApplication::Resuming +=
|
||||
ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnResuming);
|
||||
|
||||
m_renderer = ref new SDL_winrtrenderer();
|
||||
}
|
||||
|
||||
void SDL_WinRTApp::SetWindow(CoreWindow^ window)
|
||||
|
@ -136,15 +134,6 @@ void SDL_WinRTApp::PumpEvents()
|
|||
}
|
||||
}
|
||||
|
||||
void SDL_WinRTApp::UpdateWindowFramebuffer(SDL_Surface * surface, SDL_Rect * rects, int numrects)
|
||||
{
|
||||
if (!m_windowClosed && m_windowVisible)
|
||||
{
|
||||
m_renderer->Render(surface, rects, numrects);
|
||||
m_renderer->Present(); // This call is synchronized to the display frame rate.
|
||||
}
|
||||
}
|
||||
|
||||
void SDL_WinRTApp::Uninitialize()
|
||||
{
|
||||
}
|
||||
|
@ -649,11 +638,6 @@ void SDL_WinRTApp::SetSDLWindowData(const SDL_WindowData* windowData)
|
|||
m_sdlWindowData = windowData;
|
||||
}
|
||||
|
||||
void SDL_WinRTApp::ResizeMainTexture(int w, int h)
|
||||
{
|
||||
m_renderer->ResizeMainTexture(w, h);
|
||||
}
|
||||
|
||||
IFrameworkView^ Direct3DApplicationSource::CreateView()
|
||||
{
|
||||
// TODO, WinRT: see if this function (CreateView) can ever get called
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "SDLmain_WinRT_common.h"
|
||||
#include "SDL_winrtvideo.h"
|
||||
#include "SDL_winrtrenderer.h"
|
||||
#include <vector>
|
||||
|
||||
using namespace Windows::UI::Core;
|
||||
|
@ -27,8 +26,6 @@ internal:
|
|||
bool HasSDLWindowData() const;
|
||||
void SetRelativeMouseMode(bool enable);
|
||||
void SetSDLWindowData(const SDL_WindowData * windowData);
|
||||
void UpdateWindowFramebuffer(SDL_Surface * surface, SDL_Rect * rects, int numrects);
|
||||
void ResizeMainTexture(int w, int h);
|
||||
Windows::Foundation::Point TransformCursor(Windows::Foundation::Point rawPosition);
|
||||
|
||||
protected:
|
||||
|
@ -47,9 +44,6 @@ protected:
|
|||
void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
|
||||
void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
|
||||
|
||||
internal:
|
||||
SDL_winrtrenderer^ m_renderer;
|
||||
|
||||
private:
|
||||
bool m_windowClosed;
|
||||
bool m_windowVisible;
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 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_DRIVER_WINRT
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "SDL_winrtframebuffer_c.h"
|
||||
#include "SDL_WinRTApp.h"
|
||||
|
||||
extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
|
||||
|
||||
|
||||
#define WINRT_SURFACE "_SDL_WinRTSurface"
|
||||
|
||||
int SDL_WINRT_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
const Uint32 surface_format = SDL_PIXELFORMAT_RGB888;
|
||||
int w, h;
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
/* Free the old framebuffer surface */
|
||||
surface = (SDL_Surface *) SDL_GetWindowData(window, WINRT_SURFACE);
|
||||
if (surface) {
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
|
||||
/* Create a new one */
|
||||
SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Save info on the surface */
|
||||
SDL_SetWindowData(window, WINRT_SURFACE, surface);
|
||||
*format = surface_format;
|
||||
*pixels = surface->pixels;
|
||||
*pitch = surface->pitch;
|
||||
|
||||
/* Make sure a Direct3D texture exists to draw the surface onto */
|
||||
SDL_WinRTGlobalApp->ResizeMainTexture(surface->w, surface->h);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_WINRT_UpdateWindowFramebuffer(_THIS, SDL_Window * window, SDL_Rect * rects, int numrects)
|
||||
{
|
||||
static int frame_number;
|
||||
SDL_Surface *surface;
|
||||
|
||||
surface = (SDL_Surface *) SDL_GetWindowData(window, WINRT_SURFACE);
|
||||
if (!surface) {
|
||||
SDL_SetError("Couldn't find WinRT surface for window");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Send the data to the display */
|
||||
if (SDL_getenv("SDL_VIDEO_WINRT_SAVE_FRAMES")) {
|
||||
char file[128];
|
||||
SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
|
||||
SDL_GetWindowID(window), ++frame_number);
|
||||
SDL_SaveBMP(surface, file);
|
||||
}
|
||||
|
||||
SDL_WinRTGlobalApp->UpdateWindowFramebuffer(surface, rects, numrects);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_WINRT_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
|
||||
surface = (SDL_Surface *) SDL_SetWindowData(window, WINRT_SURFACE, NULL);
|
||||
if (surface) {
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINRT */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 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"
|
||||
|
||||
extern int SDL_WINRT_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
|
||||
extern int SDL_WINRT_UpdateWindowFramebuffer(_THIS, SDL_Window * window, SDL_Rect * rects, int numrects);
|
||||
extern void SDL_WINRT_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -1,87 +0,0 @@
|
|||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "SDLmain_WinRT_common.h"
|
||||
#include "SDL_winrtrenderer.h"
|
||||
|
||||
extern "C" {
|
||||
#include "SDL_syswm.h"
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
}
|
||||
|
||||
using namespace DirectX;
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace std;
|
||||
using namespace Windows::UI::Core;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::Graphics::Display;
|
||||
|
||||
// Constructor.
|
||||
SDL_winrtrenderer::SDL_winrtrenderer() :
|
||||
m_sdlRenderer(NULL),
|
||||
m_sdlRendererData(NULL),
|
||||
m_mainTexture(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
SDL_winrtrenderer::~SDL_winrtrenderer()
|
||||
{
|
||||
if (m_mainTexture) {
|
||||
SDL_DestroyTexture(m_mainTexture);
|
||||
m_mainTexture = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void SDL_winrtrenderer::ResizeMainTexture(int w, int h)
|
||||
{
|
||||
if (m_mainTexture) {
|
||||
SDL_DestroyTexture(m_mainTexture);
|
||||
m_mainTexture = NULL;
|
||||
}
|
||||
|
||||
m_mainTexture = SDL_CreateTexture(m_sdlRenderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, w, h);
|
||||
}
|
||||
|
||||
static inline Platform::Exception ^
|
||||
WINRT_CreateExceptionWithSDLError()
|
||||
{
|
||||
wchar_t * sdlErrorMessage = WIN_UTF8ToString(SDL_GetError());
|
||||
Platform::String ^ errorMessage = ref new Platform::String(sdlErrorMessage);
|
||||
SDL_free(sdlErrorMessage);
|
||||
throw ref new Platform::FailureException(errorMessage);
|
||||
}
|
||||
|
||||
void SDL_winrtrenderer::Render(SDL_Surface * surface, SDL_Rect * rects, int numrects)
|
||||
{
|
||||
D3D11_TextureData * textureData = (D3D11_TextureData *)m_mainTexture->driverdata;
|
||||
|
||||
SDL_SetRenderDrawColor(m_sdlRenderer, 0, 0, 0, 0);
|
||||
if (SDL_RenderClear(m_sdlRenderer) != 0) {
|
||||
throw WINRT_CreateExceptionWithSDLError();
|
||||
}
|
||||
|
||||
// Only draw the screen once it is loaded (some loading is asynchronous).
|
||||
if (!m_sdlRendererData->loadingComplete) {
|
||||
return;
|
||||
}
|
||||
if (!textureData->mainTextureResourceView) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the main texture (for SDL usage).
|
||||
// TODO, WinRT: only update the requested rects (passed to SDL_UpdateWindowSurface), rather than everything
|
||||
if (SDL_UpdateTexture(m_mainTexture, NULL, surface->pixels, surface->pitch) != 0) {
|
||||
throw WINRT_CreateExceptionWithSDLError();
|
||||
}
|
||||
|
||||
if (SDL_RenderCopy(m_sdlRenderer, m_mainTexture, NULL, NULL) != 0) {
|
||||
throw WINRT_CreateExceptionWithSDLError();
|
||||
}
|
||||
}
|
||||
|
||||
// Method to deliver the final image to the display.
|
||||
void SDL_winrtrenderer::Present()
|
||||
{
|
||||
SDL_RenderPresent(m_sdlRenderer);
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "DirectXHelper.h"
|
||||
#include "../../render/direct3d11/SDL_render_d3d11_cpp.h"
|
||||
|
||||
extern "C" {
|
||||
#include "SDL.h"
|
||||
#include "../../render/SDL_sysrender.h"
|
||||
}
|
||||
|
||||
// Helper class that initializes DirectX APIs for 3D rendering.
|
||||
ref class SDL_winrtrenderer
|
||||
{
|
||||
internal:
|
||||
SDL_winrtrenderer();
|
||||
|
||||
public:
|
||||
virtual ~SDL_winrtrenderer();
|
||||
virtual void Present();
|
||||
|
||||
internal:
|
||||
virtual void Render(SDL_Surface * surface, SDL_Rect * rects, int numrects);
|
||||
void ResizeMainTexture(int w, int h);
|
||||
|
||||
internal:
|
||||
// Internal SDL renderer (likely a temporary addition, for refactoring purposes):
|
||||
SDL_Renderer * m_sdlRenderer;
|
||||
D3D11_RenderData * m_sdlRendererData;
|
||||
|
||||
protected private:
|
||||
// UpdateWindowSurface helper objects
|
||||
SDL_Texture * m_mainTexture;
|
||||
};
|
|
@ -41,7 +41,6 @@ extern "C" {
|
|||
#include "SDL_WinRTApp.h"
|
||||
#include "SDL_winrtvideo.h"
|
||||
#include "SDL_winrtevents_c.h"
|
||||
#include "SDL_winrtframebuffer_c.h"
|
||||
#include "SDL_winrtmouse.h"
|
||||
|
||||
/* On Windows, windows.h defines CreateWindow */
|
||||
|
@ -100,9 +99,9 @@ WINRT_CreateDevice(int devindex)
|
|||
device->DestroyWindow = WINRT_DestroyWindow;
|
||||
device->SetDisplayMode = WINRT_SetDisplayMode;
|
||||
device->PumpEvents = WINRT_PumpEvents;
|
||||
device->CreateWindowFramebuffer = SDL_WINRT_CreateWindowFramebuffer;
|
||||
device->UpdateWindowFramebuffer = SDL_WINRT_UpdateWindowFramebuffer;
|
||||
device->DestroyWindowFramebuffer = SDL_WINRT_DestroyWindowFramebuffer;
|
||||
//device->CreateWindowFramebuffer = SDL_WINRT_CreateWindowFramebuffer;
|
||||
//device->UpdateWindowFramebuffer = SDL_WINRT_UpdateWindowFramebuffer;
|
||||
//device->DestroyWindowFramebuffer = SDL_WINRT_DestroyWindowFramebuffer;
|
||||
device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
|
||||
|
||||
device->free = WINRT_DeleteDevice;
|
||||
|
@ -167,6 +166,7 @@ WINRT_CreateWindow(_THIS, SDL_Window * window)
|
|||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
window->driverdata = data;
|
||||
data->sdlWindow = window;
|
||||
data->coreWindow = new CoreWindow^(CoreWindow::GetForCurrentThread());
|
||||
|
||||
|
@ -213,27 +213,6 @@ WINRT_CreateWindow(_THIS, SDL_Window * window)
|
|||
*/
|
||||
SDL_WinRTGlobalApp->SetSDLWindowData(data);
|
||||
|
||||
/* For now, create a Direct3D 11 renderer up-front. Eventually, this
|
||||
won't be done in WINRT_CreateWindow, although it may get done in
|
||||
SDL_WINRT_CreateWindowFramebuffer.
|
||||
*/
|
||||
|
||||
// Link SDL_winrtrenderer to the SDL_Renderer temporarily,
|
||||
// for refactoring purposes. Initialize the SDL_Renderer
|
||||
// first in order to give it the opportunity to create key
|
||||
// resources first.
|
||||
//
|
||||
// TODO, WinRT: either make WINRT_CreateWindow not call SDL_CreateRenderer, or have it do error checking if it does call it
|
||||
|
||||
// HACK: make sure the SDL window references SDL_WindowData data now, in
|
||||
// order to allow the SDL_Renderer to be created in WINRT_CreateWindow
|
||||
window->driverdata = data;
|
||||
|
||||
SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE);
|
||||
SDL_WinRTGlobalApp->m_renderer->m_sdlRenderer = renderer;
|
||||
SDL_WinRTGlobalApp->m_renderer->m_sdlRendererData = (D3D11_RenderData *) renderer->driverdata;
|
||||
//SDL_WinRTGlobalApp->m_renderer->Initialize();
|
||||
|
||||
/* All done! */
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue