Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Weird horizontal lines  (Read 4080 times)

0 Members and 1 Guest are viewing this topic.

JoshuaBehrens

  • Newbie
  • *
  • Posts: 35
    • View Profile
Weird horizontal lines
« on: July 14, 2013, 01:36:05 pm »
I do not use the sfml-graphics-package for this, so I m posting this in the General-Subforum.

I draw some triangles. My friends see these lines, me not. I tried VSync and Framelimit. Both didnt helped it. How do I fix this, and what do I need to tell you to investigate this?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Weird horizontal lines
« Reply #1 on: July 14, 2013, 01:44:29 pm »
Quote
I do not use the sfml-graphics-package
Thanks for telling us what you don't use, it's very helpful :P

I suppose you're using OpenGL. Can you show how you draw these tiles, and all the related OpenGL states?
Laurent Gomila - SFML developer

JoshuaBehrens

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Weird horizontal lines
« Reply #2 on: July 14, 2013, 02:14:15 pm »
Lol I didnt know I can draw with DirectX in SFML :P so sure I use GL. I didnt wanted to tell you, what I dont use I just wanted to verify why I'm posting here ;)
So I initialize with this:
glClearColor( 0, 0, 0, 1 );

glEnable( GL_ALPHA_TEST );
glAlphaFunc( GL_GREATER , 0.1 );

glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
And draw like that
glBindTexture( GL_TEXTURE_2D, _idtiles );

glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer( 2, GL_DOUBLE, 0, &_wayvertex[ 0 ] );

glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer( 2, GL_DOUBLE, 0, &_waytexvertex[ 0 ] );

glDrawArrays( GL_TRIANGLES, 0, _wayvertex_size );

glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
 
I also buffered the coins you can see, but they are drawn the same way.
« Last Edit: July 14, 2013, 02:15:49 pm by JoshuaBehrens »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Weird horizontal lines
« Reply #3 on: July 14, 2013, 02:41:11 pm »
Do you draw at integer coordinates? Do you use linear interpolation for your textures?
Laurent Gomila - SFML developer

JoshuaBehrens

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Weird horizontal lines
« Reply #4 on: July 14, 2013, 02:45:06 pm »
_wayvertex and _waytexvertex are both double* and the textures arent set to GL_NEAREST, but they seems to be set to GL_NEAREST by default. I load them with SOIL.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: Weird horizontal lines
« Reply #5 on: July 14, 2013, 03:11:43 pm »
I am guessing your friend is sitting on a laptop? This is a rounding error in the position of the vertices. Or well it was when it happened to me. The desktop GPU can calculate it properly while the laptop have lower precision or something like that. It was my experience when i put together a similar demo. Laurent is already in the direction I did to solve it, make sure the numbers you use are integers. Think this also apply to however you offset your view to move around.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

JoshuaBehrens

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Weird horizontal lines
« Reply #6 on: July 14, 2013, 03:29:58 pm »
One of my friend just said he uses a desktop pc for testing it. So when I use glm to modify the matrix and the pointer for the vertex I should change all of this to int/short? So like multiplying everything by 100 because the current values depend on decimals?

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: Weird horizontal lines
« Reply #7 on: July 14, 2013, 03:53:10 pm »
Could you elaborate on how you mean with depends on decimal? Can't help if I don't understand what you are doing.

also it could be the sampling is a problem that Laurent suggested, but that wasn't what I had trouble with.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

JoshuaBehrens

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Weird horizontal lines
« Reply #8 on: July 14, 2013, 03:58:35 pm »
You can see a two dimensional field. Every quad, displayed with two triangles, have the coordinates 0..1,0..1 + an offset that depends on time. So it moves all the time. This offset is between 0 and 1 so if I just use integer I wouldnt have any movement, would I?

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: Weird horizontal lines
« Reply #9 on: July 14, 2013, 07:50:36 pm »
No you wouldn't. But how do you map 1 pixel to your coordinate system? If you modify your coordinate system to be rounded integers instead that would potentially solve the problem.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio