PDA

View Full Version : newbie displaying problem



godhand
03-29-2004, 03:59 AM
Hi, I am trying to draw up a clock using primitives, but after I have drawn a certain number of element of the clock on the screen, nothing more is displayed afterwards. Any help or suggestion is appreciated, thanks.

dvm
03-29-2004, 04:27 AM
Try posting some code. There are a lot of things that could go wrong. One might be (I'm only speculating) that you forgot to put a glPopMatrix() (if you've pushed first of course). This could lead to unexpected results. Give more information so we can help you.

nexusone
03-29-2004, 04:28 AM
Without seening your code it is hard to say what is going on.

I have a clock demo using primitives on my website with source. www.angelfire.com/linux/nexusone. (http://www.angelfire.com/linux/nexusone.)

Check it out maybe it will help.


Originally posted by godhand:
Hi, I am trying to draw up a clock using primitives, but after I have drawn a certain number of element of the clock on the screen, nothing more is displayed afterwards. Any help or suggestion is appreciated, thanks.

mikael_aronsson
03-29-2004, 04:29 AM
Hi !

What do you mean with primitives ? do you use glut/glu primitives or are you talking low level primitives (line, strips, triangles...) ?

It might be easier to locate the problem if you could post the rendering part of your code here.

Mikael

godhand
03-29-2004, 04:11 PM
Hi, the code is a little bit long, so please bear with me thanks.


void display(void)
{

int i;
float angle;
GLint circle_points=100;
glClear(GL_COLOR_BUFFER_BIT);

glColor3f(1.0,1.0,1.0);
/*drawing the circle
**/
glBegin(GL_LINE_LOOP);


for(i=0;i<circle_points;i++)
{
angle=2*pi*i/circle_points;
glVertex2f(cos(angle),sin(angle));
}



glEnd();
/* drawing the hour marker
*/
glBegin(GL_POLYGON);
/*12 */
glVertex3f(-0.05,0.9,0);
glVertex3f(0.05,0.9,0);
glVertex3f(0.05,1.23,0);
glVertex3f(-0.05,1.23,0);

glEnd();


glBegin(GL_POLYGON);
/* 1 */
glVertex3f(0.32,0.88,0);


glVertex3f(0.48,0.76,0);
glVertex3f(0.68,1.1,0);
glVertex3f(0.50,1.21,0);

glEnd();

glBegin(GL_POLYGON);
/* 2 */

glVertex3f(0.7,0.55,0);
glVertex3f(0.77,0.4,0);
glVertex3f(1.1,0.7,0);
glVertex3f(0.9,0.86,0);

glEnd();
/* 3 */
glBegin(GL_POLYGON);

glVertex3f(0.9,0.08,0);
glVertex3f(0.9,-0.08,0);
glVertex3f(1.2,-0.08,0);
glVertex3f(1.2,0.08,0);

glEnd();
/* 4 */
glBegin(GL_POLYGON);

glVertex3f(0.81,-0.43,0);
glVertex3f(1.0,-0.55,0);
glVertex3f(0.912,-0.7,0);
glVertex3f(0.72,-0.58,0);

glEnd();

/*5 */
glBegin(GL_POLYGON);
glVertex3f(0.53,-0.77,0);
glVertex3f(0.66,-0.9,0);
glVertex3f(0.57,-1.0,0);
glVertex3f(0.42,-0.88,0);

glEnd();

/* 6 **/
glBegin(GL_POLYGON);


glVertex3f(-0.03,-0.9,0);
glVertex3f(0.05,-0.9,0);
glVertex3f(-0.03,-1.23,0);
glVertex3f(0.05,-1.23,0);
glEnd();

/* 7 **/
glBegin(GL_POLYGON);
glVertex3f(-0.4,-0.82,0);
glVertex3f(-0.50,-1.08,0);
glVertex3f(-0.6,-1.03,0);
glVertex3f(-0.5,-0.79,0);
glEnd();


/* 8 **/
glBegin(GL_POLYGON);
glVertex3f(-0.78,-0.53,0);
glVertex3f(-0.97,-0.72,0);
glVertex3f(-1.1,-0.58,0);
glVertex3f(-0.89,-0.38,0);
glEnd();

/* 9 */
glBegin(GL_POLYGON);
glVertex3f(-0.9,-0.13,0);
glVertex3f(-1.2,-0.13,0);
glVertex3f(-1.2,0.03,0);
glVertex3f(-0.9,0.03,0);
glEnd();

/* 10 */
glBegin(GL_POLYGON);
glVertex3f(-0.95,0.4,0);
glVertex3f(-1.15,0.5,0);
glVertex3f(-1.08,0.68,0);
glVertex3f(-0.89,0.6,0);

glEnd();
/* 11 */
glBegin(GL_POLYGON);
glVertex3f(-0.6,0.9,0);
glVertex3f(-0.7,1.05,0);
glVertex3f(-0.56,1.12,0);
glVertex3f(-0.46,0.97,0);
glEnd();

/ *** minute marker
***/
glBegin(GL_LINES);
glVertex3f(0.08,0.99,0);
glVertex3f(0.08,1.18,0);

glEnd();
/*** starting from this line
nothing is drawn on the screen
***/
glBegin(GL_POLYGON);
glVertex3f(0.089,0.991,0);
glVertex3f(0.09,1.18,0);

glEnd();


glFlush();
}

03-29-2004, 04:38 PM
Well, you're drawing a GL_POLYGON with only two points - that rightly won't display anything anyway. But what else in that position doesn't display anything?

Anyway, change the call to GL_LINES and see if that helps.

godhand
03-30-2004, 12:04 AM
Yes, starting from that comment line, nothing else is displayed. But everthing else before that did.

03-30-2004, 01:46 AM
But in the provided code there's only one drawing block after that point - is this really a case of "nothing draws after this point" or is it just "this particular drawing block is broken"? It's just that it's really odd that drawing should just suddenly stop working halfway through a program, so I'm trying to eliminate the obvious first.

Did the last block still not appear after changing the draw mode to GL_LINES?

godhand
03-30-2004, 05:14 PM
No, the last block still doesn't appear even if I changed to GL_LINES

04-01-2004, 01:57 AM
So, give us some more description - tell us what research have you done to diagnose the problem, what works and what doesn't.

For example:

If you move that block to the top does it display? Does everything else? Does the new last block now not display?

If you remove the top block does everything else work?

If you put another drawing block after the one that appears to fail, does it display correctly?

Are there any spurious errors being reported?

Are you 100% sure that the last block isn't being displayed - you're not just looking for it in the wrong place, or it's in the wrong colour or something?

Disable depth testing, alpha testing, clip planes, stencil tests or anything else that might discard a fragment before it reaches the screen. Anything?

Revisit your viewing volume code - pull the near plane and little closer and push the far plane a bit further out.

0.089 and 0.9 are very close numbers. Without knowing your viewing transformation I really can't say, but are you sure the line doesn't both start and end in the same pixel, therefore not display?

Set the point size to 10 and change the drawing mode to GL_POINTS. Do you get anything displayed then?

04-01-2004, 02:00 AM
*typo* Should read "0.089 and 0.09".

godhand
04-01-2004, 09:16 PM
Hi, I tried a different approach and it worked.