I have been trying to implement the voxel engine that is described in this guide:
Voxel Fun - How it works
I have worked my way though, and don't have any issues setting up the verts, the indexes, and the texture buffer, but I'm not seeing anything; I am unsure about whether my texture is bound correctly:
onSurfaceCreated (of class CubeRenderer implements GLSurfaceView.Renderer { )
Using java Syntax Highlighting
- gl.glEnable(GL10.GL_TEXTURE_2D);
- gl.glGenTextures(1, tex, 0);
- gl.glBindTexture(GL10.GL_TEXTURE_2D, tex[0]);
- gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_NEAREST);
- gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE);
- bitmap = Bitmap.createBitmap(16 * 16 * 4, 16, Bitmap.Config.ARGB_8888);
- // Draw the texture in red/white hatched dots
- for (int y = 0; y < 16; y += 2) {
- for (int x = 0; x < 1024; x += 2) {
- bitmap.setPixel(x, y, Color.WHITE);
- bitmap.setPixel(x + 1, y, Color.RED);
- }
- for (int x = 0; x < 1024; x += 2) {
- bitmap.setPixel(x, y + 1, Color.WHITE);
- bitmap.setPixel(x + 1, y + 1, Color.RED);
- }
- }
- GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
Then in the draw method of my cube (called from onDrawFrame)
Using java Syntax Highlighting
- gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
- gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
- // Set the face rotation
- gl.glFrontFace(GL10.GL_CCW);
- // Point to our buffers
- gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
- gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);
- // Draw the vertices as triangles, based on the Index Buffer
- // information
- gl.glDrawElements(GL10.GL_TRIANGLES, (mVerts * 3) / 2, GL10.GL_UNSIGNED_BYTE, indexBuffer);
- // Disable the client state before leaving
- gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
- gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
Will the above code display my texture on the verts? Am I missing something?
Cheers
Ed

) then try setting your clipping planes very far apart, wide angle to your lens etc. in case you just have the wrong projection or are not looking in the right place.



