Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (429)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (468)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3 ... 26
1  Game Development / Newbie & Debugging Questions / Re: How do you control game speed? on: 2014-04-24 09:06:22
What are you talking about? I told you, if you want to change game speed, use a global game_speed value, and you have to multiply everything that involves changing values with game game_speed value. That involves: the speed of spell casting, the speed of moving, the speed of rotating, the speed of everything. Every time you do something like integer++, you need to do integer+=1f*Game.speed;
2  Game Development / Newbie & Debugging Questions / Re: How do you control game speed? on: 2014-04-24 07:53:41
You mean you want game to run at 1/4 speed for example? The only way I know is to have a global variable like speed and multiply every operation you do in your game by that variable.

So if you want to have 1/4 speed, have like static float speed = 0.25f;

When you want to move character, multiply the amount you add to players position by 0.25f. So
1  
player.x += player.speed * Game.speed;


And yes, you need to do this for EVERY variable you modify that needs to change speed.. I don't know any other way.
3  Game Development / Newbie & Debugging Questions / Re: Inventory System? on: 2014-04-24 07:16:55
Here is how I did it for one of my games.

Inventory is made up of like 8*5 inventory slots or something. Basically Item[] items=new Item[8*5];
Each slots contains an item. When I want to render inventory, I go through all the item slots and if there is an item in the slot, I do item[slotIndex].render();
I mean, what do you even want to ask?

If you're asking about item system itself, I made it like this. Every item extends Item.class. Every item has its own class. Every items needs to define few parameters like sprite used, name and some other custom ones. I also have a static instance of each item in my Item class.

When I want to add item to inventory, I just do items[index]=item and the item appears in the inventory.

If you want to have more customized items like each having each own's durability, special effects, you will need to create a class like 'SpecializedItem.class'. It would accept 'base item' as parameters. When you render specializeditem, render the base item, and render the effects you want on top of it.

It is probably really hard to understand, but the easiest way to do it, would be to actually do it, and not think about it. Think about performance and saving/loading later.
4  Game Development / Newbie & Debugging Questions / Re: Java programming path on: 2014-04-23 06:22:25
I'm really against people who "think that beginners can do that". Lets the beginners try and tell you what they can do..
5  Game Development / Newbie & Debugging Questions / Re: Java programming path on: 2014-04-23 06:04:40
Some people here are soooooooooo forgetting the time when they started programming. I would suggest you guys to remember the days when you just started programming, and didn't know anything.

I would highly guess that you were using java2d to make games, because it was much simpler at first, and you didn't need all the performance anyway, because you wouldn't even need more performance in java2d anyway, meaning you were so bad at coding that you couldn't fill the game with stuff.

My suggestion would be to start with whatever you want, but when you want to start a serious game project, move to LWJGL, Libgdx, Monkey Engine or Unity or other leading game engines.

I bet no beginner would understand a thing in Libgdx/Lwjgl..
6  Game Development / Newbie & Debugging Questions / Re: Program for spritesheet? on: 2014-04-22 20:15:58
Maybe you entered image width, height in new SpriteSheet(.., int spritewidth, int spriteheight) instead of individual sprite coordinates?
7  Game Development / Newbie & Debugging Questions / Re: Program for spritesheet? on: 2014-04-22 20:07:49
What are you talking about? Are you just slapping whole texture onto the quad?
8  Game Development / Game Mechanics / Re: Mathematical curves. on: 2014-04-22 18:17:42
I don't think curves are suitable for explosions.

You just give particles a 'random' acceleration away from an origin (or apply a force, from an origin) and then simulate drag and gravity.

It would be used for more like light pulse. So it appears really quickly and slowly fades out. Wouldn't be used for the particles themselves.

EDIT-----------
Thanks for the replies, for for now I will just stick with hard coded values, since I only have 16 frames to animate. I just coded each value by hand. That looked pretty nicely. I mean, the light goes so fast that you can't really see much. Probably even linear interpolation would be enough.
9  Game Development / Game Play & Game Design / Re: Overall design strategy. on: 2014-04-22 11:21:29
My take on this topic:
* Is your room 24/7 clean? No.
* Do you clean your room everyday? No.
* Do you clean your room every weekend or something like that? Yes.

