OpenGL texturing problem

Member
Posts: 39
Joined: 2008.09
Post: #1
I want to do a very simple thing - draw textured quad, with some random points around the screen. Like this:

Code:
.

.                                 .

            .
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:
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)
[Image: 157d1232616138-opengl-texturing-problem-picture-2.jpg]
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  iPhone OpenGL Texturing / Memory fungos 4 7,406 Nov 11, 2008 05:55 AM
Last Post: fungos