I apologize for some of my ignorance as I am fairly new to Slick2D and LWJGL. Essentially what I'm trying to do is make a scene look like night time by covering it with a GL_QUADS rectangle that is tinted blue and is translucent.

That part is easy enough. What I want to do from there is draw triangles into this layer that vary the alpha channel so. The reason I want to do this is so I can simulate a light source by decreasing the opacity of the blue tinted rectangle as it gets closer to the light source.

I drew an example of what the expected result should be with the green being the background, the blue being the nighttime effect created by a blue tinted rectangle, and the increasingly dim light source in the center.

I need to find a way to do this with triangles because I created a raycasting algorithm that generates the result as a series of gradient triangles.

I apologize if this is explained poorly. I will answer any questions you might have.

Again, I'm using triangles to approximate a circle and allow for proper raycasting.

Answer:

To achieve this, the use of a Frame Buffer Object is super useful. A FBO allows you to essentially render to a texture which can then be displayed on the screen. In my particular case, I rendered the elements to a FBO then used a shader while drawing it to the screen to get the desired opacities.

I am creating a 2D game with lwjgl and slick-util. For a special feature in my game I wanted to be able to give textures a certain opacity. I have managed to figure this out but the next step is giving a Texture as a paramter which will give me the ability to give certain textures certain opacities in certain spots.

Note: I have gotten it sort of working before, but the mask also seemed to remove my background image, which I do not want.

I cannot post images because I dont have enough reputation or something but anyway what I want to basically do is:

first render a background image.

then render another images on top with a mask on it, I do not want this mask to apply onto the background.

How would I go about doing this?

Answer:

I think you use wrong blending mode. If you did not change default blending mode, then you need:

Screenshots:

http://i.imgur.com/sPmPqne.png - GL_BLEND enabled on QUAD and text, I can see the line that is on disabled GL_BLEND

i imgur com/nkda41v png - GL_BLEND disabled on everything but the text -> I need some reputation to post more than 2 links, sorry about that but I belive this image is important so i'll post it anyway. Just fill with dots

The results are the same with or without alpha argument on all these tests

I already tried:

Disabling/Enabling GL_BLEND in part of the code (I know some things wouldn't work, but you never know, right?)

Used constants to the alpha variable (such as 0.3f, 0.5f, 0.7f, 1f) instead of making it variable through Math.sin/cos using the tick as the degree

Using glRect(...)

Changing the background

Removing the glClearColor

Removing glClear(nice effect, never did this lol)

What I expect to see was a fading moving LINE_STRIP:

On one side it moves from the (0, 0) to (width - 7%, height - 5%)

On the other it stand still on (width + 3%, height + 5%)

the rectangle would make it fade (the original idea would use the same color as the background, but it didn't on my tests because I want to see the rectangle)

Answer:

I've had a similar(in terms of what I had to tackle) when doing a 2D game using my own engine. LWJGL's blend functions always have a few issues and there aren't really that many concrete answers for them as it really boils down to your code and how you placed things.

I presume you're using SlickUtil, and to that I would say write your own (or of course search around) your own methods for this. Util's methods were always somewhat wonky with blending.

Removing alpha shouldn't have changed much in terms of getting
what you want

The only time I explicitly enable GL_BLEND is
when rendering lights(always presuming you're doing 3D) and when I would render textures

I suggest not removing glClearColor, that doesn't directly affect your situation as
long as you put it in the correct place

Like I said this bug/problem could be due to quite a few things that I can't quite pin-point from what you've posted.

My suggestions are:

Organise the whole project well to be able to point bugs out quickly

Make alot of stuff generic ASAP(Doesn't matter if you just want to quickly write something)

Avoid SlickUtil, it's great and I LOVE it but it does get it's issues

Sorry I can't help too much but tracking down your issue from the jumbled up code you posted is a bit difficult. I'll keep my eye on this question in case I may be of help in the future.