Browse Source

Merge branch 'master' into compatibility

Vladimír Vondruš 13 years ago
parent
commit
f281e5fa89
  1. 20
      src/Platform/NaClApplication.cpp
  2. 19
      src/Platform/NaClApplication.h

20
src/Platform/NaClApplication.cpp

@ -27,16 +27,35 @@
#include <ppapi/cpp/graphics_3d.h>
#include <ppapi/cpp/fullscreen.h>
#include <ppapi/cpp/completion_callback.h>
#include <Utility/NaClStreamBuffer.h>
#include "Context.h"
namespace Magnum { namespace Platform {
struct NaClApplication::ConsoleDebugOutput {
explicit ConsoleDebugOutput(pp::Instance* instance);
Utility::NaClConsoleStreamBuffer debugBuffer, warningBuffer, errorBuffer;
std::ostream debugOutput, warningOutput, errorOutput;
};
NaClApplication::ConsoleDebugOutput::ConsoleDebugOutput(pp::Instance* instance): debugBuffer(instance, Utility::NaClConsoleStreamBuffer::LogLevel::Log), warningBuffer(instance, Utility::NaClConsoleStreamBuffer::LogLevel::Warning), errorBuffer(instance, Utility::NaClConsoleStreamBuffer::LogLevel::Error), debugOutput(&debugBuffer), warningOutput(&warningBuffer), errorOutput(&errorBuffer) {
/* Inform about this change on standard output */
Debug() << "Platform::NaClApplication: redirecting Debug, Warning and Error output to JavaScript console";
Debug::setOutput(&debugOutput);
Warning::setOutput(&warningOutput);
Error::setOutput(&errorOutput);
}
NaClApplication::NaClApplication(const Arguments& arguments): Instance(arguments), Graphics3DClient(this), MouseLock(this), c(nullptr) {
debugOutput = new ConsoleDebugOutput(this);
createContext(new Configuration);
}
NaClApplication::NaClApplication(const Arguments& arguments, Configuration* configuration): Instance(arguments), Graphics3DClient(this), MouseLock(this), graphics(nullptr), fullscreen(nullptr), c(nullptr) {
debugOutput = new ConsoleDebugOutput(this);
if(configuration) createContext(configuration);
}
@ -95,6 +114,7 @@ NaClApplication::~NaClApplication() {
delete c;
delete fullscreen;
delete graphics;
delete debugOutput;
}
bool NaClApplication::isFullscreen() {

19
src/Platform/NaClApplication.h

@ -61,7 +61,7 @@ You need to implement at least drawEvent() and viewportEvent() to be able to
draw on the screen. The subclass must be then registered to NaCl API using
MAGNUM_NACLAPPLICATION_MAIN() macro.
@code
class MyApplication: public Magnum::Platform::Sdl2Application {
class MyApplication: public Magnum::Platform::NaClApplication {
// implement required methods...
};
MAGNUM_NACLAPPLICATION_MAIN(MyApplication)
@ -70,6 +70,19 @@ MAGNUM_NACLAPPLICATION_MAIN(MyApplication)
If no other application header is included this class is also aliased to
`Platform::Application` and the macro is aliased to `MAGNUM_APPLICATION_MAIN()`
to simplify porting.
@section NaClApplication-html HTML markup and NMF file
You need to provide HTML markup containing `&lt;embed&gt;` pointing to `*.nmf`
file describing the application.
@todoc Document this better, add "bootstrap" examples
@subsection NaClApplication-html-console Redirecting output to Chrome's JavaScript console
The application redirects @ref Debug, @ref Warning and @ref Error output to
JavaScript console. See also @ref Corrade::Utility::NaClConsoleStreamBuffer for
more information.
*/
class NaClApplication: public pp::Instance, public pp::Graphics3DClient, public pp::MouseLock {
public:
@ -210,6 +223,8 @@ class NaClApplication: public pp::Instance, public pp::Graphics3DClient, public
/*@}*/
private:
struct ConsoleDebugOutput;
enum class Flag: UnsignedByte {
ViewportUpdated = 1 << 0,
SwapInProgress = 1 << 1,
@ -241,6 +256,8 @@ class NaClApplication: public pp::Instance, public pp::Graphics3DClient, public
Vector2i viewportSize;
Flags flags;
ConsoleDebugOutput* debugOutput;
CORRADE_ENUMSET_FRIEND_OPERATORS(Flags)
};

Loading…
Cancel
Save