Slick2D OpenGL Alpha Map problems

Hello :slight_smile:

I want to create a dark room and light the way of the character. But this code:


			g.clearAlphaMap();
			
			GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
			g.setDrawMode(Graphics.MODE_ALPHA_MAP);
			character.getAlphaMap().drawCentered(activeProt.x, activeProt.y);
			
			GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_DST_ALPHA);
			g.setColor(Color.darkGray);
			g.fillRect(0, 0, 750, 450);
			
			g.setDrawMode(Graphics.MODE_NORMAL);

does not work. This snippet is in the render method. Before this code snippet there are only items and animations drawn. And a g.resetTransform();

I already put the first part “g.clearAlphaMap()” at the beginning of the render Method. But then there is a grey box.

I tested the alpha mapping in a test project, only containing of a background image and the alphamap png. That worked as expected.
What is wrong? Please help me :slight_smile:

Shame on me… found the mistake somewhere else. This code above is good :slight_smile:

thanks though for reading :wink:

2 4 things:
Think before you post.
Think harder before you post.
Think 10x harder than before you thought harder before you posted
Slick is a little outdated, and I see that you are just using lwjgl at this point. Here is some advice: If you know how to use those commands, slick2d is not for you. Go to libgdx. You will not regret it.

Sometimes when you post, and you come to explain your problem, you start to see what you have done wrong.
No-one’s time was wasted here, through posting he came up with his own answer. I don’t see why he shouldn’t have posted this. It didn’t harm anyone.

Considering he is working with Alpha maps, I think he is a considerable way through his project. By switching to libgdx, he would not only have to go through the process of learning it, but also going through all his code and re-doing everything. When you add all that time together, it would probably not justify switching to libgdx.

Touche. Just for further reference. Sorry.

Again, just for future reference, when he can switch. None the less, good point.

  1. No
  2. No
  3. No
  4. No

I say no to 4 because building your own framework may be harder, but you learn how to actually use core OpenGL. Do you know what all those functions in LibGDX do (or how they basically work)? If you don’t, I would recommend strongly that you learn plain OpenGL and then use frameworks that build on top of it. What happens if LibGDX dies someday and there are no other libraries for Java and LWJGL? Well, you’re screwed because you have no idea how to use basic LWJGL. I think ignorance of the OpenGL language would be solved partially if new people to the library would learn how to use OpenGL first before moving onto Slick2D, LibGDX etc…

Also, don’t tell him to think harder. Everyone makes mistakes and he even admitted it. You are quite the newbie here too, don’t go around telling others what to do.

Learning straight OpenGL takes a bit of work, but it really is worth it. Have to admit, though, it took a little bit of stumbling to get used to OpenGL ES 2.0 and its shader reliance after only being used to OpenGL 1.4 for so long.

http://www.java-gaming.org/topics/slick2d-mouse-position-is-off/29876/msg/275108/view.html - Answered self on same day
http://www.java-gaming.org/topics/strange-camera-detection/29809/msg/274368/view.html - Answered self on same day
http://www.java-gaming.org/topics/get-angle-direction-from-vector2f/29871/msg/275046/view.html - Failed to read api
You’re one to talk. Most of your posts would have been solved easily after “thinking harder.”