Results 1 to 4 of 4

Thread: how to smooth out a line in iphone openGL

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2009
    Posts
    1

    how to smooth out a line in iphone openGL

    Hi all,

    I am an absolute openGL beginner. I am learning iphone game programming using cocoa and openGL . Using the below function I did draw a slanted line successfully.


    Code :
    static const GLfloat squareVertices[] = {
            -0.50f, -0.33f,
    		-0.55f, -0.38f,
        };
    .....
    .....
    .....
     
    glLineWidth(2.0);
        // Draw
    glDrawArrays(GL_LINE_STRIP, 0, 2);



    I did draw a line successfully. But it is not smooth. I tried some google and got the following antialiasing methods and inserted the below given line before glDrawArray() in the code above.

    Code :
    glEnable(GL_SMOOTH_LINE)


    But when I tried to build I am getting an error.

    error : GL_LINE_SMOOTH undeclared.


    Can anyone help me...

  2. #2
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    7

    Re: how to smooth out a line in iphone openGL

    it is indeed GL_LINE_SMOOTH not SMOOTH_LINE as in your code box.

    I take it you are using opengl es 1.x ?

  3. #3
    Member Contributor
    Join Date
    Jul 2009
    Location
    Buenos Aires
    Posts
    67

    Re: how to smooth out a line in iphone openGL

    Not sure how is on iPhone, but traditionally you also need to enable blending and set it to alpha blending to use line smoothing.

    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    glEnable(GL_LINE_SMOOTH);

    Same for point smoothing

  4. #4
    Senior Member Regular Contributor
    Join Date
    Nov 2009
    Location
    France
    Posts
    114

    Re: how to smooth out a line in iphone openGL

    hi,

    I think that you need to emulate this feature:
    - draw two triangles (a quad) instead of a line
    - make sure that your quad has the correct end cap (perpandicular to line)
    - compute texture coordinate to generate s orthogonal to the line direction
    - make sure that your texture coordinate is correctly interpolated (linear, not perspective correct).
    - bind a ramp texture to emulate the smooth in alpha
    - fetch that texture in your shader (or setup fixed function state)
    Pierre B.
    AMD Fellow

Similar Threads

  1. Line smooth not working.
    By muthuveera in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 02-23-2015, 10:36 PM
  2. Smooth/think line rasterization in 3.2 core profile
    By mlfarrell in forum OpenGL: Advanced Coding
    Replies: 11
    Last Post: 01-05-2014, 09:29 PM
  3. OpenGL iPhone tutorial
    By AmitGupta in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-03-2009, 11:16 PM
  4. Trying to get an OpenGL view in an IPhone app
    By Stoff81 in forum OpenGL ES
    Replies: 1
    Last Post: 12-21-2008, 02:49 AM
  5. iPhone OpenGL ES Simulator
    By bobGL in forum OpenGL: macOS
    Replies: 1
    Last Post: 04-29-2008, 08:11 PM

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