Results 1 to 4 of 4

Thread: fun colored line ?

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    fr
    Posts
    9

    fun colored line ?

    Hi,

    I would like to create a line with a degrade effect: for exemple, I want the first point in blue and the second in red and between a degrade of colors between red and blue...Somebody can show me how make ? thanks.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Canada
    Posts
    173

    Re: fun colored line ?

    Try assigning a color to each vertex of the line. OpenGL should produce automatically a gradient.

    glBegin(GL_LINES);

    glColor(1,0,0);

    glvertex3f(x1,y1,z1);

    glColor(0,0,1);

    glvertex3f(x2,y2,z2);

    glEnd();
    Billy

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2001
    Posts
    5

    Re: fun colored line ?

    Originally posted by frog:
    Hi,


    I would like to create a line with a degrade effect: for exemple, I want the first point in blue and the second in red and between a degrade of colors between red and blue...Somebody can show me how make ? thanks.
    Its very simple:
    glBegin (GL_LINES);
    glColor3f(0.0f,0.0f,1.0f); //blue
    glVertex3f(1.0f,1.0f,0.0f); //1 point
    glColor3f(1.0f,0.0f,0.0f); //red
    glVertex3f(1.0f,0.0f,0.0f); //2 point
    glEnd();

    You MUST activate:
    glEnable(GL_SMOOTH);
    before drawing

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2001
    Posts
    5

    Re: fun colored line ?

    Originally posted by frog:
    Hi,


    I would like to create a line with a degrade effect: for exemple, I want the first point in blue and the second in red and between a degrade of colors between red and blue...Somebody can show me how make ? thanks.
    Its very simple:
    glBegin (GL_LINES);
    glColor3f(0.0f,0.0f,1.0f); //blue
    glVertex3f(1.0f,1.0f,0.0f); //1 point
    glColor3f(1.0f,0.0f,0.0f); //red
    glVertex3f(1.0f,0.0f,0.0f); //2 point
    glEnd();

    You MUST activate:
    glEnable(GL_SMOOTH);
    before drawing

Similar Threads

  1. OGL noob question - Writing a line upon a line, avoiding conflict
    By Prospero in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-19-2015, 07:37 PM
  2. Using env_dot3 with colored lights
    By imported_RickA in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 01-29-2007, 07:51 PM
  3. colored screen
    By Tralfas in forum OpenGL: Basic Coding
    Replies: 13
    Last Post: 04-23-2006, 01:53 AM
  4. Colored Backround
    By Pip in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 04-03-2001, 03:25 AM
  5. Colored problems ...
    By Anne-Gael in forum OpenGL: Linux
    Replies: 2
    Last Post: 07-17-2000, 08:26 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
  •  
Proudly hosted by Digital Ocean