Hi I just added a background texture to the game I was working on and its taken a massive performance hit. It's now running at about half the speed it was before and I can't figure out why. The loading code looks like this:
private void LoadGLTextures()
{
Gl.glEnable(Gl.GL_TEXTURE_2D);
Bitmap image = new Bitmap("Background.bmp");
image.RotateFlip(RotateFlipType.RotateNoneFlipY);
System.Drawing.Imaging.BitmapData bitmapdata;
Rectangle rect = new Rectangle(0, 0, image.Width, image.Height);
bitmapdata = image.LockBits(rect,
System.Drawing.Imaging.ImageLockMode.ReadOnly,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture[0]);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, (int)Gl.GL_RGB8, image.Width,
image.Height, 0, Gl.GL_BGR_EXT,
Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER,
Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER,
Gl.GL_LINEAR);
image.UnlockBits(bitmapdata);
image.Dispose();
Gl.glDisable(Gl.GL_TEXTURE_2D);
}
and the drawing code looks like this:
Gl.glEnable(Gl.GL_TEXTURE_2D);
Gl.glBegin(Gl.GL_QUADS);
//Front Face
Gl.glColor3d(0.7, 0.5, 0.5);
Gl.glTexCoord2f(0.0f, 0.0f);
Gl.glVertex2d(0, 0);//BotLft Of The Texture and Quad
Gl.glTexCoord2f(1.0f, 0.0f);
Gl.glVertex2d(screenWidth, 0);//BotRt Of The Texture and Quad
Gl.glTexCoord2f(1.0f, 1.0f);
Gl.glVertex2d(screenWidth, screenHieght); //Top Right Of The Texture and Quad
Gl.glTexCoord2f(0.0f, 1.0f);
Gl.glVertex2d(0, screenHieght); //Top Left Of The Texture and Quad
Gl.glEnd();
Gl.glDisable(Gl.GL_TEXTURE_2D);
Can anybody help.
James