Casius
10-06-2008, 09:14 AM
My first time in this forum, so "Hello everybody!"
Iīm a newbee in programming openGL, but need to set up following. Before getting trouble with my generally idea to solve the problem, i want to ask you, if my concept is generally right. Please let me know, if this way is possible or if there are better solutions.
Prolem:
1. I need 2 simple rectangles (quads), one placed in front of the other.
2. Both with an overlying texture.
3. These textures are fixed, and wonīt chance during watching them.
4. The Texture are partially invisible (parts colored with RGBA and Alpha=0)
5. I wanna mask the front rectangle with an alpha mask, to control itīs opacity by a slider, which ajust the opacity during watching it. (To be able to slide gently through the foreground quad. Untill it is total transparent and you can only see the background quad. )
My concept/idea to solve it:
- Get dimension of the image to map on the quads. (Each texture got the same dimension)
- Drawing two quads with this dimension, first the far one, then the near one. One with z=0, next with z=0.5. (Iīm drawing them with z=0 and translate the far one 0.5 back.)
- Map the texture on the backgound. (I made a little testing scenario, with texture-mapped background and a flat colored (RGBA, A=0.5) forground. Iīm already able to do this for base-of-2-textures, but without any transparent parts.)
- Slider for adjust transparency already set up. When initialize the foreground alpha value to 0.5f, itīs half transparent, but when repaint the hole foreground in case of chanced alpha, it doesnīt take effect and remains 50% transparent. Does OpenGl store this RGBA-values somewhere while initializing the scene and just read this informations when repainting it? I donīt understand why it wonīt take effect.
To do so, there are some qustions, i want to ask you:
1. My textures are not of base 2. Is it possible, to map an image as texture with e.g. 600x800 onto a quad with same size?
2. While changing the foregrounds opacity, the background must be permanent visible. But the transparent parts of the background texture needed obviously to be invisible.
3. As test iīm using
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
but then the background also gets transparent! Why? I dontīs want to change anything in the background, just make the foreground invisible step by step.
4. How to mask the hole partially-transparent-textured-quad to enable adjusting itīs tranparency?
Am i totally wrong with the idea? I dontīt hope so.
Any hints and advice are wellcome.
Thanx in advance
Casius
PS:
My english makes me nowbody so fast after. :)
Iīm a newbee in programming openGL, but need to set up following. Before getting trouble with my generally idea to solve the problem, i want to ask you, if my concept is generally right. Please let me know, if this way is possible or if there are better solutions.
Prolem:
1. I need 2 simple rectangles (quads), one placed in front of the other.
2. Both with an overlying texture.
3. These textures are fixed, and wonīt chance during watching them.
4. The Texture are partially invisible (parts colored with RGBA and Alpha=0)
5. I wanna mask the front rectangle with an alpha mask, to control itīs opacity by a slider, which ajust the opacity during watching it. (To be able to slide gently through the foreground quad. Untill it is total transparent and you can only see the background quad. )
My concept/idea to solve it:
- Get dimension of the image to map on the quads. (Each texture got the same dimension)
- Drawing two quads with this dimension, first the far one, then the near one. One with z=0, next with z=0.5. (Iīm drawing them with z=0 and translate the far one 0.5 back.)
- Map the texture on the backgound. (I made a little testing scenario, with texture-mapped background and a flat colored (RGBA, A=0.5) forground. Iīm already able to do this for base-of-2-textures, but without any transparent parts.)
- Slider for adjust transparency already set up. When initialize the foreground alpha value to 0.5f, itīs half transparent, but when repaint the hole foreground in case of chanced alpha, it doesnīt take effect and remains 50% transparent. Does OpenGl store this RGBA-values somewhere while initializing the scene and just read this informations when repainting it? I donīt understand why it wonīt take effect.
To do so, there are some qustions, i want to ask you:
1. My textures are not of base 2. Is it possible, to map an image as texture with e.g. 600x800 onto a quad with same size?
2. While changing the foregrounds opacity, the background must be permanent visible. But the transparent parts of the background texture needed obviously to be invisible.
3. As test iīm using
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
but then the background also gets transparent! Why? I dontīs want to change anything in the background, just make the foreground invisible step by step.
4. How to mask the hole partially-transparent-textured-quad to enable adjusting itīs tranparency?
Am i totally wrong with the idea? I dontīt hope so.
Any hints and advice are wellcome.
Thanx in advance
Casius
PS:
My english makes me nowbody so fast after. :)