PDA

View Full Version : "balls linked togueter" in opengl



arthurprs
13-01-2008, 04:07 AM
http://img401.imageshack.us/img401/1439/progpig1.png

There is something linking the balls together when i switch blend mode to glBlendFunc(GL_SRC_ALPHA, GL_ONE);

:roll: :?:

ps: sorry for the strange title

waran
13-01-2008, 04:39 AM
I never really understood the blend-modes but I guess its the GL_ONE-part.
Has to be GL_ONE_MINUS_SRC_ALPHA.

arthurprs
13-01-2008, 04:42 AM
I never really understood the blend-modes but I guess its the GL_ONE-part.
Has to be GL_ONE_MINUS_SRC_ALPHA.
Same here :P

I need "Add" blend mode, whats the opengl code?

waran
13-01-2008, 05:03 AM
Additive Blending is "glBlendFunc(GL_SRC_COLOR, GL_ONE);".
No warranty, however :D

arthurprs
13-01-2008, 03:54 PM
with glBlendFunc(GL_SRC_COLOR, GL_ONE);
http://img142.imageshack.us/img142/8198/capture13012008135106ka0.jpg

:(

chronozphere
13-01-2008, 07:04 PM
What kind of picture are you using :?

It seems to me, that you are using a completely green picture. If that's true, it's quite logical that you get these results. You must make sure that all transparent parts of the picture are black.

If i were you, i would render a white background, and try to "Add" blend a black picture with a green ball in the middle, over it. If you see black rectangles, something went wrong. If you only see white, and those green balls, Additive blending is working correctly :)

Hope this helps. ;)

P.S. Can you post the picture that you are trying to blend??

arthurprs
13-01-2008, 08:34 PM
What kind of picture are you using :?

It seems to me, that you are using a completely green picture. If that's true, it's quite logical that you get these results. You must make sure that all transparent parts of the picture are black.

If i were you, i would render a white background, and try to "Add" blend a black picture with a green ball in the middle, over it. If you see black rectangles, something went wrong. If you only see white, and those green balls, Additive blending is working correctly :)

Hope this helps. ;)

P.S. Can you post the picture that you are trying to blend??



The pic is white, and i colorize it with glcolor()

http://img177.imageshack.us/img177/9851/particlesoh9.png

chronozphere
13-01-2008, 10:26 PM
Huh.. do you use exactly THIS png for rendering?

I don't know how PNG works, but i think that the whole picture is infact white, but there seems to be alpha data somewhere in the file. I opened it in photoshop, and when i did "Flatten image", the whole thing turned white, and all transparency was gone. I don't know how it works, but i think openGL interprets the data as a totally white picture.

Anyway... i would advice you to use a black background instead of a transparent one.. If you use photoshop you should add a black layer beneath the current one, and merge them (If im not mistaken.. no real photoshop skilzz here :roll: )

You could also use TGA. I think OpenGL can handle those quite well. I use it myself in DirectX and i must say that it works great. You can easily add an alpha layer in photoshop, and save it with 32bpp. You don't have to do that when you want to use additive blending, because alpha is not required then.

Good luck! ;)

arthurprs
13-01-2008, 11:21 PM
Thanks chronozphere :)

User137
14-01-2008, 01:33 AM
I checked out your png and it is completely the way it should be. To make additive blending you use glBlendFunc(GL_SRC_ALPHA,GL_ONE); which is what you did... Also, the balls "blending" effect is exactly what should happen. Try it with different colors, for example red ball and blue ball overlapped should result in purple color in their intersection. Or 10 very dark green balls result in a light green etc...

EDIT: Oh! yeah when it comes to additive blending you can indeed get rid of alpha channel. Images on black background in RGB image do good :) It will also take less video memory.