Thanks. I should've explained myself better though.

Currently, I have two options (that I know about):

1) I can draw my light-sprites on a black background, then blend the 
foreground on top, so the dark parts of the screen is still dark.
    The problem with this, is that the foreground consists of many layered 
sprites (a tilemap, in a single batch, using OrderedGroups), and I don't 
know whether they'll overlap, or hit the "background" directly.
2) I can draw my light-sprites on top of the foreground, blending it so it 
darkens out the non-lit parts.
    The problem I'm having with this solution, is that I can't figure out 
how to dark out all the parts outside of the light-sprites.

In both cases, I'm assuming that the solution to my problem would be to 
merge either the foreground or the lights, (respectively to solve either 1 
or 2), into a single world-sized image before blending it onto the other.

So, essentially, I'd like to draw my game, then "darken out" the inverse of 
a group of sprites.
It might be that there's some blending-setup that will just magically solve 
this problem. I just can't seem to figure out what that might be.

fredag den 22. juni 2018 kl. 00.03.05 UTC+2 skrev Neon22:
>
> If you mean what's the general way people do this then I'd suggest 
> examining the asteroids example. Use sprites and the order they are drawn 
> is the order they will appear.
> You could then look at Batches and Groups to see how to organise them 
> efficiently like you refer to layers.
>
> - 
> https://pyglet.readthedocs.io/en/pyglet-1.3-maintenance/modules/graphics/index.html#batches-and-groups
>
> On the other hand if you mean to change how the blend occurs then consider 
> this:
> 99% of the time people use gl.glBlendFunc in this way:
>
> pyglet.gl.glEnable(pyglet.gl.GL_BLEND) 
> pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA, pyglet.gl.
> GL_ONE_MINUS_SRC_ALPHA)
>
> to use the alpha in an image as a mask. but you want a different notion of 
> blending where the colors mix.
>
> There are many ways to do this.
> The different options are in the table below but this page does not 
> explain how to use them to get the effect you want.
> This page does. Go crazy :)
>
> - https://www.andersriggelsen.dk/glblendfunc.php
>
> Swap the first and second args in the above code until you get what you 
> need.
> or read up on openGL blending functon here and make an informed choice:
> - https://www.khronos.org/opengl/wiki/GlBlendFunc
>
> you could start with:
> pyglet.gl.glEnable(pyglet.gl.GL_BLEND)
> pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_COLOR, pyglet.gl.
> GL_ONE_MINUS_SRC_COLOR)
>
> or additive blending:
> pyglet.gl.GL_SRC_ALPHA, pyglet.gl.GL_ONE
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to