diff --git a/index.html b/index.html index d52cdb2..49e92cf 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ - +
diff --git a/main.cpp b/main.cpp index 938f765..8631b7f 100644 --- a/main.cpp +++ b/main.cpp @@ -174,6 +174,9 @@ void MoonlightInstance::handleStartStream(std::string startStreamMessage) { m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_STEREO; m_ServerMajorVersion = 5; + + // Initialize the rendering surface before starting the connection + InitializeRenderingSurface(m_StreamConfig.width, m_StreamConfig.height); // Store the host from the start message m_Host = splitString.at(1); diff --git a/moonlight.hpp b/moonlight.hpp index b3f36af..e35fd98 100644 --- a/moonlight.hpp +++ b/moonlight.hpp @@ -76,9 +76,6 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock { void OnConnectionStarted(uint32_t error); void StopConnection(); - void DidChangeView(const pp::Rect& position, - const pp::Rect& clip_ignored); - static void* ConnectionThreadFunc(void* context); static void* GamepadThreadFunc(void* context); static void* StopThreadFunc(void* context); @@ -97,6 +94,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock { void DispatchGetPicture(uint32_t unused); void PictureReady(int32_t result, PP_VideoPicture picture); void PaintPicture(void); + void InitializeRenderingSurface(int width, int height); static void VidDecSetup(int width, int height, int redrawRate, void* context, int drFlags); static void VidDecCleanup(void); @@ -121,7 +119,6 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock { pp::Graphics3D m_Graphics3D; pp::VideoDecoder* m_VideoDecoder; - pp::Size m_ViewSize; Shader m_Texture2DShader; Shader m_RectangleArbShader; Shader m_ExternalOesShader; diff --git a/viddec.cpp b/viddec.cpp index 9e638c5..f5d94d7 100644 --- a/viddec.cpp +++ b/viddec.cpp @@ -70,20 +70,7 @@ void MoonlightInstance::DidChangeFocus(bool got_focus) { } } -void MoonlightInstance::DidChangeView(const pp::Rect& position, - const pp::Rect& clip) { - - if (position.width() == 0 || position.height() == 0) { - return; - } - if (m_ViewSize.width()) { - assert(position.size() == m_ViewSize); - return; - } - - m_ViewSize = position.size(); - printf("View size: %dx%d\n", m_ViewSize.width(), m_ViewSize.height()); - +void MoonlightInstance::InitializeRenderingSurface(int width, int height) { if (!glInitializePPAPI(pp::Module::Get()->get_browser_interface())) { return; } @@ -97,8 +84,8 @@ void MoonlightInstance::DidChangeView(const pp::Rect& position, PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 0, PP_GRAPHICS3DATTRIB_SAMPLES, 0, PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0, - PP_GRAPHICS3DATTRIB_WIDTH, position.size().width(), - PP_GRAPHICS3DATTRIB_HEIGHT, position.size().height(), + PP_GRAPHICS3DATTRIB_WIDTH, width, + PP_GRAPHICS3DATTRIB_HEIGHT, height, PP_GRAPHICS3DATTRIB_NONE }; g_Instance->m_Graphics3D = pp::Graphics3D(this, contextAttributes); @@ -114,7 +101,7 @@ void MoonlightInstance::DidChangeView(const pp::Rect& position, glDisable(GL_DITHER); - glViewport(0, 0, m_ViewSize.width(), m_ViewSize.height()); + glViewport(0, 0, width, height); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT);