Results 1 to 4 of 4

Thread: Problem of colors when drawing lines

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Posts
    7

    Problem of colors when drawing lines

    Hi,

    I have written a drawLine method, but no matter what color I specify, my lines are always black.

    Code :
    void Game::drawLine(CGPoint origin, CGPoint dest, CGFloat width)
    {
    	glLineWidth(width);
    	GLfloat	vertices[] = {origin.x, origin.y, dest.x, dest.y};
    	GLfloat colors[] = {
    		0.0f, 1.0f, 0.0f, 1.0f,
    		0.0f, 1.0f, 0.0f, 1.0f
    	};
     
    	glVertexPointer(2, GL_FLOAT, 0, vertices);
    	glColorPointer(4, GL_FLOAT, 0, colors);
     
    	glEnableClientState(GL_COLOR_ARRAY);
    	glShadeModel(GL_FLAT);
     
    	glDrawArrays(GL_LINES, 0, 2);
     
    	glDisableClientState(GL_COLOR_ARRAY);
    }

    What did I miss ?

    Thanks !

  2. #2
    Junior Member
    Join Date
    Sep 2008
    Posts
    11

    Re: Problem of colors when drawing lines

    some suggestions to try...

    // not sure if this was already enabled
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);

    // specify the stride
    glVertexPointer(2, GL_FLOAT, 2*sizeof(float), vertices);
    glColorPointer(4, GL_FLOAT, 4*sizeof(float), colors);

    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);

  3. #3
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: Problem of colors when drawing lines

    Make sure that lighting and texturing is disabled when you draw the lines.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  4. #4
    Junior Member
    Join Date
    Jul 2008
    Posts
    7

    Re: Problem of colors when drawing lines

    That's it, texturing was not disabled.

    Thanks a lot !

Similar Threads

  1. How to get lines of different colors?
    By johndoe in forum OpenVG and VGU
    Replies: 5
    Last Post: 02-11-2010, 03:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •