|
|
|
@ -36,12 +36,21 @@ NaClApplication::NaClApplication(const Arguments& arguments): Instance(arguments |
|
|
|
createContext(new Configuration); |
|
|
|
createContext(new Configuration); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
NaClApplication::NaClApplication(const Arguments& arguments, Configuration* configuration): Instance(arguments), Graphics3DClient(this), MouseLock(this), c(nullptr) { |
|
|
|
NaClApplication::NaClApplication(const Arguments& arguments, Configuration* configuration): Instance(arguments), Graphics3DClient(this), MouseLock(this), graphics(nullptr), fullscreen(nullptr), c(nullptr) { |
|
|
|
if(configuration) createContext(configuration); |
|
|
|
if(configuration) createContext(configuration); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NaClApplication::createContext(NaClApplication::Configuration* configuration) { |
|
|
|
void NaClApplication::createContext(Configuration* configuration) { |
|
|
|
CORRADE_ASSERT(!c, "NaClApplication::createContext(): context already created", ); |
|
|
|
if(!tryCreateContext(configuration)) { |
|
|
|
|
|
|
|
Error() << "Platform::NaClApplication::createContext(): cannot create context"; |
|
|
|
|
|
|
|
delete configuration; |
|
|
|
|
|
|
|
std::exit(1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else delete configuration; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool NaClApplication::tryCreateContext(Configuration* configuration) { |
|
|
|
|
|
|
|
CORRADE_ASSERT(!c, "Platform::NaClApplication::tryCreateContext(): context already created", false); |
|
|
|
|
|
|
|
|
|
|
|
viewportSize = configuration->size(); |
|
|
|
viewportSize = configuration->size(); |
|
|
|
|
|
|
|
|
|
|
|
@ -58,11 +67,12 @@ void NaClApplication::createContext(NaClApplication::Configuration* configuratio |
|
|
|
|
|
|
|
|
|
|
|
graphics = new pp::Graphics3D(this, attributes); |
|
|
|
graphics = new pp::Graphics3D(this, attributes); |
|
|
|
if(graphics->is_null()) { |
|
|
|
if(graphics->is_null()) { |
|
|
|
Error() << "Platform::NaClApplication::NaClApplication(): cannot create graphics"; |
|
|
|
delete graphics; |
|
|
|
std::exit(1); |
|
|
|
graphics = nullptr; |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
if(!BindGraphics(*graphics)) { |
|
|
|
if(!BindGraphics(*graphics)) { |
|
|
|
Error() << "Platform::NaClApplication::NaClApplication(): cannot bind graphics"; |
|
|
|
Error() << "Platform::NaClApplication::tryCreateContext(): cannot bind graphics"; |
|
|
|
std::exit(1); |
|
|
|
std::exit(1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -70,8 +80,6 @@ void NaClApplication::createContext(NaClApplication::Configuration* configuratio |
|
|
|
|
|
|
|
|
|
|
|
glSetCurrentContextPPAPI(graphics->pp_resource()); |
|
|
|
glSetCurrentContextPPAPI(graphics->pp_resource()); |
|
|
|
|
|
|
|
|
|
|
|
c = new Context; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 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); |
|
|
|
@ -79,7 +87,8 @@ void NaClApplication::createContext(NaClApplication::Configuration* configuratio |
|
|
|
/* Make sure viewportEvent() is called for first time */ |
|
|
|
/* Make sure viewportEvent() is called for first time */ |
|
|
|
flags |= Flag::ViewportUpdated; |
|
|
|
flags |= Flag::ViewportUpdated; |
|
|
|
|
|
|
|
|
|
|
|
delete configuration; |
|
|
|
c = new Context; |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
NaClApplication::~NaClApplication() { |
|
|
|
NaClApplication::~NaClApplication() { |
|
|
|
|