Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid and OpenGL "how display faces"
    text
    copied!<p>I want to display for example an *.obj file. and normal, in OpenGL I use instruction :</p> <pre><code>glBegin(Traing..); glVertex3f(Face[i].VertexIndex); glTexcoords2f(Face[i].TexcoordIndex); glNormal(Face[i].NormalIndex); glEnd(); </code></pre> <p>But in Android OpenGL i don't have this functions... i have an DrawElements(...); but when I want draw face 34/54/3 ( vertex/texcord/normal index of arrays) it's drawing linear 34/34/34...</p> <p>so how I can draw a *.obj file?</p> <hr> <p>I search in the web and I found this topic : <a href="http://www.anddev.org/android-2d-3d-graphics-opengl-problems-f55/obj-import-to-opengl-trouble-t48883.html" rel="nofollow">http://www.anddev.org/android-2d-3d-graphics-opengl-problems-f55/obj-import-to-opengl-trouble-t48883.html</a> So.. I writing an Model editor in C# to my game and I wrote something like that for test :</p> <pre><code> public void display2() { GL.EnableClientState(ArrayCap.VertexArray); GL.EnableClientState(ArrayCap.TextureCoordArray); GL.EnableClientState(ArrayCap.NormalArray); double[] vertexBuff = new double[faces.Count * 3 * 3]; double[] normalBuff = new double[faces.Count * 3 * 3]; double[] texcorBuff = new double[faces.Count * 3 * 2]; foreach (face f in faces) { for (int i = 0; i &lt; f.vector.Length; i++) { vertexBuff[i_3] = mesh[f.vector[i]].X; vertexBuff[i_3 + 1] = mesh[f.vector[i]].Y; vertexBuff[i_3 + 2] = mesh[f.vector[i]].Z; normalBuff[i_3] = normal[f.normal[i]].X; normalBuff[i_3 + 1] = normal[f.normal[i]].Y; normalBuff[i_3 + 2] = normal[f.normal[i]].Z; texcorBuff[i_2] = texture[f.texCord[i]].X; texcorBuff[i_2 + 1] = texture[f.texCord[i]].Y; i_3 += 3; i_2 += 2; } } GL.VertexPointer&lt;double&gt;(3, VertexPointerType.Double, 0, vertexBuff); GL.TexCoordPointer&lt;double&gt;(2, TexCoordPointerType.Double, 0, texcorBuff); GL.NormalPointer&lt;double&gt;(NormalPointerType.Double, 0, normalBuff); GL.DrawArrays(BeginMode.Triangles, 0, faces.Count * 3); GL.DisableClientState(ArrayCap.VertexArray); GL.DisableClientState(ArrayCap.TextureCoordArray); GL.DisableClientState(ArrayCap.NormalArray); } </code></pre> <p>and it's working.. but I think that this could be more optimized?... I don't want to change my data of model to the arraysbuffer, because it takes too much space in memory.. any suggestion? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload