Qythyx's picture

Blend problems

I'm working on an OpenGL based game using MonoTouch for the iPhone, which uses OpenTK. I actually started my game in native Objective-C, but then decided to explore MonoTouch (since I have a lot of .NET/C# experience) and am now porting it over. The problem I'm facing is that I'm trying to blend multiple transparent textures. This worked perfectly in the native Objective-C version, but not with OpenTK.

The problem is that I have a black background with a transparent white texture that I'm drawing in multiple overlaps. On my original version if I drew the texture once it showed a grey image (transparent white on black). If I then draw the same texture again overlapping that then it should make the overlapped area brighter by adding more white to it. Instead what I'm getting is that each successive overlap makes the grey color darker.

I believe the relevant code is just this:

GL.Enable(All.Blend);
GL.BlendFunc(All.One, All.OneMinusSrcAlpha);

Is there any reason this wouldn't work in OpenTK when it worked fine in native OpenGL?


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Qythyx's picture

Never mind. Completely my fault. Nothing to do with Blend at all.

Move along folks. Nothing to see here.

Hortus Longus's picture
Qythyx wrote:

Never mind. Completely my fault. Nothing to do with Blend at all.

Move along folks. Nothing to see here.

I love such mails and writers.
Realy.
I mean: if I can not put such people in a bucket I will love them.
Qythyx -> bucket. :-)

c2woody's picture

I like those people. They work on their problems, instead of posting "can you do xyz for me".

Qythyx -> different bucket.

Hortus Longus's picture
c2woody wrote:

... They work on their problems, ...

Yes, that is good. But (because of public forum) it would be nicer to say "The problem was this and this, and I have solved the problem by that and that."

And to go with

Qythyx wrote:

Move along folks. Nothing to see here.

is, in my eyes, very heavy.

c2woody wrote:

..., instead of posting "can you do xyz for me".

Oh, also still barrels exist. ;-)

Qythyx's picture

Actually, in most cases I would have written something more that would help others. In this case my mistake was not at all related to Blend that it wouldn't help others. If you really want a hint my mistake and solutions, then here you go....

If you want your textures to show up correctly, then one important prerequisite is to actually draw them. My problem was that I wasn't passing the right number to DrawArrays, so it wasn't drawing all of my triangles. It happening to be that the ones I was trying to overlay were at the end of the list, so the underlying faint one was drawn, but the ones that were supposed to be layered on top of it weren't but that gave me the impression they were dimming it.

Hortus Longus's picture

Thx. ;-)