Logic:
Just slam the code in the same class. Once you can see that you need to move it somewhere, do it. There is no point in structuring the code if you don't feel like it. If you code is perfectly readable without structuring it, whats the point of doing so?
10  Game Development / Game Mechanics / Re: Mathematical curves. on: 2014-04-22 07:19:20
I'm sorry to be asking again, but, I need some kind of equation for explosion. I basically want an equation that would explode at its peak in the first few moments and would gradually increase slow down speed until 0. Any ideas which one I should use? Tongue
11  Game Development / Newbie & Debugging Questions / Re: Best way for using keypress to move images/character on: 2014-04-22 06:12:38
Here use this! Cheesy
http://www.java-gaming.org/topics/is-lwjgl-capable-of-checking-if-a-key-was-tapped/31827/view.html

You can easily incorporate keyboardhandler class with swing/awt or whatever you are using.
12  Game Development / Newbie & Debugging Questions / Re: Collision detection rotated rectangle on: 2014-04-21 15:38:41
I have this bad boy written here.

The way it works is, you define a simple rectangle(x,y,width,height). You can rotate that rectangle around specified point in .rotate method.

If you want access to the rotated coordinates, you have x1,y1,x2,y2,x3,y3,x4,y4 which basically represent the rotated corners. You might also want to make a move method or something so that these 8 values get updated when you change x,y values.

Although .translate does that I think.

Here is the code. You will also need to put Rotation class somewhere. It might be pretty helpful too.

PS I have no idea how to make my rect class work again. I tried rewriting it today, but the collision were kinda off. So I thought I would just use this one, because it works magic Cheesy

Ow and to people who say "He isn't asking for code, he is asking for help". Well most of you say "Don't reinvent the wheel" so here you go.

So here is the Rect.java class.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
public class Rect {

   public float x, y, width, height, rot, px, py;

   public float x1, y1, x2, y2, x3, y3, x4, y4;

   public Rect(float x, float y, float width, float height) {
      this.x = x;
      this.y = y;
      this.width = width;
      this.height = height;
      this.px = x + width / 2;
      this.py = y + height / 2;
      set(x, y, x + width, y, x + width, y + height, x, y + height);
   }

   public Rect(Rect rect) {
      this(rect.x, rect.y, rect.width, rect.height);
      rot = rect.rot;
      px = rect.px;
      py = rect.py;

      x1 = rect.x1;
      y1 = rect.y1;
      x2 = rect.x2;
      y2 = rect.y2;
      x3 = rect.x3;
      y3 = rect.y3;
      x4 = rect.x4;
      y4 = rect.y4;
   }

   private void set(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) {
      this.x1 = x1;
      this.y1 = y1;
      this.x2 = x2;
      this.y2 = y2;
      this.x3 = x3;
      this.y3 = y3;
      this.x4 = x4;
      this.y4 = y4;
   }

   public Rect rotate(float px, float py, float rot) {

      this.px = px;
      this.py = py;

      float sin = (float) (Math.sin(Math.toRadians(rot)));
      float cos = (float) (Math.cos(Math.toRadians(rot)));

      float x = this.x - px;
      float y = this.y - py;

      float x1 = cos * (x) - sin * (y) + px;
      float y1 = sin * (x) + cos * (y) + py;

      float x2 = cos * (x + width) - sin * (y) + px;
      float y2 = sin * (x + width) + cos * (y) + py;

      float x3 = cos * (x + width) - sin * (y + height) + px;
      float y3 = sin * (x + width) + cos * (y + height) + py;

      float x4 = cos * (x) - sin * (y + height) + px;
      float y4 = sin * (x) + cos * (y + height) + py;

      set(x1, y1, x2, y2, x3, y3, x4, y4);

      return this;

   }

   public boolean collides(float x, float y) {

      vec2 p = Rotation.point(new vec2(px, py), new vec2(x, y), -this.rot);

      x = p.x;
      y = p.y;

      return collidesSimple(x, y);
   }

   public Rect translate(float x, float y) {
      this.x += x;
      this.y += y;
      px += x;
      py += y;
      x1 += x;
      y1 += y;
      x2 += x;
      y2 += y;
      x3 += x;
      y3 += y;
      x4 += x;
      y4 += y;
      return this;
   }

