小编use*_*140的帖子

来自非Activity类的android getResources()

我正在尝试从assets/model.txt加载我的顶点数组我有OpenGLActivity,GLRenderer和Mymodel类我将此行添加到OpenGLActivity:

public static Context context;
Run Code Online (Sandbox Code Playgroud)

这到Mymodel类:

Context context = OpenGLActivity.context;
    AssetManager am = context.getResources().getAssets();
    InputStream is = null;
    try {
        is = am.open("model.txt");
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    Scanner s = new Scanner(is);
    long numfloats = s.nextLong();
    float[] vertices = new float[(int) numfloats];
    for (int ctr = 0; ctr < vertices.length; ctr++) {
        vertices[ctr] = s.nextFloat();
    }
Run Code Online (Sandbox Code Playgroud)

但它确实不起作用(

android opengl-es

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

标签 统计

android ×1

opengl-es ×1