Skip to main content
gamedev.net
🔒 Locked

Weird texture question

Started by Slug 1 reply 500+ views
Original Post
Slug
Slug
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?
_the_phantom_
_the_phantom_
How do you mean 'use them correctly'?
What do you want todo with them?
WarMuuh
WarMuuh
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{
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.