Jump to content
  • Advertisement
Sign in to follow this  
Slug

Weird texture question

This topic is 4440 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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;//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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!