Esempio n. 1
0
  bool InitGL(int32_t new_width, int32_t new_height) {
    if (!glInitializePPAPI(pp::Module::Get()->get_browser_interface())) {
      fprintf(stderr, "Unable to initialize GL PPAPI!\n");
      return false;
    }

    const int32_t attrib_list[] = {
      PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
      PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24,
      PP_GRAPHICS3DATTRIB_WIDTH, new_width,
      PP_GRAPHICS3DATTRIB_HEIGHT, new_height,
      PP_GRAPHICS3DATTRIB_NONE
    };

    context_ = pp::Graphics3D(this, attrib_list);
    if (!BindGraphics(context_)) {
      fprintf(stderr, "Unable to bind 3d context!\n");
      context_ = pp::Graphics3D();
      glSetCurrentContextPPAPI(0);
      return false;
    }

    glSetCurrentContextPPAPI(context_.pp_resource());
    return true;
  }
Esempio n. 2
0
bool NaCl::init(int32_t new_width, int32_t new_height) {
    lout << "init opengl" << endl;
    if (!glInitializePPAPI(pp::Module::Get()->get_browser_interface())) {
        return false;
    }

    const int32_t attrib_list[] = {
        PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
        PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24,
        PP_GRAPHICS3DATTRIB_WIDTH, new_width,
        PP_GRAPHICS3DATTRIB_HEIGHT, new_height,
        PP_GRAPHICS3DATTRIB_NONE
    };

    context = pp::Graphics3D(this, attrib_list);
    if (!BindGraphics(context)) {
        context = pp::Graphics3D();
        glSetCurrentContextPPAPI(0);
        return false;
    }

    glSetCurrentContextPPAPI(context.pp_resource());
    game.init(new_width, new_height);
    return true;
}
Esempio n. 3
0
bool DiagrammarInterface::InitGL(int32_t width, int32_t height) {
  if (!glInitializePPAPI(pp::Module::Get()->get_browser_interface())) {
    std::cerr << "Unable to initialize GL PPAPI!\n";
    return false;
  }
  if (context_.is_null()) {
    int32_t attrib_list[] = {
        PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
        PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24,
        PP_GRAPHICS3DATTRIB_WIDTH,      width,
        PP_GRAPHICS3DATTRIB_HEIGHT,     height,
        PP_GRAPHICS3DATTRIB_NONE,
    };
    context_ = pp::Graphics3D(this, attrib_list);

    assert(!context_.is_null());

    if (!BindGraphics(context_)) {
      std::cerr << "Unable to bind 3d context!\n";
      context_ = pp::Graphics3D();
      glSetCurrentContextPPAPI(0);
      return false;
    }
  }

  return true;
}
Esempio n. 4
0
PP_EXPORT int32_t PPP_InitializeModule(PP_Module _module, PPB_GetInterface _interface)
{
	s_ctx.m_module = _module;

	bool result = true;
	result &= initializeInterface(s_ctx.m_instInterface, _interface, PPB_INSTANCE_INTERFACE);
	result &= initializeInterface(s_ctx.m_graphicsInterface, _interface, PPB_GRAPHICS_3D_INTERFACE);
	result &= glInitializePPAPI(_interface);

	return result ? PP_OK : PP_ERROR_NOINTERFACE;
}
Esempio n. 5
0
int32_t PPP_InitializeModule(PP_Module mod, PPB_GetInterface get_interface) {
  g_module = mod;

  if(_internal_VLCInitializeGetInterface(get_interface) != PP_TRUE) {
    return PP_FALSE;
  }

  if(!glInitializePPAPI(get_interface)) {
    printf("failed to initialize ppapi gles2 interface");
    abort();
    return PP_FALSE;
  } else {
    return PP_OK;
  }
}
/**
 * Entry points for the module.
 * Initialize needed interfaces: PPB_Core, PPB_Messaging and PPB_Var.
 * @param[in] a_module_id module ID
 * @param[in] get_browser pointer to PPB_GetInterface
 * @return PP_OK on success, any other value on failure.
 */
