Results 1 to 3 of 3

Thread: Need help with glPixelStorei (and glTexImage2D)

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2009
    Location
    EE
    Posts
    15

    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 768x12 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:
    http://www.opengl.org/discussion_boards/...true#Post236512


    here is the code:
    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 ?

  2. #2
    Senior Member Frequent Contributor scratt's Avatar
    Join Date
    May 2008
    Location
    Thailand
    Posts
    555

    Re: Need help with glPixelStorei (and glTexImage2D)

    I don't understand what you are doing. Or the practicality of it.

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

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2009
    Location
    EE
    Posts
    15

    Re: Need help with glPixelStorei (and glTexImage2D)

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

Similar Threads

  1. FBO and glTexImage2D
    By LaLaChen in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 04-30-2013, 11:23 PM
  2. Bitmap Texture glPixelStorei Problem
    By Shari in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-23-2008, 06:39 PM
  3. glTexImage2D
    By rpenland in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-10-2003, 02:06 AM
  4. glTexImage2D
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-28-2003, 01:19 AM
  5. glTexImage2D
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-26-2003, 08:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean