>a texture of e.g. height 150 pixels and
>width 50 pixels
First of all, texture widths and heights always have to be a power of 2 (2, 4, 8, 16, 32, 64, 128, 256…)
Others might work on some OpenGL-implementations, but definitely won’t work on all of them.
>and I want to fade the upper pixelrows 0-9
>of the texture with a gradient fade so that
>pixelrow 0 is transparent and pixelrow 10 is
>opaque, how would I go about doing that?
Is this fading static or will it change while the program runs? If you want do have the upper 10 pixels faded statically, use an RGBA-texture with an alpha channel. Every pixel in the texture has 4 bytes, R, G, B and A. Where A is 0, the texture is fully transparent, where A is 255 it’s completely opaque. Don’t forget to use GL_RGBA and GL_RGBA8 as the respective parameters in glTeximage2D().
For dynamic fading, you could either generate the alpha channel in your texture on-the-fly (could be done by drawing a gradient quad into the alpha buffer and copying it to your texture using glCopyTexImage2D() or glCopySubTexImage2D()), and you could also generate non-linear alpha channels.
Or, if I understand it correctly, go by your pseudocode - only draw the alpha texture first, then the RGB texture (if I’m not mistaken).
The third possbility would be, to tesselate the texture polygon into several quads, the top row of quads being 10 pixels high, and using glColor4f(r, g, b, alpha) to generate the alpha gradient by giving alpha 1.0 at the bottom vertices of the row, and 0.0 at the top vertices. Then the fading could also be dynamic and you could do some other neat effects with the texture (warping, etc.).