Can anybody explain to me how the u,v texure coordinates work with the primitive addon? For example, what range are they in? 0 to 1? And what do you when mapping a square texture to two triangle faces joined as a quadrilateral?
Thanks guys,
Ted
The first couple of questions are answered in the ALLEGRO_VERTEX documentation. I don't understand your last question very well...
He asks how to assign the u,v coords to triangles. Since the ALLEGRO_VERTEX doc says it's in pixels, and the primitive vertices are in pixels and assume ccw winding, and suppose the hypotenuse was from top right to bottom left, it'd be something like this with a 256x256 texture.
{"name":"606560","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/e\/ee4fad063f15b8b9aa71b6ab00cf66b7.png","w":854,"h":476,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/e\/ee4fad063f15b8b9aa71b6ab00cf66b7"}
You act like I don't read the documentation :-p
Yeah, I tried 0,0 60,0 60,60, etc... for my texture (it is a 60x60 image). All I get is a solid pale blue, no texture.
That's why I posted to make sure I was doing the u,v coordinates mapping to the texture correctly, seems I am.
OK, let me try it myself (for the first time). Gimme 30-40 minutes.
Image is 60x60
Should work, right? Or am I missing something major.
You act like I don't read the documentation :-p
That's because there are too many questions from people who haven't read the documentation. It can be a good idea to indicate that you have looked for an answer but have been unsuccessful.
I know. Just kidding around. I guess when it hits 3:32 AM (my time) my sense of humor is poor.
Welp, took me a little longer than I thought. I had to insert colors into the vertex definitions, unlike the example code on http://www.allegro.cc/manual/5/al_draw_prim.
Anyway, here's a zipfile to play with.
[EDIT]
Probably the vertices could have been in one struct, and only one al_draw_prim() call would have to be made, adjusting the 3 to 6.
Thanks I'll check it out either tonight or tomorrow...its getting late.
My vertices are not colored also, which may be part of the problem.
Thanks.
I tried it your way (where you commented them out) but the compiler complained, I assume that's why you commented them out. If you play with those colors to be other than white, they'll tint the texture. Maybe this is because Linux uses OpenGL? If DirectX is different, it's a bug?
You definitely have to specify the color... the documentation is wrong in that part... jokes on me for referring you there, I suppose .
You definitely have to specify the color... the documentation is wrong in that part
Note that when you must initialize all members of this struct when you're using it.
I think it's pretty clear. (emphasis added by me)
I meant the example here: http://www.allegro.cc/manual/5/al_draw_prim
UPDATE
I've got my texture mapping working now. Turns out the texture I was passing in was NULL. I'm still not quite sure why.
I had something similar to this:
I am assuming the problem comes when trying to change the private pointer member (*texture).
I changed textureToLoad = al_load_bitmap(path) to
a.setTexture(textureToLoad)
and the problem resolved.
So now I have a texture mapped nxn square surface made up on quads (that are made up of triangles) to work with.
Next is adding a height map to adjust the z values of the quad surface.
Yipee. :-)