Javascript からネイティブ クライアント モジュールに配列バッファーを送信し、配列バッファーを整数ポインターに変換したいと考えています。nacl-sdk ディレクトリにある地球の例を見ました。画像データを渡し、次のように変換します。
//javascript
var imageData = context.getImageData(0, 0, img.width, img.height);
// Send NaCl module the raw image data obtained from canvas.
common.naclModule.postMessage({'message' : 'texture',
'name' : name,
'width' : img.width,
'height' : img.height,
'data' : imageData.data.buffer});
//nativeclient
std::string name = dictionary.Get("name").AsString();
int width = dictionary.Get("width").AsInt();
int height = dictionary.Get("height").AsInt();
pp::VarArrayBuffer array_buffer(dictionary.Get("data"));
if (!name.empty() && !array_buffer.is_null()) {
if (width > 0 && height > 0) {
uint32_t* pixels = static_cast<uint32_t*>(array_buffer.Map());
SetTexture(name, width, height, pixels);
array_buffer.Unmap();
eclipse デバッグを使用していますが、配列バッファーが正しく受信されたかどうか、ピクセルをパラメーターとして関数に渡すことができるかどうか、またはpixels = new uint32_t[size]
渡す前にピクセルを作成する必要があるかどうかを確認する方法がわかりません。uint32_t*
さらに重要なことは、辞書を使用してピクセルをJavascriptに変換しVarArrayBuffer
て送信し、メッセージを投稿する方法と、それを Javascript で受信してメッセージをArrayBuffer
値として処理する方法を知る必要があることです。