我想獲得一個簡單的renderscript函數來取兩個numnbers,添加它們並返回結果,但是我還沒有設法找到一個可以順利執行的示例項目。 我不斷收到一個奇怪的錯誤,當我嘗試加載該文件:無法獲得簡單的renderscript數學運算功能
ScriptC_myexamplescript myScript;
RenderScript rs = RenderScript.create(this);
我得到的錯誤:
Symbol not found: .rs.dtor on the next line:
myScript = new ScriptC_myexamplescript(rs, getResources(), R.raw.myexamplescript);
我.RS文件只是一些簡單:
#pragma version(1)
#pragma rs java_package_name(com.exercise.<my pacakge name>);
void init(){
}
void root(const float *v_in, float *v_out) {
const float *data = v_in;
float *outData = v_out;
*outData = *data;
}
有誰知道這意味着什麼,或者如果有一個簡單的項目,我可以下載Android ICS和後來做數學,而不是實際的渲染,只是工作?
(我可以得到一個渲染腳本文件的工作,但是這不是我想要的。我不希望在任何圖形)
編輯 今天,我試圖使它運行,得到以下問題:
Allocation mInAllocation = null;
Allocation mOutAllocation;
float[] A = new float[1];
for (int i = 0; i < 1; i++) {
A[i] = 2;
}
Allocation inFloatPointer = Allocation.createSized(rs, Element.F32(rs), A.length, Allocation.USAGE_SCRIPT);
Allocation outFloatPointer = Allocation.createSized(rs, Element.F32(rs), A.length, Allocation.USAGE_SCRIPT);
inFloatPointer.copyFrom(A); // copies from an array of floats (random numbers in this test case).
mScript.forEach_root(inFloatPointer, outFloatPointer);
我得到的錯誤信息: forEach_root是undedifed類型ScriptC_RenderScript 有一個在java文件沒有功能forEach_root甚至後我清理項目,它仍然是不存在的方法。
有沒有一個簡單的項目,我可以下載只有一個數學函數,我可以下載?
後提到的錯誤是出現了錯誤,但是今天我甚至不能得到它當我將forEach_root函數放入時,就像上面提到的那樣編譯。你能指出一個剛剛起作用的示例項目嗎?我認爲這將是最簡單的。 –
您可能會看到Java缺少forEach_root()錯誤,因爲您的目標是早期的API(未反映forEach的Java版本)。嘗試使用更高的目標API(至少ICS)。 SDK包含一個示例HelloCompute基準。我也可以將您指向AOSP資源(http://source.android.com/source/downloading.html)。在AOSP中,您可以在frameworks/base/tests/RenderScriptTests /中查看一些我們用於測試的應用程序。該目錄中的最佳示例可能是ImageProcessing。 –
謝謝。更改API無法正常工作,但是我將手機更新至JB 4.2,現在hellocompute示例適用於數學函數。我不知道是什麼導致了這個問題,但現在已經消失了。 –