Need help with glPixelStorei (and glTexImage2D)

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:…true#Post236512

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

      glBindTexture(GL_TEXTURE_2D, tekstures[i]);


      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 );


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 ?

I don’t understand what you are doing. Or the practicality of it. :slight_smile:

Why not leave the tiles in the BMP, and then just use it as a texture atlas to render from? Less binding then surely?

I don’t know how to use texture atlas.
That’s the problem. But i will try to find stuff about it on Google.