Advertisement

Drawing Quads -- Getting Rid Of The "Line"

Started by January 12, 2003 02:52 PM
13 comments, last by OpenGL_Guru 22 years, 1 month ago
Hi There, i am not an OpenGL beginner, but not nearly an expert. I am new to this forum though, so i would like to say hello to everyone! Where is everyone from? Maybe i have some close OpenGL guys, i am in Southern Mississippi. I am writing a couple of screensavers and i just started on a game i have an idea for and am in the design stage. My question that i have to ask i have been wondering since i started OpenGL back in March. When i draw Quads, particulary a 2D one, i always get this "line" drawn through the middle of it, when i try to color it. I have a 2D quad, each point has a little different color but right through the middle of the thing there is a distinct line. Has anyone ever had this problem before? --also something to add...sometimes when i have some colored quads or triangles and i have them rotating around the x-axis, the colors seem to switch back and forth sometimes once that side comes into camera view. then when it is about to go out of the view, it turns back to the original color. anyone have any suggestions? thanks!
heh
I''m also having trouble witht that line going through the center of the quad when I''m making my screen fade to black (because I just make a screen sized black colored quad and change its opacity.) If anyone has the solution I''d be interested in knowing lol
Advertisement
Well my background is black too, i dont think that would make a difference. when i draw a triangle (2D or 3D) and some other poly''s, it doesnt do this. i mean , yes the color blends well, but there IS a distinct line.. please anyone who could help it would be appreciated. i imagine there are a lot of people who have had the same problem. Also i would like to know where everyone is from! thanks!


********************
P.S. if any OpenGL programmers would like to start a game or help me with a game, perhaps we could get together. i have a Bachelors Degree in Computer Science so the programming part is not a big deal. If you are a computer programmer, or maybe if you know Adobe Photo or 3D Studio Max, that would be cool. I am taking Photoshop and 3D Studio in the Fall 2003 Semester.
heh
i guess the line is appearing because the quad is drawn as 2 triangles - is it a diagonal line?
Yes it is
yes it, its a diagnal line.. here is my code for a 3D triangle. Put it in your DrawGLScene and see if you get the same thing. If its the only thing on ur screen make sure you translate so you can see it. when the triangle spins around, the bottom QUAD(bottom of the triangle) changes color, switches back and forth.

even if it doesn't change you still get that line.
Here is my 3D Traingle and the 2D Quad is after that. You can see the line i am talking about. thanks if anyone has any info on this....

glBegin(GL_TRIANGLES);

glColor3f(1.0,0.0f,0.0f); // Red
glVertex3f( 0.0f, 1.0, 0.0f); // Top Of Triangle (Front)
glColor3f(0.0f,1.0,0.0f); // Green
glVertex3f(-1.0,-1.0, 1.0); // Left Of Triangle (Front)
glColor3f(0.0f,0.0f,1.0); // Blue
glVertex3f( 1.0f,-1.0f, 1.0f); // Right Of Triangle (Front)

glColor3f(1.0,0.0f,0.0f); // Red
glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Right)
glColor3f(0.0f,0.0f,1.0); // Blue
glVertex3f( 1.0f,-1.0f, 1.0f); // Left Of Triangle (Right)
glColor3f(0.0f,1.0,0.0f); // Green
glVertex3f( 1.0f,-1.0f, -1.0f); // Right Of Triangle (Right)

glColor3f(1.0,0.0f,0.0f); // Red
glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Back)
glColor3f(0.0f,1.0,0.0f); // Green
glVertex3f( 1.0f,-1.0f, -1.0f); // Left Of Triangle (Back)
glColor3f(0.0f,0.0f,1.0); // Blue
glVertex3f(-1.0f,-1.0f, -1.0f); // Right Of Triangle (Back)

glColor3f(1.0,0.0f,0.0f); // Red
glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Left)
glColor3f(0.0f,0.0f,1.0); // Blue
glVertex3f(-1.0f,-1.0f,-1.0f); // Left Of Triangle (Left)
glColor3f(0.0f,1.0,0.0f); // Green
glVertex3f(-1.0f,-1.0f, 1.0f); // Right Of Triangle (Left)

glEnd(); // Done Drawing The 3D Pyramid

**** //2D Quad(Bottom of Traingle)**********

glBegin(GL_QUADS);
glColor3f(0.5, 0.4, 1.0);
glVertex3f( 1.0f,-1.0f, 1.0f); // Top Right Of The Quad (Bottom)
glColor3f(0.5, 1.0, 0.4);
glVertex3f(-1.0f,-1.0f, 1.0f); // Top Left Of The Quad (Bottom)
glColor3f(0.5, 0.4, 1.0);
glVertex3f(-1.0f,-1.0f,-1.0f); // Bottom Left Of The Quad (Bottom)
glColor3f(0.5, 1.0, 0.4);
glVertex3f( 1.0f,-1.0f,-1.0f); // Bottom Right Of The Quad (Bottom)

glEnd();





[edited by - OpenGL_Guru on January 12, 2003 4:41:56 PM]
heh
Advertisement
here is my 2D Quad. it is not drawn as 2 triangles though...

??????

size is however big i want it to be passed in from a function, just replace size with 1.0 and go from there, thanks..

glBegin(GL_POLYGON);

glColor3f(1.0, 0.0, 0.5);
glVertex2f(size, size); //upper right
glColor3f(0.35, 1.0, 0.2);
glVertex2f(size, -size); //lower right
glColor3f(0.35, 0.3, 0.9);
glVertex2f(-size, -size); //lower left
glColor3f(0.7, 0.7, 0.0);
glVertex2f(-size, size); //upper left
glEnd();

[edited by - OpenGL_Guru on January 12, 2003 4:40:56 PM]
heh
how the hell can you be an ''OpenGL_Guru'' and write such crappy code... GL_POLYGON, i too have the same problem, maybe GL_TRIANGLE_STRIP?
anonymous...if you are referring to my code as crappy by it not being indented or readable, then that is just how it copied and pasted and i wasnt going to indent it all again. i''m not sure why you say its crappy otherwise. you dont have to be so judgemental and mean about it.

--anyway i dont know about the triangle strip.. ill try it out


--anyway have anny ideas about the flickering of the colors i have described above in this thread? thanks.
heh
you might find that frustum clipping is causing the two triangles to be clipped slightly differently.. causing the issues with the diagonal line..
a simple fix for this would be to set the modelview and projection matricies to identity temporarily and draw the quad from 0,0,0.5f to 1,1,0.5f. This in theory at least shouldn''t frustum clip.

but, also, if you are really drawing a quad, as in GL_QUAD, the vertecies generated by the frustum clipping should be used for both triangles used.

| - Project-X - my mega project.. big things comming soon - | - adDeath - an ad blocker I made - | - email me - |

This topic is closed to new replies.

Advertisement