Is the profiler lying/can GL use previous binds/will...

Jones
Unregistered
 
Post: #46
Perhaps my understanding of 3D textures is crap, but I don't think this code:

Code:
glBegin(GL_QUADS);
    
        glTexCoord3i(0,0,0);
        glVertex2i(0,0);
        
        glTexCoord3i(1, 0, 1);
        glVertex2i(256,0);
        
        glTexCoord3i(1, 1, 1);
        glVertex2i(256, 256);
        
        glTexCoord3i(0, 1, 0);
        glVertex2i(0, 256);
    
    glEnd();

Should produce this:
[Image: wtf_tex3d.png]

I'm asking for the first two textures which are grass and rock. Brick should not appear, and neither should the random colors. (The random colors are a fourth texture, added to make the depth value a power of two.)

Am I doing something incredibly wrong or something?

Thanks!
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #47
What is the value of depth when creating the texture? It looks like you're specifying 4 rather than 2, which causes those extra textures.
Quote this message in a reply
Jones
Unregistered
 
Post: #48
The depth value is 4. I pass a depth of 3 to my function, but it automatically determines the nearest power of 2 and passes it. The extra space is filled with random pixels. The pixel data in the arrays goes like this:

256 * 256 * 3 bytes of picture one.
" " two.
" " three.
256 * 256 * 3 bytes of random pixel colors.

The '* 3' is for components, not BPP.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #49
You can't do that. If you want to have the 3 textures in there, you will need to keep a value of 4. In order to then only go between grass and dirt, you will need to go from 0 to 0.5. The r coordinate works the same way as the s and t coordinates, where it goes from 0 to 1 regardless of the dimensions. In order to use layer k out of n layers, you're going to need to use an r coordinate of k/(n - 1).

Edit: and to avoid memory issues, you're going to have to do one of two things: make sure that you have space allocated for 4 layers and pass that into glTexImage3D, or pass in NULL for glTexImage3D and use glTexSubImage3D to put in only the 3 textures. (which would also allow you to input the textures 1 at a time if you wanted)
Quote this message in a reply
Jones
Unregistered
 
Post: #50
akb825 Wrote:You can't do that. If you want to have the 3 textures in there, you will need to keep a value of 4. In order to then only go between grass and dirt, you will need to go from 0 to 0.5. The r coordinate works the same way as the s and t coordinates, where it goes from 0 to 1 regardless of the dimensions. In order to use layer k out of n layers, you're going to need to use an r coordinate of k/(n - 1).

*Stupid stupid stupid stupid me*.

Heh, I should have realized that. Jeeze. Rasp

Thanks!
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #51
Wow, that was a quick response. Be sure to check my edit.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL profiler 3.2 - 0.0 Frame Rate? kelvin 0 2,579 Mar 3, 2006 01:21 AM
Last Post: kelvin
  OpenGL Profiler Nick 15 6,734 Mar 29, 2005 06:56 PM
Last Post: Nick
  OpenGL Profiler, or, "where did all my files go?" sealfin 2 2,800 Sep 3, 2004 12:19 AM
Last Post: sealfin
  OpenGL profiler & display lists MattDiamond 9 4,365 Sep 1, 2003 08:07 PM
Last Post: MattDiamond
  OpenGL profiler LongJumper 11 4,461 Apr 4, 2003 08:18 PM
Last Post: Fenris