I need to create a OpenGL texture out of a ftgl::texture_atlas_t*.
I used to do it with a depth of one byte (atlas = texture_atlas_new(512, 512, 1))
I used to upload it to OpenGL with glTexImage2D on the GL_RED channel.
But now I need the fontData to be in the alpha channel.
In the fragment-shader I want to have a sampler which returns me a vec4 (the pixelColor) [with rgb=1 & a=0-1 (fontData)]
But the problem is that I don’t actually know how to get the single channel data from freetype-gl into the alpha channel of the OpenGL-texture.
(I guess I’m using the glTexImage2D(…) function in the wrong way.
I hope you’re able to find a solution to my problem,
rnholzinger01
In the core profile a single-channel texture doesn’t have an alpha channel, only a red channel. You could use a 4-channel texture, but that wastes memory and you can’t upload just the alpha channel. In the compatibility profile you can use e.g. GL_ALPHA8 as the internal format to generate a texture with only an alpha channel (the other channels will be zero).
In 3.3 (core or compatibility profile) or with the ARB_texture_swizzle extension you can use swizzling, e.g.:
[QUOTE=GClements;1292575]In the core profile a single-channel texture doesn’t have an alpha channel, only a red channel. You could use a 4-channel texture, but that wastes memory and you can’t upload just the alpha channel. In the compatibility profile you can use e.g. GL_ALPHA8 as the internal format to generate a texture with only an alpha channel (the other channels will be zero).
In 3.3 (core or compatibility profile) or with the ARB_texture_swizzle extension you can use swizzling, e.g.: