Original Post
Hello Community,
I´ve got a problem with the texturing of some Quads (about 4000) in a 2D Projection.
@ first: Here´s the code
This does draw the whole Quads with their Texture. But cause these are so many, my framerate really crashes. My Bitmaps are about 32 x 32 pixel, and are drawn 30 times to the right, and same to the bottom. Is there a better way to draw the Bitmaps? Maybe I should use a big bitmap to do so?
Thanks guys
I´ve got a problem with the texturing of some Quads (about 4000) in a 2D Projection.
@ first: Here´s the code
int x = 0;
int y = 0;
m_Width = 32;
m_Height = 32;
handle = new int[1];
m_Handle = handle[0];
Gl.glGenTextures(handle.Length, handle);
rect = new Rectangle(0, 0, m_Width, m_Height);
while (x < 30)
{
while (y < 30)
{
bitmap = (Bitmap)values.bmpBackgroundArray[x, y].Clone();
bdata = bitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, bitmap.PixelFormat);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, m_Handle);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, m_Width, m_Height, 0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bdata.Scan0);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR);
Gl.glEnable(Gl.GL_TEXTURE_2D);
Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2f(0, 0); Gl.glVertex2f(x * 32, y * 32);
Gl.glTexCoord2f(0, 1); Gl.glVertex2f(x * 32, y * 32 + m_Height);
Gl.glTexCoord2f(1, 1); Gl.glVertex2f(x * 32 + m_Width, y * 32 + m_Height);
Gl.glTexCoord2f(1, 0); Gl.glVertex2f(x * 32 + m_Width, y * 32);
Gl.glEnd();
Gl.glDisable(Gl.GL_TEXTURE_2D);
bitmap.UnlockBits(bdata);
bitmap.Dispose();
Gl.glDeleteTextures(1, handle);
y++;
}
y = 0;
x++;
}This does draw the whole Quads with their Texture. But cause these are so many, my framerate really crashes. My Bitmaps are about 32 x 32 pixel, and are drawn 30 times to the right, and same to the bottom. Is there a better way to draw the Bitmaps? Maybe I should use a big bitmap to do so?
Thanks guys