Hi,
I'm a newbie at coding in openGL. Can someone please take a look at this code and tell me what I'm doing wrong? I've been playing with it and moving things around. So far, it's only the triangle shape that is showing when I compile it. The line, circle and arc are not showing. Thanks.

You are not calling drawFace() (or drawArc(), etc.) from your display function.
Oh, wait, you copied their function bodies into display() - please try to avoid posting code from the middle of a debugging session where you (pseudo) randomly moved around code, it makes it much harder to find any problem.
For example you now have:

which uses dt without ever initializing it (that happened at the beginning of drawArc(), but you never call that any more). Which probably prevents it from being drawn.
FWIW I ran your program and the short line

glBegin(GL_LINES);
glVertex2i( 0, 0);
glVertex2i( 10, 10);
glEnd();

does show up in the bottom corner (it's small since you only go 10 pixel to the right and up).

drawTriangle() will draw a 1 pixel triangle so it's really hard to see. For drawArc() I did not quite understand the arguments, but I can get it to draw a tiny arc when changing display() to this:

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);

drawTriangle();
drawArc(100, 100, 30, 0, 10);

drawCircle(100, 1000);

glFlush(); /* Single buffered, so needs a flush. */
}

As an aside, is there a reason all your variables are global ones, even loop counters like 'i'? This is a style of coding that will not scale to the size your program will end up being if you want to render facial expressions.

annette

10-14-2011, 08:33 AM

Carsten,
Thanks for the reply. I am new at coding in openGL so I'm still learning. I removed all the variables from the global section and rewrote and restructured some of the code. I still can't get my circle function to work. The triangle, arc and lines are displaying fine but I need to re-position them. How do I go about that, please. Is the something I am doing wrong with the circle function?
Thanks.
I could not locate [ code][ /code] among the menu options so I typed it. Sorry if the code looks unreadable again.

Your drawCircle() function does not draw anything, it only compiles a display list. To execute the drawing commands stored in the display list you need to use glCallList().

Why are you creating a display list in the first place? If the function does not draw a circle the way you want adding the complication of display lists is not going to make it easier. First make your drawing function work, then you can worry about using display lists.
The first argument to glNewList should be a number that was allocated by a preceding call to glGenLists(), not one you pick.

You don't need the calls to glEnable/glDisable with GL_TEXTURE_2D. There are no textures used anywhere in the code you posted.

annette

10-14-2011, 01:11 PM

My final code without the GL_TEXTURE_2D works. See below. Thanks a lot.

I figured out why my screen was blank. It was not GL_LoadIdentity(); I didn't put the right values in GL_Translatef() and GL_Rotate() and that caused the shape to move away from the screen. I still haven't been able to reposition the objects yet but I'm working on that too. Any help will be appreciated. Thanks.

ugluk

10-15-2011, 03:01 PM

Anette, stop using the glRotate*, glTranslate* ... commands, they are obsolete. Start using shaders. There's a tut for modern opengl somwhere (google for it); do the exercises it contains then go to