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.
- I need 2 simple rectangles (quads), one placed in front of the other.
- Both with an overlying texture.
- These textures are fixed, and won´t chance during watching them.
- The Texture are partially invisible (parts colored with RGBA and Alpha=0)
- 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:
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?
While changing the foregrounds opacity, the background must be permanent visible. But the transparent parts of the background texture needed obviously to be invisible.
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.
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
My english makes me nowbody so fast after.