PP_EXPORT int32_t PPP_InitializeModule(PP_Module a_module_id,
                                       PPB_GetInterface get_browser)
{
    psNaCLContext = (NaCLContext*)malloc(sizeof(NaCLContext));

    psNaCLContext->psMessagingInterface =
      (PPB_Messaging*)(get_browser(PPB_MESSAGING_INTERFACE));

    psNaCLContext->psVarInterface = (PPB_Var*)(get_browser(PPB_VAR_INTERFACE));

    if(!glInitializePPAPI(get_browser))
    {
      return PP_ERROR_FAILED;
    }

    psNaCLContext->psGL = (PPB_OpenGLES2*)get_browser(PPB_OPENGLES2_INTERFACE);

    psNaCLContext->psG3D = (PPB_Graphics3D*)get_browser(PPB_GRAPHICS_3D_INTERFACE);

    psNaCLContext->psInstanceInterface = (PPB_Instance*)get_browser(PPB_INSTANCE_INTERFACE);

    psNaCLContext->psView = (PPB_View*)get_browser(PPB_VIEW_INTERFACE);

    psNaCLContext->psCore = (PPB_Core*)get_browser(PPB_CORE_INTERFACE);

    psNaCLContext->psVar = (PPB_Var*)get_browser(PPB_VAR_INTERFACE);

    psNaCLContext->psInputEventInterface = (PPB_InputEvent*)get_browser(PPB_INPUT_EVENT_INTERFACE);

    psNaCLContext->psKeyboard = (PPB_KeyboardInputEvent*)get_browser(PPB_KEYBOARD_INPUT_EVENT_INTERFACE);

    psNaCLContext->psURLRequest = (PPB_URLRequestInfo*) get_browser(PPB_URLREQUESTINFO_INTERFACE);

    psNaCLContext->psURLLoader = (PPB_URLLoader*) get_browser(PPB_URLLOADER_INTERFACE);

    return PP_OK;
}
Esempio n. 7
0
PP_EXPORT int32_t PPP_InitializeModule(PP_Module /*a_module_id*/, PPB_GetInterface get_browser)
{
	ppb_core_interface =                             (PPB_Core*)(get_browser(PPB_CORE_INTERFACE));
	ppb_messaging_interface =                   (PPB_Messaging*)(get_browser(PPB_MESSAGING_INTERFACE));
	ppb_var_interface =                               (PPB_Var*)(get_browser(PPB_VAR_INTERFACE));
	ppb_audio_interface =                           (PPB_Audio*)(get_browser(PPB_AUDIO_INTERFACE));
	ppb_audioconfig_interface =               (PPB_AudioConfig*)(get_browser(PPB_AUDIO_CONFIG_INTERFACE));
	ppb_instance_interface =                     (PPB_Instance*)(get_browser(PPB_INSTANCE_INTERFACE));
	ppb_graphics3d_interface =                 (PPB_Graphics3D*)(get_browser(PPB_GRAPHICS_3D_INTERFACE));
	ppb_view_interface =                             (PPB_View*)(get_browser(PPB_VIEW_INTERFACE));
	ppb_urlloader_interface =                   (PPB_URLLoader*)(get_browser(PPB_URLLOADER_INTERFACE));
	ppb_urlrequestinfo_interface =         (PPB_URLRequestInfo*)(get_browser(PPB_URLREQUESTINFO_INTERFACE));
	ppb_urlresponseinfo_interface =       (PPB_URLResponseInfo*)(get_browser(PPB_URLRESPONSEINFO_INTERFACE));
	ppb_inputevent_interface =                 (PPB_InputEvent*)(get_browser(PPB_INPUT_EVENT_INTERFACE));
	ppb_mouseinputevent_interface =       (PPB_MouseInputEvent*)(get_browser(PPB_MOUSE_INPUT_EVENT_INTERFACE));
	ppb_wheelinputevent_interface =       (PPB_WheelInputEvent*)(get_browser(PPB_WHEEL_INPUT_EVENT_INTERFACE));
	ppb_keyboardinputevent_interface = (PPB_KeyboardInputEvent*)(get_browser(PPB_KEYBOARD_INPUT_EVENT_INTERFACE));
	ppb_fullscreen_interface =                 (PPB_Fullscreen*)(get_browser(PPB_FULLSCREEN_INTERFACE));
	ppb_mouselock_interface =                   (PPB_MouseLock*)(get_browser(PPB_MOUSELOCK_INTERFACE));
	ppb_websocket_interface =                   (PPB_WebSocket*)(get_browser(PPB_WEBSOCKET_INTERFACE));
	ppb_vararraybuffer_interface =         (PPB_VarArrayBuffer*)(get_browser(PPB_VAR_ARRAY_BUFFER_INTERFACE));
	if (glInitializePPAPI(get_browser) != GL_TRUE) return PP_ERROR_NOTSUPPORTED;
	return PP_OK;
}
Esempio n. 8
0
  /// 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());
  }
