Changeset 1440
- Timestamp:
- Jun 5, 2012, 8:15:56 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 1 deleted
- 3 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Makefile.am
r1406 r1440 72 72 if USE_NACL 73 73 nacl_sources = \ 74 platform/nacl/nacl app.cpp platform/nacl/naclapp.h \75 platform/nacl/nacl _instance.cpp platform/nacl/nacl_instance.h \76 platform/nacl/nacl _module.cpp \74 platform/nacl/nacl-app.cpp platform/nacl/nacl-app.h \ 75 platform/nacl/nacl-instance.cpp platform/nacl/nacl-instance.h \ 76 platform/nacl/nacl-module.cpp \ 77 77 platform/nacl/opengl_context.cpp platform/nacl/opengl_context.h \ 78 78 platform/nacl/opengl_context_ptrs.h -
trunk/src/application/application.cpp
r1219 r1440 21 21 # include "platform/xbox/xboxapp.h" 22 22 #elif defined __native_client__ 23 # include "platform/nacl/nacl app.h"23 # include "platform/nacl/nacl-app.h" 24 24 #elif defined __ANDROID__ 25 25 # include "platform/android/androidapp.h" -
trunk/src/platform/nacl/nacl-app.cpp
r1439 r1440 13 13 #endif 14 14 15 #if defined __native_client__ 16 # include <ppapi/cpp/instance.h> 17 # include <ppapi/cpp/module.h> 18 # include <ppapi/cpp/var.h> 19 #endif 15 #include "core.h" 20 16 21 #include "core.h" 22 #include "lolgl.h" 23 #include "naclapp.h" 17 #include "nacl-app.h" 18 #include "nacl-instance.h" 24 19 25 20 namespace lol … … 46 41 data(new NaClAppData()) 47 42 { 43 Ticker::Setup(fps); 48 44 #if defined __native_client__ 49 45 #endif … … 57 53 void NaClApp::Run() 58 54 { 59 while (!Ticker::Finished()) 60 { 61 /* Tick the renderer, show the frame and clamp to desired framerate. */ 62 Ticker::TickDraw(); 55 #if defined __native_client__ 56 NaClInstance::MainSignal(); 57 #endif 63 58 64 #if defined __native_client__ 65 #endif 66 }59 /* Wait forever */ 60 Queue<int, 1> q; 61 q.Pop(); 67 62 } 68 63 -
trunk/src/platform/nacl/nacl-instance.cpp
r1439 r1440 11 11 #include <cstring> 12 12 #include <string> 13 #include <vector>14 13 15 14 #include <ppapi/cpp/rect.h> … … 21 20 22 21 #include "core.h" 23 #include "debug/quad.h"24 22 25 #include "platform/nacl/nacl _instance.h"23 #include "platform/nacl/nacl-instance.h" 26 24 #include "platform/nacl/opengl_context.h" 27 25 … … 47 45 { 48 46 // Destroy the cube view while GL context is current. 49 opengl_context_->MakeContextCurrent(this);47 m_opengl_ctx->MakeContextCurrent(this); 50 48 } 51 49 … … 85 83 } 86 84 85 Mutex NaClInstance::main_mutex; 86 Queue<NaClInstance::Args *, 1> NaClInstance::main_queue; 87 87 88 bool NaClInstance::Init(uint32_t argc, 88 89 const char* /* argn */[], 89 90 const char* argv[]) 90 91 { 91 Ticker::Setup(60.0f); 92 93 /* Call the user's main() function. FIXME: run it in a thread */ 92 /* Ensure only one NaClInstance does Init() at the same time. */ 93 main_mutex.Lock(); 94 94 char *env[] = { NULL }; 95 lol_nacl_main(); 96 lol_nacl_main(argc, const_cast<char **>(argv)); 97 lol_nacl_main(argc, const_cast<char **>(argv), (char **)env); 95 Args arglist(argc, const_cast<char **>(argv), const_cast<char **>(env)); 96 main_queue.Push(&arglist); 97 m_main_thread = new Thread(MainRun, NULL); 98 /* Push so that only MainSignal() can unblock us */ 99 main_queue.Push(NULL); 100 main_queue.Push(NULL); 101 main_mutex.Unlock(); 98 102 99 103 // My timer callback … … 108 112 } 109 113 110 void NaClInstance::RunMain(uint32_t argc, 111 const char* /* argn */[], 112 const char* argv[]) 114 void * NaClInstance::MainRun(void *data) 113 115 { 116 Args *arglist = main_queue.Pop(); 114 117 118 /* Call the user's main() function. One of these will work. */ 119 lol_nacl_main(); 120 lol_nacl_main(arglist->m_argc, arglist->m_argv); 121 lol_nacl_main(arglist->m_argc, arglist->m_argv, arglist->m_env); 122 123 return NULL; 124 } 125 126 void NaClInstance::MainSignal() 127 { 128 /* FIXME: find something more elegant. */ 129 main_queue.Pop(); 130 main_queue.Pop(); 115 131 } 116 132 … … 130 146 m_size = ivec2(position.size().width(), position.size().height()); 131 147 132 if ( opengl_context_== NULL)133 opengl_context_.reset(new OpenGLContext(this));134 opengl_context_->InvalidateContext(this);135 opengl_context_->ResizeContext(position.size());136 if (! opengl_context_->MakeContextCurrent(this))148 if (m_opengl_ctx == NULL) 149 m_opengl_ctx.reset(new OpenGLContext(this)); 150 m_opengl_ctx->InvalidateContext(this); 151 m_opengl_ctx->ResizeContext(position.size()); 152 if (!m_opengl_ctx->MakeContextCurrent(this)) 137 153 return; 138 154 … … 152 168 break; 153 169 case PP_INPUTEVENT_TYPE_MOUSEMOVE: 154 Input::SetMousePos(ivec2(pp::MouseInputEvent(event).GetPosition().x(), opengl_context_->GetSize().height() - 1 - pp::MouseInputEvent(event).GetPosition().y()));170 Input::SetMousePos(ivec2(pp::MouseInputEvent(event).GetPosition().x(), m_opengl_ctx->GetSize().height() - 1 - pp::MouseInputEvent(event).GetPosition().y())); 155 171 break; 156 172 default: … … 162 178 void NaClInstance::DrawSelf() 163 179 { 164 if ( opengl_context_== NULL)180 if (m_opengl_ctx == NULL) 165 181 return; 166 182 167 opengl_context_->MakeContextCurrent(this);183 m_opengl_ctx->MakeContextCurrent(this); 168 184 Ticker::TickDraw(); 169 opengl_context_->FlushContext();185 m_opengl_ctx->FlushContext(); 170 186 } 171 187 -
trunk/src/platform/nacl/nacl-module.cpp
r1439 r1440 12 12 13 13 #include "core.h" 14 #include "lolgl.h" 14 #include "lolgl.h" /* needed for GL_TRUE */ 15 15 16 #include "platform/nacl/nacl _instance.h"16 #include "platform/nacl/nacl-instance.h" 17 17 18 18 /// The Module class. The browser calls the CreateInstance() method to create -
trunk/src/platform/nacl/opengl_context.h
r1087 r1440 70 70 71 71 /// The PP_Resource needed to make GLES2 calls through the Pepper interface. 72 constPP_Resource gl_context() const {72 PP_Resource gl_context() const { 73 73 return context_.pp_resource(); 74 74 }
Note: See TracChangeset
for help on using the changeset viewer.