Hi,
Have you idea about opengl texturing skew quad ?
Regards
Hi,
Have you idea about opengl texturing skew quad ?
Regards
Good!!!!.....and?
Regards
Sesilla
Why do I have feeling that Nuno spends too much time on communities like Stack Overflow?
I would expect such answer on the Stack Overflow where most people blindly tends to answer the question that was asked and not the question that was intended to be asked.
Yes sometimes it is hard to figure out what asker is trying to ask. But here I think it is quite clear that Sesilla also wants to see an example of how this is done.
So Nuno can you please provide short example for rendering skew quad using OpenGL?
Last edited by SilverWarior; 06-03-2015 at 10:03 AM.
@Sesilla
While here on PGD we usually don't treat weak or broad questions as plague like they are commonly treated on Stack Overflow it is still good if you can provide more information in your question about what kind of an answer do you expect as this helps us understand of what do you need.
Also sometimes it might be better to provide description of that final results do you expect instead of asking about specific approach. Why? This way you might get answer with multiple possible approaches so you can then chose the one that suits you best.
@SilverWarior
Thanks for your suggestions!
Thi is my quad:
This is a texture:
And this the result with possibilities to "deform" the scale or tile of the texture:
Thanks in advance
Sesilla
Do you wan't the texture to be projected on your quad so that it looks like rotated plane (texture rotates and scales with the quad) or just use your quad as mask to show only part of the texture as it is done in your image example?
The first one! The texture projected like pseudo 3d!
Sesilla
If you're in OpenGL then you're providing texture coordinates for the quad. Perspective correction is automatic. You provide coordinates between 0.0 and 1.0 for each of your vertices. To produce an image like you've posted you have to scale the texture coordinates in relation to your vertex coordinates, or in much older versions of GL you can use automatic texture coordinate generation which in 2D will produce the same result.
The solution for 'perspective' in 2D as you desire is to simply leave your texture coordinates at each corner of the texture while altering the vertices of the quad.
Input the vertex coordinates that would give you a quad like in the image you have provided and in counter-clockwise order (OpenGL defaults to counter-clockwise winding to determine front facing polygons) set your texture coordinates as (x:0,y:0) (x:0,y:1) (x:1,y:1) (x:1,x:0)
As long as you keep your texture coordinates the same, you can draw your (convex) quad at any combination of vertices and openGL will 'skew' the texture automatically.
When the moon hits your eye like a big pizza pie - that's an extinction level impact event.
Hi phibermon,
with this code:
Code:glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2f (500, 200); glTexCoord2f(0, 1); glVertex2f (600, 200); glTexCoord2f(1, 1); glVertex2f (1000, 700); glTexCoord2f(1, 0); glVertex2f (50, 700);
this is the rendering:
Browsing the web i found the Opengl glTexCoord4f function, but it is not clear about use it.
Thanks
Sesilla
Bookmarks