glut Initialization?

Hello, I’ve just started to use OpenGL and I have some problems with GLUT. Here is my piece of code (straight from some tutorial):

void GLCanvas::Render(void)
	int a;
	char b[10][10];

	glTranslatef(0.0, 0.0, -15.0);
	glRotatef(30.0, 1.0, 0.0, 0.0);
	glColor4f(0.3, 0.3, 0.3, 1.0);

The problem is: when I compile this code I’m getting:

freeglut  ERROR:  Function <glutWireTeapot> called without first calling 'glutInit'.

So I’ve thought I just to use that glutInit function:

glutInit(&a, (char **)b);

(My program doesn’t use arc or argv and I don’t pass any glut command-line arguments so I think it makes no difference what will I use as parameters?)

And now I’m getting this error:

freeglut illegal glutInit() reinitialization attempt

And I am completely lost here :frowning: So was the glut already initialized or not :confused:

I’ll be grateful for any advice.

You had better show us the code that does the initializing.

OK. I believe initialization is being done by this piece of code:

void GLCanvas::OnPaint(wxPaintEvent & event)

	wxPaintDC dc(this);
#ifndef __WXMOTIF__
	if (!GetContext()) return;

	//init OpenGL once, but after SetCurrent
	if (!init)
		init = true;

OK, I think I’ve fixed that by adding GlutInit into this part of code:) But now I have another question: I’ve tried glutSolidTeapot and it looks ugly, just like a flat bitmap - is it normal (looking at my “settings” above) or something is broken again in my OpenGL?

The problem is that the teapot has the same color value everywhere. You can enable lighting to make it appear 3 dimensional, because different areas of the teapot will then be lit in different color tones. You need to specify normals so that OpenGL or you own shader can compute the color value depending on the light’s direction. glutSolidTeapot() does automatically provide the normal vectors for this. So just search the web for lighting. Or maybe somebody else here can point you to some good tutorial.