   public boolean collidesSimple(float x, float y) {
      return x >= this.x && x < this.x + width && y >= this.y && y < this.y + height;
   }

   public boolean collidesSimple(Rect rect) {
      return this.collides(rect.x, rect.y) || this.collides(rect.x + rect.width, rect.y) || this.collides(rect.x + rect.width, rect.y + rect.height) || this.collides(rect.x, rect.y + rect.height);
   }

   public Rect rotate(float rot) {
      return this.rotate(x + width / 2, y + height / 2, rot);
   }

   public void updateSimpleData() {
      x1=x;
      y1=y;
      x2=x+width;
      y2=y;
      x3=x+width;
      y3=y+height;
      x4=x;
      y4=y+height;
   }
   
   public vec2 getCenter() {
      return new vec2(x + getWidth() / 2, y + getHeight() / 2);
   }

   public int getX() {
      return (int) x;
   }

   public int getY() {
      return (int) y;
   }

   public int getWidth() {
      return (int) width;
   }

   public int getHeight() {
      return (int) height;
   }

   public float[] rotateData(float rot, float px, float py) {

      float[] values = new float[8];

      if (rot != 0) {

         float x1 = this.x1 - px;
         float y1 = this.y1 - py;

         float x2 = this.x2 - px;
         float y2 = this.y2 - py;

         float x3 = this.x3 - px;
         float y3 = this.y3 - py;

         float x4 = this.x4 - px;
         float y4 = this.y4 - py;

         float sin = (float) Math.sin(Math.toRadians(rot));
         float cos = (float) Math.cos(Math.toRadians(rot));

         int pos = 0;

         values[pos++] = cos * x1 - sin * y1 + px;
         values[pos++] = sin * x1 + cos * y1 + py;

         values[pos++] = cos * x2 - sin * y2 + px;
         values[pos++] = sin * x2 + cos * y2 + py;

         values[pos++] = cos * x3 - sin * y3 + px;
         values[pos++] = sin * x3 + cos * y3 + py;

         values[pos++] = cos * x4 - sin * y4 + px;
         values[pos++] = sin * x4 + cos * y4 + py;
      } else {
         int pos = 0;

         values[pos++] = x1;
         values[pos++] = y1;
         values[pos++] = x2;
         values[pos++] = y2;
         values[pos++] = x3;
         values[pos++] = y3;
         values[pos++] = x4;
         values[pos++] = y4;

      }

      return values;
   }

   public static boolean collides(Rect r1, Rect r2) {
      return r1.collidesSimple(r2) || r2.collidesSimple(r1);
   }

}


And here is the Rotation class used in .collides(float, float)  method.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
public class Rotation {

   public static int angle(vec2 pivot, vec2 point) {

      float xdiff = pivot.x - point.x;
      float ydiff = pivot.y - point.y;
     
      float angle = (float) ((Math.atan2(xdiff, ydiff)) * 180 / Math.PI);
     
      return -(int)angle;
   }
   
   public static float angle(float x0, float y0, float x1, float y1) {
      return angle(new vec2(x0, y0), new vec2(x1, y1));
   }
   
   public static vec2 point(vec2 pivot, vec2 point, float rotation) {
     
      float rot = (float)(1f / 180 * rotation * Math.PI);
     
      float x = point.x - pivot.x;
      float y = point.y - pivot.y;
     
      float newx = (float)(x * Math.cos(rot) - y * Math.sin(rot));
      float newy = (float)(x * Math.sin(rot) + y * Math.cos(rot));
     
     
      newx += pivot.x;
      newy += pivot.y;
     
      return new vec2(newx, newy);
   }
   
}
13  Game Development / Newbie & Debugging Questions / Re: Path easing? on: 2014-04-21 08:52:54
I think I need to use splines. Just need to figure out how to do it.
14  Game Development / Newbie & Debugging Questions / Path easing? on: 2014-04-21 08:26:29
I have this path drawn out in black. Green pixel is starting point. Red pixel is the end of the path. The movement happens from center of each black pixel the the next black pixels center.

