I am developing a small OpenGL renderer with a loader for OBJ files. It works well for some OBJ files and not for others... See the captures please.
Here is my code. Can you help me to determinate why I have these strange artifacts ?
Thanks
ModelRenderer.java :
Using java Syntax Highlighting
- public float xrot;
- public float yrot;
- public float camZ;
- public ModelRenderer(final Model pModel) {
- super();
- this.model = pModel;
- this.xrot = 0;
- this.yrot = 0;
- this.camZ = 3;
- }
- public void onSurfaceCreated(final GL10 pGl, final EGLConfig pConfig) {
- // Enabling the states...
- pGl.glEnable(GL10.GL_DEPTH_TEST);
- pGl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
- pGl.glEnableClientState(GL10.GL_COLOR_ARRAY);
- pGl.glShadeModel(GL10.GL_SMOOTH);
- }
- public void onSurfaceChanged(final GL10 pGl, final int pWidth,
- final int pHeight) {
- pGl.glViewport(0, 0, pWidth, pHeight);
- // Setup project matrix
- pGl.glMatrixMode(GL10.GL_PROJECTION);
- pGl.glLoadIdentity();
- GLU.gluPerspective(pGl, 45.0f, (float) pWidth / pHeight, 1f, 200f);
- }
- public void onDrawFrame(final GL10 pGl) {
- pGl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- pGl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
- pGl.glMatrixMode(GL10.GL_MODELVIEW);
- pGl.glLoadIdentity();
- GLU.gluLookAt(pGl, 0, 0, this.camZ, 0, 0, 0, 0, 1, 0);
- Buffer vertices = this.model.getVertices();
- pGl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertices);
- Buffer colors = this.model.getColors();
- pGl.glColorPointer(4, GL10.GL_FLOAT, 0, colors);
- pGl.glRotatef(this.xrot, 1, 0, 0);
- pGl.glRotatef(this.yrot, 0, 1, 0);
- pGl.glDrawElements(GL10.GL_TRIANGLES, this.model.getFacesCount(),
- GL10.GL_UNSIGNED_SHORT, this.model.getFaces());
- }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4

