0

I get this strange distorted primitive shape (instead of a square) when i move the primitive through the x and y co-ordinates.

Here is a snapshot: http://img535.imageshack.us/img535/9046/screenshot20120126at122.png

I'm using orthogonal projection since i want to render in 2D.

Here is the render code:

//vertex definition
static GLfloat qdt[] = {
    30.0f, 60.0f, -0.03f,
    30.0f, 30.0f, -0.03f,
    60.0f, 60.0f, -0.03f,
    60.0f, 30.0f, -0.03f
};

//clear buffers
glClear(GL_COLOR_BUFFER_BIT);// also tried using GL_DEPTH_BUFFER_BIT

//load matrices
glLoadIdentity();

//drawing
glVertexPointer(3, GL_FLOAT, 0, &qdt[0]);
glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 12);

//swap buffers
[glContext presentRenderbuffer:GL_RENDERBUFFER_OES];

I've disabled the depth buffers too. It would be nice if someone points out the mistakes which is causing this distortion. Thanks in advance.

1 Answer 1

0

Replace 12 by 4, because you draw 4 vertices:

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
1
  • Oh my! I thought you had to pass the number of floating points, of the figure, into the function. Thank you very much. I was trying every other thing.
    – Alterecho
    Jan 26, 2012 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.