public void RecursRender( TriTreeNode tri, int leftX, int leftY, int rightX, int rightY, int apexX, int apexY, GL10 gl ){ //方法定义时使用GL10 gl作为参数没有报错 if ( tri.LeftChild != null ) int centerX = (leftX + rightX)>>1; int centerY = (leftY + rightY)>>1; RecursRender( tri.LeftChild, apexX, apexY, leftX, leftY, centerX, centerY, GL10 gl ); RecursRender( tri.RightChild, rightX, rightY, apexX, apexY, centerX, centerY, GL10 gl ); }//在此处迭代调用该函数时,参数GL10 gl处提示错误GL10 cannot be resolved to a variable else { // Actual number of rendered triangles... landscape.gNumTrisRendered++; float leftZ = m_HeightMap[(leftY *MAP_SIZE)+leftX ]; float rightZ = m_HeightMap[(rightY*MAP_SIZE)+rightX]; float apexZ = m_HeightMap[(apexY *MAP_SIZE)+apexX ]; List<Float> coordsList = new ArrayList<Float>(); coordsList.add((float)leftX); coordsList.add((float)leftY); coordsList.add(leftZ); coordsList.add((float)rightX); coordsList.add((float)rightY); coordsList.add(rightZ); coordsList.add((float)apexX); coordsList.add((float)apexY); coordsList.add(apexZ); //将三角形三个点存入待绘制顶点序列 gl.glVertexPointer(3, GL10.GL_FLOAT, 0, BufferUtil.list2ByteBuffer(coordsList)); gl.glDrawArrays(GL10.GL_LINE_LOOP, 0, coordsList.size()/3); } }
总结一下,问题就是
1.OpenGL ES库里的GL10 gl这个参数可以用来自己定义绘制方法么?
2.如果可以,那为什么在迭代函数里不能第二次调用呢?
慕课上肯定有做移动端3D游戏的大神吧?小弟诚心求助!