diff --git a/platform/nacl/SCsub b/platform/nacl/SCsub deleted file mode 100644 index ac01752dbb8..00000000000 --- a/platform/nacl/SCsub +++ /dev/null @@ -1,30 +0,0 @@ -Import('env') - -nacl_lib = [ - - 'os_nacl.cpp', - 'audio_driver_nacl.cpp', - 'godot_nacl.cpp', - #'pepper_main.cpp', - 'opengl_context.cpp', - 'godot_module.cpp', - 'geturl_handler.cpp', -] - -nacl_posix = [ - - '#drivers/unix/thread_posix.cpp', - '#drivers/unix/mutex_posix.cpp', - '#drivers/unix/semaphore_posix.cpp', -] - -posix_lib = [] -for f in nacl_posix: - posix_lib.append(env.Object(f, CPPFLAGS = env['CPPFLAGS']+['-DUNIX_ENABLED'], OBJSUFFIX = '.posix'+env['OBJSUFFIX'])) - -prog = env.Program('#bin/godot_nacl', nacl_lib + posix_lib) - -if (env['nacl_arch'] == 'i686'): - env.Alias("nacl_32", prog) -if (env['nacl_arch'] == 'x86_64'): - env.Alias("nacl_64", prog) diff --git a/platform/nacl/audio_driver_nacl.cpp b/platform/nacl/audio_driver_nacl.cpp deleted file mode 100644 index dac95214874..00000000000 --- a/platform/nacl/audio_driver_nacl.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/*************************************************************************/ -/* audio_driver_nacl.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "audio_driver_nacl.h" - -#include "ppapi/cpp/instance.h" - -extern pp::Instance* godot_instance; - -const char* AudioDriverNacl::get_name() const { - - return "Nacl"; -} - -void AudioDriverNacl::output_callback(void* samples, uint32_t buffer_size, void* data) { - - AudioDriverNacl* ad = (AudioDriverNacl*)data; - int16_t* out = (int16_t*)samples; - - ad->lock(); - ad->audio_server_process(ad->sample_frame_count_, ad->samples_in); - ad->unlock(); - - for (int i=0; isample_count; i++) { - - out[i] = ad->samples_in[i]>>16; - }; - -}; - -Error AudioDriverNacl::init(){ - - int frame_size = 4096; - sample_frame_count_ = pp::AudioConfig::RecommendSampleFrameCount(godot_instance,PP_AUDIOSAMPLERATE_44100, frame_size); - sample_count = sample_frame_count_ * 2; - - audio_ = pp::Audio(godot_instance, - pp::AudioConfig(godot_instance, - PP_AUDIOSAMPLERATE_44100, - sample_frame_count_), - &AudioDriverNacl::output_callback, - this); - - samples_in = memnew_arr(int32_t, sample_frame_count_ * 2); - - return OK; -} -void AudioDriverNacl::start(){ - - audio_.StartPlayback(); -} -int AudioDriverNacl::get_mix_rate() const { - - return 44100; -} -AudioDriverSW::OutputFormat AudioDriverNacl::get_output_format() const{ - - return OUTPUT_STEREO; -} -void AudioDriverNacl::lock(){ - -} -void AudioDriverNacl::unlock() { - - -} -void AudioDriverNacl::finish(){ - - audio_.StopPlayback(); -} - - -AudioDriverNacl::AudioDriverNacl() { -} - -AudioDriverNacl::~AudioDriverNacl() { - - memdelete_arr(samples_in); -} - - diff --git a/platform/nacl/audio_driver_nacl.h b/platform/nacl/audio_driver_nacl.h deleted file mode 100644 index d14e60717a9..00000000000 --- a/platform/nacl/audio_driver_nacl.h +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************/ -/* audio_driver_nacl.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef AUDIO_DRIVER_NACL_H -#define AUDIO_DRIVER_NACL_H - -#include "servers/audio/audio_server_sw.h" - -#include "ppapi/cpp/audio.h" - -class AudioDriverNacl : public AudioDriverSW { - - static void output_callback(void* samples, uint32_t buffer_size, void* data); - - int32_t* samples_in; - int sample_frame_count_; - int sample_count; - pp::Audio audio_; - -public: - - virtual const char* get_name() const; - - virtual Error init(); - virtual void start(); - virtual int get_mix_rate() const ; - virtual OutputFormat get_output_format() const; - virtual void lock(); - virtual void unlock(); - virtual void finish(); - - - AudioDriverNacl(); - ~AudioDriverNacl(); -}; - -#endif // AUDIO_DRIVER_NACL_H - diff --git a/platform/nacl/context_gl_nacl.cpp b/platform/nacl/context_gl_nacl.cpp deleted file mode 100644 index ce2f25b69f2..00000000000 --- a/platform/nacl/context_gl_nacl.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************/ -/* context_gl_nacl.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "context_gl_nacl.h" - -#include -#include -#include -#include -#include -#include - -void ContextGLNacl::make_current() { - -}; - -int ContextGLNacl::get_window_width() { - -}; - -int ContextGLNacl::get_window_height() { - -}; - -void ContextGLNacl::swap_buffers() { - -}; - -Error ContextGLNacl::initialize() { - -}; - - -ContextGLNacl::ContextGLNacl() { - - -}; - -ContextGLNacl::~ContextGLNacl() { - -}; - diff --git a/platform/nacl/context_gl_nacl.h b/platform/nacl/context_gl_nacl.h deleted file mode 100644 index 82b9ba07755..00000000000 --- a/platform/nacl/context_gl_nacl.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************/ -/* context_gl_nacl.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef CONTEXT_GL_NACL_H -#define CONTEXT_GL_NACL_H - -#include "drivers/gl_context/context_gl.h" - -class NPDevice; - -class ContextGLNacl : public ContextGL { - - enum { - COMMAND_BUFFER_SIZE = 1024 * 1024, - }; - - NPDevice* device3d_; - -public: - - virtual void make_current(); - - virtual int get_window_width(); - virtual int get_window_height(); - virtual void swap_buffers(); - - virtual Error initialize(); - - ContextGLNacl(); - ~ContextGLNacl(); -}; - -#endif // CONTEXT_GL_NACL_H diff --git a/platform/nacl/detect.py b/platform/nacl/detect.py deleted file mode 100644 index eedb29746a8..00000000000 --- a/platform/nacl/detect.py +++ /dev/null @@ -1,71 +0,0 @@ -import os -import sys - -def is_active(): - return True - -def get_name(): - return "NaCl" - -def can_build(): - - import os - if not os.environ.has_key("NACLPATH"): - return False - return True - -def get_opts(): - - return [ - ('NACLPATH', 'the path to nacl', os.environ.get("NACLPATH", 0)), - ('nacl_arch', 'The architecture for Nacl build (can be i686 or x86_64', 'i686'), - ] - -def get_flags(): - - return [ - ('nedmalloc', 'no'), - ('tools', 'no'), - ] - - - -def configure(env): - - env.Append(CPPPATH=['#platform/nacl']) - - env['OBJSUFFIX'] = ".nacl.${nacl_arch}.o" - env['LIBSUFFIX'] = ".nacl.${nacl_arch}.a" - env['PROGSUFFIX'] = ".${nacl_arch}.nexe" - - env['ENV']['PATH'] = env['ENV']['PATH']+":"+env['NACLPATH']+"/toolchain/linux_x86_newlib/bin" - - env['CC'] = '${nacl_arch}-nacl-gcc' - env['CXX'] = '${nacl_arch}-nacl-g++' - env['AR'] = '${nacl_arch}-nacl-ar' - - env.Append(CCFLAGS=['-fexceptions', '-Wno-long-long', '-pthread', '-DXP_UNIX']) - - env.Append(CPPPATH=env['NACLPATH']) - - if (env["target"]=="release"): - - env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer', '-ffunction-sections', '-fdata-sections', '-fno-default-inline']) - - elif (env["target"]=="debug"): - - env.Append(CCFLAGS=['-g', '-O0', '-Wall','-DDEBUG_ENABLED']) - - - elif (env["target"]=="profile"): - - env.Append(CCFLAGS=['-g','-pg']) - env.Append(LINKFLAGS=['-pg']) - - env.Append(CCFLAGS=['-DNACL_ENABLED', '-DGLES2_ENABLED']) - - env.Append(LIBFLAGS=['m32']) - env.Append(LIBS=env.Split('ppapi ppapi_cpp pthread srpc ppapi_gles22')) - - import methods - env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) diff --git a/platform/nacl/geturl_handler.cpp b/platform/nacl/geturl_handler.cpp deleted file mode 100644 index 6be82f3f5a2..00000000000 --- a/platform/nacl/geturl_handler.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/*************************************************************************/ -/* geturl_handler.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "geturl_handler.h" - -#include "core/os/copymem.h" - -#include -#include -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/ppb_instance.h" -#include "ppapi/cpp/module.h" -#include "ppapi/cpp/var.h" - -void GetURLHandler::Start() { - pp::CompletionCallback cc = - cc_factory_.NewCallback(&GetURLHandler::OnOpen); - url_loader_.Open(url_request_, cc); -} - -void GetURLHandler::OnOpen(int32_t result) { - if (result != PP_OK) { - status = STATUS_ERROR; - return; - } - // Here you would process the headers. A real program would want to at least - // check the HTTP code and potentially cancel the request. - // pp::URLResponseInfo response = loader_.GetResponseInfo(); - - // Start streaming. - ReadBody(); -} - -void GetURLHandler::AppendDataBytes(const char* buffer, int32_t num_bytes) { - if (num_bytes <= 0) - return; - // Make sure we don't get a buffer overrun. - num_bytes = std::min(READ_BUFFER_SIZE, num_bytes); - int ofs = data.size(); - data.resize(ofs + num_bytes); - copymem(&data[ofs], buffer, num_bytes); -} - -void GetURLHandler::OnRead(int32_t result) { - if (result == PP_OK) { - // Streaming the file is complete. - status = STATUS_COMPLETED; - instance_->HandleMessage("package_finished"); - instance_->HandleMessage(0); - printf("completed!\n"); - } else if (result > 0) { - // The URLLoader just filled "result" number of bytes into our buffer. - // Save them and perform another read. - AppendDataBytes(buffer_, result); - ReadBody(); - } else { - // A read error occurred. - status = STATUS_ERROR; - ERR_FAIL_COND(result < 0); - } -} - -void GetURLHandler::ReadBody() { - // Note that you specifically want an "optional" callback here. This will - // allow ReadBody() to return synchronously, ignoring your completion - // callback, if data is available. For fast connections and large files, - // reading as fast as we can will make a large performance difference - // However, in the case of a synchronous return, we need to be sure to run - // the callback we created since the loader won't do anything with it. - pp::CompletionCallback cc = - cc_factory_.NewOptionalCallback(&GetURLHandler::OnRead); - int32_t result = PP_OK; - do { - result = url_loader_.ReadResponseBody(buffer_, sizeof(buffer_), cc); - // Handle streaming data directly. Note that we *don't* want to call - // OnRead here, since in the case of result > 0 it will schedule - // another call to this function. If the network is very fast, we could - // end up with a deeply recursive stack. - if (result > 0) { - AppendDataBytes(buffer_, result); - } - } while (result > 0); - - if (result != PP_OK_COMPLETIONPENDING) { - // Either we reached the end of the stream (result == PP_OK) or there was - // an error. We want OnRead to get called no matter what to handle - // that case, whether the error is synchronous or asynchronous. If the - // result code *is* COMPLETIONPENDING, our callback will be called - // asynchronously. - cc.Run(result); - } -} - -GetURLHandler::Status GetURLHandler::get_status() const { - - return status; -}; - -Vector GetURLHandler::get_data() const { - - return data; -}; - -int GetURLHandler::get_bytes_read() const { - - return data.size(); -}; - -GetURLHandler::GetURLHandler(pp::Instance* instance, - const String& url) - : instance_(instance), - url_(url), - url_request_(instance), - url_loader_(instance), - cc_factory_(this) { - url_request_.SetURL(std::string(url.utf8().get_data())); - url_request_.SetMethod("GET"); - status = STATUS_NONE; - printf("url handler for url %ls!\n", url.c_str()); -} - -GetURLHandler::~GetURLHandler() { -} - - diff --git a/platform/nacl/geturl_handler.h b/platform/nacl/geturl_handler.h deleted file mode 100644 index c310ed942de..00000000000 --- a/platform/nacl/geturl_handler.h +++ /dev/null @@ -1,115 +0,0 @@ -/*************************************************************************/ -/* geturl_handler.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef EXAMPLES_GETURL_GETURL_HANDLER_H_ -#define EXAMPLES_GETURL_GETURL_HANDLER_H_ - -#include "core/ustring.h" -#include "core/vector.h" -#include "ppapi/cpp/completion_callback.h" -#include "ppapi/cpp/url_loader.h" -#include "ppapi/cpp/url_request_info.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/utility/completion_callback_factory.h" - -#define READ_BUFFER_SIZE 32768 - -// GetURLHandler is used to download data from |url|. When download is -// finished or when an error occurs, it posts a message back to the browser -// with the results encoded in the message as a string and self-destroys. -// -// EXAMPLE USAGE: -// GetURLHandler* handler* = GetURLHandler::Create(instance,url); -// handler->Start(); -// -class GetURLHandler { - -public: - - enum Status { - - STATUS_NONE, - STATUS_IN_PROGRESS, - STATUS_COMPLETED, - STATUS_ERROR, - }; - -private: - - Status status; - - // Callback fo the pp::URLLoader::Open(). - // Called by pp::URLLoader when response headers are received or when an - // error occurs (in response to the call of pp::URLLoader::Open()). - // Look at and - // for more information about pp::URLLoader. - void OnOpen(int32_t result); - - // Callback fo the pp::URLLoader::ReadResponseBody(). - // |result| contains the number of bytes read or an error code. - // Appends data from this->buffer_ to this->url_response_body_. - void OnRead(int32_t result); - - // Reads the response body (asynchronously) into this->buffer_. - // OnRead() will be called when bytes are received or when an error occurs. - void ReadBody(); - - // Append data bytes read from the URL onto the internal buffer. Does - // nothing if |num_bytes| is 0. - void AppendDataBytes(const char* buffer, int32_t num_bytes); - - pp::Instance* instance_; // Weak pointer. - String url_; // URL to be downloaded. - pp::URLRequestInfo url_request_; - pp::URLLoader url_loader_; // URLLoader provides an API to download URLs. - char buffer_[READ_BUFFER_SIZE]; // Temporary buffer for reads. - Vector data; // Contains accumulated downloaded data. - pp::CompletionCallbackFactory cc_factory_; - bool complete; - - GetURLHandler(const GetURLHandler&); - void operator=(const GetURLHandler&); - -public: - // Creates instance of GetURLHandler on the heap. - // GetURLHandler objects shall be created only on the heap (they - // self-destroy when all data is in). - // Initiates page (URL) download. - void Start(); - - Status get_status() const; - Vector get_data() const; - - int get_bytes_read() const; - - GetURLHandler(pp::Instance* instance_, const String& url); - ~GetURLHandler(); -}; - -#endif // EXAMPLES_GETURL_GETURL_HANDLER_H_ - diff --git a/platform/nacl/godot_module.cpp b/platform/nacl/godot_module.cpp deleted file mode 100644 index 5c558f5ecea..00000000000 --- a/platform/nacl/godot_module.cpp +++ /dev/null @@ -1,332 +0,0 @@ -/*************************************************************************/ -/* godot_module.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "opengl_context.h" - -#include -#include -#include -#include - -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/module.h" -#include "ppapi/gles2/gl2ext_ppapi.h" - -#include "ppapi/cpp/rect.h" -#include "ppapi/cpp/size.h" -#include "ppapi/cpp/var.h" -#include "geturl_handler.h" - -#include "core/variant.h" -#include "os_nacl.h" - -extern int nacl_main(int argc, const char** argn, const char** argv); -extern void nacl_cleanup(); - -static String pkg_url; - -pp::Instance* godot_instance = NULL; - -struct StateData { - int arg_count; - Array args; - String method; -}; - -extern OSNacl* os_nacl; - -class GodotInstance : public pp::Instance { - - enum State { - STATE_METHOD, - STATE_PARAM_COUNT, - STATE_PARAMS, - STATE_CALL, - }; - - State state; - StateData* sd; - SharedOpenGLContext opengl_context_; - int width; - int height; - - #define MAX_ARGS 64 - uint32_t init_argc; - char* init_argn[MAX_ARGS]; - char* init_argv[MAX_ARGS]; - - bool package_loaded; - GetURLHandler* package_pending; - -public: - explicit GodotInstance(PP_Instance instance) : pp::Instance(instance) { - printf("GodotInstance!\n"); - state = STATE_METHOD; - RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_KEYBOARD | PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_TOUCH); - sd = NULL; - package_pending = NULL; - package_loaded = false; - godot_instance = this; - } - virtual ~GodotInstance() { - - nacl_cleanup(); - } - - /// Called by the browser to handle the postMessage() call in Javascript. - /// Detects which method is being called from the message contents, and - /// calls the appropriate function. Posts the result back to the browser - /// asynchronously. - /// @param[in] var_message The message posted by the browser. The possible - /// messages are 'fortyTwo' and 'reverseText:Hello World'. Note that - /// the 'reverseText' form contains the string to reverse following a ':' - /// separator. - virtual void HandleMessage(const pp::Var& var_message); - - bool HandleInputEvent(const pp::InputEvent& event); - - bool Init(uint32_t argc, const char* argn[], const char* argv[]) { - - printf("******* init! %i, %p, %p\n", argc, argn, argv); - fflush(stdout); - if (opengl_context_ == NULL) { - opengl_context_.reset(new OpenGLContext(this)); - }; - opengl_context_->InvalidateContext(this); - opengl_context_->ResizeContext(pp::Size(0, 0)); - int current = opengl_context_->MakeContextCurrent(this); - printf("current is %i\n", current); - - os_nacl = new OSNacl; - - pkg_url = ""; - for (uint32_t i=0; iStart(); - }; - return true; - }; - - // Called whenever the in-browser window changes size. - virtual void DidChangeView(const pp::Rect& position, const pp::Rect& clip) { - - if (position.size().width() == width && - position.size().height() == height) - return; // Size didn't change, no need to update anything. - - if (opengl_context_ == NULL) { - opengl_context_.reset(new OpenGLContext(this)); - }; - opengl_context_->InvalidateContext(this); - opengl_context_->ResizeContext(position.size()); - if (!opengl_context_->MakeContextCurrent(this)) - return; - - width = position.size().width(); - height = position.size().height(); - // init gl here? - OS::VideoMode vm; - vm.width = width; - vm.height = height; - vm.resizable = false; - vm.fullscreen = true; - OS::get_singleton()->set_video_mode(vm, 0); - - DrawSelf(); - }; - - // Called to draw the contents of the module's browser area. - void DrawSelf() { - - if (opengl_context_ == NULL) - return; - - opengl_context_->FlushContext(); - }; -}; - -static Variant to_variant(const pp::Var& p_var) { - - if (p_var.is_undefined() || p_var.is_null()) - return Variant(); - if (p_var.is_bool()) - return Variant(p_var.AsBool()); - if (p_var.is_double()) - return Variant(p_var.AsDouble()); - if (p_var.is_int()) - return Variant((int64_t)p_var.AsInt()); - if (p_var.is_string()) - return Variant(String::utf8(p_var.AsString().c_str())); - - return Variant(); -}; - -void GodotInstance::HandleMessage(const pp::Var& var_message) { - - switch (state) { - - case STATE_METHOD: { - - ERR_FAIL_COND(!var_message.is_string()); - sd->method = var_message.AsString().c_str(); - state = STATE_PARAM_COUNT; - } break; - case STATE_PARAM_COUNT: { - - ERR_FAIL_COND(!var_message.is_number()); - sd->arg_count = var_message.AsInt(); - state = sd->arg_count>0?STATE_PARAMS:STATE_CALL; - - } break; - case STATE_PARAMS: { - - Variant p = to_variant(var_message); - sd->args.push_back(p); - if (sd->args.size() >= sd->arg_count) - state = STATE_CALL; - } break; - default: - break; - }; - - if (state == STATE_CALL) { - - // call - state = STATE_METHOD; - - - if (sd->method == "package_finished") { - - GetURLHandler::Status status = package_pending->get_status(); - printf("status is %i, %i, %i\n", status, GetURLHandler::STATUS_ERROR, GetURLHandler::STATUS_COMPLETED); - if (status == GetURLHandler::STATUS_ERROR) { - printf("Error fetching package!\n"); - }; - if (status == GetURLHandler::STATUS_COMPLETED) { - - OSNacl* os = (OSNacl*)OS::get_singleton(); - os->add_package(pkg_url, package_pending->get_data()); - }; - memdelete(package_pending); - package_pending = NULL; - - package_loaded = true; - - opengl_context_->MakeContextCurrent(this); - nacl_main(init_argc, (const char**)init_argn, (const char**)init_argv); - for (uint32_t i=0; imethod == "get_package_status") { - - if (package_loaded) { - // post "loaded" - PostMessage("loaded"); - } else if (package_pending == NULL) { - // post "none" - PostMessage("none"); - } else { - // post package_pending->get_bytes_read(); - PostMessage(package_pending->get_bytes_read()); - }; - }; - }; -} - -bool GodotInstance::HandleInputEvent(const pp::InputEvent& event) { - - OSNacl* os = (OSNacl*)OS::get_singleton(); - os->handle_event(event); - return true; -}; - -class GodotModule : public pp::Module { - public: - GodotModule() : pp::Module() {} - virtual ~GodotModule() { - glTerminatePPAPI(); - } - - /// Create and return a GodotInstance object. - /// @param[in] instance a handle to a plug-in instance. - /// @return a newly created GodotInstance. - /// @note The browser is responsible for calling @a delete when done. - virtual pp::Instance* CreateInstance(PP_Instance instance) { - printf("CreateInstance! %x\n", instance); - return new GodotInstance(instance); - } - - /// Called by the browser when the module is first loaded and ready to run. - /// This is called once per module, not once per instance of the module on - /// the page. - virtual bool Init() { - printf("GodotModule::init!\n"); - return glInitializePPAPI(get_browser_interface()); - } -}; - -namespace pp { -/// Factory function called by the browser when the module is first loaded. -/// The browser keeps a singleton of this module. It calls the -/// CreateInstance() method on the object you return to make instances. There -/// is one instance per tag on the page. This is the main binding -/// point for your NaCl module with the browser. -/// @return new GodotModule. -/// @note The browser is responsible for deleting returned @a Module. -Module* CreateModule() { - printf("CreateModule!\n"); - return new GodotModule(); -} -} // namespace pp diff --git a/platform/nacl/godot_nacl.cpp b/platform/nacl/godot_nacl.cpp deleted file mode 100644 index d8447390c1d..00000000000 --- a/platform/nacl/godot_nacl.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/*************************************************************************/ -/* godot_nacl.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "os_nacl.h" -#include "main/main.h" - -#include -#include - -OSNacl* os_nacl = NULL; - -int nacl_main(int argc, const char** argn, const char** argv) { - - // os is created in GodotModule::Init for the nacl module - printf("called with %i args, %p, %p\n", argc, argn, argv); - char* nargv[64]; - int nargc = 1; - nargv[0] = (char*)argv[0]; - for (int i=1; i= |minChromeVersion_|. - * @type {integer} - * @private - */ - this.minChromeVersion_ = minChromeVersion; - - /** - * List of Browser plugin objects. - * @type {Ojbect array} - * @private - */ - this.plugins_ = plugins; - - /** - * Application version string from the Browser. - * @type {integer} - * @private - */ - this.appVersion_ = appVersion; - - /** - * Flag used to indicate if the browser has Native Client and is if the - * browser version is recent enough. - * @type {boolean} - * @private - */ - this.isValidBrowser_ = false; - - /** - * Actual major version of Chrome -- found by querying the browser. - * @type {integer} - * @private - */ - this.chromeVersion_ = null; - - /** - * Browser support status. This allows the user to get a detailed status - * rather than using this.browserSupportMessage. - */ - this.browserSupportStatus_ = - browser_version.BrowserChecker.StatusValues.UNKNOWN; -} - -/** - * The values used for BrowserChecker status to indicate success or - * a specific error. - * @enum {id} - */ -browser_version.BrowserChecker.StatusValues = { - UNKNOWN: 0, - NACL_ENABLED: 1, - UNKNOWN_BROWSER: 2, - CHROME_VERSION_TOO_OLD: 3, - NACL_NOT_ENABLED: 4, - NOT_USING_SERVER: 5 -}; - -/** - * Determines if the plugin with name |name| exists in the browser. - * @param {string} name The name of the plugin. - * @param {Object array} plugins The plugins in this browser. - * @return {bool} |true| if the plugin is found. - */ -browser_version.BrowserChecker.prototype.pluginExists = function(name, - plugins) { - for (var index=0; index < plugins.length; index++) { - var plugin = this.plugins_[index]; - var plugin_name = plugin['name']; - // If the plugin is not found, you can use the Javascript console - // to see the names of the plugins that were found when debugging. - if (plugin_name.indexOf(name) != -1) { - return true; - } - } - return false; -} - -/** - * Returns browserSupportStatus_ which indicates if the browser supports - * Native Client. Values are defined as literals in - * browser_version.BrowserChecker.StatusValues. - * @ return {int} Level of NaCl support. - */ -browser_version.BrowserChecker.prototype.getBrowserSupportStatus = function() { - return this.browserSupportStatus_; -} - -/** - * Returns isValidBrowser (true/false) to indicate if the browser supports - * Native Client. - * @ return {bool} If this browser has NativeClient and correct version. - */ -browser_version.BrowserChecker.prototype.getIsValidBrowser = function() { - return this.isValidBrowser_; -} - -/** - * Checks to see if this browser can support Native Client applications. - * For Chrome browsers, checks to see if the "Native Client" plugin is - * enabled. - */ -browser_version.BrowserChecker.prototype.checkBrowser = function() { - var versionPatt = /Chrome\/(\d+)\.(\d+)\.(\d+)\.(\d+)/; - var result = this.appVersion_.match(versionPatt); - - // |result| stores the Chrome version number. - if (!result) { - this.isValidBrowser_ = false; - this.browserSupportStatus_ = - browser_version.BrowserChecker.StatusValues.UNKNOWN_BROWSER; - } else { - this.chromeVersion_ = result[1]; - // We know we have Chrome, check version and/or plugin named Native Client - if (this.chromeVersion_ >= this.minChromeVersion_) { - var found_nacl = this.pluginExists('Native Client', this.plugins_); - if (found_nacl) { - this.isValidBrowser_ = true; - this.browserSupportStatus_ = - browser_version.BrowserChecker.StatusValues.NACL_ENABLED; - } else { - this.isValidBrowser_ = false; - this.browserSupportStatus_ = - browser_version.BrowserChecker.StatusValues.NACL_NOT_ENABLED; - } - } else { - // We are in a version that is less than |minChromeVersion_| - this.isValidBrowser_ = false; - this.browserSupportStatus_ = - browser_version.BrowserChecker.StatusValues.CHROME_VERSION_TOO_OLD; - } - } - var my_protocol = window.location.protocol; - if (my_protocol.indexOf('file') == 0) { - this.isValidBrowser_ = false; - this.browserSupportStatus_ = - browser_version.BrowserChecker.StatusValues.NOT_USING_SERVER; - } -} - diff --git a/platform/nacl/html/godot_nacl.nmf b/platform/nacl/html/godot_nacl.nmf deleted file mode 100644 index eca039ec1ee..00000000000 --- a/platform/nacl/html/godot_nacl.nmf +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": { - "x86-64": {"url": "godot_nacl.x86_64.nexe"}, - "x86-32": {"url": "godot_nacl.i686.nexe"} - } -} diff --git a/platform/nacl/html/icon_128.png b/platform/nacl/html/icon_128.png deleted file mode 100644 index 653669c38dc..00000000000 Binary files a/platform/nacl/html/icon_128.png and /dev/null differ diff --git a/platform/nacl/html/icon_16.png b/platform/nacl/html/icon_16.png deleted file mode 100644 index 9f6678c2894..00000000000 Binary files a/platform/nacl/html/icon_16.png and /dev/null differ diff --git a/platform/nacl/html/index.html b/platform/nacl/html/index.html deleted file mode 100644 index e8be6f69b97..00000000000 --- a/platform/nacl/html/index.html +++ /dev/null @@ -1,258 +0,0 @@ - - - - - Load Progress Example - - - - - - - -

Native Client Load Event Example

- -

Status

-
NO-STATUS
- -
- - - - - - -
- -

Event Log

-
event log?
- - - - diff --git a/platform/nacl/html/manifest.json b/platform/nacl/html/manifest.json deleted file mode 100644 index 6e271507a99..00000000000 --- a/platform/nacl/html/manifest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "Capsuleman's Castle Adventure", - "description": "Capsuleman's Castle Adventure", - "version": "1", - "app": { - "launch": { - "local_path": "index.html" - } - }, - "icons": { - "16": "icon_16.png", - "128": "icon_128.png" - }, - "permissions": [ - "unlimitedStorage", - "notifications", - "experimental" - ] -} diff --git a/platform/nacl/logo.png b/platform/nacl/logo.png deleted file mode 100644 index aac72c01b26..00000000000 Binary files a/platform/nacl/logo.png and /dev/null differ diff --git a/platform/nacl/nacl_keycodes.h b/platform/nacl/nacl_keycodes.h deleted file mode 100644 index a0642fc3b71..00000000000 --- a/platform/nacl/nacl_keycodes.h +++ /dev/null @@ -1,422 +0,0 @@ -/*************************************************************************/ -/* nacl_keycodes.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com. All rights reserved. - * Copyright (C) 2008, 2009 Google Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF USE, DATA, OR - * PROFITS, OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BASE_KEYBOARD_CODES_POSIX_H_ -#define BASE_KEYBOARD_CODES_POSIX_H_ -#pragma once - -#include "core/os/keyboard.h" - -enum { - VKEY_BACK = 0x08, - VKEY_TAB = 0x09, - VKEY_CLEAR = 0x0C, - VKEY_RETURN = 0x0D, - VKEY_SHIFT = 0x10, - VKEY_CONTROL = 0x11, - VKEY_MENU = 0x12, - VKEY_PAUSE = 0x13, - VKEY_CAPITAL = 0x14, - VKEY_KANA = 0x15, - VKEY_HANGUL = 0x15, - VKEY_JUNJA = 0x17, - VKEY_FINAL = 0x18, - VKEY_HANJA = 0x19, - VKEY_KANJI = 0x19, - VKEY_ESCAPE = 0x1B, - VKEY_CONVERT = 0x1C, - VKEY_NONCONVERT = 0x1D, - VKEY_ACCEPT = 0x1E, - VKEY_MODECHANGE = 0x1F, - VKEY_SPACE = 0x20, - VKEY_PRIOR = 0x21, - VKEY_NEXT = 0x22, - VKEY_END = 0x23, - VKEY_HOME = 0x24, - VKEY_LEFT = 0x25, - VKEY_UP = 0x26, - VKEY_RIGHT = 0x27, - VKEY_DOWN = 0x28, - VKEY_SELECT = 0x29, - VKEY_PRINT = 0x2A, - VKEY_EXECUTE = 0x2B, - VKEY_SNAPSHOT = 0x2C, - VKEY_INSERT = 0x2D, - VKEY_DELETE = 0x2E, - VKEY_HELP = 0x2F, - VKEY_0 = 0x30, - VKEY_1 = 0x31, - VKEY_2 = 0x32, - VKEY_3 = 0x33, - VKEY_4 = 0x34, - VKEY_5 = 0x35, - VKEY_6 = 0x36, - VKEY_7 = 0x37, - VKEY_8 = 0x38, - VKEY_9 = 0x39, - VKEY_A = 0x41, - VKEY_B = 0x42, - VKEY_C = 0x43, - VKEY_D = 0x44, - VKEY_E = 0x45, - VKEY_F = 0x46, - VKEY_G = 0x47, - VKEY_H = 0x48, - VKEY_I = 0x49, - VKEY_J = 0x4A, - VKEY_K = 0x4B, - VKEY_L = 0x4C, - VKEY_M = 0x4D, - VKEY_N = 0x4E, - VKEY_O = 0x4F, - VKEY_P = 0x50, - VKEY_Q = 0x51, - VKEY_R = 0x52, - VKEY_S = 0x53, - VKEY_T = 0x54, - VKEY_U = 0x55, - VKEY_V = 0x56, - VKEY_W = 0x57, - VKEY_X = 0x58, - VKEY_Y = 0x59, - VKEY_Z = 0x5A, - VKEY_LWIN = 0x5B, - VKEY_COMMAND = VKEY_LWIN, // Provide the Mac name for convenience. - VKEY_RWIN = 0x5C, - VKEY_APPS = 0x5D, - VKEY_SLEEP = 0x5F, - VKEY_NUMPAD0 = 0x60, - VKEY_NUMPAD1 = 0x61, - VKEY_NUMPAD2 = 0x62, - VKEY_NUMPAD3 = 0x63, - VKEY_NUMPAD4 = 0x64, - VKEY_NUMPAD5 = 0x65, - VKEY_NUMPAD6 = 0x66, - VKEY_NUMPAD7 = 0x67, - VKEY_NUMPAD8 = 0x68, - VKEY_NUMPAD9 = 0x69, - VKEY_MULTIPLY = 0x6A, - VKEY_ADD = 0x6B, - VKEY_SEPARATOR = 0x6C, - VKEY_SUBTRACT = 0x6D, - VKEY_DECIMAL = 0x6E, - VKEY_DIVIDE = 0x6F, - VKEY_F1 = 0x70, - VKEY_F2 = 0x71, - VKEY_F3 = 0x72, - VKEY_F4 = 0x73, - VKEY_F5 = 0x74, - VKEY_F6 = 0x75, - VKEY_F7 = 0x76, - VKEY_F8 = 0x77, - VKEY_F9 = 0x78, - VKEY_F10 = 0x79, - VKEY_F11 = 0x7A, - VKEY_F12 = 0x7B, - VKEY_F13 = 0x7C, - VKEY_F14 = 0x7D, - VKEY_F15 = 0x7E, - VKEY_F16 = 0x7F, - VKEY_F17 = 0x80, - VKEY_F18 = 0x81, - VKEY_F19 = 0x82, - VKEY_F20 = 0x83, - VKEY_F21 = 0x84, - VKEY_F22 = 0x85, - VKEY_F23 = 0x86, - VKEY_F24 = 0x87, - VKEY_NUMLOCK = 0x90, - VKEY_SCROLL = 0x91, - VKEY_LSHIFT = 0xA0, - VKEY_RSHIFT = 0xA1, - VKEY_LCONTROL = 0xA2, - VKEY_RCONTROL = 0xA3, - VKEY_LMENU = 0xA4, - VKEY_RMENU = 0xA5, - VKEY_BROWSER_BACK = 0xA6, - VKEY_BROWSER_FORWARD = 0xA7, - VKEY_BROWSER_REFRESH = 0xA8, - VKEY_BROWSER_STOP = 0xA9, - VKEY_BROWSER_SEARCH = 0xAA, - VKEY_BROWSER_FAVORITES = 0xAB, - VKEY_BROWSER_HOME = 0xAC, - VKEY_VOLUME_MUTE = 0xAD, - VKEY_VOLUME_DOWN = 0xAE, - VKEY_VOLUME_UP = 0xAF, - VKEY_MEDIA_NEXT_TRACK = 0xB0, - VKEY_MEDIA_PREV_TRACK = 0xB1, - VKEY_MEDIA_STOP = 0xB2, - VKEY_MEDIA_PLAY_PAUSE = 0xB3, - VKEY_MEDIA_LAUNCH_MAIL = 0xB4, - VKEY_MEDIA_LAUNCH_MEDIA_SELECT = 0xB5, - VKEY_MEDIA_LAUNCH_APP1 = 0xB6, - VKEY_MEDIA_LAUNCH_APP2 = 0xB7, - VKEY_OEM_1 = 0xBA, - VKEY_OEM_PLUS = 0xBB, - VKEY_OEM_COMMA = 0xBC, - VKEY_OEM_MINUS = 0xBD, - VKEY_OEM_PERIOD = 0xBE, - VKEY_OEM_2 = 0xBF, - VKEY_OEM_3 = 0xC0, - VKEY_OEM_4 = 0xDB, - VKEY_OEM_5 = 0xDC, - VKEY_OEM_6 = 0xDD, - VKEY_OEM_7 = 0xDE, - VKEY_OEM_8 = 0xDF, - VKEY_OEM_102 = 0xE2, - VKEY_PROCESSKEY = 0xE5, - VKEY_PACKET = 0xE7, - VKEY_ATTN = 0xF6, - VKEY_CRSEL = 0xF7, - VKEY_EXSEL = 0xF8, - VKEY_EREOF = 0xF9, - VKEY_PLAY = 0xFA, - VKEY_ZOOM = 0xFB, - VKEY_NONAME = 0xFC, - VKEY_PA1 = 0xFD, - VKEY_OEM_CLEAR = 0xFE, - VKEY_UNKNOWN = 0 -}; - -static uint32_t godot_key(uint32_t p_key, bool& is_char) { - - is_char = false; - - switch (p_key) { - - case VKEY_BACK: return KEY_BACKSPACE; - case VKEY_TAB: return KEY_TAB; - case VKEY_CLEAR: return KEY_CLEAR; - case VKEY_RETURN: return KEY_RETURN; - case VKEY_SHIFT: return KEY_SHIFT; - case VKEY_CONTROL: return KEY_CONTROL; - case VKEY_MENU: return KEY_MENU; - case VKEY_PAUSE: return KEY_PAUSE; -// case VKEY_CAPITAL: return KEY_CAPITAL; -// case VKEY_KANA: return KEY_KANA; -// case VKEY_HANGUL: return KEY_HANGUL; -// case VKEY_JUNJA: return KEY_JUNJA; -// case VKEY_FINAL: return KEY_FINAL; -// case VKEY_HANJA: return KEY_HANJA; -// case VKEY_KANJI: return KEY_KANJI; - case VKEY_ESCAPE: return KEY_ESCAPE; -// case VKEY_CONVERT: return KEY_CONVERT; -// case VKEY_NONCONVERT: return KEY_NONCONVERT; -// case VKEY_ACCEPT: return KEY_ACCEPT; -// case VKEY_MODECHANGE: return KEY_MODECHANGE; -// case VKEY_PRIOR: return KEY_PRIOR; -// case VKEY_NEXT: return KEY_NEXT; - case VKEY_END: return KEY_END; - case VKEY_HOME: return KEY_HOME; - case VKEY_LEFT: return KEY_LEFT; - case VKEY_UP: return KEY_UP; - case VKEY_RIGHT: return KEY_RIGHT; - case VKEY_DOWN: return KEY_DOWN; -// case VKEY_SELECT: return KEY_SELECT; - case VKEY_PRINT: return KEY_PRINT; -// case VKEY_EXECUTE: return KEY_EXECUTE; -// case VKEY_SNAPSHOT: return KEY_SNAPSHOT; - case VKEY_INSERT: return KEY_INSERT; - case VKEY_DELETE: return KEY_DELETE; - case VKEY_HELP: return KEY_HELP; -// case VKEY_LWIN: return KEY_LWIN; -// case VKEY_RWIN: return KEY_RWIN; -// case VKEY_APPS: return KEY_APPS; -// case VKEY_SLEEP: return KEY_SLEEP; - case VKEY_NUMPAD0: return KEY_KP_0; - case VKEY_NUMPAD1: return KEY_KP_1; - case VKEY_NUMPAD2: return KEY_KP_2; - case VKEY_NUMPAD3: return KEY_KP_3; - case VKEY_NUMPAD4: return KEY_KP_4; - case VKEY_NUMPAD5: return KEY_KP_5; - case VKEY_NUMPAD6: return KEY_KP_6; - case VKEY_NUMPAD7: return KEY_KP_7; - case VKEY_NUMPAD8: return KEY_KP_8; - case VKEY_NUMPAD9: return KEY_KP_9; - case VKEY_MULTIPLY: return KEY_KP_MULTIPLY; - case VKEY_ADD: return KEY_KP_ADD; -// case VKEY_SEPARATOR: return KEY_SEPARATOR; - case VKEY_SUBTRACT: return KEY_KP_SUBTRACT; - case VKEY_DECIMAL: return KEY_KP_PERIOD; - case VKEY_DIVIDE: return KEY_KP_DIVIDE; - case VKEY_F1: return KEY_F1; - case VKEY_F2: return KEY_F2; - case VKEY_F3: return KEY_F3; - case VKEY_F4: return KEY_F4; - case VKEY_F5: return KEY_F5; - case VKEY_F6: return KEY_F6; - case VKEY_F7: return KEY_F7; - case VKEY_F8: return KEY_F8; - case VKEY_F9: return KEY_F9; - case VKEY_F10: return KEY_F10; - case VKEY_F11: return KEY_F11; - case VKEY_F12: return KEY_F12; - case VKEY_F13: return KEY_F13; - case VKEY_F14: return KEY_F14; - case VKEY_F15: return KEY_F15; - case VKEY_F16: return KEY_F16; - /* - case VKEY_F17: return KEY_F17; - case VKEY_F18: return KEY_F18; - case VKEY_F19: return KEY_F19; - case VKEY_F20: return KEY_F20; - case VKEY_F21: return KEY_F21; - case VKEY_F22: return KEY_F22; - case VKEY_F23: return KEY_F23; - case VKEY_F24: return KEY_F24; - */ - case VKEY_NUMLOCK: return KEY_NUMLOCK; - case VKEY_SCROLL: return KEY_SCROLLLOCK; - case VKEY_LSHIFT: return KEY_SHIFT; - case VKEY_RSHIFT: return KEY_SHIFT; - case VKEY_LCONTROL: return KEY_CONTROL; - case VKEY_RCONTROL: return KEY_CONTROL; - case VKEY_LMENU: return KEY_MENU; - case VKEY_RMENU: return KEY_MENU; - case VKEY_BROWSER_BACK: return KEY_BACK; - case VKEY_BROWSER_FORWARD: return KEY_FORWARD; - case VKEY_BROWSER_REFRESH: return KEY_REFRESH; - case VKEY_BROWSER_STOP: return KEY_STOP; - case VKEY_BROWSER_SEARCH: return KEY_SEARCH; - case VKEY_BROWSER_FAVORITES: return KEY_FAVORITES; - case VKEY_BROWSER_HOME: return KEY_HOMEPAGE; - case VKEY_VOLUME_MUTE: return KEY_VOLUMEMUTE; - case VKEY_VOLUME_DOWN: return KEY_VOLUMEDOWN; - case VKEY_VOLUME_UP: return KEY_VOLUMEUP; - case VKEY_MEDIA_NEXT_TRACK: return KEY_MEDIANEXT; - case VKEY_MEDIA_PREV_TRACK: return KEY_MEDIAPREVIOUS; - case VKEY_MEDIA_STOP: return KEY_MEDIASTOP; - case VKEY_MEDIA_PLAY_PAUSE: return KEY_MEDIAPLAY; - case VKEY_MEDIA_LAUNCH_MAIL: return KEY_LAUNCHMAIL; - case VKEY_MEDIA_LAUNCH_MEDIA_SELECT: return KEY_LAUNCHMEDIA; // FUCKING USELESS KEYS, HOW DO THEY WORK? - case VKEY_MEDIA_LAUNCH_APP1: return KEY_LAUNCH0; - case VKEY_MEDIA_LAUNCH_APP2: return KEY_LAUNCH0; -// case VKEY_OEM_102: return KEY_OEM_102; -// case VKEY_PROCESSKEY: return KEY_PROCESSKEY; -// case VKEY_PACKET: return KEY_PACKET; -// case VKEY_ATTN: return KEY_ATTN; -// case VKEY_CRSEL: return KEY_CRSEL; -// case VKEY_EXSEL: return KEY_EXSEL; -// case VKEY_EREOF: return KEY_EREOF; -// case VKEY_PLAY: return KEY_PLAY; -// case VKEY_ZOOM: return KEY_ZOOM; -// case VKEY_NONAME: return KEY_NONAME; -// case VKEY_PA1: return KEY_PA1; -// case VKEY_OEM_CLEAR: return KEY_OEM_CLEAR; - - default: break; - }; - - is_char = true; - - switch (p_key) { - - case VKEY_SPACE: return KEY_SPACE; - case VKEY_0: return KEY_0; - case VKEY_1: return KEY_1; - case VKEY_2: return KEY_2; - case VKEY_3: return KEY_3; - case VKEY_4: return KEY_4; - case VKEY_5: return KEY_5; - case VKEY_6: return KEY_6; - case VKEY_7: return KEY_7; - case VKEY_8: return KEY_8; - case VKEY_9: return KEY_9; - case VKEY_A: return KEY_A; - case VKEY_B: return KEY_B; - case VKEY_C: return KEY_C; - case VKEY_D: return KEY_D; - case VKEY_E: return KEY_E; - case VKEY_F: return KEY_F; - case VKEY_G: return KEY_G; - case VKEY_H: return KEY_H; - case VKEY_I: return KEY_I; - case VKEY_J: return KEY_J; - case VKEY_K: return KEY_K; - case VKEY_L: return KEY_L; - case VKEY_M: return KEY_M; - case VKEY_N: return KEY_N; - case VKEY_O: return KEY_O; - case VKEY_P: return KEY_P; - case VKEY_Q: return KEY_Q; - case VKEY_R: return KEY_R; - case VKEY_S: return KEY_S; - case VKEY_T: return KEY_T; - case VKEY_U: return KEY_U; - case VKEY_V: return KEY_V; - case VKEY_W: return KEY_W; - case VKEY_X: return KEY_X; - case VKEY_Y: return KEY_Y; - case VKEY_Z: return KEY_Z; - /* - case VKEY_OEM_PLUS: return KEY_PLUS; - case VKEY_OEM_COMMA: return KEY_COMMA; - case VKEY_OEM_MINUS: return KEY_MINUS; - case VKEY_OEM_PERIOD: return KEY_PERIOD; - case VKEY_OEM_1: return KEY_OEM_1; - case VKEY_OEM_2: return KEY_OEM_2; - case VKEY_OEM_3: return KEY_OEM_3; - case VKEY_OEM_4: return KEY_OEM_4; - case VKEY_OEM_5: return KEY_OEM_5; - case VKEY_OEM_6: return KEY_OEM_6; - case VKEY_OEM_7: return KEY_OEM_7; - case VKEY_OEM_8: return KEY_OEM_8; - */ - default: break; - - }; - - return 0; -}; - -#endif // BASE_KEYBOARD_CODES_POSIX_H_ diff --git a/platform/nacl/opengl_context.cpp b/platform/nacl/opengl_context.cpp deleted file mode 100644 index ae72e4ddbbd..00000000000 --- a/platform/nacl/opengl_context.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/*************************************************************************/ -/* opengl_context.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "opengl_context.h" - -#include -#include "ppapi/gles2/gl2ext_ppapi.h" -#include "os_nacl.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/module.h" -#include "ppapi/cpp/completion_callback.h" -#include "ppapi/utility/completion_callback_factory.h" - - -namespace { -// This is called by the brower when the 3D context has been flushed to the -// browser window. -void FlushCallback(void* data, int32_t result) { - static_cast(data)->set_flush_pending(false); - static_cast(data)->FlushContext(); -} -} // namespace - -OpenGLContext::OpenGLContext(pp::Instance* p_instance) - : pp::Graphics3DClient(p_instance), - flush_pending_(false) { - - instance = p_instance; - pp::Module* module = pp::Module::Get(); - assert(module); - gles2_interface_ = static_cast( - module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE)); - assert(gles2_interface_); -} - -OpenGLContext::~OpenGLContext() { - glSetCurrentContextPPAPI(0); -} - -bool OpenGLContext::MakeContextCurrent(pp::Instance* instance) { - - if (instance == NULL) { - glSetCurrentContextPPAPI(0); - return false; - } - // Lazily create the Pepper context. - if (context_.is_null()) { - int32_t attribs[] = { - PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8, - PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24, - PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 8, - PP_GRAPHICS3DATTRIB_SAMPLES, 0, - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0, - PP_GRAPHICS3DATTRIB_WIDTH, width, - PP_GRAPHICS3DATTRIB_HEIGHT, height, - PP_GRAPHICS3DATTRIB_NONE - }; - - context_ = pp::Graphics3D(instance, pp::Graphics3D(), attribs); - if (context_.is_null()) { - glSetCurrentContextPPAPI(0); - return false; - } - instance->BindGraphics(context_); - } - glSetCurrentContextPPAPI(context_.pp_resource()); - return true; -} - -void OpenGLContext::ResizeContext(const pp::Size& size) { - - width = size.width(); - height = size.height(); - - if (!context_.is_null()) { - context_.ResizeBuffers(size.width(), size.height()); - } -} - - -void OpenGLContext::InvalidateContext(pp::Instance* instance) { - glSetCurrentContextPPAPI(0); -} - -void OpenGLContext::FlushContext() { - if (flush_pending()) { - // A flush is pending so do nothing; just drop this flush on the floor. - return; - } - set_flush_pending(true); - - OSNacl* os = (OSNacl*)OS::get_singleton(); - MakeContextCurrent(instance); - os->iterate(); - - context_.SwapBuffers(pp::CompletionCallback(&FlushCallback, this)); -} - diff --git a/platform/nacl/opengl_context.h b/platform/nacl/opengl_context.h deleted file mode 100644 index f03a4b3e53c..00000000000 --- a/platform/nacl/opengl_context.h +++ /dev/null @@ -1,124 +0,0 @@ -/*************************************************************************/ -/* opengl_context.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef EXAMPLES_TUMBLER_OPENGL_CONTEXT_H_ -#define EXAMPLES_TUMBLER_OPENGL_CONTEXT_H_ - -/// -/// @file -/// OpenGLContext manages the OpenGL context in the browser that is associated -/// with a @a pp::Instance instance. -/// - -#include - -#include -#include - -#include "ppapi/c/ppb_opengles2.h" -//#include "ppapi/cpp/dev/context_3d_dev.h" -#include "ppapi/cpp/graphics_3d_client.h" -#include "ppapi/cpp/graphics_3d.h" -//#include "ppapi/cpp/dev/surface_3d_dev.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/size.h" - -// A convenience wrapper for a shared OpenGLContext pointer type. As other -// smart pointer types are needed, add them here. - -#include - -class OpenGLContext; - -typedef std::tr1::shared_ptr SharedOpenGLContext; - -/// OpenGLContext manages an OpenGL rendering context in the browser. -/// -class OpenGLContext : public pp::Graphics3DClient { - public: - explicit OpenGLContext(pp::Instance* instance); - - /// Release all the in-browser resources used by this context, and make this - /// context invalid. - virtual ~OpenGLContext(); - - /// The Graphics3DClient interfcace. - virtual void Graphics3DContextLost() { - assert(!"Unexpectedly lost graphics context"); - } - - /// Make @a this the current 3D context in @a instance. - /// @param instance The instance of the NaCl module that will receive the - /// the current 3D context. - /// @return success. - bool MakeContextCurrent(pp::Instance* instance); - - /// Flush the contents of this context to the browser's 3D device. - void FlushContext(); - - /// Make the underlying 3D device invalid, so that any subsequent rendering - /// commands will have no effect. The next call to MakeContextCurrent() will - /// cause the underlying 3D device to get rebound and start receiving - /// receiving rendering commands again. Use InvalidateContext(), for - /// example, when resizing the context's viewing area. - void InvalidateContext(pp::Instance* instance); - - void ResizeContext(const pp::Size& size); - - /// The OpenGL ES 2.0 interface. - const struct PPB_OpenGLES2_Dev* gles2() const { - return gles2_interface_; - } - - /// The PP_Resource needed to make GLES2 calls through the Pepper interface. - const PP_Resource gl_context() const { - return context_.pp_resource(); - } - - /// Indicate whether a flush is pending. This can only be called from the - /// main thread; it is not thread safe. - bool flush_pending() const { - return flush_pending_; - } - void set_flush_pending(bool flag) { - flush_pending_ = flag; - } - - private: - pp::Graphics3D context_; - bool flush_pending_; - - int width, height; - - pp::Instance* instance; - - const struct PPB_OpenGLES2_Dev* gles2_interface_; -}; - -#endif // EXAMPLES_TUMBLER_OPENGL_CONTEXT_H_ - diff --git a/platform/nacl/os_nacl.h b/platform/nacl/os_nacl.h deleted file mode 100644 index 689aa07e207..00000000000 --- a/platform/nacl/os_nacl.h +++ /dev/null @@ -1,156 +0,0 @@ -/*************************************************************************/ -/* os_nacl.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef OS_NACL_H -#define OS_NACL_H - -#include "core/os/os.h" - -#include "servers/visual_server.h" -#include "servers/visual/rasterizer.h" -#include "servers/physics/physics_server_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" -#include "servers/audio/audio_server_sw.h" -#include "servers/physics_2d/physics_2d_server_sw.h" -#include "audio_driver_nacl.h" -#include "os/input.h" - - -#include - -class OSNacl : OS { - - uint64_t ticks_start; - -protected: - - enum { - MAX_EVENTS = 64, - }; - - MainLoop *main_loop; - - Rasterizer *rasterizer; - VisualServer *visual_server; - PhysicsServer *physics_server; - SpatialSoundServerSW *spatial_sound_server; - - AudioServerSW *audio_server; - SampleManagerMallocSW *sample_manager; - SpatialSound2DServerSW *spatial_sound_2d_server; - Physics2DServer *physics_2d_server; - AudioDriverNacl* audio_driver; - - - // functions used by main to initialize/deintialize the OS - virtual int get_video_driver_count() const; - virtual const char * get_video_driver_name(int p_driver) const; - - virtual VideoMode get_default_video_mode() const; - - virtual int get_audio_driver_count() const; - virtual const char * get_audio_driver_name(int p_driver) const; - - void vprint(const char* p_format, va_list p_list, bool p_stderr); - - virtual void initialize_core(); - virtual void initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver); - - virtual void set_main_loop( MainLoop * p_main_loop ); - virtual void delete_main_loop(); - - virtual void finalize(); - virtual void finalize_core(); - - int mouse_last_x, mouse_last_y; - - InputEvent event_queue[MAX_EVENTS]; - int event_count; - void queue_event(const InputEvent& p_event); - - int event_id; - uint32_t mouse_mask; - - uint32_t last_scancode; - - bool minimized; - - VideoMode video_mode; - - InputDefault *input; - -public: - - void add_package(String p_name, Vector p_data); - - void handle_event(const pp::InputEvent& p_event); - - virtual void alert(const String& p_alert,const String& p_title); - virtual String get_stdin_string(bool p_block); - - virtual void set_mouse_show(bool p_show); - virtual void set_mouse_grab(bool p_grab); - virtual bool is_mouse_grab_enabled() const; - virtual Point2 get_mouse_pos() const; - virtual int get_mouse_button_state() const; - virtual void set_window_title(const String& p_title); - - virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen); - virtual VideoMode get_video_mode(int p_screen) const; - virtual void get_fullscreen_mode_list(List *p_list,int p_screen) const; - - virtual Error execute(const String& p_path, const List& p_arguments,bool p_blocking,ProcessID *r_child_id=NULL,String* r_pipe=NULL,int *r_exitcode=NULL); - virtual Error kill(const ProcessID& p_pid); - - virtual bool has_environment(const String& p_var) const; - virtual String get_environment(const String& p_var) const; - - virtual void set_cursor_shape(CursorShape p_shape); - - virtual String get_name(); - - virtual MainLoop *get_main_loop() const; - - virtual Date get_date(bool utc) const; - virtual Time get_time(bool utc) const; - - virtual void delay_usec(uint32_t p_usec) const; - virtual uint64_t get_ticks_usec() const; - - virtual String get_resource_dir() const; - - virtual bool can_draw() const; - - bool iterate(); - - OSNacl(); - ~OSNacl(); -}; - -#endif // OS_NACL_H diff --git a/platform/nacl/pepper_main.cpp b/platform/nacl/pepper_main.cpp deleted file mode 100644 index 6b817766246..00000000000 --- a/platform/nacl/pepper_main.cpp +++ /dev/null @@ -1,541 +0,0 @@ -/*************************************************************************/ -/* pepper_main.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. - ("Apple") in consideration of your agreement to the following terms, and - your use, installation, modification or redistribution of this Apple software - constitutes acceptance of these terms. If you do not agree with these terms, - please do not use, install, modify or redistribute this Apple software. - - In consideration of your agreement to abide by the following terms, and - subject to these terms, Apple grants you a personal, non-exclusive license, - under Apple's copyrights in this original Apple software - (the "Apple Software"), to use, reproduce, modify and redistribute the Apple - Software, with or without modifications, in source and/or binary forms; - provided that if you redistribute the Apple Software in its entirety and - without modifications, you must retain this notice and the following text and - disclaimers in all such redistributions of the Apple Software. Neither the - name, trademarks, service marks or logos of Apple Computer, Inc. may be used - to endorse or promote products derived from the Apple Software without - specific prior written permission from Apple. Except as expressly stated in - this notice, no other rights or licenses, express or implied, are granted by - Apple herein, including but not limited to any patent rights that may be - infringed by your derivative works or by other works in which the Apple - Software may be incorporated. - - The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO - WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED - WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN - COMBINATION WITH YOUR PRODUCTS. - - IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION - AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER - THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR - OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "os_nacl.h" -#include - -#include -#include -#include -#include - -static NPNetscapeFuncs kBrowserFuncs = { 0 }; -static NPNetscapeFuncs* browser = &kBrowserFuncs; - -static NPDevice* device3d_ = NULL; -static PGLContext pgl_context_; -static NPDeviceContext3D context3d_; -static int width_; -static int height_; - -extern int nacl_main(int argc, char** argn, char** argv); -extern void nacl_cleanup(); - -NPExtensions* extensions = NULL; -static NPP npp_; - -const int32_t kCommandBufferSize = 1024 * 1024; - -// Plugin entry points -extern "C" { - -// Plugin entry points - -// Entrypoints ----------------------------------------------------------------- - -NPError NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) { - plugin_funcs->version = 11; - plugin_funcs->size = sizeof(plugin_funcs); - plugin_funcs->newp = NPP_New; - plugin_funcs->destroy = NPP_Destroy; - plugin_funcs->setwindow = NPP_SetWindow; - plugin_funcs->newstream = NPP_NewStream; - plugin_funcs->destroystream = NPP_DestroyStream; - plugin_funcs->asfile = NPP_StreamAsFile; - plugin_funcs->writeready = NPP_WriteReady; - plugin_funcs->write = (NPP_WriteUPP)NPP_Write; - plugin_funcs->print = NPP_Print; - plugin_funcs->event = NPP_HandleEvent; - plugin_funcs->urlnotify = NPP_URLNotify; - plugin_funcs->getvalue = NPP_GetValue; - plugin_funcs->setvalue = NPP_SetValue; - - return NPERR_NO_ERROR; -} - -NPError NP_Shutdown() { - pglTerminate(); - return NPERR_NO_ERROR; -} - -NPError NP_GetValue(void* instance, NPPVariable variable, void* value); -char* NP_GetMIMEDescription(); - -NPError NP_Initialize(NPNetscapeFuncs* browser_funcs, - NPPluginFuncs* plugin_funcs) { - printf("NPP_Initialize\n"); - memcpy(&kBrowserFuncs, browser_funcs, sizeof(kBrowserFuncs)); - pglInitialize(); - return NP_GetEntryPoints(plugin_funcs); -} - - -} // extern "C" - -void Initialize3D() { - // Initialize a 3D context. - NPDeviceContext3DConfig config; - config.commandBufferSize = kCommandBufferSize; - NPError err = device3d_->initializeContext(npp_, &config, &context3d_); - if (err != NPERR_NO_ERROR) { - printf("Failed to initialize 3D context\n"); - exit(1); - } - - // Create a PGL context. - pgl_context_ = pglCreateContext(npp_, device3d_, &context3d_); - - // Initialize the demo GL state. - //pglMakeCurrent(pgl_context_); - //GLFromCPPInit(); - //pglMakeCurrent(NULL); -} - -NPError NPP_New(NPMIMEType pluginType, - NPP instance, - uint16_t mode, - int16_t argc, char* argn[], char* argv[], - NPSavedData* saved) { - printf("NPP_New\n"); - if (browser->version >= 14) { - - npp_ = instance; - if (!extensions) { - browser->getvalue(npp_, NPNVPepperExtensions, - reinterpret_cast(&extensions)); - // CHECK(extensions); - } - - printf("%s: %i\n", __FUNCTION__, __LINE__); - - device3d_ = extensions->acquireDevice(npp_, NPPepper3DDevice); - if (device3d_ == NULL) { - printf("Failed to acquire 3DDevice\n"); - exit(1); - } - printf("%s: %i\n", __FUNCTION__, __LINE__); - - /* - deviceaudio_ = extensions->acquireDevice(npp_, NPPepperAudioDevice); - if (deviceaudio_ == NULL) { - printf("Failed to acquire AudioDevice\n"); - exit(1); - } - */ - Initialize3D(); - pglMakeCurrent(pgl_context_); - nacl_main(argc, argn, argv); - pglMakeCurrent(NULL); - }; - - return NPERR_NO_ERROR; -} - -NPError NPP_Destroy(NPP instance, NPSavedData** save) { - - nacl_cleanup(); - - return NPERR_NO_ERROR; -} - -void Destroy3D() { - printf("destroy 3d\n"); - // Destroy the PGL context. - pglDestroyContext(pgl_context_); - pgl_context_ = NULL; - - // Destroy the Device3D context. - device3d_->destroyContext(npp_, &context3d_); -} - -static void iteration(void* data) { - - (void)data; - OSNacl* os = (OSNacl*)OS::get_singleton(); - - if (!pglMakeCurrent(pgl_context_) && pglGetError() == PGL_CONTEXT_LOST) { - printf("******* Lost context! :O\n"); - Destroy3D(); - Initialize3D(); - pglMakeCurrent(pgl_context_); - } - - glViewport(0, 0, width_, height_); - - os->iterate(); - - pglSwapBuffers(); - pglMakeCurrent(NULL); - - browser->pluginthreadasynccall(npp_, iteration, NULL); -}; - -NPError NPP_SetWindow(NPP instance, NPWindow* window) { - - width_ = window->width; - height_ = window->height; - - if (!pgl_context_) - Initialize3D(); - - // Schedule the first call to Draw. - OSNacl* os = (OSNacl*)OS::get_singleton(); - OS::VideoMode vm; - vm.width = width_; - vm.height = height_; - vm.resizable = false; - vm.fullscreen = false; - os->set_video_mode(vm); - - browser->pluginthreadasynccall(npp_, iteration, NULL); - - return NPERR_NO_ERROR; -} - -NPError NPP_NewStream(NPP instance, - NPMIMEType type, - NPStream* stream, - NPBool seekable, - uint16_t* stype) { - *stype = NP_ASFILEONLY; - return NPERR_NO_ERROR; -} - -NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason) { - return NPERR_NO_ERROR; -} - -void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname) { -} - -int32_t NPP_Write(NPP instance, - NPStream* stream, - int32_t offset, - int32_t len, - void* buffer) { - return 0; -} - -int32_t NPP_WriteReady(NPP instance, NPStream* stream) { - return 0; -} - -void NPP_Print(NPP instance, NPPrint* platformPrint) { -} - -int16_t NPP_HandleEvent(NPP instance, void* event) { - - OSNacl* os = (OSNacl*)OS::get_singleton(); - os->handle_event(event); - return 1; -} - -void NPP_URLNotify(NPP instance, - const char* url, - NPReason reason, - void* notify_data) { - // PluginObject* obj = static_cast(instance->pdata); -} - -static NPObject* Allocate(NPP npp, NPClass* npclass) { - return new NPObject; -} - -static void Deallocate(NPObject* object) { - delete object; -} - -// Return |true| if |method_name| is a recognized method. -static bool HasMethod(NPObject* obj, NPIdentifier method_name) { - - char *name = NPN_UTF8FromIdentifier(method_name); - bool is_method = false; - if (strcmp((const char *)name, "start_package") == 0) { - is_method = true; - } else if (strcmp((const char*)name, "add_package_chunk") == 0) { - is_method = true; - } else if (strcmp((const char*)name, "end_package") == 0) { - is_method = true; - } else if (strcmp((const char*)name, "start_scene") == 0) { - is_method = true; - } - NPN_MemFree(name); - return is_method; -} - -// I don't know what this is -static bool InvokeDefault(NPObject *obj, const NPVariant *args, - uint32_t argCount, NPVariant *result) { - if (result) { - NULL_TO_NPVARIANT(*result); - } - return true; -} - -static uint8_t* mem = NULL; -static int pkg_size = 0; -static String pkgname; - -static bool variant_is_number(const NPVariant& v) { - - switch (v.type) { - - case NPVariantType_Int32: - case NPVariantType_Double: - return true; - - default: - return false; - } - return false; -}; - -static double variant_as_number(const NPVariant& v) { - - switch (v.type) { - - case NPVariantType_Int32: - return (double)v.value.intValue; - case NPVariantType_Double: - return (double)v.value.doubleValue; - default: - return 0; - } - - return 0; -}; - -// Invoke() is called by the browser to invoke a function object whose name -// is |method_name|. -static bool Invoke(NPObject* obj, - NPIdentifier method_name, - const NPVariant *args, - uint32_t arg_count, - NPVariant *result) { - NULL_TO_NPVARIANT(*result); - char *name = NPN_UTF8FromIdentifier(method_name); - if (name == NULL) - return false; - bool rval = false; - - OSNacl* os = (OSNacl*)OS::get_singleton(); - - if (strcmp(name, "start_package") == 0) { - - printf("arg count is %i\n", arg_count); - for (int i=0; iadd_package(pkgname, mem, pkg_size); - return true; - }; - - - if (strcmp(name, "start_scene") == 0) { -printf("start_scene!\n"); - if (arg_count != 1) { - return false; - }; - - if (args[0].type != NPVariantType_String) return false; -printf("calling with param %s\n", args[0].value.stringValue.UTF8Characters); - - printf("pepper iteration\n"); - if (!pglMakeCurrent(pgl_context_) && pglGetError() == PGL_CONTEXT_LOST) { - printf("******* Lost context! :O\n"); - Destroy3D(); - Initialize3D(); - pglMakeCurrent(pgl_context_); - } - os->start_scene(String::utf8(args[0].value.stringValue.UTF8Characters)); - pglSwapBuffers(); - pglMakeCurrent(NULL); - -printf("returning true\n"); - return true; - }; - - NPN_MemFree(name); - - return rval; -} - - -static NPClass GodotClass = { - NP_CLASS_STRUCT_VERSION, - Allocate, - Deallocate, - NULL, // Invalidate is not implemented - HasMethod, - Invoke, - InvokeDefault, - NULL, // HasProperty is not implemented - NULL, // GetProperty is not implemented - NULL, // SetProperty is not implemented -}; - -static NPObject* npobject = NULL; - -NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) { - NPError err = NPERR_NO_ERROR; - - switch (variable) { - case NPPVpluginNameString: - *(reinterpret_cast(value)) = "Pepper Test PlugIn"; - break; - case NPPVpluginDescriptionString: - *(reinterpret_cast(value)) = - "Simple Pepper plug-in for manual testing."; - break; - case NPPVpluginNeedsXEmbed: - *(reinterpret_cast(value)) = 1; - break; - case NPPVpluginScriptableNPObject: { - if (npobject == NULL) { - npobject = NPN_CreateObject(instance, &GodotClass); - } else { - NPN_RetainObject(npobject); - }; - void** v = reinterpret_cast(value); - *v = npobject; - } break; - default: - fprintf(stderr, "Unhandled variable to NPP_GetValue\n"); - err = NPERR_GENERIC_ERROR; - break; - } - - return err; -} - -NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value) { - return NPERR_GENERIC_ERROR; -} - -NPError NP_GetValue(void* instance, NPPVariable variable, void* value) { - return NPP_GetValue(reinterpret_cast(instance), variable, value); -} - -char* NP_GetMIMEDescription() { - return const_cast("pepper-application/x-pepper-test-plugin;"); -} diff --git a/platform/nacl/platform_config.h b/platform/nacl/platform_config.h deleted file mode 100644 index 143f16c1fa7..00000000000 --- a/platform/nacl/platform_config.h +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************/ -/* platform_config.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include