Esempio n. 9
0
void MoonlightInstance::InitializeRenderingSurface(int width, int height) {
    if (!glInitializePPAPI(pp::Module::Get()->get_browser_interface())) {
        return;
    }
    
    int32_t contextAttributes[] = {
        PP_GRAPHICS3DATTRIB_ALPHA_SIZE,     8,
        PP_GRAPHICS3DATTRIB_BLUE_SIZE,      8,
        PP_GRAPHICS3DATTRIB_GREEN_SIZE,     8,
        PP_GRAPHICS3DATTRIB_RED_SIZE,       8,
        PP_GRAPHICS3DATTRIB_DEPTH_SIZE,     0,
        PP_GRAPHICS3DATTRIB_STENCIL_SIZE,   0,
        PP_GRAPHICS3DATTRIB_SAMPLES,        0,
        PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0,
        PP_GRAPHICS3DATTRIB_WIDTH,          width,
        PP_GRAPHICS3DATTRIB_HEIGHT,         height,
        PP_GRAPHICS3DATTRIB_NONE
    };
    g_Instance->m_Graphics3D = pp::Graphics3D(this, contextAttributes);
    
    int32_t swapBehaviorAttribute[] = {
        PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR, PP_GRAPHICS3DATTRIB_BUFFER_DESTROYED,
        PP_GRAPHICS3DATTRIB_NONE
    };
    g_Instance->m_Graphics3D.SetAttribs(swapBehaviorAttribute);
    
    if (!BindGraphics(m_Graphics3D)) {
      fprintf(stderr, "Unable to bind 3d context!\n");
      m_Graphics3D = pp::Graphics3D();
      glSetCurrentContextPPAPI(0);
      return;
    }
    
    glSetCurrentContextPPAPI(m_Graphics3D.pp_resource());
    
    glDisable(GL_DITHER);
    
    glViewport(0, 0, width, height);
    
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    
    assertNoGLError();
    
    static const float k_Vertices[] = {
        -1, -1, -1, 1, 1, -1, 1, 1,  // Position coordinates.
        0,  1,  0,  0, 1, 1,  1, 0,  // Texture coordinates.
    };

    GLuint buffer;
    glGenBuffers(1, &buffer);
    glBindBuffer(GL_ARRAY_BUFFER, buffer);

    glBufferData(GL_ARRAY_BUFFER,
                 sizeof(k_Vertices),
                 k_Vertices,
                 GL_STATIC_DRAW);
    assertNoGLError();
    
    g_Instance->m_Graphics3D.SwapBuffers(pp::BlockUntilComplete());
}
 virtual bool Init() {
   return glInitializePPAPI(get_browser_interface()) == GL_TRUE;
 }
Esempio n. 11
0
bool FujiModule::Init()
{
	return glInitializePPAPI(get_browser_interface()) == GL_TRUE;
}
Esempio n. 12
0
/* GL functions */
int
NACL_GLES_LoadLibrary(_THIS, const char *path)
{
    /* FIXME: Support dynamic linking when PNACL supports it */
    return glInitializePPAPI(PSGetInterface) == 0;
}