The problem is that this path look really cornery if you will.

Here is the small res path I would like to smooth out (It is scaled 300%)


Here is how I would like the path to look (green line)


Any ideas how I could smooth the path out?
15  Game Development / Newbie & Debugging Questions / Re: [LWJGL/Slick] How do you distribute a game without JarSplice? on: 2014-04-21 06:13:01
I know how to help. Here:
http://www.java-gaming.org/topics/compiling-and-running-a-lwjgl-project/31479/view.html

Eclipse doesn't export with natives. Libgdx is a whole different story. It loads natives from a jar at runtime, so you don't have to do anything about it. For Libgdx natives are like resources or something like that.
16  Game Development / Newbie & Debugging Questions / Re: [LIBGDX] Tiled pathfinding, any examples? on: 2014-04-20 16:01:30
If you want path finding, use A*. Here is the simplest and best tutorial on it.

http://www.policyalmanac.org/games/aStarTutorial.htm
17  Discussions / Miscellaneous Topics / Re: Where to find dark windows themes? on: 2014-04-19 11:02:10
f.lux or turn down the brightness down. I'm pretty sure your new monitor should have a button that would have some presets already made.
18  Game Development / Newbie & Debugging Questions / Re: Advice for learning game development? on: 2014-04-19 09:33:37
I don't think there is a point in brain storming ideas, if you cannot implement them. Start with something like moving square which is rotating towards the movement direction and when left mouse click occurs you shoot a small projectile toward the mouse, which disappears when it hits the end of the screen.

I mean, if you really don't have any experience, this would probably be more than enough for exercise. Also, if you're not using Libgdx of LWJGL, remove the rotation part, because with Java2D learning how to rotate objects is a mess, and even if you learn to do that, you won't be using it in the future anyway.
19  Game Development / Newbie & Debugging Questions / Re: OpenGL shaders Texture Buffer Object not working on: 2014-04-19 09:24:00
It seems that most of my code was correct. The only thing I had to modify from what I posted in the thread, is remove this line:
1  
GL11.glBindTexture(GL31.GL_TEXTURE_BUFFER, 0);


I didn't realize you need to keep the texture bound for it to work.
20  Game Development / Newbie & Debugging Questions / Re: Advice for learning game development? on: 2014-04-19 09:21:51
Just make any game you want. If it is your first game, you should probably choose simplest game possible, because you would be surprised how much you need to do to make even very simple playable game.

Seriously, stop thinking about what you need to learn to make a game, and learn while making the game. When you run into a problem when making a game and don't know how to fix it, you need to look more into it. You won't really be able to make games without making games.
21  Game Development / Newbie & Debugging Questions / OpenGL shaders Texture Buffer Object not working on: 2014-04-19 08:02:25
Shader uniform samplers:
1  
2  
uniform sampler2D u_texture;
uniform samplerBuffer u_lights;


Somewhere in shader program code I link the shader program, use it, bind my texture used for rendering textures to texture unit 1, bind my light texture buffer sampler to texture unit 2 and validate the shader:
1  
2  
3  
4  
5  
6  
      link();
      use();
      GL20.glUniform1i(getUniformLocation("u_texture"), 1);
      GL20.glUniform1i(getUniformLocation("u_lights"), 2);      
     
      validate();




Create texture buffer and buffer object:
1  
2  
      textureBuffer = GL11.glGenTextures();
      lightBuffer = GL15.glGenBuffers();


Here is where I deal with texture buffer data:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
      GL15.glBindBuffer(GL31.GL_TEXTURE_BUFFER, lightBuffer);
      FloatBuffer lightData=makeLightData();
      GL15.glBufferData(GL31.GL_TEXTURE_BUFFER, lightData, GL15.GL_STREAM_DRAW);
     
      GL13.glActiveTexture(GL13.GL_TEXTURE2); // activate texture unit 2, which is sampler 'u_lights'
     
      GL11.glBindTexture(GL31.GL_TEXTURE_BUFFER, textureBuffer);
      GL31.glTexBuffer(GL31.GL_TEXTURE_BUFFER, ARBTextureRg.GL_R32F, lightBuffer); // R32F big floats
     
      GL11.glBindTexture(GL31.GL_TEXTURE_BUFFER, 0);
      GL15.glBindBuffer(GL31.GL_TEXTURE_BUFFER, 0);
      GL13.glActiveTexture(GL13.GL_TEXTURE1); // activate my default texture unit


