小编hae*_*ehn的帖子

在Xfvb中渲染WebGL

我想使用Xvfb无头测试WebGL代码.有谁知道怎么做?

我有2台机器 - 都运行Ubuntu.一个使用NVidia卡,另一个使用ATI:

NVidia机器:

ipmi:~ $>xvfb-run glxinfo
name of display: :455
display: :455  screen: 0
direct rendering: No (If you want to find out why, try setting LIBGL_DEBUG=verbose)
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
    GLX_ARB_multisample, GLX_EXT_visual_info, GLX_EXT_visual_rating, 
    GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, GLX_OML_swap_method, 
    GLX_SGI_make_current_read, GLX_SGIS_multisample, GLX_SGIX_fbconfig, 
    GLX_SGIX_pbuffer, GLX_MESA_copy_sub_buffer, GLX_INTEL_swap_event
client glx vendor string: NVIDIA Corporation
client glx version string: 1.4
...

ipmi:~ $>xvfb-run glxgears
3725 frames in 5.0 seconds = 741.884 FPS
3840 frames in …
Run Code Online (Sandbox Code Playgroud)

webgl xvfb

5
推荐指数
1
解决办法
2334
查看次数

用defineProperty替换原型上的__defineGetter__和__defineSetter__

我目前使用以下语法来定义具有getter和setter的类.

SomeObject = function() {

  this._propertyOne = 'test';

}

SomeObject.prototype.__defineGetter__('propertyOne', function() {

  return this._propertyOne;

});

SomeObject.prototype.__defineSetter__('propertyOne', function(value) {

  this._propertyOne = value;

});
Run Code Online (Sandbox Code Playgroud)

然后我可以像这样访问该属性:

var o = new SomeObject();
o.propertyOne = 'test2';
console.log(o.propertyOne);
Run Code Online (Sandbox Code Playgroud)

如何使用非弃用的defineProperty命令或类似的东西实现相同的功能?

我试过这样的事情:

Object.defineProperty(SomeObject.prototype, 'propertyOne', {
  get: function() {

    return this._propertyOne;

  }.bind(this),
  set: function(value) {

    this._propertyOne = value;

  }.bind(this)
});
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

javascript

1
推荐指数
1
解决办法
1851
查看次数

标签 统计

javascript ×1

webgl ×1

xvfb ×1