Browse Source

Merge branch 'master' into compatibility

Vladimír Vondruš 14 years ago
parent
commit
26eb19458d
  1. 2
      PKGBUILD-nacl
  2. 7
      src/DebugMarker.cpp
  3. 46
      src/Platform/NaClApplication.cpp
  4. 20
      src/Platform/NaClApplication.h

2
PKGBUILD-nacl

@ -8,7 +8,7 @@ url="https://github.com/mosra/magnum"
license=('LGPLv3') license=('LGPLv3')
depends=('nacl-corrade') depends=('nacl-corrade')
makedepends=('nacl-sdk' 'cmake') makedepends=('nacl-sdk' 'cmake')
options=(!makeflags !buildflags !strip) options=(!buildflags !strip)
build() { build() {
# Build 32bit # Build 32bit

7
src/DebugMarker.cpp

@ -25,11 +25,16 @@ namespace Magnum {
DebugMarker::MarkImplementation DebugMarker::markImplementation = &DebugMarker::markImplementationDefault; DebugMarker::MarkImplementation DebugMarker::markImplementation = &DebugMarker::markImplementationDefault;
void DebugMarker::initializeContextBasedFunctionality(Context* context) { void DebugMarker::initializeContextBasedFunctionality(Context* context) {
/** @todo Re-enable when extension wrangler is available for ES */
#ifndef MAGNUM_TARGET_GLES
if(context->isExtensionSupported<Extensions::GL::GREMEDY::string_marker>()) { if(context->isExtensionSupported<Extensions::GL::GREMEDY::string_marker>()) {
Debug() << "DebugMarker: using" << Extensions::GL::GREMEDY::string_marker::string() << "features"; Debug() << "DebugMarker: using" << Extensions::GL::GREMEDY::string_marker::string() << "features";
markImplementation = &DebugMarker::markImplementationDebugger; markImplementation = &DebugMarker::markImplementationDebugger;
} }
#else
static_cast<void>(context);
#endif
} }
void DebugMarker::markImplementationDefault(const std::string&) {} void DebugMarker::markImplementationDefault(const std::string&) {}
@ -41,6 +46,8 @@ void DebugMarker::markImplementationDebugger(const std::string& string) {
#else #else
#if 0 #if 0
glInsertEventMarkerEXT(string.length(), string.c_str()); glInsertEventMarkerEXT(string.length(), string.c_str());
#else
static_cast<void>(string);
#endif #endif
#endif #endif
} }

46
src/Platform/NaClApplication.cpp

@ -16,8 +16,8 @@
#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 <ppapi/lib/gl/gles2/gl2ext_ppapi.h>
#include "Context.h" #include "Context.h"
@ -45,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;
@ -52,14 +54,51 @@ NaClApplication::NaClApplication(PP_Instance instance, const Math::Vector2<GLsiz
/* Enable input handling for mouse and keyboard */ /* Enable input handling for mouse and keyboard */
RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE|PP_INPUTEVENT_CLASS_WHEEL); RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE|PP_INPUTEVENT_CLASS_WHEEL);
RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD);
/* Make sure viewportEvent() is called for first time */
flags |= Flag::ViewportUpdated;
} }
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 */
@ -70,7 +109,7 @@ void NaClApplication::DidChangeView(const pp::View& view) {
} }
/* Update viewport, if changed */ /* Update viewport, if changed */
if(!(flags & Flag::ViewportUpdated)) { if(flags & Flag::ViewportUpdated) {
flags &= ~Flag::ViewportUpdated; flags &= ~Flag::ViewportUpdated;
viewportEvent(size); viewportEvent(size);
} }
@ -79,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()) {

20
src/Platform/NaClApplication.h

@ -23,7 +23,6 @@
#include <Containers/EnumSet.h> #include <Containers/EnumSet.h>
#include <ppapi/cpp/input_event.h> #include <ppapi/cpp/input_event.h>
#include <ppapi/cpp/instance.h> #include <ppapi/cpp/instance.h>
#include <ppapi/cpp/instance_handle.h>
#include <ppapi/cpp/module.h> #include <ppapi/cpp/module.h>
#include <ppapi/cpp/graphics_3d_client.h> #include <ppapi/cpp/graphics_3d_client.h>
#include <ppapi/gles2/gl2ext_ppapi.h> #include <ppapi/gles2/gl2ext_ppapi.h>
@ -35,6 +34,7 @@
namespace pp { namespace pp {
class Graphics3D; class Graphics3D;
class Fullscreen;
} }
namespace Magnum { namespace Magnum {
@ -79,6 +79,19 @@ class NaClApplication: public pp::Instance, public pp::Graphics3DClient {
~NaClApplication(); ~NaClApplication();
/** @brief Whether the application runs fullscreen */
bool isFullscreen();
/**
* @brief Set fullscreen
* @return `False` if switch to opposite mode is in progress or if the
* switch is not possible, `true` otherwise.
*
* The switch is done asynchronously, during the switch no event
* processing is done.
*/
bool setFullscreen(bool enabled);
protected: protected:
/** @{ @name Drawing functions */ /** @{ @name Drawing functions */
@ -154,7 +167,9 @@ class NaClApplication: public pp::Instance, public pp::Graphics3DClient {
enum class Flag: std::uint8_t { enum class Flag: std::uint8_t {
ViewportUpdated = 1 << 0, ViewportUpdated = 1 << 0,
SwapInProgress = 1 << 1, SwapInProgress = 1 << 1,
Redraw = 1 << 2 Redraw = 1 << 2,
FullscreenSwitchInProgress = 1 << 3,
WillBeFullscreen = 1 << 4
}; };
typedef Corrade::Containers::EnumSet<Flag, std::uint8_t> Flags; typedef Corrade::Containers::EnumSet<Flag, std::uint8_t> Flags;
@ -169,6 +184,7 @@ class NaClApplication: public pp::Instance, public pp::Graphics3DClient {
static void swapCallback(void* applicationInstance, std::int32_t); static void swapCallback(void* applicationInstance, std::int32_t);
pp::Graphics3D* graphics; pp::Graphics3D* graphics;
pp::Fullscreen* fullscreen;
Context* c; Context* c;
Math::Vector2<GLsizei> viewportSize; Math::Vector2<GLsizei> viewportSize;
Flags flags; Flags flags;

Loading…
Cancel
Save