Here is my FloatBuffer creation method:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
   private FloatBuffer makeLightData() {

      FloatBuffer buffer = BufferUtils.createFloatBuffer(1);

      buffer.put(1);
     
      buffer.flip();

      return buffer;
   }


Here is somewhere in my fragment shader where I render the scene. The problem is that the scene turns out black. Should be white. If I swap texelFetch() with 1.0, the scene turns out white.
1  
   lighting.rgb+=texelFetch(u_lights, 0).r;
22  Game Development / Newbie & Debugging Questions / Re: LWJGL Invalid Enum Exception on: 2014-04-18 19:41:57
OK it would seem that I have found the problem. When I start my game, somewhere in that process, 1280 occurs. Since I'm not doing glGetError, it stays there. When doing Display.setVsyncEnabled(), it seems to do glGetError() in the stack trace, so I would assume that it throws an error that it isn't supposed to. I mean, there should be notes left or something for developers of such pitfalls. Something like 'must read' or something. It was my codes fault, but it only happened, because of kinda faulty design that could at least warn you of such pit falls..
23  Game Development / Newbie & Debugging Questions / Re: LWJGL Invalid Enum Exception on: 2014-04-18 19:23:50
Here you go help yourselves. I got the exception on my other very old laptop as well. Not only it seems that this very old laptop doesn't support anything that is useful shader wise, but it also has this stupid bug with throwing enum exception when switching vsync. I can get around dynamic indexing with huge pieces of code (maybe, i hope), but I have literally no idea how to fix that vsync bug. Anyway, here is the error I get.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
org.lwjgl.opengl.OpenGLException: Invalid enum (1280)
        at org.lwjgl.opengl.Util.checkGLError(Util.java:59)
        at org.lwjgl.opengl.WindowsContextImplementation.setSwapInterval(Windows
ContextImplementation.java:113)
        at org.lwjgl.opengl.ContextGL.setSwapInterval(ContextGL.java:232)
        at org.lwjgl.opengl.DrawableGL.setSwapInterval(DrawableGL.java:86)
        at org.lwjgl.opengl.Display.setSwapInterval(Display.java:1129)
        at org.lwjgl.opengl.Display.setVSyncEnabled(Display.java:1142)
        at com.cig.survival.menu.OptionsMenu$1$1.doAction(OptionsMenu.java:22)
        at com.cig.survival.Game.tick(Game.java:264)
        at com.cig.survival.WildernessToHome.loop(WildernessToHome.java:75)
        at com.cig.survival.WildernessToHome.start(WildernessToHome.java:47)
        at com.cig.survival.WildernessToHome.main(WildernessToHome.java:182)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
24  Game Development / Newbie & Debugging Questions / Re: LWJGL Invalid Enum Exception on: 2014-04-18 18:08:41
I'm pretty sure setVSyncEnabled() cannot cause an OpenGL error. Code?

How am I supposed to show you the code? What code? I mean, do I upload my game source or something? What kind of code do you want? VBO? Shaders? Something else?
25  Game Development / Newbie & Debugging Questions / Re: LWJGL Invalid Enum Exception on: 2014-04-18 17:21:31
Invalid enum means error code 1280 by itself.

I'm starting to hate this.. It seems that what I can do on older machines is limited by their hardware. On my machine everything works, but on those machines you get stupid errors that don't make any sense to you unless you know everything about the API..

Does the same thing happen when you use C++ and OpenGL? Should I just concentrate on newer hardware? I mean, I can't even debug properly the errors I get on that 4 or 5 year old laptop. I mean, it gives me this stupid error with invalid enum, which make no sense to me..

26  Game Development / Newbie & Debugging Questions / LWJGL Invalid Enum Exception on: 2014-04-18 16:21:04
My game runs perfectly fine on my computer. When I start it on some laptop, and try to do Display.setVsyncEnabled() I get LWJGL Invalid Enum Exception.

