0

I am trying to draw some lines in my GLView, but it just doesn't do anything.

I'm using Xcode 4.5 for iOS 6.0 application.

This is my code:

//Draw Axes
{

    const GLfloat lineX[] = {
        -100.0f, 0.0f, 0.0f, //point A
        100.0f, 0.0f, 0.0f //point B
    };
    const GLfloat lineY[] = {
        0.0f, -100.0f, 0.0f, //point A
        0.0f, 100.0f, 0.0f //point B
    };
    const GLfloat lineZ[] = {
        0.0f, 0.0f, -100.0f, //point A
        0.0f, 0.0f, 100.0f //point B
    };




    glEnableClientState(GL_VERTEX_ARRAY);
    glColor4f(1.0f, 0.0f, 0.0f, 1.0f); // opaque red
    glVertexPointer(3, GL_FLOAT, 0, lineX);
    glDrawArrays(GL_LINES, 0, 2);

    glColor4f(0.0f, 1.0f, 0.0f, 1.0f); // opaque green

    glVertexPointer(3, GL_FLOAT, 0, lineY);
    glDrawArrays(GL_LINES, 0, 2);

    glColor4f(0.0f, 0.0f, 1.0f, 1.0f); // opaque blue

    glVertexPointer(3, GL_FLOAT, 0, lineZ);
    glDrawArrays(GL_LINES, 0, 2);

    glDisableClientState(GL_VERTEX_ARRAY);
}   

I'm new to openGL and I'm just trying to do some basic stuff. I can use glClear:

glClearColor(1, 0, 1, 1);
glClear(GL_COLOR_BUFFER_BIT);

so it seems that the context is right but I can't draw the lines.

any help... Thank you.

Alex Fish
  • 768
  • 6
  • 18

1 Answers1

0

Why don't you try having a look at the GLPaint sample code.

It draws lines (based on touch input) using OpenGL ES 1.0

Bobjt
  • 4,040
  • 1
  • 29
  • 29
  • Thanks but it doesn't draw lines. It draws points based on touch input. – Alex Fish Oct 29 '12 at 16:22
  • Hmm. What are "lines" but filled pixels connecting two points? I don't think I see the distinction you're making. This sample does draw lines (based on touch input, but the source of the points is completely arbitrary). Within the sample, see PaintingView -renderLineFromPoint:toPoint: ... ? – Bobjt Oct 31 '12 at 15:39
  • I understand this but I don't want to draw my lines as a set of pointes like they do in that sample I would like to use GL_LINES to do so. I don't see any point in drawing my lines as sets of points if I just need linear line and openGL has a separate function for that. Thank you but I prefer a solution using the function I want to use. – Alex Fish Oct 31 '12 at 18:15
  • Got ya. I haven't used GL_LINES yet, so anyone else who can chime in here? – Bobjt Oct 31 '12 at 20:27