Hello!
I am having a problem again. This time it is the shader. I have made up a cube out of 6*2 triangles and I am feeding the textureCoordinates to the GPU. But I am not able to get the coordinates to work inside the shader. They seem to be 0, 0 all the time, so that the applied texture is just made up of the first pixel at position 0,0.
I have surely made some superstupid mistake. Or maybe a hundred. And I know my code is crap because I thought I would just make a few tests and then do some serious work refactoring it all beautifully… :S
Here is the constructor for the box:
public Box(){
vertBuff = new VertexBufferObject(6*6*3);
texCoordBuff = new VertexBufferObject(6*6*2);
vertBuff.put(new float[]{ -1,-1,1, 1,-1,1, 1,1,1, // first side
-1,-1,1, 1,1,1, -1,1,1,
1,-1,1, 1,-1,-1, 1,1,-1, // second side
1,-1,1, 1,1,-1, 1,-1,1,
1,-1,-1, -1,-1,-1, -1,1,-1, // third side
1,-1,-1, -1,1,-1, 1,1,-1,
-1,-1,-1, -1,-1,1, -1,1,1, // fourth side
-1,-1,-1, -1,1,1, -1,1,-1,
-1,1,1, 1,1,1, 1,1,-1, // fifth side
-1,1,1, 1,1,-1, -1,1,-1,
-1,-1,1, 1,-1,1, 1,-1,-1, // sixth side
-1,-1,1, 1,-1,-1, -1,-1,-1,
});
texCoordBuff.put(new float[]{ 0,0, 1,0, 1,1,
0,0, 1,1, 0,1,
0,0, 1,0, 1,1,
0,0, 1,1, 0,1,
0,0, 1,0, 1,1,
0,0, 1,1, 0,1,
0,0, 1,0, 1,1,
0,0, 1,1, 0,1,
0,0, 1,0, 1,1,
0,0, 1,1, 0,1,
0,0, 1,0, 1,1,
0,0, 1,1, 0,1,});
vertBuff.glBufferData();
useShader = setupShader(); // does all the shader stuff to get the shader working...
tM = TextureManager.getTextureManager();
tM.addTexture("tex", "img/testTextur.png");
tex = tM.getTexture("tex");
}
The rest of the code with the relevant parts can be found here:
http://pastebin.java-gaming.org/04394478943
OOOOpppppssss… forgot the rest of the post:
I know you have great knowledge about those things!
Can someone help me with this? The tutorials I found are just confusing me. And programs like ShaderDesigner and RenderMonkey couldn’t help me either.