I used the search, but seems that no-one has such problem like me. The story is:
Im taking big BMP (for example 768x128) that contains 64x64 tiles. I need to extract these tiles and create textures from each one with glTexImage2D. I have done something already but it doesn’t work like i need and want.
Practically same problem like here:
here is the code:
// generate 24 textures glGenTextures(24, @tekstures); // 12 columns for i:=0 to 11 do // 2 rows of tiles in total for j:=0 to 1 do begin glBindTexture(GL_TEXTURE_2D, tekstures[i]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glPixelStorei(GL_UNPACK_ROW_LENGTH,768); //image width=768 glPixelStorei(GL_UNPACK_SKIP_PIXELS, i * 64); glPixelStorei(GL_UNPACK_SKIP_ROWS, j * 64); // pBits contains image data glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE,pbits ); end;
PROBLEM: it just jumps to the last row and just skips the any previous ones. So as result: i have only textures generated from the last row of my tilesheet.
I guess more calculations must be done?
But what calculations? This is the place im stuck.
Why it skips to last row and doesn’t generate textures from whole BMP ?