tags:

views:

108

answers:

2

I draw an image as a back on the screen first, then draw a mask for a picture like this: it is a circle with a white color in the middle, and all of the left is black. I use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); to make it display only the white circle on the back image. Then i need to draw another image on the same position of mask. my aim is to make this image only be drawed where the part is corresponding with the white circle. In fact what i want to draw is a moon. And i must make it opaque. What should i do?

i wish recive your help. you can email me at [email protected]

thanks very much!

A: 

I don't know if I am just not understanding correctly the question, but couldn't you use just a single image, with the circle and the last used image in it?

If that don't fits, you could use the stencil buffer: Setting it to a value when drawing the second image and rendering only on those pixels at that value in the third image.

Artur Soler
A: 

Just put the black/white in the alpha channel of the moon image? That is probably the most sensible thing you can do, and it follows convention.

Or, if you're committed to your approach. render your black/white into the alpha part of the frame buffer (it's probably there already if you do what you say you do) then use DST_ALPHA instead of SRC_ALPHA for the next pass. However, this is not how one usually does it in OpenGL.

Marcus Lindblom
hi, Marcus Lindblom, i am new user both in stackoverflow and openGL, may be i didn't describe my question very clearly, now i uploaded some pictures that do help make my means clearly.1 the back image that i will draw is the following:http://profile.imageshack.us/user/walking_snail/images/detail/#197/backdrop00.jpg2. then i will draw a image as a mask for another picturehttp://profile.imageshack.us/user/walking_snail/images/detail/#192/planet1.gif3. now i need to draw the following picturehttp://profile.imageshack.us/user/walking_snail/images/detail/#194/planet1.gifwhat shoud i do?
forget that, this is the fianl result sample:http://profile.imageshack.us/user/walking_snail/images/detail/#32/sampley.pngyes, maybe you know this a the game Bejeweled of the popcap. I want to clone it as all the resources are found in the instal directory. Wish get your more help, thank you very much!