views:

37

answers:

2

Hello! I have a texture in my Square. The problem is when I assign floating texture points the image gets rotated 45 degrees at right. I want it without the rotation.

The current texture points:

texture = new float[]{
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 0.0f,
1.0f, 1.0f,
};

Any ideas? Thanks in advance!

This is how it ends:

alt text

This is how I want it:

alt text

+1  A: 

I think you want:

texture = new float[]{
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.0f,
};

i.e. swapping the third and fourth entries.

Edit: Should be:

texture = new float[]{
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
};
Jackson Pope
Hm, didn't worked.
Julian Assange
Could you post a picture of the problem?
Jackson Pope
Look at my edited post. :)
Julian Assange
Well, it worked, but I noticed that my texture now was flipped horizontally, any ideas? It was not flipped horizontally when it had been rotated?
Julian Assange
Should be fixed now.
Jackson Pope
Thank you, it works now. But (!) I'm not sure how to use the texture floats, how it is meant to be used. I understand the vertexs and indices floating points. It just the texture floating points that confuses me. Any resources where I can learn this?
Julian Assange
The texture floating point values correspond to the coordinates of that vertex on the texture. with the first coordinate being the x coordinate (0.0 = left edge, 1.0 = right edge) and the second being vertical coordinate (0.0 = top edge, 1.0 = bottom edge), so 0.5,0.5 would be the centre of the texture image.
Jackson Pope
Thank you very much!
Julian Assange
A: 

This is OpenGL right? There could be several reasons... please post some code. Firstly are you sure your projection is set up correctly?

Secondly, check that your texture co-ords correctly correspond to your vertex coords.

Reuben Scratton
The projection is correctly set up. When you say correspond to my vertex coords, how exactly do you mean?
Julian Assange