[Touch Diamond, MDA Compact IV Themes and Apps] doc morelli:
Texture Mapping

hey everyone,

im just playing around with some of Koushs TestOpenGLES sample code. I read a few tutorials and searched around the hole day but i still dont know why it wont work.

i draw a rectangle and im just trying map a texture on it.

unsafe void InitGL()
{
myTexture = new uint[1];
gl.ShadeModel(gl.GL_SMOOTH);
gl.ClearColor(0.0f, 0.0f, 0.0f, 0.5f);
gl.ClearDepthf(1.0f);
gl.Enable(gl.GL_DEPTH_TEST);
gl.BlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA);
gl.DepthFunc(gl.GL_LEQUAL);
gl.Hint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST);
gl.Enable(gl.GL_TEXTURE_2D);

myFont = new OpenGLFont(new Font(FontFamily.GenericSerif, 12, FontStyle.Regular));
myHugeFont = new OpenGLFont(new Font(FontFamily.GenericSerif, 32, FontStyle.Regular));

zoomFactor = zoomMax;

// Loading Bitmap
currentBitmap = new Bitmap("zeus.bmp");

System.Drawing.Imaging.BitmapData bitmapdata;
Rectangle rect = new Rectangle(0, 0, currentBitmap.Width, currentBitmap.Height);

bitmapdata = currentBitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

fixed (uint* myTexturePointer = &myTexture[0])
{
gl.GenTextures(1, myTexturePointer);
}
gl.BindTexture(gl.GL_TEXTURE_2D, myTexture[0]);
gl.TexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, currentBitmap.Width, currentBitmap.Height, 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);
gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);

currentBitmap.UnlockBits(bitmapdata);
currentBitmap.Dispose();
}

unsafe void DrawGLScene()
{
int count;

gl.GetIntegerv(gl.GL_MAX_TEXTURE_UNITS, &count);

gl.Viewport(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width, ClientRectangle.Height);
gl.MatrixMode(gl.GL_PROJECTION);
gl.LoadIdentity();
gluPerspective(45, (float)ClientSize.Width / (float)ClientSize.Height, .1f, 100);

gl.MatrixMode(gl.GL_MODELVIEW);
gl.BindTexture(gl.GL_TEXTURE_2D, myTexture[0]);
gl.LoadIdentity();

float[] square = { -1f, -1f, 0f, 1f, -1f, 0f, -1f, 1f, 0f, 1f, 1f, 0f };
float[] texCoords = { 1f, 1f, 0f, 1f, 0f, 0f, 1f, 0f};

gl.LoadIdentity();
gl.Translatef(0.0f, 0.0f, zoomFactor);
gl.Rotatef(myRotation, 0.0f, 1.0f, 0.0f);

fixed (float* squarePointer = &square[0], texCoordsPointer = &texCoords[0])
{
gl.EnableClientState(gl.GL_VERTEX_ARRAY);
gl.EnableClientState(gl.GL_TEXTURE_COORD_ARRAY);

gl.VertexPointer(3, gl.GL_FLOAT, 0, (IntPtr)squarePointer);
gl.TexCoordPointer(2, gl.GL_FLOAT, 0, (IntPtr)texCoordsPointer);

gl.DrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4);

gl.DisableClientState(gl.GL_TEXTURE_COORD_ARRAY);
gl.DisableClientState(gl.GL_VERTEX_ARRAY);
gl.Flush();
}

gl.MatrixMode(gl.GL_PROJECTION);
gl.LoadIdentity();
gl.Orthof(0, ClientSize.Width, ClientSize.Height, 0, -10, 10);

gl.MatrixMode(gl.GL_MODELVIEW);
gl.LoadIdentity();

gl.Translatef(0, 0, 0);

GlyphRun fpsText = new GlyphRun(myFont, Math.Round(myFps, 2).ToString() + " FPS" + ", " + myRotation.ToString());
fpsText.Draw();
}
}

But its just displaying a white square with no texture on it. Please can someone help me? I also checked zeuscmd.com and nehe.gamedev.net tutorials and cant manage to get it work.

btw sorry for my english