hi!
just a question:
i am loading textures in my openGL engine by opening the image file and putting each texel into the bank like that:
this is extremely slow because i am using ~20 textures about 512*512 on a little demo map. isn't there any way to make it work faster?
thanks.
just a question:
i am loading textures in my openGL engine by opening the image file and putting each texel into the bank like that:
Function LoadTexture(file$, flags = 0) img = LoadImage(file$) w = ImageWidth(img) h = ImageHeight(img) nw = GetWidth(w) nh = GetWidth(h) t.texture = New texture t\bank = CreateBank(12) t\w = nw / BLE_TextureQuality t\h = nh / BLE_TextureQuality t\sx# = 1 t\sy# = 1 bank_size = t\w * t\h * 3 bank_img = CreateBank(bank_size) ib = ImageBuffer(img) LockBuffer ib For y = 0 To t\h - 1 off = bank_size - (y + 1) * t\w * 3 For x = 0 To t\w - 1 rgb = ReadPixelFast(w * x * BLE_TextureQuality / nw, h * y * BLE_TextureQuality / nh, ib) PokeByte bank_img, off, (rgb And $FF0000) Shr 16 PokeByte bank_img, off + 1, (rgb And $FF00) Shr 8 PokeByte bank_img, off + 2, rgb And $FF off = off + 3 Next Next UnlockBuffer ib FreeImage img glGenTextures 3, t\bank glBindTexture GL_TEXTURE_2D, PeekInt(t\bank, 0) glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST glTexImage2D GL_TEXTURE_2D, 0, 3, t\w, t\h, 0, GL_RGB, GL_UNSIGNED_BYTE, bank_img glBindTexture GL_TEXTURE_2D, PeekInt(t\bank, 4) glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR glTexImage2D GL_TEXTURE_2D, 0, 3, t\w, t\h, 0, GL_RGB, GL_UNSIGNED_BYTE, bank_img glBindTexture GL_TEXTURE_2D, PeekInt(t\bank, 8) glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR gluBuild2DMipmaps GL_TEXTURE_2D, 3, t\w, t\h, GL_RGB, GL_UNSIGNED_BYTE, bank_img FreeBank bank_img Return Handle(t) End Function
this is extremely slow because i am using ~20 textures about 512*512 on a little demo map. isn't there any way to make it work faster?
thanks.