[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: opengl and textures

Scrive Randall Hopper:

> Sure sounds like your texture isn't being loaded up-front.  Use glGetError
> (for testing only) and make sure no OpenGL errors are being thrown in your
> startup and draw.  If so, chase 'em down.
glGetError() always returns 0 at any point of the loadup/draw code.

I suppose that the required steps are only:

1. Create a texture id with glGenTextures()
2. Select the created texture with glBindTexture()
3. Load the actualimage with glTexImage2d()
4. Set minification and magnification parameters with glTexParameteri()

I also tried to enable GL_TEXTURE_2D...
With the second (tank) texture, skipping step 4. results in the same effect i
have with the first: a flat square. 

> Shots in the dark:
>   glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_S, GL_CLAMP   ) ;
>   glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_T, GL_CLAMP   ) ;
> Probably not:
>   glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 ) ;
> since you said it works the second time, without reloading the texture
> presumably.
It works, but with a different texture, loaded in the same way.

> Also what's your blend function set to?
I make all blend/alpha/color settings, then:

-bind the first (select) texture
-draw a quad
-bind the second (tank) texture
-draw a quad (the same, i just cut&paste the lines from glBegin() to glEnd())

All i get is a flat white quad with a perfectly rendered tank over it.
And no glGetError().

If i copy select.png over tank.png, i get a flat white quad with a perfectly
rendered selection mark over it.

I'm feeling quite stupid....

> Grab a copy of the OpenGL red book and turn to a texturing example.
I'll do it.

Thank you for the help, maybe I'll put the code online...
Francesco Orsenigo