OpenGL texturing problem
I want to do a very simple thing - draw textured quad, with some random points around the screen. Like this:
In fact I'm trying to render a trapezium, but I'd like to have a more common version of the render function.
I'm doing this:
And it works fine if I render a rectangle, but when lines are not parallel, texturing fails - it splits on two triangles with different texturing.
(see this)
Code:
.
. .
.I'm doing this:
Code:
- (void) draw4Points:(CGPoint)point1:(CGPoint)point2:(CGPoint)point3:(CGPoint)point4:
{
GLfloat coordinates[] = {
0, _maxT,
_maxS, _maxT,
0, 0,
_maxS, 0
};
GLfloat vertices[] = {
point1.x, point1.y,
point2.x, point2.y,
point3.x, point3.y,
point4.x, point4.y,
};
glBindTexture(GL_TEXTURE_2D, _name);
glVertexPointer(2, GL_FLOAT, 0, vertices);
glTexCoordPointer(2, GL_FLOAT, 0, coordinates);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}And it works fine if I render a rectangle, but when lines are not parallel, texturing fails - it splits on two triangles with different texturing.
(see this)
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| iPhone OpenGL Texturing / Memory | fungos | 4 | 6,726 |
Nov 11, 2008 05:55 AM Last Post: fungos |
|

