Page 3 of 3 FirstFirst 123
Results 21 to 29 of 29

Thread: Nice looking lines [OpenGL]

  1. #21

    Nice looking lines [OpenGL]

    Quote Originally Posted by arthurprs
    mag and min filters set to GL_LINEAR
    ... after glBindTexture on the specific texture?

  2. #22

    Nice looking lines [OpenGL]

    Quote Originally Posted by User137
    Quote Originally Posted by arthurprs
    mag and min filters set to GL_LINEAR
    ... after glBindTexture on the specific texture?
    yes

    i have tried rendering with trianglestrip, same result =\
    From brazil (:

    Pascal pownz!

  3. #23

    Nice looking lines [OpenGL]

    Try this version, use the same texture as you posted before, it renders 3 quads, uses some vector math to avoid messing with rotations.

    Code:
    Procedure DrawLine(const PStart: TVector2f; const PEnd: TVector2f; Width: Single);
    var Vector   : TVector2f;
    var Normal   : TVector2f;
    var NXW: Single;
    var NYW: Single;
    var VXW: Single;
    var VYW: Single;
    begin
      Vector.X:= PEnd.X - PStart.X;
      Vector.Y:= PEnd.Y - PStart.Y;
      
      Vector:= Normalize(Vector);
    
      // Calculate the normal to the vector
      Normal.X:= -Vector.Y;
      Normal.Y:=  Vector.X;
    
      // Precompute the factors
      NXW:= Normal.X * Width;
      NYW:= Normal.Y * Width;
    
      VXW:= Vector.X * Width;
      VYW:= Vector.Y * Width;
    
      glEnable(GL_TEXTURE_2D);
    
      glBegin(GL_QUADS);
        // First quad
        glTexCoord2f(0.0, 0.5); glVertex2f(PStart.X - NXW + VYW, PStart.Y - NYW + VYW);
        glTexCoord2f(1.0, 0.5); glVertex2f(PStart.X + NXW + VYW, PStart.Y + NYW + VYW);
        glTexCoord2f(1.0, 0.5); glVertex2f(PEnd.X   + NXW - VYW, PEnd.Y   + NYW - VYW);
        glTexCoord2f(0.0, 0.5); glVertex2f(PEnd.X   - NXW - VYW, PEnd.Y   - NYW - VYW);
    
        // Middle quad
        glTexCoord2f(0.0, 0.0); glVertex2f(PStart.X - NXW      , PStart.Y - NYW);
        glTexCoord2f(1.0, 0.0); glVertex2f(PStart.X + NXW      , PStart.Y + NYW);
        glTexCoord2f(1.0, 0.5); glVertex2f(PStart.X + NXW + VXW, PStart.Y + NYW + VYW);
        glTexCoord2f(0.0, 0.5); glVertex2f(PStart.X - NXW + VXW, PStart.Y - NYW + VYW);
    
        // End quad
        glTexCoord2f(0.0, 0.0); glVertex2f(PEnd.X - NXW      , PEnd.Y - NYW);
        glTexCoord2f(1.0, 0.0); glVertex2f(PEnd.X + NXW      , PEnd.Y + NYW);
        glTexCoord2f(1.0, 0.5); glVertex2f(PEnd.X + NXW - VXW, PEnd.Y + NYW - VYW);
        glTexCoord2f(0.0, 0.5); glVertex2f(PEnd.X - NXW - VXW, PEnd.Y - NYW - VYW);
      glEnd();
    end;
    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

  4. #24

    Nice looking lines [OpenGL]

    the result andreaz
    From brazil (:

    Pascal pownz!

  5. #25

    Nice looking lines [OpenGL]

    Quote Originally Posted by arthurprs
    and how it looks when i draw stretched
    I don't understand, i can clearly see you have LINEAR working in that screenshot, yet it stopped working?

  6. #26

    Nice looking lines [OpenGL]

    EDIT: forget about the errors, the code is working perfectly, the #@!@# here forgot that he changed the texture...
    From brazil (:

    Pascal pownz!

  7. #27

    Nice looking lines [OpenGL]

    Quote Originally Posted by arthurprs
    the result andreaz
    ...snip...
    It should really look like this,


    Well here's the complete source
    http://phoenixlib.net/files/Nice_looking_lines.zip
    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

  8. #28

    Nice looking lines [OpenGL]

    Thanks Andreaz, the code works good

    changing topic,

    I was looking on phoenixlib sources and i noticed that you use display lists and vertexarray on particles, those method are really faster?
    From brazil (:

    Pascal pownz!

  9. #29

    Nice looking lines [OpenGL]

    Yeah, vertex arrays is alot faster then intermediate mode (glBegin, glVertex, glEnd).

    And displaylists can be faster then vertex arrays, atleast for static geometry. However displaylists is a tricky subject, they might be implemented in the driver and not in the gpu.

    In the new version of Phoenix i'm going away from displaylists and using vertex arrays and vertex buffer objects instead.
    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

Page 3 of 3 FirstFirst 123

Bookmarks

Posting Permissions

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