|
|
|
@ -16,6 +16,7 @@ |
|
|
|
#include "NaClApplication.h" |
|
|
|
#include "NaClApplication.h" |
|
|
|
|
|
|
|
|
|
|
|
#include <ppapi/cpp/graphics_3d.h> |
|
|
|
#include <ppapi/cpp/graphics_3d.h> |
|
|
|
|
|
|
|
#include <ppapi/cpp/fullscreen.h> |
|
|
|
#include <ppapi/cpp/completion_callback.h> |
|
|
|
#include <ppapi/cpp/completion_callback.h> |
|
|
|
|
|
|
|
|
|
|
|
#include "Context.h" |
|
|
|
#include "Context.h" |
|
|
|
@ -44,6 +45,8 @@ NaClApplication::NaClApplication(PP_Instance instance, const Math::Vector2<GLsiz |
|
|
|
exit(1); |
|
|
|
exit(1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fullscreen = new pp::Fullscreen(this); |
|
|
|
|
|
|
|
|
|
|
|
glSetCurrentContextPPAPI(graphics->pp_resource()); |
|
|
|
glSetCurrentContextPPAPI(graphics->pp_resource()); |
|
|
|
|
|
|
|
|
|
|
|
c = new Context; |
|
|
|
c = new Context; |
|
|
|
@ -58,10 +61,44 @@ NaClApplication::NaClApplication(PP_Instance instance, const Math::Vector2<GLsiz |
|
|
|
|
|
|
|
|
|
|
|
NaClApplication::~NaClApplication() { |
|
|
|
NaClApplication::~NaClApplication() { |
|
|
|
delete c; |
|
|
|
delete c; |
|
|
|
|
|
|
|
delete fullscreen; |
|
|
|
delete graphics; |
|
|
|
delete graphics; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool NaClApplication::isFullscreen() { |
|
|
|
|
|
|
|
return fullscreen->IsFullscreen(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool NaClApplication::setFullscreen(bool enabled) { |
|
|
|
|
|
|
|
/* Given fullscreen mode already set or switching to it is in progress, done */ |
|
|
|
|
|
|
|
if(isFullscreen() == enabled || ((flags & Flag::FullscreenSwitchInProgress) && (flags & Flag::WillBeFullscreen) == enabled)) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Switch to opposite fullscreen mode is in progress, can't revert it back */ |
|
|
|
|
|
|
|
if((flags & Flag::FullscreenSwitchInProgress) && (flags & Flag::WillBeFullscreen) != enabled) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Set fullscreen */ |
|
|
|
|
|
|
|
if(!fullscreen->SetFullscreen(enabled)) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Set flags */ |
|
|
|
|
|
|
|
flags |= Flag::FullscreenSwitchInProgress; |
|
|
|
|
|
|
|
enabled ? flags |= Flag::WillBeFullscreen : flags &= ~Flag::WillBeFullscreen; |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NaClApplication::DidChangeView(const pp::View& view) { |
|
|
|
void NaClApplication::DidChangeView(const pp::View& view) { |
|
|
|
|
|
|
|
/* Fullscreen switch in progress */ |
|
|
|
|
|
|
|
if(flags & Flag::FullscreenSwitchInProgress) { |
|
|
|
|
|
|
|
/* Done, remove the progress flag */ |
|
|
|
|
|
|
|
if(isFullscreen() == bool(flags & Flag::WillBeFullscreen)) |
|
|
|
|
|
|
|
flags &= ~Flag::FullscreenSwitchInProgress; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Don't process anything during the switch */ |
|
|
|
|
|
|
|
else return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Math::Vector2<GLsizei> size(view.GetRect().width(), view.GetRect().height()); |
|
|
|
Math::Vector2<GLsizei> size(view.GetRect().width(), view.GetRect().height()); |
|
|
|
|
|
|
|
|
|
|
|
/* Canvas resized */ |
|
|
|
/* Canvas resized */ |
|
|
|
@ -81,6 +118,9 @@ void NaClApplication::DidChangeView(const pp::View& view) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool NaClApplication::HandleInputEvent(const pp::InputEvent& event) { |
|
|
|
bool NaClApplication::HandleInputEvent(const pp::InputEvent& event) { |
|
|
|
|
|
|
|
/* Don't handle anything during switch from/to fullscreen */ |
|
|
|
|
|
|
|
if(flags & Flag::FullscreenSwitchInProgress) return false; |
|
|
|
|
|
|
|
|
|
|
|
Flags tmpFlags = flags; |
|
|
|
Flags tmpFlags = flags; |
|
|
|
|
|
|
|
|
|
|
|
switch(event.GetType()) { |
|
|
|
switch(event.GetType()) { |
|
|
|
|