Results 1 to 6 of 6

Thread: Quads not displaying correctly in Wireframe

  1. #1

    Quads not displaying correctly in Wireframe

    Sorry to bug you again here, but everyone I showed the code said it is correct and I am out of friends now to ask more .

    I draw my vertices as triangle strip and I generate 2 Triangles to draw a quad (sprite).
    The Output of OpenGL is okay and as expected as long as I a use filled Polygons. But when I switch to Wireframe, they draw only as a diagonal line. There is not quad visible in Wireframe mode.
    Hence this image:
    http://img717.imageshack.us/img717/3863/samplea.png

    So I drawed multiple quads with the same code to see whats going on. This looks like this:
    http://img687.imageshack.us/img687/1340/samplep.png

    Here is the code responsible for this:
    http://pastebin.com/PqxHxUsT

    I generate the Array of Vertices in counter-clock-wise Order. But still it does not work out.
    Anyone got a clue what I am doing wrong?

  2. #2
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,674

    Re: Quads not displaying correctly in Wireframe

    Anyone got a clue what I am doing wrong?
    Yes. You're assuming that the hardware actually renders quads. It doesn't; it renders triangles. It simply takes a quad and breaks it down into two triangles.

    So when you tell it to render a quad in wireframe mode, it will break them down into triangles and render them in wireframe mode.

  3. #3

    Re: Quads not displaying correctly in Wireframe

    Sorry Alfonse, but thats not true (the first sentence) . No offense.
    I assume the Harware renders 2 Polygons. GL_QUAD in 3.2 is deprecated, so I do not use it. I render with GL_TRIANGLE_STRIP as shown in my code.
    Originally I wanted to generate a 2D Map over my screen, but then I noticed those 2 Lines going away from my triangles. There should be 4 "Quads", but there are only 2. When I say Quad, I mean whats displayed, not what the hardware uses for rendering.
    But my vertice generation looks okay according to the redbook:
    Code :
    glBegin(GL_TRIANGLE_STRIP);	
     glVertex3f( 0.0f, 0.0f, 0.0f ); //vertex 1
     glVertex3f( 0.0f, 1.0f, 0.0f ); //vertex 2
     glVertex3f( 1.0f, 0.0f, 0.0f ); //vertex 3
     glVertex3f( 1.5f, 1.0f, 0.0f ); //vertex 4
     glEnd();
    So I have taken this and converted it for making my vertice-array.

    But still, when I switch to Wireframe mode, there should be still 2 Polyongs visible instead of a diagonal line for every sprite or not?

  4. #4
    Member Contributor
    Join Date
    Dec 2010
    Posts
    92

    Re: Quads not displaying correctly in Wireframe

    I think you need to set glVertexAttribPointer's stride parameter if you are interleaving the data.

    EDIT:
    Also if you are using GL3 you could use geometry shaders or instancing to reduce the amount of vertex data to send to the GPU and move some of the CPU computations to the GPU.

  5. #5

    Re: Quads not displaying correctly in Wireframe

    I have reworked this code partially. I did not use interleaving correctly. My data was VVVVCCCCTTTT but it should be VCTVCTVCT.
    So this is now what I have:
    http://pastebin.com/0VFfy40W
    But not it is displaying nothing :P.

    edit:
    Found the error, the stride was not correct. Now it displays corect.

  6. #6
    Member Contributor
    Join Date
    Dec 2010
    Posts
    92

    Re: Quads not displaying correctly in Wireframe

    Great to know I was correct!

Similar Threads

  1. 3D cube not displaying correctly
    By Syzygy187 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-12-2015, 06:36 AM
  2. Textures not displaying correctly
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-17-2005, 03:26 PM
  3. bitmaps not displaying correctly
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-29-2002, 09:15 AM
  4. Wireframe
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-11-2002, 09:11 AM
  5. Displaying Quads
    By guju in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-16-2002, 10:19 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