What could be causing this absurd error? Is this error in my code?

Worst case scenario is I would go and install Eclipse on that laptop and find out what is causing this error with a lot of trial and error, which I would rather avoid if possible.
27  Discussions / Miscellaneous Topics / Re: f.lux on: 2014-04-18 11:54:56
When it gets dark I turn on table lamp Cheesy That way screen is not too bright. I don't understand people who spend their night with monitor and back lit keyboard's lights.
28  Discussions / Miscellaneous Topics / Re: f.lux on: 2014-04-18 10:42:49
It seems that this was just a coincidence, and my eye redness is no flux fault.

It seems that if I eat even few small bytes of smoked bacon (i don't know how to properly translate it) my eyes turn red if I sit even for short periods of time in front of computer for next 2 days. I remember eating some of it the night I downloaded flux. I'm using it now also and enjoying it Cheesy

I don't even know how can such coincidences happen..
29  Game Development / Newbie & Debugging Questions / Re: LWJGL sending information to shaders via texture on: 2014-04-18 09:48:51
I think I got one last mystery problem.

I fill texture:
1  
GL11.glTexImage1D(target, 0, ARBTextureRg.GL_R16F, 2, 0, GL11.GL_RGBA, GL11.GL_FLOAT, makeLightData());


with this data:
1  
2  
      buffer.put(1f).put(0).put(0).put(0);
      buffer.put(0).put(1).put(0).put(0);

As you can see I make 2 pixel wide texture, which's first pixel is red, and second pixel is green.


In fragment shader, I multiply the output of my game color by this:
1  
   vec4 col = texture(u_lights, 0.0);

so that I know what kind of color I'm picking from my 1d texture.
The problem is that when texcoord is 0.0, it picks the red color. When texoord is 1.0, it still picks the red texel. Any suggestions?


EDIT-
I fixed it.
I needed to do image for GL_RED so that I only had 1 component / texel.
1  
GL11.glTexImage1D(target, 0, ARBTextureRg.GL_R16F, 2, 0, GL11.GL_RED, GL11.GL_FLOAT, makeLightData());

ARBTextureRg.GL_R16F allows to send floats bigger than 1. That means you can send 10 or 800 or 10055 or whatever you want and that value will arrive to the shader.

Also, trying to access 1.0 texel basically tells GLSL to access texel of 0.0, because it probably does inputTexel%1, which means it is capped to 1.0.

So now I can basically send an array of floats to shaders via texture and access that array by doing:
1  
2  
float index=float(i) / arraySize;
texture(u_lights, index).r;


There is a lot to explain so I will just write a tutorial in a few days.
30  Game Development / Newbie & Debugging Questions / Re: LWJGL sending information to shaders via texture on: 2014-04-18 09:22:05
Ok I got into kinda another problem. When I get 2 samplers, for example:
1  
2  
uniform sampler2D u_texture;
uniform sampler1D u_lights;


I get this GLSL validation error:
Quote
Validation failed! - Different sampler types for same sample texture unit in fragment shader.

Any ideas how I go about fixing it?

I already tried this before validating, linking the shader, in between those, after those and none of it helps.
1  
2  
GL20.glUniform1i(getUniformLocation("u_texture"), 1);
      GL20.glUniform1i(getUniformLocation("u_lights"), 2);


EDIT-
Ok I fixed it. Here is the link that helped me.
http://www.opengl.org/discussion_boards/showthread.php/176366-Samplers-of-different-types-use-the-same-textur
Pages: [1] 2 3 ... 26
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

theagentd (6 views)
2014-04-24 23:00:44

xsi3rr4x (83 views)
2014-04-15 18:08:23

BurntPizza (75 views)
2014-04-15 03:46:01

UprightPath (86 views)
2014-04-14 17:39:50

UprightPath (69 views)
2014-04-14 17:35:47

Porlus (86 views)
2014-04-14 15:48:38

tom_mai78101 (109 views)
2014-04-10 04:04:31

BurntPizza (169 views)
2014-04-08 23:06:04

tom_mai78101 (265 views)
2014-04-05 13:34:39

trollwarrior1 (216 views)
2014-04-04 12:06:45
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!