Sign in to follow this  
Slug

Weird texture question

Recommended Posts

Slug    100
I wanna compact 2 texture into one and i need help to do it. The first texture is of type GL_LUMINANCE_ALPHA(2 channels) and the second one is of type GL_LUMINANCE(1 channel). So, i want to compact them in one RGB texture, the first one in the Red and Green channel, and the second one in the blue channel. How can i use them correctly once the're are compacted? Someone can help me?

Share this post


Link to post
Share on other sites
WarMuuh    145
Hi!
One method needs the data itself
byte data1[data1Size]; //your first-bitmap-data , just 2 channels
byte data2[data2Size]; //second one with ust one channel

if you have the data, then you can do a simple loop:
byte* data3 = new byte[data1Size+data2Size];

for(int i=0;i<data2Size;i++)
{
data3[3*i] = data1[2*i];//R
data3[3*i+1] = data1[2*i+1];//G
data3[3*i+2] = data2[i];//B
};

and then, you load the data3 as a normal texture in ogl

you can use the textures by using glMask(...) and masking R and G for second one (or just B for the first texture)

i dont know if this method is working too, but give it a try:
render a quad into a textureSize*textureSize-viewport with glColor3f(1.0f,1.0f,0.0f) your first texture and after that, just render it again with 0,0,1.0f and the second texture (maybe you need blending...)
then use glCopyTexImage2d to save the combined texture

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this