nehe's tut code not working... WHYWHYWHYWHYWHYWHYWHY??!!

sorry the topic is so annoying, and don’t be misled, i have no intention of bashing nehe.

okay, guys, i PASTED nehe’s code for lesson6, the tm tut. the only thing i’ve changed is that w and h represent the width and height of my texture, and image is the unsigned byte array. also, it’s 4 component and RGBA.

when i call glTexImage2D(), though, gl sets the invalid value error flag, and no texture mapping is done… hrmmm.

any ideas, i’m using vc++ 6.0 w/ the ms software drivers for now…
i hate when people say, hey guys, debug my code for me, so please understand, i just posted the code to show it’s an exact paste, - my parameters, but the function calls are in order.

GLuint Texture[1];

glEnable( GL_TEXTURE_2D );

glGenTextures( 1,&Texture[0] );
glBindTexture( GL_TEXTURE_2D,Texture[0] );
glTexImage2D( GL_TEXTURE_2D,0,4,w,h,0,GL_RGBA,GL_UNSIGNED_BYTE,Image );
glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR );

anyone been bit by this bug?

hrmmm.

thx now for later

P.S. is it because mip mapping is enabled, but i haven’t defined all of the mip-maps?

i don’t want mip mapping enabled yet, besides, is it by default?

if it is, what’s the GL_MACRO to send to glDisable, and is that the only problem…
phew, long ps

[This message has been edited by Succinct (edited 10-26-2000).]

using gluBuildMipMaps makes it work, but i don’t need mip maps, cuz i’m just displaying a textured quad for text…

hrmmm

What w and h does your texture have? Texture width and height has to be a power of 2 (2, 4, 8, 16, 32, 64, 128, 256…)
AFAIK mipmapping is not enabled by default.

According to the red book, if the image has dimensions that are not powers of 2, gluBuild2DMipmaps scales the image to the nearest powers of 2. Therefore Dodger probably got it right, if it doesn’t work without mipmaps then its likely that the image has dimensions that are not powers of 2.

Antonio www.fatech.com/tech

I was having big probs with something similar to this a few weeks ago…

My problem was that I was building my textures before creating an OpenGL context to actually render into…

might be worth a check.

okay, now it works, because the texture is a square power of two…

the reference say that the w and h have only a 2n + 2 constraint, not a 2^n/ square constraint.

maybe since they use the same n, n for w must equal n for h, but that’s fairly implicit, but i should have realized that earlier.

anyway, i can deal w/ them being square, but why do the have to be powers of two?

1,2,4,8… etc

why not 12x12?

thx, guys, all of ya for all of the replies!
-newbie

It’s probably easier (and therefore cheaper in hardware) for OpenGL implementations to do linear filtering on textures that have dimensions that are a power of 2. I dunno

Paul.