Java GLColorPointer不是';t使用gldraw数组

Java GLColorPointer不是';t使用gldraw数组,java,android,opengl-es,Java,Android,Opengl Es,我是OpenGL新手,在使用ColorPointer函数和DrawArray时遇到了一些问题。。。我似乎无法用颜色渲染对象。。但当我使用glColor4f函数时,这是可行的。。我认为这与我如何构建我的颜色缓冲区有关。。然而,我似乎无法理解这一点 请看一下我的一些代码,让我知道我在这里做错了什么。。。此外,这是我在Flow Post上的第一个堆栈(: 这是另一个班级的 numOfFacets = ByteBuffer.wrap(numberOfFacets).order(ByteOrder.nat

我是OpenGL新手,在使用ColorPointer函数和DrawArray时遇到了一些问题。。。我似乎无法用颜色渲染对象。。但当我使用glColor4f函数时,这是可行的。。我认为这与我如何构建我的颜色缓冲区有关。。然而,我似乎无法理解这一点

请看一下我的一些代码,让我知道我在这里做错了什么。。。此外,这是我在Flow Post上的第一个堆栈(:

这是另一个班级的

numOfFacets = ByteBuffer.wrap(numberOfFacets).order(ByteOrder.nativeOrder()).getInt();

        // Allocate memory for the FloatBuffers since we now know the number of Facets
        // we use a ByteBuffer to ensure native ordering .........
        // * 3 for each vertex point in 3D (* 3) space. Size of float is 4 bytes
        vertices = ByteBuffer.allocateDirect((numOfFacets * 3 * 3) * 4)
                        .order(ByteOrder.nativeOrder()).asFloatBuffer();

        // * 3 for each coordinate in vector. Size of float is 4 bytes
        normalVectors = ByteBuffer.allocateDirect((numOfFacets * 3) * 4)
                        .order(ByteOrder.nativeOrder()).asFloatBuffer();

        // * 3 for each vertex point in 4D (* 4) RBGA space. Size of float is 4 bytes
        colours = ByteBuffer.allocateDirect((numOfFacets * 3 * 4) * 4)
                .order(ByteOrder.nativeOrder()).asFloatBuffer();

        for(int i = 0 ; i < numOfFacets*3; i++){
            colours.put(new float[] {0.0f, 1.0f, 0.0f, 0.5f});
        }
        colours.position(0);
numfofacets=ByteBuffer.wrap(numberOfFacets.order(ByteOrder.nativeOrder()).getInt();
//为FloatBuffers分配内存,因为我们现在知道了facet的数量
//我们使用ByteBuffer以确保本地订购。。。。。。。。。
//*3表示3D(*3)空间中的每个顶点。浮点大小为4字节
顶点=ByteBuffer.allocateDirect((numFacets*3*3)*4)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
//*3表示矢量中的每个坐标。浮点大小为4字节
normalVectors=ByteBuffer.allocateDirect((numFacets*3)*4)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
//*3表示4D(*4)RBGA空间中的每个顶点。浮点大小为4字节
颜色=ByteBuffer.allocateDirect((numFacets*3*4)*4)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
对于(int i=0;i
我明白了!只是想把答案贴出来,以防它对其他人有帮助(:

愚蠢的错误…看起来我在使用:

gl.glEnable(GL10.gl_彩色_阵列)

而不是

gl.glEnableClientState(GL10.gl\u颜色\u数组)


FloatBuffers存储在客户端堆上,我想OpenGL被认为是服务器端。

我不明白为什么这一点会持续下去,为什么我会处于负面2。建设性的批评也会有所帮助。。
numOfFacets = ByteBuffer.wrap(numberOfFacets).order(ByteOrder.nativeOrder()).getInt();

        // Allocate memory for the FloatBuffers since we now know the number of Facets
        // we use a ByteBuffer to ensure native ordering .........
        // * 3 for each vertex point in 3D (* 3) space. Size of float is 4 bytes
        vertices = ByteBuffer.allocateDirect((numOfFacets * 3 * 3) * 4)
                        .order(ByteOrder.nativeOrder()).asFloatBuffer();

        // * 3 for each coordinate in vector. Size of float is 4 bytes
        normalVectors = ByteBuffer.allocateDirect((numOfFacets * 3) * 4)
                        .order(ByteOrder.nativeOrder()).asFloatBuffer();

        // * 3 for each vertex point in 4D (* 4) RBGA space. Size of float is 4 bytes
        colours = ByteBuffer.allocateDirect((numOfFacets * 3 * 4) * 4)
                .order(ByteOrder.nativeOrder()).asFloatBuffer();

        for(int i = 0 ; i < numOfFacets*3; i++){
            colours.put(new float[] {0.0f, 1.0f, 0.0f, 0.5f});
        }
        colours.position(0);